コード例 #1
0
ファイル: GroupingView.java プロジェクト: Elisabitao/gxt-rtl
  @Override
  protected Menu createContextMenu(final int colIndex) {
    Menu menu = super.createContextMenu(colIndex);

    if (menu != null && enableGroupingMenu && cm.isGroupable(colIndex)) {
      MenuItem groupBy = new MenuItem(GXT.MESSAGES.groupingView_groupByText());
      groupBy.setIcon(getImages().getGroupBy());
      groupBy.addSelectionListener(
          new SelectionListener<MenuEvent>() {

            @Override
            public void componentSelected(MenuEvent ce) {
              onGroupByClick(ce, colIndex);
            }
          });
      menu.add(new SeparatorMenuItem());
      menu.add(groupBy);
    }

    if (menu != null && enableGroupingMenu && enableGrouping && enableNoGroups) {
      final CheckMenuItem showInGroups =
          new CheckMenuItem(GXT.MESSAGES.groupingView_showGroupsText());
      showInGroups.setChecked(true);
      showInGroups.addSelectionListener(
          new SelectionListener<MenuEvent>() {

            @Override
            public void componentSelected(MenuEvent ce) {
              onShowGroupsClick(ce, showInGroups.isChecked());
            }
          });
      menu.add(showInGroups);
    }
    return menu;
  }
コード例 #2
0
ファイル: StringFilter.java プロジェクト: Elisabitao/gxt-rtl
  public static class StringFilterMessages extends FilterMessages {
    private String emptyText = GXT.MESSAGES.stringFilter_emptyText();

    /**
     * Returns the field's empty text.
     *
     * @return the empty text
     */
    public String getEmptyText() {
      return emptyText;
    }

    /**
     * Sets the field empty text (defaults to 'Enter filter text...').
     *
     * @param emptyText the empty text
     */
    public void setEmptyText(String emptyText) {
      this.emptyText = emptyText;
    }
  }
コード例 #3
0
ファイル: LiveGridView.java プロジェクト: Elisabitao/gxt-rtl
 private void maskView() {
   if (!isMasked && grid.isLoadMask()) {
     scroller.mask(GXT.MESSAGES.loadMask_msg());
     isMasked = true;
   }
 }
コード例 #4
0
  /**
   * @param master
   * @param newClient
   */
  public ClientImportWindow(GroupJSO group, boolean master) {
    this.group = group;
    this.master = master;

    clientConstants = GWT.create(ClientConstants.class);

    clientFactory = BeanModelLookup.get().getFactory(ClientJSO.CLASS_NAME);

    setIcon(IconHelper.createStyle("icon-grid"));
    setMinimizable(true);
    setMaximizable(true);
    setSize(640, 350);
    setHeading("Import klientů");
    //		setBodyStyle("padding: 0px; ");

    //		FormLayout layout = new FormLayout();
    //		layout.setLabelAlign(LabelAlign.LEFT);
    //		setLayout(layout);
    setLayout(new FitLayout());

    clientStore = new ListStore<BeanModel>();
    clientStore.sort("name", SortDir.ASC);
    clientStore.setKeyProvider(
        new ModelKeyProvider<BeanModel>() {

          @Override
          public String getKey(BeanModel model) {
            return model.get("uuid");
          }
        });
    clientStore.setModelComparer(
        new ModelComparer<BeanModel>() {

          @Override
          public boolean equals(BeanModel m1, BeanModel m2) {
            if (m1 == m2) {
              return true;
            }
            if (m1 == null || m2 == null) {
              return false;
            }
            return m1.get("uuid").equals(m2.get("uuid"));
          }
        });

    ColumnConfig name = new ColumnConfig("name", clientConstants.getName(), 180);
    ColumnConfig description =
        new ColumnConfig("description", clientConstants.getDescription(), 180);
    ColumnConfig macAddress = new ColumnConfig("macAddress", clientConstants.getMacAddress(), 140);
    ColumnConfig ipAddress = new ColumnConfig("ipAddress", clientConstants.getIpAddress(), 80);

    final CheckBoxSelectionModel<BeanModel> sm = new CheckBoxSelectionModel<BeanModel>();

    List<ColumnConfig> config = new ArrayList<ColumnConfig>();

    config.add(sm.getColumn());
    config.add(name);
    config.add(description);
    config.add(macAddress);
    config.add(ipAddress);

    final ColumnModel cm = new ColumnModel(config);

    clientsGrid = new Grid<BeanModel>(clientStore, cm);
    clientsGrid.setBorders(true);
    clientsGrid.setColumnReordering(true);
    clientsGrid.setSelectionModel(sm);
    clientsGrid.addPlugin(sm);

    GridFilters filters = new GridFilters();
    filters.setLocal(true);

    filters.addFilter(new StringFilter("name"));
    filters.addFilter(new StringFilter("description"));
    filters.addFilter(new StringFilter("ipAddress"));
    filters.addFilter(new StringFilter("macAddress"));

    clientsGrid.addPlugin(filters);

    add(clientsGrid, new FitData());

    clientsGrid.mask(GXT.MESSAGES.loadMask_msg());

    generateButtons();
  }
コード例 #5
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);
    }
  }
コード例 #6
0
  /** SpinnerField messages. */
  public class SpinnerFieldMessages extends TextFieldMessages {
    private String maxText;
    private String minText;
    private String nanText;
    private String negativeText = GXT.MESSAGES.numberField_negativeText();

    /**
     * Returns the max error text.
     *
     * @return the error text
     */
    public String getMaxText() {
      return maxText;
    }

    /**
     * Returns the minimum error text.
     *
     * @return the minimum error text
     */
    public String getMinText() {
      return minText;
    }

    /**
     * Returns the not a number error text.
     *
     * @return the not a number error text
     */
    public String getNanText() {
      return nanText;
    }

    /**
     * Returns the negative error text.
     *
     * @return the error text
     */
    public String getNegativeText() {
      return negativeText;
    }

    /**
     * Error text to display if the maximum value validation fails (defaults to "The maximum value
     * for this field is {maxValue}").
     *
     * @param maxText the max error text
     */
    public void setMaxText(String maxText) {
      this.maxText = maxText;
    }

    /**
     * Sets the Error text to display if the minimum value validation fails (defaults to "The
     * minimum value for this field is {minValue}").
     *
     * @param minText min error text
     */
    public void setMinText(String minText) {
      this.minText = minText;
    }

    /**
     * Sets the error text to display if the value is not a valid number. For example, this can
     * happen if a valid character like '.' or '-' is left in the field with no number (defaults to
     * "{value} is not a valid number").
     *
     * @param nanText the not a number text
     */
    public void setNanText(String nanText) {
      this.nanText = nanText;
    }

    /**
     * Sets the negative error text (defaults to 'The value must be greater or equal to 0').
     *
     * @param negativeText the error text
     */
    public void setNegativeText(String negativeText) {
      this.negativeText = negativeText;
    }
  }
コード例 #7
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;
  }