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

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


    private void buildPasswordMenu(MenuBar mainMenu)
    {
        Menu passwordMenu = new Menu();
        if (clientSessionUtil.isAuthorized(Function.ADD_PASSWORD))
        {
            passwordMenu.add(new MenuItem(textMessages.add(), new SelectionListener<MenuEvent>() {
                @Override
                public void componentSelected(MenuEvent ce) {
                    doNewPassword();
                }
            }));
        }
        MenuItem passwordSearch = new MenuItem(textMessages.search());
        Menu passwordSearchMenu = new Menu();
        passwordSearchMenu.add(new MenuItem(textMessages.openSelectedPassword(), new SelectionListener<MenuEvent>() {
            @Override
            public void componentSelected(MenuEvent ce) {
                if (null != passwordSearchPanel)
                {
                    passwordSearchPanel.openSelectedPassword();
                }
            }
        }));
        passwordSearchMenu.add(new MenuItem(textMessages.getSelectedPasswordValue(), new SelectionListener<MenuEvent>() {
            @Override
            public void componentSelected(MenuEvent ce) {
                if (null != passwordSearchPanel)
                {
                    passwordSearchPanel.getSelectedCurrentPasswordData();
                }
            }
        }));
        passwordSearchMenu.add(new MenuItem(textMessages.refreshSearch(), new SelectionListener<MenuEvent>() {
            @Override
            public void componentSelected(MenuEvent ce) {
                refreshPasswordSearch();
            }
        }));
        passwordSearch.setSubMenu(passwordSearchMenu);
        passwordMenu.add(passwordSearch);

        MenuItem passwordTemplate = new MenuItem(textMessages.template());
        Menu passwordTemplateMenu = new Menu();
        if (clientSessionUtil.isAuthorized(Function.ADD_TEMPLATE))
        {
            passwordTemplateMenu.add(new MenuItem(textMessages.add(), new SelectionListener<MenuEvent>() {
                @Override
                public void componentSelected(MenuEvent ce) {
                    doAddTemplate();
                }
            }));
        }
        if (clientSessionUtil.isAuthorized(Function.UPDATE_TEMPLATE))
        {
            passwordTemplateMenu.add(new MenuItem(textMessages.edit(), new SelectionListener<MenuEvent>() {
                @Override
                public void componentSelected(MenuEvent ce) {
                    doEditTemplate();
                }
            }));
        }
        passwordTemplate.setSubMenu(passwordTemplateMenu);
        passwordMenu.add(passwordTemplate);

        mainMenu.add(new MenuBarItem(textMessages.password(), passwordMenu));
    }
View Full Code Here


            clientSessionUtil.isAuthorized(Function.UNBLOCK_IP))
        {
            Menu adminMenu = new Menu();
            //adminMenu.add(new MenuItem("Settings"));
   
            MenuItem adminUser = new MenuItem(textMessages.users());
            Menu adminUserMenu = new Menu();
            if (clientSessionUtil.isAuthorized(Function.ADD_USER))
            {
                adminUserMenu.add(new MenuItem(textMessages.add(), new SelectionListener<MenuEvent>() {
                    @Override
                    public void componentSelected(MenuEvent ce) {
                        doAddUser();
                    }
                }));
            }
            if (clientSessionUtil.isAuthorized(Function.UPDATE_USER))
            {
                adminUserMenu.add(new MenuItem(textMessages.edit(), new SelectionListener<MenuEvent>() {
                    @Override
                    public void componentSelected(MenuEvent ce) {
                        doEditUser();
                    }
                }));
            }
            adminUser.setSubMenu(adminUserMenu);
            adminMenu.add(adminUser);
           
            MenuItem adminGroup = new MenuItem(textMessages.groups());
            Menu adminGroupMenu = new Menu();
            if (clientSessionUtil.isAuthorized(Function.ADD_GROUP))
            {
                adminGroupMenu.add(new MenuItem(textMessages.add(), new SelectionListener<MenuEvent>() {
                    @Override
                    public void componentSelected(MenuEvent ce) {
                        doAddGroup();
                    }
                }));
            }
            if (clientSessionUtil.isAuthorized(Function.UPDATE_GROUP))
            {
                adminGroupMenu.add(new MenuItem(textMessages.edit(), new SelectionListener<MenuEvent>() {
                    @Override
                    public void componentSelected(MenuEvent ce) {
                        doEditGroup();
                    }
                }));
            }
            adminGroup.setSubMenu(adminGroupMenu);
            adminMenu.add(adminGroup);

            MenuItem adminTools = new MenuItem(textMessages.tools());
            Menu adminToolsMenu = new Menu();
            if (clientSessionUtil.isAuthorized(Function.UNBLOCK_IP))
            {
                adminToolsMenu.add(new MenuItem(textMessages.unblockIP(), new SelectionListener<MenuEvent>() {
                    @Override
                    public void componentSelected(MenuEvent ce) {
                        doUnblockIP();
                    }
                }));
            }
            adminTools.setSubMenu(adminToolsMenu);
            adminMenu.add(adminTools);
           
            mainMenu.add(new MenuBarItem(textMessages.admin(), adminMenu));
        }
