コード例 #1
0
ファイル: FieldSet.java プロジェクト: Jullil/gxt
  @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);
    }
  }
コード例 #2
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  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;
        }
      }
    }
  }
コード例 #3
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
 @Override
 protected void onHide() {
   super.onHide();
   if (GXT.isAriaEnabled()) {
     Accessibility.setState(getElement(), "aria-hidden", "true");
   }
 }
コード例 #4
0
ファイル: Menu.java プロジェクト: mxro/osgi-maven
  /**
   * Sets the active item. The component must be of type <code>Item</code> to be activated. All
   * other types are ignored.
   *
   * @param c the component to set active
   * @param autoExpand true to auto expand the item
   */
  public void setActiveItem(Component c, boolean autoExpand) {
    if (c == null) {
      deactiveActiveItem();
      return;
    }
    if (c instanceof Item) {
      Item item = (Item) c;
      if (item != activeItem) {
        deactiveActiveItem();

        this.activeItem = item;
        item.activate(autoExpand);
        item.el().scrollIntoView(ul.dom, false);
        focus();

        if (GXT.isFocusManagerEnabled()) {
          FocusFrame.get().frame(item);
          Accessibility.setState(getElement(), "aria-activedescendant", item.getId());
        }

      } else if (autoExpand) {
        item.expandMenu(autoExpand);
      }
    }
  }
コード例 #5
0
ファイル: Menu.java プロジェクト: mxro/osgi-maven
 @Override
 protected void onRemove(Component item) {
   super.onRemove(item);
   if (rendered && GXT.isAriaEnabled() && item instanceof CheckMenuItem) {
     handleRadioGroups();
   }
 }
コード例 #6
0
ファイル: Menu.java プロジェクト: mxro/osgi-maven
  @Override
  protected void onRender(Element target, int index) {
    setElement(DOM.createDiv(), target, index);
    el().makePositionable(true);
    super.onRender(target, index);

    ul = new El(DOM.createDiv());
    ul.addStyleName(baseStyle + "-list");

    getElement().appendChild(ul.dom);

    // add menu to ignore list
    eventPreview.getIgnoreList().add(getElement());

    el().setTabIndex(0);
    el().setElementAttribute("hideFocus", "true");

    el().addStyleName("x-ignore");
    if (GXT.isAriaEnabled()) {
      Accessibility.setRole(getElement(), "menu");
      Accessibility.setRole(ul.dom, "presentation");
      handleRadioGroups();
    }

    if (plain) {
      addStyleName("x-menu-plain");
    }
    if (!showSeparator) {
      addStyleName("x-menu-nosep");
    }

    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.KEYEVENTS | Event.ONMOUSEWHEEL);
  }
コード例 #7
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
 @Override
 protected void onFocus(ComponentEvent ce) {
   super.onFocus(ce);
   if (GXT.isFocusManagerEnabled()) {
     if (focusWidget != null) {
       El.fly(focusWidget.getElement()).focus();
     }
   }
 }
コード例 #8
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  @Override
  protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);

    el().makePositionable(true);

    if (manager == null) {
      manager = WindowManager.get();
    }

    if (plain) {
      addStyleName("x-window-plain");
    }

    eventPreview =
        new BaseEventPreview() {

          @Override
          protected boolean onAutoHide(PreviewEvent ce) {
            if (autoHide) {
              if (resizing) {
                return false;
              }
              hide();
              return true;
            }
            return false;
          }

          @Override
          protected void onPreviewKeyPress(PreviewEvent pe) {
            WindowEvent we = new WindowEvent(Window.this, pe.getEvent());
            onKeyPress(we);
          }
        };
    eventPreview.getIgnoreList().add(getElement());

    sinkEvents(Event.ONMOUSEDOWN | Event.ONKEYPRESS);

    el().setTabIndex(0);
    el().setElementAttribute("hideFocus", "true");

    if (GXT.isAriaEnabled()) {
      Accessibility.setRole(getElement(), "alertdialog");
      Accessibility.setState(getElement(), "aria-labelledby", head.getId() + "-label");
      Accessibility.setState(getElement(), "aria-hidden", "true");
    }

    if (modal || maximizable || constrain) {
      monitorWindowResize = true;
    }

    if (super.width == null) {
      setWidth(Math.max(initialWidth, minWidth));
    }
  }
