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

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


     * @param title
     * @param selectedPartsID
     */
    private void createFindMatchesMenu(ToolBar mb, String title, final String selectedPartsID){
      Button addMatchesMenuHead = new Button(title);
    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>(){
                public void cc_callback(Section value) {
                  displaySectionInDerivedPanelForMatching(value);
                }
               });
            }
             } 
        );
      }
    });
    addMatchesMenu.add(manuallyNavigateMatch);
    }
View Full Code Here


      // create menu
      ToolBar mb = new ToolBar();
     
      // Match Menu
      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());
        }
      });
      highlightingMenu.add(highlightInSource);
     
      // separator
      mb.add(new SeparatorToolItem());
     
     
View Full Code Here

    // separator
    mb.add(new SeparatorToolItem());
   
    // Proposal
    Button proposalMenuHead = new Button("Proposal");
    Menu proposalMenu = new Menu();
   
    proposalMenuHead.setMenu(proposalMenu);
    mb.add(proposalMenuHead);   
   
    MenuItem entireProposal = new MenuItem("Show Proposal");
    entireProposal.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
        matchProp.showProposal();
      }
    });
    proposalMenu.add(entireProposal);

    MenuItem moreInformation = new MenuItem("More Information");
    moreInformation.setIconStyle("icon-menu-information");
    moreInformation.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
        matchProp.displayInformation();       
      }
    });
    proposalMenu.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) {
        MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
        if(null == selectedProposal)
          Window.alert("Please select proposal");
        else
          Commands.getInstance().gotoStaticDisplay(selectedProposal.getId(), ClientUtils.DERIVED);
      }
    });
    proposalMenu.add(gotoStaticDisplay);

    proposalMenu.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) {
        //
        MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
        if(null == selectedProposal)
          Window.alert("Please select proposal.");
        else {
          String id = selectedProposal.getId();
          new NotesPanel(id, TCNote.TYPE_PARAGRAPH, new NotePanelCallback<TCNote, Integer>(){
            public void callback(TCNote note, Integer type) {
              if(type == NotesPanel.NOTE_ADDED)
                matchProp.addNote(note);
            }
           });
        }
      }
    });
    proposalMenu.add(addNote);
   
    proposalMenu.add(new SeparatorMenuItem());
   
    MenuItem createLink = new MenuItem("Create Link");
    createLink.setIconStyle("icon-menu-createLink");
    createLink.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
        MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
        if(null == selectedProposal)
          Window.alert("Please select proposal.");
        else if(selectedProposal.isMatched())
          Window.alert("The match has has already been established.");
        else
          Commands.getInstance().createLink(selectedPartsID, selectedProposal);
      }
    });
    proposalMenu.add(createLink);
   
    // sepearator
    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-highlightingDeactivated");
    } else {
      toggleHighlighting.setText("Activate Highlighting");
      toggleHighlighting.setIconStyle("icon-menu-highlightingActivated");
    }
   
    toggleHighlighting.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
        matchProp.toggleHighlighting();   
       
        // 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 Proposal in Source");
    highlightInSource.addSelectionListener(new SelectionListener<MenuEvent>(){
      @Override
      public void componentSelected(MenuEvent ce) {
        MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
        if(null == selectedProposal)
          Window.alert("Please select proposal");
        else
          Commands.getInstance().highlightSource(selectedPartsID, selectedProposal.getId());
      }
    });
    highlightingMenu.add(highlightInSource);

   
    // separator
    mb.add(new SeparatorToolItem());
   
    // more matches
    if(results.getType() == SearchResults.TYPE_PROPOSED){
      // propose matches
      final Button proposeMatch = new Button("Propose More Matches");
      if(null != ClientState.proposeMoreMatches && ClientState.proposeMoreMatches.equals(selectedPartsID))
        proposeMatch.disable();
      proposeMatch.addSelectionListener(new SelectionListener<ButtonEvent>(){
        @Override
        public void componentSelected(ButtonEvent ce) {
          proposeMatch.disable();
          ClientState.proposeMoreMatches = selectedPartsID;
          Commands.getInstance().findNewMatchFor(selectedPartsID,ClientUtils.SHINGLE_CLOUD_FUZZY);
        }
      });
      mb.add(proposeMatch);
    }
   
    // Navigation
    if(results.getType() == SearchResults.TYPE_MANUAL_SEARCH){
      Button navigationMenuHead = new Button("Navigation");
      Menu navigationMenu = new Menu();
      navigationMenuHead.setMenu(navigationMenu);
      mb.add(navigationMenuHead);
     
      Button gotoNextSection = new Button("Goto Next Page");
      gotoNextSection.setIconStyle("icon-menu-nextSection");
      if(! results.isMore())
        gotoNextSection.disable();
      gotoNextSection.addSelectionListener(new SelectionListener<ButtonEvent>(){
        @Override
        public void componentSelected(ButtonEvent ce) {
          Commands.getInstance().performManualSearch(
                      ClientState.getCurrentlyDerivedFile(), results.getQuery(), results.getStart() + results.getOffset(),
                      new CommandCallback<SearchResults>(){
                public void cc_callback(SearchResults proposals) {
                  displayMatchProposalsFor(selectedPartsID, proposals);
                }
                       }
                     );
        }
      } );
      navigationMenu.add(gotoNextSection);
     
      Button gotoPrevSection = new Button("Goto Previous Page");
      gotoPrevSection.setIconStyle("icon-menu-previousSection");
      if(results.getStart() == 0)
        gotoPrevSection.disable();
      gotoPrevSection.addSelectionListener(new SelectionListener<ButtonEvent>(){
        @Override
        public void componentSelected(ButtonEvent ce) {
          Commands.getInstance().performManualSearch(
                      ClientState.getCurrentlyDerivedFile(), results.getQuery(), results.getStart() - results.getOffset(),
                      new CommandCallback<SearchResults>(){
                public void cc_callback(SearchResults proposals) {
                  displayMatchProposalsFor(selectedPartsID, proposals);
                }
                       }
                     );
        }
      } );
      navigationMenu.add(gotoPrevSection);
    }
   
   
   
    // end toolbar
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();
          }
        }