//        MenuItem adminRole = new MenuItem("Roles");
View Full Code Here

    {
        Menu reportsMenu = new Menu();
        List<Map<String, Object>> reports = getClientModel().getAvailableReports();
        for (final Map<String, Object> report : reports)
        {
            MenuItem menuItem = new MenuItem((String)report.get(Constants.I18N), new SelectionListener<MenuEvent>()
            {
                @Override
                public void componentSelected(MenuEvent ce)
                {
                    displayReportDialog(report);
View Full Code Here

    }

    private void buildAboutMenu(MenuBar mainMenu)
    {
        Menu aboutMenu = new Menu();
        aboutMenu.add(new MenuItem(textMessages.help(), new SelectionListener<MenuEvent>()
        {
            @Override
            public void componentSelected(MenuEvent ce)
            {
                doShowHelp();
            }
        }));
        aboutMenu.add(new MenuItem(textMessages.about(), new SelectionListener<MenuEvent>()
        {
            @Override
            public void componentSelected(MenuEvent ce)
            {
                doShowAbout();
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

  @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

    Menu selectiontMenu = new Menu();
    selectionMenuHead.setMenu(selectiontMenu);
    mb.add(selectionMenuHead);
   
   
    MenuItem getInformation = new MenuItem("More Information");
    getInformation.setIconStyle("icon-menu-information");
    getInformation.addSelectionListener(new SelectionListener<MenuEvent>(){

      @Override
      public void componentSelected(MenuEvent ce) {

        //
        String id = contentSection.getSelectedItemsId();
        if(null == id)
          Window.alert("Please select item");
        else
          Commands.getInstance().getInformationOn(id, ClientUtils.MASTER);
      }
    });
    selectiontMenu.add(getInformation);
   
    MenuItem gotoStaticDisplay = new MenuItem("Goto Static Display");
    gotoStaticDisplay.setIconStyle("icon-menu-gotoStatic");
    gotoStaticDisplay.addSelectionListener(new SelectionListener<MenuEvent>(){

      @Override
      public void componentSelected(MenuEvent ce) {
        //
        String id = contentSection.getSelectedItemsId();
        if(null == id)
          Window.alert("Please select item");
        else
          Commands.getInstance().gotoStaticDisplay(id, ClientUtils.MASTER);
      }
    });
    selectiontMenu.add(gotoStaticDisplay);
    selectiontMenu.add(new SeparatorMenuItem());
   

    MenuItem addNote = new MenuItem("Add Note to Paragraph");
    addNote.setIconStyle("icon-menu-addNote");
    addNote.addSelectionListener(new SelectionListener<MenuEvent>(){

      @Override
      public void componentSelected(MenuEvent ce) {
        //
        String id = contentSection.getSelectedItemsId();
        if(null == id)
          Window.alert("Please select item");
        else {
           new NotesPanel(id, TCNote.TYPE_PARAGRAPH, new NotePanelCallback<TCNote, Integer>(){
            public void callback(TCNote note, Integer type) {
              if(type == NotesPanel.NOTE_ADDED)
                contentSection.addNote(note);
            }
           });
        }
      }
    });
    selectiontMenu.add(addNote);
   
   
   
   
    selectiontMenu.add(new SeparatorMenuItem());
   
    MenuItem showMatches = new MenuItem("Display Matches");
    showMatches.setIconStyle("icon-menu-displayMatches");
    showMatches.addSelectionListener(new SelectionListener<MenuEvent>(){

      @Override
      public void componentSelected(MenuEvent ce) {
        contentSection.loadAndDisplayMatches();
      }
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

    Menu addMatchesMenu = new Menu();
    addMatchesMenuHead.setMenu(addMatchesMenu);
    mb.add(addMatchesMenuHead);     
   
    // propose matches
    MenuItem proposeMatch = new MenuItem("Propose Matches");
    proposeMatch.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
        ClientState.proposeMoreMatches = null;
        Commands.getInstance().findNewMatchFor(selectedPartsID,ClientUtils.SHINGLE_CLOUD_NORMAL);
      }
    });
    addMatchesMenu.add(proposeMatch);
   
    MenuItem manuallySearchMatch = new MenuItem("Manual Search");
    manuallySearchMatch.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
          final MessageBox box = MessageBox.prompt("Manual Search", "Please enter your search query:")
          box.addCallback(new Listener<MessageBoxEvent>() { 
               public void handleEvent(MessageBoxEvent ce) { 
                 Dialog box = (Dialog) ce.getBoxComponent();
                 TextField<String> textField = (TextField<String>) box.getFocusWidget();
                       String query = (String) textField.getValue();

                       if(query.length() > 0){
                         Info.display("Notice", "Manual search for: {0}", new Params(query));
                        
                         Commands.getInstance().performManualSearch(
                          ClientState.getCurrentlyDerivedFile(), query, 0,
                          new CommandCallback<SearchResults>(){
                    public void cc_callback(SearchResults proposals) {
                      displayMatchProposalsFor(selectedPartsID, proposals);
                    }
                           }
                         );
                       } else
                         Info.display("Error", "You cannot search for an empty string.");
              
         })
      }
    });
    addMatchesMenu.add(manuallySearchMatch);
   
    MenuItem manuallyNavigateMatch = new MenuItem("Manual Navigation");
    manuallyNavigateMatch.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
        Commands.getInstance().showSelectSection(ClientState.getCurrentlyDerivedFile(), new TableOfContentsPanelItemSelectedListener(){
          public void tocp_itemSelected(TableOfContentsEntry entry) {
               Commands.getInstance().selectSection(ClientState.getCurrentlyDerivedFile(), entry, new CommandCallback<Section>(){
View Full Code Here

      Button matchMenuHead = new Button("Match");
      Menu matchMenu = new Menu();
      matchMenuHead.setMenu(matchMenu);
      mb.add(matchMenuHead)
     
      MenuItem moreInformation = new MenuItem("More Information");
      moreInformation.setIconStyle("icon-menu-information");
      moreInformation.addSelectionListener(new SelectionListener<MenuEvent>(){
        @Override
        public void componentSelected(MenuEvent ce) {
          // find out which tab was selected
          TCLink link = tabLookup.get(tabPanel.getSelectedItem());
          Commands.getInstance().getInformationOn(link.getCurrentDerivedId(), ClientUtils.DERIVED);
        }
      });
      matchMenu.add(moreInformation);
     
      MenuItem gotoStaticDisplay = new MenuItem("Goto static display");
      gotoStaticDisplay.setIconStyle("icon-menu-gotoStatic");
      gotoStaticDisplay.addSelectionListener(new SelectionListener<MenuEvent>(){
        @Override
        public void componentSelected(MenuEvent ce) {
          // find out which tab was selected
          TCLink link = tabLookup.get(tabPanel.getSelectedItem());
          Commands.getInstance().gotoStaticDisplay(link.getCurrentDerivedId(), ClientUtils.DERIVED);
        }
      });
      matchMenu.add(gotoStaticDisplay);
     
      matchMenu.add(new SeparatorMenuItem());
     
      MenuItem addNote = new MenuItem("Add Note to Paragraph");
      addNote.setIconStyle("icon-menu-addNote");
      addNote.addSelectionListener(new SelectionListener<MenuEvent>(){

        @Override
        public void componentSelected(MenuEvent ce) {
          //
          final NoteItem mItem = (NoteItem) tabPanel.getSelectedItem().getWidget(0);
          String id = mItem.getId();
           new NotesPanel(id, TCNote.TYPE_PARAGRAPH, new NotePanelCallback<TCNote, Integer>(){
            public void callback(TCNote note, Integer type) {
              if(type == NotesPanel.NOTE_ADDED)
                mItem.addNote(note);
            }
           });
        }
      });
      matchMenu.add(addNote);
     
      MenuItem addNoteMatch = new MenuItem("Add Note to Match");
      addNoteMatch.setIconStyle("icon-menu-addNote");
      addNoteMatch.addSelectionListener(new SelectionListener<MenuEvent>(){

        @Override
        public void componentSelected(MenuEvent ce) {
          //
          final NoteItem mItem = (NoteItem) tabPanel.getSelectedItem().getWidget(0);
          String id = mItem.getId();
           new NotesPanel(id, TCNote.TYPE_LINK, new NotePanelCallback<TCNote, Integer>(){
            public void callback(TCNote note, Integer type) {
              if(type == NotesPanel.NOTE_ADDED)
                mItem.addNote(note);
            }
           });
        }
      });
      matchMenu.add(addNoteMatch);
     
      matchMenu.add(new SeparatorMenuItem());
     
      MenuItem confirmLink = new MenuItem("Confirm Match");
      confirmLink.setIconStyle("icon-menu-confirmLink");
      confirmLink.addSelectionListener(new SelectionListener<MenuEvent>(){
        @Override
        public void componentSelected(MenuEvent ce) {
          // find out which tab was selected
          TCLink link = tabLookup.get(tabPanel.getSelectedItem());
          Commands.getInstance().confirmMatch(link);
        }
      });
      matchMenu.add(confirmLink);
     
      matchMenu.add(new SeparatorMenuItem());

      MenuItem deleteLink = new MenuItem("Delete Match");
      deleteLink.setIconStyle("icon-menu-deleteLink");
      deleteLink.addSelectionListener(new SelectionListener<MenuEvent>(){
        @Override
        public void componentSelected(MenuEvent ce) {
          // find out which tab was selected
          TCLink link = tabLookup.get(tabPanel.getSelectedItem());
          Commands.getInstance().removeMatch(link);
        }
      });
      matchMenu.add(deleteLink);
     
     
      // separator
      mb.add(new SeparatorToolItem());
     
      // Highlighting
      Button highlightingMenuHead = new Button("Highlighting");
      highlightingMenuHead.setIconStyle("icon-menu-highlightMenu");
      Menu highlightingMenu = new Menu();
     
      highlightingMenuHead.setMenu(highlightingMenu);
      mb.add(highlightingMenuHead)
     
      final MenuItem toggleHighlighting = new MenuItem();
      if(ClientState.showHighlighting){
        toggleHighlighting.setText("Deactivate Highlighting");
        toggleHighlighting.setIconStyle("icon-menu-highlightingActivated");
      } else {
        toggleHighlighting.setText("Activate Highlighting");
        toggleHighlighting.setIconStyle("icon-menu-highlightingDeactivated");
      }
     
      toggleHighlighting.addSelectionListener(new SelectionListener<MenuEvent>(){
        @Override
        public void componentSelected(MenuEvent ce) {
          ClientState.showHighlighting = !ClientState.showHighlighting;

          if(ClientState.showHighlighting)
            tabPanel.addStyleName("showHighlighting");
          else
            tabPanel.removeStyleName("showHighlighting");   
         
          // switch state
          if(ClientState.showHighlighting){
            toggleHighlighting.setText("Deactivate Highlighting");
            toggleHighlighting.setIconStyle("icon-menu-highlightingActivated");
          } else {
            toggleHighlighting.setText("Activate Highlighting");
            toggleHighlighting.setIconStyle("icon-menu-highlightingDeactivated");
          }
        }
      });
      highlightingMenu.add(toggleHighlighting);
     
      highlightingMenu.add(new SeparatorMenuItem());
     
      MenuItem highlightInSource = new MenuItem("Highlight in Source");
      highlightInSource.addSelectionListener(new SelectionListener<MenuEvent>(){
        @Override
        public void componentSelected(MenuEvent ce) {
          // find out which tab was selected
          TCLink link = tabLookup.get(tabPanel.getSelectedItem());
          Commands.getInstance().highlightSource(selectedPartsID, link.getCurrentDerivedId());
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.