Package com.extjs.gxt.ui.client.widget.menu

Examples of com.extjs.gxt.ui.client.widget.menu.MenuItem


          icon = GXT.IMAGES.grid_filter_equal();
          eq = field;
          break;
      }

      MenuItem menuItem = new MenuItem();
      menuItem.setCanActivate(false);
      menuItem.setHideOnClick(false);
      menuItem.setIcon(icon);

      menuItem.setWidget(field);

      add(menuItem);
    }
    layout();
  }
View Full Code Here


  }

  protected abstract Loader<?> getLoader(Store<ModelData> store);

  protected Filter getMenuFilter(MenuEvent me) {
    MenuItem item = (MenuItem) me.getItem();
    ColumnConfig config = grid.getColumnModel().getColumn((Integer) item.getData("index"));
    return getFilter(config.getDataIndex());
  }
View Full Code Here

  @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);
        }
View Full Code Here

          public void handleEvent(MenuEvent be) {
            be.getContainer().setData("tab", null);
          }
        });

        closeContextMenu.add(new MenuItem(messages.getCloseText(), new SelectionListener<MenuEvent>() {
          @Override
          public void componentSelected(MenuEvent ce) {
            TabItem item = (TabItem) ce.getContainer().getData("tab");
            close(item);
          }
        }));
        closeContextMenu.add(new MenuItem(messages.getCloseOtherText(), new SelectionListener<MenuEvent>() {

          @Override
          public void componentSelected(MenuEvent ce) {
            TabItem item = (TabItem) ce.getContainer().getData("tab");
            List<TabItem> items = new ArrayList<TabItem>();
View Full Code Here

  protected Menu onShowContextMenu(final TableColumn column) {
    final Menu menu = new Menu();

    if (column.isSortable()) {
      MenuItem item = new MenuItem();
      item.setText(GXT.MESSAGES.gridView_sortAscText());
      item.setIconStyle("my-icon-asc");
      item.addSelectionListener(new SelectionListener<ComponentEvent>() {
        public void componentSelected(ComponentEvent ce) {
          table.sort(column.index, SortDir.ASC);
        }

      });
      menu.add(item);

      item = new MenuItem();
      item.setText(GXT.MESSAGES.gridView_sortDescText());
      item.setIconStyle("my-icon-desc");
      item.addSelectionListener(new SelectionListener<ComponentEvent>() {
        public void componentSelected(ComponentEvent ce) {
          table.sort(column.index, SortDir.DESC);
        }
      });
      menu.add(item);
    }

    MenuItem columns = new MenuItem();
    columns.setText(GXT.MESSAGES.gridView_columnsText());
    columns.setIconStyle("icon-columns");

    final Menu columnMenu = new Menu();

    int cols = columnModel.getColumnCount();
    for (int i = 0; i < cols; i++) {
      final TableColumn def = columnModel.getColumn(i);
      final CheckMenuItem check = new CheckMenuItem();
      check.setHideOnClick(false);
      check.setText(def.getText());
      check.setChecked(!def.isHidden());
      check.addSelectionListener(new SelectionListener<ComponentEvent>() {

        public void componentSelected(ComponentEvent ce) {
          def.setHidden(!check.isChecked());
          showColumn(def.index, !def.isHidden());

          if (columnModel.getVariableColumnCount() > 0) {
            resizeColumns(false, true);
          }

          if (columnModel.getVisibleColumnCount() == 1) {
            for (Item item : columnMenu.getItems()) {
              CheckMenuItem check = (CheckMenuItem) item;
              if (check.isChecked()) {
                item.disable();
              }
            }
          } else if (columnModel.getVisibleColumnCount() == 2) {
            for (Item item : columnMenu.getItems()) {
              item.enable();
            }
          }
        }

      });
      columnMenu.add(check);

      if (columnModel.getVisibleColumnCount() == 1) {
        for (Item item : columnMenu.getItems()) {
          CheckMenuItem ci = (CheckMenuItem) item;
          if (ci.isChecked()) {
            ci.disable();
          }
        }
      }
    }

    columns.setSubMenu(columnMenu);
    menu.add(columns);

    return menu;
  }
View Full Code Here

  protected Menu createContextMenu(final int colIndex) {
    final Menu menu = new Menu();

    if (cm.isSortable(colIndex)) {
      MenuItem item = new MenuItem();
      item.setHtml(GXT.MESSAGES.gridView_sortAscText());
      item.setIcon(getImages().getSortAsc());
      item.addSelectionListener(new SelectionListener<MenuEvent>() {
        public void componentSelected(MenuEvent ce) {
          doSort(colIndex, SortDir.ASC);
        }

      });
      menu.add(item);

      item = new MenuItem();
      item.setHtml(GXT.MESSAGES.gridView_sortDescText());
      item.setIcon(getImages().getSortDesc());
      item.addSelectionListener(new SelectionListener<MenuEvent>() {
        public void componentSelected(MenuEvent ce) {
          doSort(colIndex, SortDir.DESC);
        }
      });
      menu.add(item);
    }

    MenuItem columns = new MenuItem();
    columns.setHtml(GXT.MESSAGES.gridView_columnsText());
    columns.setIcon(getImages().getColumns());
    columns.setData("gxt-columns", "true");

    final Menu columnMenu = new Menu();

    int cols = cm.getColumnCount();
    for (int i = 0; i < cols; i++) {
      if (shouldNotCount(i, false)) {
        continue;
      }
      final int fcol = i;
      final CheckMenuItem check = new CheckMenuItem();
      check.setHideOnClick(false);
      check.setHtml(cm.getColumnHeader(i));
      check.setChecked(!cm.isHidden(i));
      check.addSelectionListener(new SelectionListener<MenuEvent>() {
        public void componentSelected(MenuEvent ce) {
          cm.setHidden(fcol, !cm.isHidden(fcol));
          restrictMenu(columnMenu);
        }
      });
      columnMenu.add(check);
    }

    restrictMenu(columnMenu);
    columns.setEnabled(columnMenu.getItemCount() > 0);
    columns.setSubMenu(columnMenu);
    menu.add(columns);
    return menu;
  }
View Full Code Here

  protected void addComponentToMenu(Menu menu, Component c) {
    if (c instanceof SeparatorToolItem) {
      menu.add(new SeparatorMenuItem());
    } else if (c instanceof SplitButton) {
      final SplitButton sb = (SplitButton) c;
      MenuItem item = new MenuItem(sb.getHtml(), sb.getIcon());
      item.setEnabled(c.isEnabled());
      item.setItemId(c.getItemId());
      if (sb.getData("gxt-menutext") != null) {
        item.setHtml(sb.getData("gxt-menutext").toString());
      }
      if (sb.getMenu() != null) {
        item.setSubMenu(sb.getMenu());
      }
      item.addSelectionListener(new SelectionListener<MenuEvent>() {

        @Override
        public void componentSelected(MenuEvent ce) {
          ButtonEvent e = new ButtonEvent(sb);
          e.setEvent(ce.getEvent());
          sb.fireEvent(Events.Select, e);
        }

      });
      menu.add(item);

    } else if (c instanceof Button) {
      final Button b = (Button) c;
      MenuItem item = new MenuItem(b.getHtml(), b.getIcon());
      item.setItemId(c.getItemId());

      if (b.getData("gxt-menutext") != null) {
        item.setHtml(b.getData("gxt-menutext").toString());
      }
      if (b.getMenu() != null) {
        item.setHideOnClick(false);
        item.setSubMenu(b.getMenu());
      }
      item.setEnabled(c.isEnabled());
      item.addSelectionListener(new SelectionListener<MenuEvent>() {

        @Override
        public void componentSelected(MenuEvent ce) {
          ButtonEvent e = new ButtonEvent(b);
          e.setEvent(ce.getEvent());
View Full Code Here

  @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);
        }
View Full Code Here

          icon = GXT.IMAGES.grid_filter_equal();
          eq = field;
          break;
      }

      MenuItem menuItem = new MenuItem();
      menuItem.addStyleName("x-range-menu-item");
      menuItem.setCanActivate(false);
      menuItem.setHideOnClick(false);
      menuItem.setIcon(icon);

      menuItem.setWidget(field);
     
      menuItem.removeStyleName("x-unselectable");

      add(menuItem);
    }
    layout();
  }
View Full Code Here

  }

  protected abstract Loader<?> getLoader(Store<ModelData> store);

  protected Filter getMenuFilter(MenuEvent me) {
    MenuItem item = (MenuItem) me.getItem();
    ColumnConfig config = grid.getColumnModel().getColumn((Integer) item.getData("index"));
    return getFilter(config.getDataIndex());
  }
View Full Code Here

TOP

Related Classes of com.extjs.gxt.ui.client.widget.menu.MenuItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.