Esempio n. 1
0
  /**
   * Restores a maximized window back to its original size and position prior to being maximized and
   * also replaces the 'restore' tool button with the 'maximize' tool button.
   */
  public void restore() {
    if (maximized) {
      el().removeStyleName("x-window-maximized");
      if (maximizable) {
        restoreBtn.setVisible(false);
        maxBtn.setVisible(true);
      }
      if (restoreShadow != null && restoreShadow.booleanValue() && layer != null) {
        layer.enableShadow();
        restoreShadow = null;
      }
      if (draggable) {
        dragger.setEnabled(true);
      }
      if (resizable) {
        resizer.setEnabled(true);
      }
      head.addStyleName("x-window-draggable");
      if (restorePos != null) {
        setPosition(restorePos.x, restorePos.y);

        boolean cacheSizesRestore = cacheSizes;
        cacheSizes = false;
        setSize(restoreSize.width, restoreSize.height);
        cacheSizes = cacheSizesRestore;
      }
      if (container == null && restoreWindowScrolling != null) {
        com.google.gwt.dom.client.Document.get()
            .enableScrolling(restoreWindowScrolling.booleanValue());
        restoreWindowScrolling = null;
      }
      maximized = false;
      fireEvent(Events.Restore, new WindowEvent(this));
    }
  }
Esempio n. 2
0
  @Override
  protected void onRender(Element parent, int pos) {
    setElement(DOM.createFieldSet(), parent, pos);

    legend = new El(DOM.createLegend());
    legend.addStyleName("x-fieldset-header");

    if (checkboxToggle && collapsible) {
      checkbox = DOM.createInputCheck().cast();
      sinkEvents(Event.ONCLICK);
      if (checkboxName != null) {
        checkbox.setAttribute("name", checkboxName);
      }
      legend.appendChild((Element) checkbox.cast());
      checkbox.setDefaultChecked(!collapsed);
      checkbox.setChecked(!collapsed);
      if (GXT.isAriaEnabled()) {
        checkbox.setTitle("Expand " + html);
      }
    } else if (!checkboxToggle && collapsible) {
      collapseBtn = new ToolButton("x-tool-toggle");
      collapseBtn.addListener(
          Events.Select,
          new Listener<ComponentEvent>() {
            public void handleEvent(ComponentEvent be) {
              setExpanded(!isExpanded());
            }
          });
      collapseBtn.render(legend.dom);
      collapseBtn.getAriaSupport().setRole("checkbox");
      if (GXT.isAriaEnabled()) {
        collapseBtn.setTitle("Expand " + html);
      }
      ComponentHelper.setParent(this, collapseBtn);
    }

    heading = DOM.createSpan();
    heading.setClassName("x-fieldset-header-text");
    legend.appendChild(heading);
    getElement().appendChild(legend.dom);

    body = el().appendChild(DOM.createDiv());

    if (html != null) {
      setHeadingHtml(html);
    }

    if (collapsed) {
      onCollapse();
    }

    updateIconTitles();

    if (GXT.isFocusManagerEnabled() && !getFocusSupport().isIgnore()) {
      el().setTabIndex(0);
      el().setElementAttribute("hideFocus", "true");
      sinkEvents(Event.FOCUSEVENTS);
    }
  }
 public ToolButton getParametersTool() {
   ToolButton parametersTool =
       new ToolButton("x-tool-search") {
         @Override
         protected void onClick(ComponentEvent ce) {
           if (contentPanel.getHeader().getToolTip() != null)
             contentPanel.getHeader().getToolTip().show();
         }
       };
   parametersTool.enable();
   return parametersTool;
 }
Esempio n. 4
0
 protected void updateIconTitles() {
   if (GXT.isAriaEnabled()) {
     String txt = "Expand " + html;
     if (checkbox != null) {
       checkbox.setTitle(txt);
     }
     if (collapseBtn != null) {
       collapseBtn.setTitle(txt);
       collapseBtn.getAriaSupport().setState("aria-checked", !collapsed ? "true" : "false");
     }
   }
 }
