Java 类com.intellij.openapi.ui.JBMenuItem 实例源码

项目:PackageTemplates    文件:GlobalVariableWrapper.java   
@NotNull
private JPopupMenu getPopupMenu(final PackageTemplateWrapper ptWrapper) {
    JPopupMenu popupMenu = new JBPopupMenu();

    JMenuItem itemAddVariable = new JBMenuItem(Localizer.get("AddVariable"), AllIcons.Nodes.Variable);
    JMenuItem itemDelete = new JBMenuItem(Localizer.get("Delete"), AllIcons.Actions.Delete);

    itemAddVariable.addActionListener(e -> addVariable(ptWrapper));
    itemDelete.addActionListener(e -> deleteVariable(ptWrapper));

    popupMenu.add(itemAddVariable);
    addScriptMenuItems(popupMenu, ptWrapper.getProject());
    if (!getGlobalVariable().getName().equals(ATTRIBUTE_BASE_NAME)) {
        popupMenu.add(itemDelete);
    }
    return popupMenu;
}
项目:tmc-intellij    文件:CourseTabFactory.java   
private void addRightMouseButtonFunctionality(MouseEvent mouseEvent,
                                              final JBList list,
                                              JBScrollPane panel) {

    logger.info("Adding functionality for right mouse button. @CourseTabFactory");
    if (!SwingUtilities.isRightMouseButton(mouseEvent)) {
        return;
    }

    int index = list.locationToIndex(mouseEvent.getPoint());
    list.setSelectedIndex(index);
    PopUpMenu menu = new PopUpMenu();
    JBMenuItem openInExplorer = new JBMenuItem("Open path");
    final Object selectedItem = list.getSelectedValue();
    JBMenuItem deleteFolder = new JBMenuItem("Delete folder");

    openInExplorer.addActionListener(createOpenInExploreListener(list, selectedItem));

    deleteFolder.addActionListener(createDeleteButtonActionListener(list, selectedItem));

    menu.add(openInExplorer);
    menu.add(deleteFolder);
    menu.show(panel, mouseEvent.getX(), mouseEvent.getY());
    menu.setLocation(mouseEvent.getXOnScreen(), mouseEvent.getYOnScreen());

}
项目:PackageTemplates    文件:ElementWrapper.java   
private void createPopupForEditMode(MouseEvent mouseEvent) {
    JPopupMenu popupMenu = new JBPopupMenu();

    JMenuItem itemAddFile = new JBMenuItem(Localizer.get("AddFile"), AllIcons.FileTypes.Text);
    JMenuItem itemAddDirectory = new JBMenuItem(Localizer.get("AddDirectory"), AllIcons.Nodes.Package);
    JMenuItem itemChangeFileTemplate = new JBMenuItem(Localizer.get("action.ChangeFileTemplate"), AllIcons.Actions.Edit);
    JMenuItem itemDelete = new JBMenuItem(Localizer.get("Delete"), AllIcons.Actions.Delete);

    itemAddFile.addActionListener(e -> AddFile());
    itemAddDirectory.addActionListener(e -> addDirectory());
    itemDelete.addActionListener(e -> deleteElement());

    popupMenu.add(itemAddFile);
    popupMenu.add(itemAddDirectory);

    // if NOT root element
    if (getParent() != null) {
        popupMenu.add(itemDelete);
    }

    // Dir Specific
    if (isDirectory()) {
        //nothing
    } else {
        // File Specific
        itemChangeFileTemplate.addActionListener(e -> changeFileTemplate());
        popupMenu.add(itemChangeFileTemplate);
    }

    addScriptMenuItems(popupMenu);
    addCustomPathMenuItems(popupMenu);
    addWriteRulesMenuItems(popupMenu);

    popupMenu.show(jlName, mouseEvent.getX(), mouseEvent.getY());
}
项目:intellij-ce-playground    文件:SearchTextField.java   
private void addMenuItem(final String item) {
  if (myNativeSearchPopup != null) {
    myNativeSearchPopup.remove(myNoItems);
    final JMenuItem menuItem = new JBMenuItem(item);
    myNativeSearchPopup.add(menuItem);
    menuItem.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        myTextField.setText(item);
        addCurrentTextToHistory();
      }
    });
  }
}
项目:intellij-ce-playground    文件:TabbedLanguageCodeStylePanel.java   
private void fillPredefined(JMenuItem parentMenu) {
  for (final PredefinedCodeStyle predefinedCodeStyle : myPredefinedCodeStyles) {
    JMenuItem predefinedItem = new JBMenuItem(predefinedCodeStyle.getName());
    parentMenu.add(predefinedItem);
    predefinedItem.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        applyPredefinedStyle(predefinedCodeStyle.getName());
      }
    });
  }
}
项目:vso-intellij    文件:VcsWorkItemsForm.java   
protected List<JBMenuItem> getMenuItems(final ActionListener listener) {
    final List<JBMenuItem> menuItems = new ArrayList<JBMenuItem>();
    menuItems.add(createMenuItem(TfPluginBundle.KEY_VCS_OPEN_IN_BROWSER, null, CMD_OPEN_SELECTED_ITEM_IN_BROWSER, listener));

    // only show create branch option for Git repos
    if (isGitRepo) {
        menuItems.add(createMenuItem(TfPluginBundle.KEY_VCS_WIT_CREATE_BRANCH, null, CMD_CREATE_BRANCH, listener));
    }

    return menuItems;
}
项目:vso-intellij    文件:TabFormImpl.java   
/**
 * Display popup menu on the view
 *
 * @param component
 * @param x
 * @param y
 * @param listener
 */
