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

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


   private void createStatusMenu()
   {
     iJabConstants constants = JabberApp.getConstants();
     statusMenu = new Menu();
    
     onlineItem = new MenuItem();
     onlineItem.setText(constants.online());
     onlineItem.addSelectionListener(new SelectionListener<MenuEvent>()
     {
      public void componentSelected(MenuEvent ce) {
        changeShow("");
       
      }
     });

     onlineItem.setIconStyle("contact-icon-online");
     statusMenu.add(onlineItem);
    
     chatItem = new MenuItem();
     chatItem.setText(constants.freeChat());
     chatItem.addSelectionListener(new SelectionListener<MenuEvent>()
     {
      public void componentSelected(MenuEvent ce) {
        changeShow("chat");
      }      
     });

     chatItem.setIconStyle("contact-icon-online");
     statusMenu.add(chatItem);
    
     awayItem = new MenuItem();
     awayItem.setText(constants.away());
     awayItem.addSelectionListener(new SelectionListener<MenuEvent>()
     {
      public void componentSelected(MenuEvent ce) {
        changeShow("away")
      }      
     });
     awayItem.setIconStyle("contact-icon-away");
     statusMenu.add(awayItem);
    
     dndItem = new MenuItem();
     dndItem.setText(constants.dnd());
     dndItem.setIconStyle("contact-icon-busy");
     dndItem.addSelectionListener(new SelectionListener<MenuEvent>()
     {
      public void componentSelected(MenuEvent ce) {
        changeShow("dnd");        
      }
     });
     statusMenu.add(dndItem);
    
     xaItem = new MenuItem();
     xaItem.setText(constants.xa());
     xaItem.addSelectionListener(new SelectionListener<MenuEvent>()
     {
      public void componentSelected(MenuEvent ce) {
         changeShow("xa");
View Full Code Here


    }
   
    private Menu createContextMenu()
    {
      Menu menu = new Menu();
      chatItem = new MenuItem(JabberApp.getConstants().openChat());
      chatItem.addListener(Events.Select, new Listener<MenuEvent>()
      {
      public void handleEvent(MenuEvent me)
      {
        List<ContactData> datas = store.getModels();
        ContactData data = datas.get(currentItem);
        if(data == null)
          return;
        String jid = data.get(JID);
        ChatWindow.openChat(XmppID.parseId(jid));
       
      }
       
      });
     
      infoItem = new MenuItem(JabberApp.getConstants().userInfo());
      infoItem.addListener(Events.Select, new Listener<MenuEvent>()
      {
      public void handleEvent(MenuEvent me)
      {
        List<ContactData> datas = store.getModels();
        ContactData data = datas.get(currentItem);
        if(data == null)
          return;
        String jid = data.get(JID);
        JabberApp.instance().showInfo(XmppID.parseId(jid));
      }
       
      });
     
      requestAuth = new MenuItem(JabberApp.getConstants().Rerequset_authorization());
      requestAuth.addListener(Events.Select, new Listener<MenuEvent>()
      {
      public void handleEvent(MenuEvent me)
      {
        List<ContactData> datas = store.getModels();
        ContactData data = datas.get(currentItem);
        if(data == null)
          return;
        String jid = data.get(JID);
        JabberApp.instance().dj_authReq(XmppID.parseId(jid),"");
      }
       
      });
     
      deleteItem = new MenuItem(JabberApp.getConstants().Delete());
      deleteItem.addListener(Events.Select, new Listener<MenuEvent>()
      {
      public void handleEvent(MenuEvent me)
      {
        List<ContactData> datas = store.getModels();
        ContactData data = datas.get(currentItem);
        if(data == null)
          return;
        final String jid = data.get(JID);       
        String msg = JabberApp.getConstants().DeleteConfirm() +" "+jid+"?";
        MessageBox.confirm("Confirm",msg, new Listener<WindowEvent>()
        {
          public void handleEvent(WindowEvent be)
          {
            Dialog dialog = (Dialog) be.component;
            Button btn = dialog.getButtonPressed();
            if(btn.getItemId().equals(Dialog.YES))
              JabberApp.instance().removeUser(XmppID.parseId(jid));
             
          }

        });
      }
       
      });
     
      onlineOnlyItem = new CheckMenuItem(JabberApp.getConstants().Show_online_only());
      onlineOnlyItem.setChecked(iJabPrefs.instance().showOnlineOnly);
      onlineOnlyItem.addListener(Events.Select, new Listener<MenuEvent>()
      {
      public void handleEvent(MenuEvent me)
      {
        CheckMenuItem item = (CheckMenuItem)me.item;
        if(item.isChecked())
          iJabPrefs.instance().showOnlineOnly = true;
        else
          iJabPrefs.instance().showOnlineOnly = false;
        grid.getSelectionModel().deselectAll();
        store.clearFilters();
        store.applyFilters("");
      }
       
      });
     
      renameItem = new MenuItem(JabberApp.getConstants().Rename());
      renameItem.addListener(Events.Select, new Listener<MenuEvent>()
      {
      public void handleEvent(MenuEvent me)
      {
        List<ContactData> datas = store.getModels();
        ContactData data = datas.get(currentItem);
        if(data == null)
          return;
        final String jid = data.get(JID);   
        final String nick = data.get(ALIAS);
        final MessageBox box = MessageBox.prompt(JabberApp.getConstants().Rename(), JabberApp.getConstants().RenamePrompt()+" "+nick+":");
        box.addCallback(new Listener<MessageBoxEvent>()
        { 
          public void handleEvent(MessageBoxEvent be)
          { 
            if(!be.value.isEmpty())
            {
              if(!be.buttonClicked.getItemId().equals(MessageBox.OK))
                return;
              if(!nick.equals(be.value))
                JabberApp.instance().renameUser(XmppID.parseId(jid), be.value);
            }
          } 
        });
      }
       
      });
     
      groupMenuItem = new MenuItem(JabberApp.getConstants().Group());
      groupMenu = new Menu();
      groupMenuItem.setSubMenu(groupMenu);
      groupMenuItem.addListener(Events.Activate, new Listener<MenuEvent>()
      {
      public void handleEvent(MenuEvent be)
      {
        List<ContactData> datas = store.getModels();
        ContactData data = datas.get(currentItem);
        if(data == null)
          return;
        final String jid = data.get(JID);
        final String group = data.get(USER_GROUP_DD);
        final String nick = data.get(ALIAS);
       
        Menu groupMenu = groupMenuItem.getSubMenu();
        groupMenu.removeAll();
        for(String g:m_groups)
        {
          CheckMenuItem gItem = new CheckMenuItem(g);
          gItem.setGroup("groups");
          if(g.equals(group))
            gItem.setChecked(true);
          groupMenu.add(gItem);
          gItem.addListener(Events.Select, new Listener<MenuEvent>()
          {
            public void handleEvent(MenuEvent be)
            {
              MenuItem mItem = (MenuItem)be.item;
              String newGroup = mItem.getText();
              if(!newGroup.equals(group))
                JabberApp.instance().changeGroup(XmppID.parseId(jid),nick, newGroup);
            }
           
          });
        }
        groupMenu.add(new SeparatorMenuItem());
        MenuItem newGroupItem = new MenuItem(JabberApp.getConstants().New_Group());
        newGroupItem.addListener(Events.Select, new Listener<MenuEvent>()
        {
          public void handleEvent(MenuEvent be)
          {
            final MessageBox box = MessageBox.prompt(JabberApp.getConstants().New_Group(), JabberApp.getConstants().NewGroupPrompt());
            box.addCallback(new Listener<MessageBoxEvent>()
View Full Code Here

   * @return
   */
  public MenuItem addContextMenuItem(String text, Boolean enabled,
      SelectionListener<MenuEvent> listener) {
    initializeContextMenu();
    MenuItem item = new MenuItem();
    item.setText(text);
    item.addSelectionListener(listener);
    item.setEnabled(enabled);
    contextMenu.add(item);
    return item;
  }
View Full Code Here

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

    if (cm.isSortable(colIndex)) {
      MenuItem item = new MenuItem();
      item.setText(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.setText(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);
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.setIcon(IconHelper.createStyle("my-icon-asc"));
      item.addSelectionListener(new SelectionListener<MenuEvent>() {
        public void componentSelected(MenuEvent ce) {
          table.sort(column.index, SortDir.ASC);
        }

      });
      menu.add(item);

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

    MenuItem columns = new MenuItem();
    columns.setText(GXT.MESSAGES.gridView_columnsText());
    columns.setIcon(IconHelper.createStyle("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<MenuEvent>() {

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

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

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

      });
      columnMenu.add(check);

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

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

    if (table instanceof Table) {
      TableEvent e = new TableEvent((Table) table);
      e.setColumnIndex(column.getIndex());
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

  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.getText(), sb.getIcon());
      item.setEnabled(c.isEnabled());
      item.setItemId(c.getItemId());
      if (sb.getData("gxt-menutext") != null) {
        item.setText(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.getText(), b.getIcon());
      item.setItemId(c.getItemId());

      if (b.getData("gxt-menutext") != null) {
        item.setText(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

          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

          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

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.