Esempio n. 5
0
  protected void onKeyPress(WindowEvent we) {
    int keyCode = we.getKeyCode();
    boolean t =
        getElement()
            .isOrHasChild(
                (com.google.gwt.dom.client.Element) we.getEvent().getEventTarget().cast());
    boolean key = GXT.isFocusManagerEnabled() ? we.isShiftKey() : true;
    if (key && closable && onEsc && keyCode == KeyCodes.KEY_ESCAPE && t) {
      hide();
    }

    if (GXT.isAriaEnabled()) {
      if (we.getTarget() == moveBtn.getElement()) {
        Point p = getPosition(true);
        switch (we.getKeyCode()) {
          case KeyCodes.KEY_LEFT:
            setPosition(p.x - ariaMoveResizeDistance, p.y);
            break;
          case KeyCodes.KEY_RIGHT:
            setPosition(p.x + ariaMoveResizeDistance, p.y);
            break;
          case KeyCodes.KEY_DOWN:
            setPosition(p.x, p.y + ariaMoveResizeDistance);
            break;
          case KeyCodes.KEY_UP:
            setPosition(p.x, p.y - ariaMoveResizeDistance);
            break;
        }
      } else if (we.getTarget() == resizeBtn.getElement()) {
        if (!resizable) {
          return;
        }
        Size s = getSize();
        switch (we.getKeyCode()) {
          case KeyCodes.KEY_LEFT:
            setSize(s.width - ariaMoveResizeDistance, s.height);
            break;
          case KeyCodes.KEY_RIGHT:
            setSize(s.width + ariaMoveResizeDistance, s.height);
            break;
          case KeyCodes.KEY_DOWN:
            setSize(s.width, s.height + ariaMoveResizeDistance);
            break;
          case KeyCodes.KEY_UP:
            setSize(s.width, s.height - ariaMoveResizeDistance);
            break;
        }
      }
    }
  }
Esempio n. 6
0
  /**
   * Fits the window within its current container and automatically replaces the 'maximize' tool
   * button with the 'restore' tool button.
   */
  public void maximize() {
    if (!maximized) {
      restoreSize = getSize();
      restorePos = getPosition(true);
      restoreShadow = getShadow();
      if (container == null) {
        String bodyOverflow =
            com.google.gwt.dom.client.Document.get().isCSS1Compat()
                ? com.google.gwt.dom.client.Document.get()
                    .getDocumentElement()
                    .getStyle()
                    .getProperty("overflow")
                : com.google.gwt.dom.client.Document.get()
                    .getBody()
                    .getStyle()
                    .getProperty("overflow");
        if (!"hidden".equals(bodyOverflow)) {
          restoreWindowScrolling = true;
        }
        com.google.gwt.dom.client.Document.get().enableScrolling(false);
      }
      maximized = true;
      addStyleName("x-window-maximized");
      head.removeStyleName("x-window-draggable");
      if (layer != null) {
        layer.disableShadow();
      }

      boolean cacheSizesRestore = cacheSizes;
      cacheSizes = false;
      fitContainer();
      cacheSizes = cacheSizesRestore;

      if (maximizable) {
        maxBtn.setVisible(false);
        restoreBtn.setVisible(true);
      }
      if (draggable) {
        dragger.setEnabled(false);
      }
      if (resizable) {
        resizer.setEnabled(false);
      }

      fireEvent(Events.Maximize, new WindowEvent(this));
    } else {
      fitContainer();
    }
  }
  protected void addHelpTool(ContentPanel panel) {
    if (helpTextId == null) return;

    ToolButton helpBtn = new ToolButton("x-tool-help");
    //		if (GXT.isAriaEnabled()) {
    //			helpBtn.setTitle(GXT.MESSAGES.pagingToolBar_beforePageText());
    //		}
    helpBtn.addListener(
        Events.Select,
        new Listener<ComponentEvent>() {
          public void handleEvent(ComponentEvent ce) {
            HelpTextDialog htd = new HelpTextDialog(helpTextId);
            htd.show();
          }
        });
    panel.getHeader().addTool(helpBtn);
  }