コード例 #9
0
ファイル: Menu.java プロジェクト: mxro/osgi-maven
 protected void deactiveActiveItem() {
   if (activeItem != null) {
     activeItem.deactivate();
     activeItem = null;
   }
   if (GXT.isFocusManagerEnabled()) {
     FocusFrame.get().unframe();
     Accessibility.setState(getElement(), "aria-activedescendant", "");
   }
 }
コード例 #10
0
ファイル: TabItem.java プロジェクト: Elisabitao/gxt-rtl
 @Override
 protected void onRender(Element parent, int index) {
   super.onRender(parent, index);
   if (autoLoad != null) {
     el().load(autoLoad);
   }
   if (GXT.isAriaEnabled()) {
     Accessibility.setRole(getElement(), Accessibility.ROLE_TABPANEL);
   }
 }
コード例 #11
0
  public void onModuleLoad() {

    GXT.setDefaultTheme(Theme.BLUE, true);

    Dispatcher dispatcher = Dispatcher.get();
    dispatcher.addController(new DesktopController());

    dispatcher.dispatch(DesktopAppEvents.Login);

    GXT.hideLoadingPanel("loading");

    /*
    if (!GXT.isChrome){
    	WebMessageBox.info("Navegador incompatível", "Utilize o Google Chrome para um melhor funcionamento do sistema. " +
    			"Caso não tenha instalado no seu computador faça o download clicando <a href='http://www.google.com/intl/pt-BR/chrome/browser/' target='_blank'>aqui</a>.");
    }
    */

  }
コード例 #12
0
ファイル: Button.java プロジェクト: FURCAS-dev/FURCAS
  protected void onRender(Element target, int index) {
    if (template == null) {
      if (buttonTemplate == null) {
        StringBuffer sb = new StringBuffer();
        sb.append(
            "<table cellspacing=\"0\" class=\"x-btn\" role=\"presentation\"><tbody class=\"{2}\" >");
        sb.append(
            "<tr><td class=\"x-btn-tl\"><i>&#160;</i></td><td class=\"x-btn-tc\"></td><td class=\"x-btn-tr\"><i>&#160;</i></td></tr>");
        sb.append(
            "<tr><td class=\"x-btn-ml\"><i>&#160;</i></td><td class=\"x-btn-mc\"><em class=\"{3}\" unselectable=\"on\"><button class=\"x-btn-text\" type=\"{1}\">{0}</button></em></td><td class=\"x-btn-mr\"><i>&#160;</i></td></tr>");
        sb.append(
            "<tr><td class=\"x-btn-bl\"><i>&#160;</i></td><td class=\"x-btn-bc\"></td><td class=\"x-btn-br\"><i>&#160;</i></td></tr>");
        sb.append("</tbody></table>");

        buttonTemplate = new Template(sb.toString());
      }
      template = buttonTemplate;
    }

    setElement(
        template.create(
            (text != null && text.length() > 0) ? text : "&nbsp;",
            getType(),
            "x-btn-"
                + scale.name().toLowerCase()
                + " x-btn-icon-"
                + scale.name().toLowerCase()
                + "-"
                + iconAlign.name().toLowerCase(),
            getMenuClass()),
        target,
        index);

    super.onRender(target, index);

    buttonEl = el().selectNode(buttonSelector);
    buttonEl.makePositionable();

    if (getFocusEl() != null) {
      getFocusEl().addEventsSunk(Event.FOCUSEVENTS);
    }

    preview.getIgnoreList().add(getElement());

    buttonEl.setTabIndex(0);

    if (GXT.isAriaEnabled()) {
      Accessibility.setRole(buttonEl.dom, Accessibility.ROLE_BUTTON);
      if (menu != null) {
        Accessibility.setState(buttonEl.dom, "aria-haspopup", "true");
      }
    }

    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS);
  }