protected void showPopupMenu(final Component component, final int x, final int y, final ActionListener listener) {
    final JBPopupMenu menu = new JBPopupMenu();
    final List<JBMenuItem> openMenuItems = getMenuItems(listener);
    for (JBMenuItem menuItem : openMenuItems) {
        menu.add(menuItem);
    }
    menu.show(component, x, y);
}
项目:vso-intellij    文件:FeedbackAction.java   
private JBMenuItem createMenuItem(final String resourceKey, final Icon icon, final String actionCommand) {
    final String text = TfPluginBundle.message(resourceKey);
    final JBMenuItem menuItem = new JBMenuItem(text, icon);
    menuItem.setActionCommand(actionCommand);
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            menuItemAction(e);
        }
    });

    return menuItem;
}
项目:vso-intellij    文件:VcsPullRequestsFormTest.java   
@Test
public void testGetMenuItems() {
    List<JBMenuItem> menuItemList = underTest.getMenuItems(null);
    assertEquals(2, menuItemList.size());
    assertEquals(TabForm.CMD_OPEN_SELECTED_ITEM_IN_BROWSER, menuItemList.get(0).getActionCommand());
    assertEquals(VcsPullRequestsForm.CMD_ABANDON_SELECTED_PR, menuItemList.get(1).getActionCommand());
}
项目:vso-intellij    文件:VcsWorkItemsFormTest.java   
@Test
public void testGetMenuItems_Git() {
    List<JBMenuItem> menuItemList = underTest.getMenuItems(null);
    assertEquals(2, menuItemList.size());
    assertEquals(TabForm.CMD_OPEN_SELECTED_ITEM_IN_BROWSER, menuItemList.get(0).getActionCommand());
    assertEquals(VcsWorkItemsForm.CMD_CREATE_BRANCH, menuItemList.get(1).getActionCommand());
}
项目:vso-intellij    文件:VcsWorkItemsFormTest.java   
@Test
public void testGetMenuItems_TFVC() {
    underTest = spy(new VcsWorkItemsForm(false, mockWorkItemQueryDropDown));

    List<JBMenuItem> menuItemList = underTest.getMenuItems(null);
    assertEquals(1, menuItemList.size());
    assertEquals(TabForm.CMD_OPEN_SELECTED_ITEM_IN_BROWSER, menuItemList.get(0).getActionCommand());
}
项目:tools-idea    文件:SearchTextField.java   
private void addMenuItem(final String item) {
  if (myNativeSearchPopup != null) {
    myNativeSearchPopup.remove(myNoItems);
    final JMenuItem menuItem = new JBMenuItem(item);
    myNativeSearchPopup.add(menuItem);
    menuItem.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        myTextField.setText(item);
      }
    });
  }
}
项目:tools-idea    文件:TabbedLanguageCodeStylePanel.java   
private void fillPredefined(JMenuItem parentMenu) {
  for (final PredefinedCodeStyle predefinedCodeStyle : myPredefinedCodeStyles) {
    JMenuItem predefinedItem = new JBMenuItem(predefinedCodeStyle.getName());
    parentMenu.add(predefinedItem);
    predefinedItem.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        applyPredefinedStyle(predefinedCodeStyle.getName());
      }
    });
  }
}
项目:consulo    文件:SearchTextField.java   
private void addMenuItem(final String item) {
  if (myNativeSearchPopup != null) {
    myNativeSearchPopup.remove(myNoItems);
    final JMenuItem menuItem = new JBMenuItem(item);
    myNativeSearchPopup.add(menuItem);
    menuItem.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(final ActionEvent e) {
        myTextField.setText(item);
        addCurrentTextToHistory();
      }
    });
  }
}
项目:consulo    文件:TabbedLanguageCodeStylePanel.java   
private void fillPredefined(JMenuItem parentMenu) {
  for (final PredefinedCodeStyle predefinedCodeStyle : myPredefinedCodeStyles) {
    JMenuItem predefinedItem = new JBMenuItem(predefinedCodeStyle.getName());
    parentMenu.add(predefinedItem);
    predefinedItem.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        applyPredefinedStyle(predefinedCodeStyle.getName());
      }
    });
  }
}
项目:tmc-intellij    文件:PopUpMenu.java   
public void addItemToMenu(JBMenuItem item) {
    add(item);
}
项目:intellij-ce-playground    文件:DeviceDefinitionList.java   
@NotNull
private static JBMenuItem createMenuItem(@NotNull DeviceUiAction action) {
  JBMenuItem item = new JBMenuItem(action);
  item.setText(action.getText());
  return item;
}
项目:vso-intellij    文件:VcsPullRequestsForm.java   
protected List<JBMenuItem> getMenuItems(final ActionListener listener) {
    return Arrays.asList(
            createMenuItem(TfPluginBundle.KEY_VCS_OPEN_IN_BROWSER, null, CMD_OPEN_SELECTED_ITEM_IN_BROWSER, listener),
            createMenuItem(TfPluginBundle.KEY_VCS_PR_ABANDON, null, VcsPullRequestsForm.CMD_ABANDON_SELECTED_PR, listener));
}
项目:vso-intellij    文件:TabFormImplTest.java   
@Before
@SuppressWarnings("unchecked")
public void setUp() {
    underTest = Mockito.spy(new TabFormImpl<WorkItemsTableModel>(TAB_TITLE,
            CREATE_DIALOG_TITLE,
            REFRESH_TOOLTIP,
            TOOLBAR_LOCATION) {
        @Override
        protected void createCustomView() {
            scrollPanel = new JBScrollPane();
        }

        @Override
        protected void addCustomTools(final JPanel panel) {
        }

        @Override
        protected List<JBMenuItem> getMenuItems(ActionListener listener) {
            return null;
        }

        @Override
        public void setModelForView(WorkItemsTableModel modelView) {

        }

        @Override
        public Operation.CredInputsImpl getOperationInputs() {
            return null;
        }

        @Override
        public void refresh(boolean isTeamServicesRepository) {

        }
    });
    underTest.statusLabel = new JLabel();
    underTest.statusLink = new Hyperlink();

    // Mock needed for creating DefaultActionGroup in create group tests
    PowerMockito.mockStatic(ActionManager.class);
    ActionManager actionManager = Mockito.mock(ActionManager.class);
    Mockito.when(ActionManager.getInstance()).thenReturn(actionManager);
}
项目:vso-intellij    文件:TabFormImplTest.java   
@Test
public void testCreateMenuItem() {
    JBMenuItem item = underTest.createMenuItem(TAB_TITLE, null, "action", null);
    assertEquals(TfPluginBundle.message(TAB_TITLE), item.getText());
    assertEquals("action", item.getActionCommand());
}
项目:netbeans-mmd-plugin    文件:IdeaUIComponentFactory.java   
@Override
@Nonnull
public JMenuItem makeMenuItem(@Nonnull final String s, final Icon icon) {
    return new JBMenuItem(s, icon);
}
项目:vso-intellij    文件:TabFormImpl.java   
/**
 * Creates a menu item to use in the popup menu
 *
 * @param resourceKey
 * @param icon
 * @param actionCommand
 * @param listener
 * @return menu item
 */
protected JBMenuItem createMenuItem(final String resourceKey, final Icon icon, final String actionCommand, final ActionListener listener) {
    final String text = TfPluginBundle.message(resourceKey);
    final JBMenuItem menuItem = new JBMenuItem(text, icon);
    menuItem.setActionCommand(actionCommand);
    menuItem.addActionListener(listener);
    return menuItem;
}
项目:vso-intellij    文件:TabFormImpl.java   
/**
 * Creates and returns the menu items to be shown in the popup menu
 *
 * @param listener
 * @return list of menu items
 */
protected abstract List<JBMenuItem> getMenuItems(final ActionListener listener);