Esempio n. 8
0
 @Override
 protected void onEnable() {
   super.onEnable();
   if (collapseBtn != null) {
     collapseBtn.enable();
   } else if (checkbox != null) {
     checkbox.setDisabled(false);
   }
 }
Esempio n. 9
0
 @Override
 protected void onFocus(ComponentEvent ce) {
   super.onFocus(ce);
   if (GXT.isFocusManagerEnabled()) {
     if (checkboxToggle && checkbox != null) {
       checkbox.focus();
     } else if (collapseBtn != null) {
       collapseBtn.focus();
     }
   }
 }
Esempio n. 10
0
  @Test
  public void onModuleLoad() {
    // Arrange
    MyGXTApp app = new MyGXTApp();

    // Act
    app.onModuleLoad();

    // Assert
    ContentPanel cp = (ContentPanel) RootPanel.get().getWidget(0);
    assertEquals(10, cp.getPosition(true).x);
    assertEquals(10, cp.getPosition(true).y);
    assertEquals("my title", cp.getTitle());
    assertEquals(250, cp.getSize().width);
    // assertEquals(140, cp.getSize().height);
    assertTrue(cp.getCollapsible());
    assertTrue(cp.getFrame());
    assertEquals("backgroundColor: white;", cp.getBodyStyle());
    assertEquals(3, cp.getHeader().getToolCount());

    ToolButton tool0 = (ToolButton) cp.getHeader().getTool(0);
    assertEquals("x-nodrag x-tool-gear x-tool x-component", tool0.getStyleName());

    ToolButton tool1 = (ToolButton) cp.getHeader().getTool(1);
    assertEquals("x-nodrag x-tool-close x-tool x-component", tool1.getStyleName());

    ToolButton tool2 = (ToolButton) cp.getHeader().getTool(2);
    assertEquals("x-nodrag x-tool-toggle x-tool x-component", tool2.getStyleName());
  }
Esempio n. 11
0
  protected void initTools() {
    super.initTools();

    if (GXT.isAriaEnabled()) {
      moveBtn = new ToolButton("x-tool-move");
      moveBtn.getAriaSupport().setLabel(GXT.MESSAGES.window_ariaMove());
      moveBtn.getAriaSupport().setDescription(GXT.MESSAGES.window_ariaMoveDescription());
      head.addTool(moveBtn);

      resizeBtn = new ToolButton("x-tool-resize");
      resizeBtn.getAriaSupport().setLabel(GXT.MESSAGES.window_ariaResize());
      resizeBtn.getAriaSupport().setDescription(GXT.MESSAGES.window_ariaResizeDescription());
      head.addTool(resizeBtn);
    }

    if (minimizable) {
      minBtn = new ToolButton("x-tool-minimize");
      minBtn.addSelectionListener(
          new SelectionListener<IconButtonEvent>() {
            public void componentSelected(IconButtonEvent ce) {
              minimize();
            }
          });
      head.addTool(minBtn);
    }

    if (maximizable) {
      maxBtn = new ToolButton("x-tool-maximize");
      maxBtn.addSelectionListener(
          new SelectionListener<IconButtonEvent>() {
            public void componentSelected(IconButtonEvent ce) {
              maximize();
            }
          });
      head.addTool(maxBtn);

      restoreBtn = new ToolButton("x-tool-restore");
      restoreBtn.setVisible(false);
      restoreBtn.addSelectionListener(
          new SelectionListener<IconButtonEvent>() {
            public void componentSelected(IconButtonEvent ce) {
              restore();
            }
          });
      head.addTool(restoreBtn);
    }

    if (closable) {
      closeBtn = new ToolButton("x-tool-close");
      if (GXT.isAriaEnabled()) {
        closeBtn.setTitle(GXT.MESSAGES.messageBox_close());
      }
      closeBtn.addListener(
          Events.Select,
          new Listener<ComponentEvent>() {
            public void handleEvent(ComponentEvent ce) {
              hide();
            }
          });
      head.addTool(closeBtn);
    }
  }