コード例 #13
0
ファイル: FieldSet.java プロジェクト: Jullil/gxt
 @Override
 protected void onFocus(ComponentEvent ce) {
   super.onFocus(ce);
   if (GXT.isFocusManagerEnabled()) {
     if (checkboxToggle && checkbox != null) {
       checkbox.focus();
     } else if (collapseBtn != null) {
       collapseBtn.focus();
     }
   }
 }
コード例 #14
0
ファイル: FieldSet.java プロジェクト: Jullil/gxt
 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");
     }
   }
 }
コード例 #15
0
ファイル: IconButton.java プロジェクト: Elisabitao/gxt-rtl
  protected void onRender(Element target, int index) {
    setElement(DOM.createDiv(), target, index);
    addStyleName("x-icon-btn");
    addStyleName("x-nodrag");
    addStyleName(style);
    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS | Event.ONKEYUP);
    super.onRender(target, index);

    if (GXT.isHighContrastMode) {
      getElement().setInnerHTML("<i>&nbsp;</i>");
    }

    if (GXT.isFocusManagerEnabled()) {
      el().setTabIndex(0);
      Accessibility.setRole(getElement(), Accessibility.ROLE_BUTTON);
    }
  }
コード例 #16
0
ファイル: IconButton.java プロジェクト: Elisabitao/gxt-rtl
 protected void onBlur(ComponentEvent ce) {
   if (GXT.isFocusManagerEnabled()) {
     FocusFrame.get().unframe();
   }
 }
コード例 #17
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  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);
    }
  }
コード例 #18
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  protected void afterShow() {
    hidden = false;

    // layout early to render window's content for size calcs
    if (!layoutExecuted || isLayoutNeeded()) {
      layout();
    }

    if (restorePos != null) {
      setPosition(restorePos.x, restorePos.y);
      if (restoreSize != null) {
        setSize(restoreSize.width, restoreSize.height);
      }
    }
    if (restoreWindowScrolling != null) {
      com.google.gwt.dom.client.Document.get().enableScrolling(false);
    }

    int h = getHeight();
    int w = getWidth();
    if (h < minHeight && w < minWidth) {
      setSize(minWidth, minHeight);
    } else if (h < minHeight) {
      setHeight(minHeight);
    } else if (w < minWidth) {
      setWidth(minWidth);
    }

    // not positioned, then center
    if (!positioned) {
      el().center(true);
    }

    el().updateZIndex(0);
    if (modal) {
      modalPreview =
          Event.addNativePreviewHandler(
              new NativePreviewHandler() {
                public void onPreviewNativeEvent(NativePreviewEvent event) {
                  if (Element.is(event.getNativeEvent().getEventTarget())) {
                    Element target = (Element) Element.as(event.getNativeEvent().getEventTarget());

                    String tag = target.getTagName();
                    // ignore html and body because of frames
                    if (!resizing
                        && !dragging
                        && !tag.equalsIgnoreCase("html")
                        && !tag.equalsIgnoreCase("body")
                        && event.getTypeInt() != Event.ONLOAD
                        && manager.getActive() == Window.this
                        && (modalPanel == null
                            || (modalPanel != null
                                && !modalPanel.getElement().isOrHasChild(target)))
                        && !Window.this.getElement().isOrHasChild(target)
                        && fly(target).findParent(".x-ignore", -1) == null) {
                      ArrayList<Component> col =
                          new ArrayList<Component>(ComponentManager.get().getAll());
                      for (Component c : col) {
                        if (c instanceof TriggerField<?>) {
                          triggerBlur((TriggerField<?>) c);
                        } else if (c instanceof Menu) {
                          ((Menu) c).hide(true);
                        }
                      }
                      Window.this.focus();
                    }
                  }
                }

                private native void triggerBlur(TriggerField<?> field) /*-{
    [email protected]::triggerBlur(Lcom/extjs/gxt/ui/client/event/ComponentEvent;)(null);
  }-*/;
              });
    }

    // missing cursor workaround
    if (GXT.isGecko) {
      El e = el().selectNode(".x-window-bwrap");
      if (e != null) {
        e.dom.getStyle().setProperty("overflow", "auto");
        e.dom.getStyle().setProperty("position", "static");
      }
    }

    eventPreview.add();

    if (maximized) {
      maximize();
    }
    removeStyleName(HideMode.VISIBILITY.value());

    if (GXT.isAriaEnabled()) {
      Accessibility.setState(getElement(), "aria-hidden", "false");
    }

    fireEvent(Events.Show, new WindowEvent(this));
    toFront();
  }
