com.intellij.openapi.ui.JBMenuItem Java Examples
The following examples show how to use
com.intellij.openapi.ui.JBMenuItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlobalVariableWrapper.java From PackageTemplates with Apache License 2.0 | 6 votes |
@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; }
Example #2
Source File: CourseTabFactory.java From tmc-intellij with MIT License | 6 votes |
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()); }
Example #3
Source File: TabbedLanguageCodeStylePanel.java From consulo with Apache License 2.0 | 5 votes |
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()); } }); } }
Example #4
Source File: SearchTextField.java From consulo with Apache License 2.0 | 5 votes |
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(); } }); } }
Example #5
Source File: ConnectButton.java From saros with GNU General Public License v2.0 | 5 votes |
private JMenuItem getPreconfiguredMenuItem(String text) { JMenuItem jMenuItem = new JBMenuItem(text); jMenuItem.setForeground(FOREGROUND_COLOR); jMenuItem.setBackground(BACKGROUND_COLOR); return jMenuItem; }
Example #6
Source File: FollowButton.java From saros with GNU General Public License v2.0 | 5 votes |
private JMenuItem createItemForUser(User user) { String userName = CoreUtils.determineUserDisplayName(user); String userNameShort = userName; int index = userNameShort.indexOf("@"); if (index > -1) { userNameShort = userNameShort.substring(0, index); } JMenuItem menuItem = new JBMenuItem(menuItemPrefix + " " + userNameShort); menuItem.setForeground(FOREGROUND_COLOR); menuItem.setBackground(BACKGROUND_COLOR); FollowModeManager currentFollowModeManager = followModeManager; User currentlyFollowedUser = null; if (currentFollowModeManager != null) { currentlyFollowedUser = currentFollowModeManager.getFollowedUser(); } if (currentlyFollowedUser != null) { String currentUserName = CoreUtils.determineUserDisplayName(currentlyFollowedUser); if (currentUserName.equalsIgnoreCase(userNameShort)) { menuItem.setEnabled(false); } } menuItem.setActionCommand(userName); menuItem.addActionListener( e -> followModeAction.execute(session, followModeManager, e.getActionCommand())); return menuItem; }
Example #7
Source File: FollowButton.java From saros with GNU General Public License v2.0 | 5 votes |
private void createMenu() { popupMenu = new JBPopupMenu(); popupMenu.setForeground(FOREGROUND_COLOR); popupMenu.setBackground(BACKGROUND_COLOR); menuItemPrefix = Messages.FollowButton_user_entry_prefix; ISarosSession currentSession = session; FollowModeManager currentFollowModeManager = followModeManager; if (currentSession == null || currentFollowModeManager == null) { return; } for (User user : currentSession.getRemoteUsers()) { JMenuItem menuItem = createItemForUser(user); popupMenu.add(menuItem); } popupMenu.addSeparator(); JMenuItem leaveItem = new JBMenuItem(Messages.FollowButton_leave_follow_mode_entry); leaveItem.setForeground(FOREGROUND_COLOR); leaveItem.setBackground(BACKGROUND_COLOR); leaveItem.addActionListener(e -> followModeAction.execute(session, followModeManager, null)); leaveItem.setEnabled(currentFollowModeManager.getFollowedUser() != null); popupMenu.add(leaveItem); }
Example #8
Source File: VcsWorkItemsFormTest.java From azure-devops-intellij with MIT License | 5 votes |
@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()); }
Example #9
Source File: VcsWorkItemsFormTest.java From azure-devops-intellij with MIT License | 5 votes |
@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()); }
Example #10
Source File: VcsPullRequestsFormTest.java From azure-devops-intellij with MIT License | 5 votes |
@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()); }
Example #11
Source File: FeedbackAction.java From azure-devops-intellij with MIT License | 5 votes |
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; }
Example #12
Source File: TabFormImpl.java From azure-devops-intellij with MIT License | 5 votes |
/** * 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); }
Example #13
Source File: VcsWorkItemsForm.java From azure-devops-intellij with MIT License | 5 votes |
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; }
Example #14
Source File: TabFormImplTest.java From azure-devops-intellij with MIT License | 4 votes |
@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); }
Example #15
Source File: TabFormImplTest.java From azure-devops-intellij with MIT License | 4 votes |
@Test public void testCreateMenuItem() { JBMenuItem item = underTest.createMenuItem(TAB_TITLE, null, "action", null); assertEquals(TfPluginBundle.message(TAB_TITLE), item.getText()); assertEquals("action", item.getActionCommand()); }
Example #16
Source File: IdeaUIComponentFactory.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override @Nonnull public JMenuItem makeMenuItem(@Nonnull final String s, final Icon icon) { return new JBMenuItem(s, icon); }
Example #17
Source File: VcsPullRequestsForm.java From azure-devops-intellij with MIT License | 4 votes |
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)); }
Example #18
Source File: PopUpMenu.java From tmc-intellij with MIT License | 4 votes |
public void addItemToMenu(JBMenuItem item) { add(item); }
Example #19
Source File: ElementWrapper.java From PackageTemplates with Apache License 2.0 | 4 votes |
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 itemAddBinaryFile = new JBMenuItem(Localizer.get("action.AddBinaryFile"), AllIcons.FileTypes.Text); JMenuItem itemEditSourcePath = new JBMenuItem(Localizer.get("action.EditSourcePath"), AllIcons.FileTypes.Text); 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()); itemAddBinaryFile.addActionListener(e -> addBinaryFile()); itemDelete.addActionListener(e -> deleteElement()); popupMenu.add(itemAddFile); popupMenu.add(itemAddDirectory); popupMenu.add(itemAddBinaryFile); // if NOT root element if (getParent() != null) { popupMenu.add(itemDelete); } // Dir Specific if (isDirectory()) { //nothing } else { // File Specific if (this instanceof FileWrapper) { itemChangeFileTemplate.addActionListener(e -> changeFileTemplate()); popupMenu.add(itemChangeFileTemplate); } else if (this instanceof BinaryFileWrapper){ itemEditSourcePath.addActionListener(e -> changeFileTemplate()); popupMenu.add(itemEditSourcePath); } } addScriptMenuItems(popupMenu); addCustomPathMenuItems(popupMenu); addWriteRulesMenuItems(popupMenu); popupMenu.show(jlName, mouseEvent.getX(), mouseEvent.getY()); }
Example #20
Source File: TabFormImpl.java From azure-devops-intellij with MIT License | 3 votes |
/** * 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; }
Example #21
Source File: TabFormImpl.java From azure-devops-intellij with MIT License | 2 votes |
/** * 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);