View Full Code Here

    //
    mb.add(new SeparatorToolItem());
   
    // Selected paragraph
    Button selectionMenuHead = new Button("Selected Paragraph");
    Menu selectionMenu = new Menu();
    selectionMenuHead.setMenu(selectionMenu);
    mb.add(selectionMenuHead);
   
    Button getInformation = new Button("More Information");
    getInformation.setIconStyle("icon-menu-information");
    getInformation.addSelectionListener(new SelectionListener<ButtonEvent>(){

      @Override
      public void componentSelected(ButtonEvent ce) {
        String id = tcSection.getSelectedItemsId();
        if(null == id)
          Window.alert("Please select item");
        else
          Commands.getInstance().getInformationOn(id, ClientUtils.DERIVED);
      }
    });
    selectionMenu.add(getInformation);
   
    selectionMenu.add(new SeparatorMenuItem());
   
    Button createLink = new Button("Create Link");
    createLink.addSelectionListener(new SelectionListener<ButtonEvent>(){

      @Override
      public void componentSelected(ButtonEvent ce) {
        try{
          LinkableItem linkItem = tcSection.getLinkableItem();
          Commands.getInstance().createLink(contentSection.getSelectedItemsId(),linkItem );
        } catch(IllegalStateException e){
          Window.alert("Please select item");
        }
      }
    });
    selectionMenu.add(createLink);
   
    //
    mb.add(new SeparatorToolItem());
   
    // Navigation
View Full Code Here

   *
   * @param dataIndex the data index the filter is mapped to
   */
  public Filter(String dataIndex) {
    this.dataIndex = dataIndex;
    menu = new Menu();
  }
View Full Code Here

  protected GridEvent<?> createComponentEvent(Event event) {
    return new GridEvent(grid, event);
  }

  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);
    }

    MenuItem columns = new MenuItem();
    columns.setText(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.setText(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 onItemContextMenu(TabItem item, int x, int y) {
    if (closeMenu) {
      if (closeContextMenu == null) {
        closeContextMenu = new Menu();
        closeContextMenu.addListener(Events.Hide, new Listener<MenuEvent>() {
          public void handleEvent(MenuEvent be) {
            be.getContainer().setData("tab", null);
          }
        });
View Full Code Here

  }
 
  @Override
  public void onTab(Component component, PreviewEvent pe) {
    if (!isManaged()) return;
    Menu menu = (Menu)component;
    if (menu.isVisible()) {
      Button btn = menu.getData("parent");
      if (btn != null) {
        pe.preventDefault();
        btn.hideMenu();
        focusNextWidget(btn.getParent());
      }
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();
          }
        }
View Full Code Here

TOP

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

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.