コード例 #19
0
ファイル: Smape.java プロジェクト: rabbbit/mock-up-with-GWT
  public void onModuleLoad() {
    GXT.setDefaultTheme(Theme.GRAY, true);

    Window gridWindow = createGridWindow();
    Window accordionWindow = createAccordionWindow();
    Window statisticWindow = createStatisticWindow();
    Window geolocationWindow = createGeolocationWindow();
    Window prezioWindow = createPrezioWindow();
    Window videoWindow = createVideoWindow();

    //		Dispatcher dispatcher = Dispatcher.get();
    //	    dispatcher.dispatch(AppEvents.Login);

    //	    desktop.getDesktop().hide();

    //	    desktop.getShortcuts().noti

    //	    desktop.getDesktop().setEnabled(false);
    //	    desktop.getDesktop().hide();
    //	    GXT.hideLoadingPanel("loading");
    //		desktop.getDesktop().setEnabled(true);
    //		desktop.getDesktop().show();
    //		desktop.getDesktop().setZIndex(10);
    //	    desktop.getTaskBar().setVisible(false);
    Window w = getEmptyWindow();
    desktop.addWindow(w);
    w.show();
    w.maximize();
    LoginDialog login = new LoginDialog(w);

    w.setZIndex(1);
    login.show();
    login.focus();
    login.setVisible(true);

    desktop.addWindow(prezioWindow);
    prezioWindow.show();
    prezioWindow.maximize();
    prezioWindow.focus();

    //	    login.setZIndex(15);

    SelectionListener<MenuEvent> menuListener =
        new SelectionListener<MenuEvent>() {
          @Override
          public void componentSelected(MenuEvent me) {
            itemSelected(me);
          }
        };

    SelectionListener<ComponentEvent> shortcutListener =
        new SelectionListener<ComponentEvent>() {
          @Override
          public void componentSelected(ComponentEvent ce) {
            itemSelected(ce);
          }
        };

    Shortcut s1 = new Shortcut();
    s1.setText("Messages Window");
    s1.setId("grid-win-shortcut");
    s1.setData("window", gridWindow);
    s1.addSelectionListener(shortcutListener);
    desktop.addShortcut(s1);

    Shortcut s2 = new Shortcut();
    s2.setText("Contact list");
    s2.setId("acc-win-shortcut");
    s2.setData("window", accordionWindow);
    s2.addSelectionListener(shortcutListener);
    desktop.addShortcut(s2);

    Shortcut s3 = new Shortcut();
    s3.setText("Statistics");
    s3.setId("stat-win-shortcut");
    s3.setData("window", statisticWindow);
    s3.addSelectionListener(shortcutListener);
    desktop.addShortcut(s3);

    TaskBar taskBar = desktop.getTaskBar();

    StartMenu menu = taskBar.getStartMenu();
    menu.setHeading("Eurecom Presentation!");
    menu.setIconStyle("user");

    MenuItem menuItem = new MenuItem("Messages Window");
    menuItem.setData("window", gridWindow);
    menuItem.setIcon(IconHelper.createStyle("icon-grid"));
    menuItem.addSelectionListener(menuListener);
    menu.add(menuItem);

    menuItem = new MenuItem("Archives Window");
    menuItem.setIcon(IconHelper.createStyle("tabs"));
    menuItem.addSelectionListener(menuListener);
    menuItem.setData("window", createTabWindow());
    menu.add(menuItem);

    menuItem = new MenuItem("Contact list");
    menuItem.setIcon(IconHelper.createStyle("accordion"));
    menuItem.addSelectionListener(menuListener);
    menuItem.setData("window", accordionWindow);
    menu.add(menuItem);

    menuItem = new MenuItem("Statistic window");
    menuItem.setIcon(IconHelper.createStyle("icon-statistic"));
    menuItem.addSelectionListener(menuListener);
    menuItem.setData("window", statisticWindow);
    menu.add(menuItem);

    menuItem = new MenuItem("Geolocation window");
    menuItem.setIcon(IconHelper.createStyle("icon-geo"));
    menuItem.addSelectionListener(menuListener);
    menuItem.setData("window", geolocationWindow);
    menu.add(menuItem);

    menuItem = new MenuItem("Last messages");
    menuItem.setIcon(IconHelper.createStyle("icon-sms-menu"));

    Menu sub = new Menu();

    for (int i = 0; i < 3; i++) {
      MenuItem item = new MenuItem("Message " + (i + 1));
      item.setData("window", createBogusWindow(i));
      item.setIcon(IconHelper.createStyle("icon-sms"));
      item.addSelectionListener(menuListener);
      sub.add(item);
    }

    MenuItem item = new MenuItem("Received mms");
    item.setIcon(IconHelper.createStyle("icon-video"));
    item.addSelectionListener(menuListener);
    item.setData("window", videoWindow);
    sub.add(item);

    item = new MenuItem("Presentation window");
    item.setIcon(IconHelper.createStyle("icon-ppt"));
    item.addSelectionListener(menuListener);
    item.setData("window", prezioWindow);
    sub.add(item);

    menuItem.setSubMenu(sub);

    menu.add(menuItem);

    // tools
    MenuItem tool = new MenuItem("Settings");
    tool.setIcon(IconHelper.createStyle("settings"));
    tool.addSelectionListener(
        new SelectionListener<MenuEvent>() {
          @Override
          public void componentSelected(MenuEvent ce) {
            Info.display("Event", "The 'Settings' tool was clicked");
          }
        });
    menu.addTool(tool);

    menu.addToolSeperator();

    tool = new MenuItem("Logout");
    tool.setIcon(IconHelper.createStyle("logout"));
    tool.addSelectionListener(
        new SelectionListener<MenuEvent>() {
          @Override
          public void componentSelected(MenuEvent ce) {
            Info.display("Event", "The 'Logout' tool was clicked");
          }
        });
    menu.addTool(tool);
  }
コード例 #20
0
ファイル: IconButton.java プロジェクト: Elisabitao/gxt-rtl
 protected void onFocus(ComponentEvent ce) {
   if (GXT.isFocusManagerEnabled() && !GXT.isIE) {
     FocusFrame.get().frame(this);
   }
 }
コード例 #21
0
  @Override
  protected boolean validateValue(String value) {
    // validator should run after super rules
    Validator tv = validator;
    validator = null;
    if (!super.validateValue(value)) {
      validator = tv;
      return false;
    }
    validator = tv;
    if (value.length() < 1) { // if it's blank and textfield didn't flag it then
      // its valid it's valid
      return true;
    }

    String v = value;

    Number d = null;
    try {
      d = getPropertyEditor().convertStringValue(v);
    } catch (Exception e) {
      String error = "";
      if (getMessages().getNanText() == null) {
        error = GXT.MESSAGES.numberField_nanText(v);
      } else {
        error = Format.substitute(getMessages().getNanText(), v);
      }
      markInvalid(error);
      return false;
    }
    if (d.doubleValue() < minValue.doubleValue()) {
      String error = "";
      if (getMessages().getMinText() == null) {
        error = GXT.MESSAGES.numberField_minText(minValue.doubleValue());
      } else {
        error = Format.substitute(getMessages().getMinText(), minValue);
      }
      markInvalid(error);
      return false;
    }

    if (d.doubleValue() > maxValue.doubleValue()) {
      String error = "";
      if (getMessages().getMaxText() == null) {
        error = GXT.MESSAGES.numberField_maxText(maxValue.doubleValue());
      } else {
        error = Format.substitute(getMessages().getMaxText(), maxValue);
      }
      markInvalid(error);
      return false;
    }

    if (!allowNegative && d.doubleValue() < 0) {
      markInvalid(getMessages().getNegativeText());
      return false;
    }

    if (validator != null) {
      String msg = validator.validate(this, value);
      if (msg != null) {
        markInvalid(msg);
        return false;
      }
    }

    if (GXT.isAriaEnabled()) {
      getInputEl().dom.setAttribute("aria-valuenow", "" + value);
    }

    return true;
  }