@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; }
private void showPopup() { myPopup = new JBPopupMenu(); myPopup.addPopupMenuListener(myPopupListener); ArrayList<ContentTabLabel> tabs = myTabs; for (final ContentTabLabel each : tabs) { final JCheckBoxMenuItem item = new JCheckBoxMenuItem(each.getText()); if (myUi.myManager.isSelected(each.myContent)) { item.setSelected(true); } item.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { myUi.myManager.setSelectedContent(each.myContent, true); } }); myPopup.add(item); } myPopup.show(myUi, myLastLayout.moreRect.x, myLastLayout.moreRect.y); }
private static void fixGtkPopupStyle() { if (!UIUtil.isUnderGTKLookAndFeel()) return; final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory(); SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() { @Override public SynthStyle getStyle(final JComponent c, final Region id) { final SynthStyle style = original.getStyle(c, id); if (id == Region.POPUP_MENU) { final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness"); if (x != null && x == 0) { // workaround for Sun bug #6636964 ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1); ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3); } } return style; } }); new JBPopupMenu(); // invokes updateUI() -> updateStyle() SynthLookAndFeel.setStyleFactory(original); }
private void possiblyShowPopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } Point p = e.getPoint(); int row = myTable.rowAtPoint(p); int col = myTable.columnAtPoint(p); if (row != -1 && col != -1) { JBPopupMenu menu = new JBPopupMenu(); menu.add(createMenuItem(new CloneDeviceAction(this))); menu.add(createMenuItem(new EditDeviceAction(this))); menu.add(createMenuItem(new ExportDeviceAction(this))); menu.add(createMenuItem(new DeleteDeviceAction(this))); menu.show(myTable, p.x, p.y); } }
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()); }
private void makePopup() { myPopup = new JBPopupMenu(); String[] macrosName = RegexpFilter.getMacrosName(); JMenuItem[] items = new JMenuItem[macrosName.length]; for (int i = 0; i < macrosName.length; i++) { items[i] = myPopup.add(macrosName[i]); items[i].addActionListener(new MenuItemListener(macrosName[i])); } myRegexpField.addMouseListener(new PopupListener()); }
public ThemeEditorTable() { myPopupMenu = new JBPopupMenu(); myGoToDefinitionItem = myPopupMenu.add(new JMenuItem("Go to definition")); myGoToDefinitionItem.setVisible(false); myResetItem = myPopupMenu.add(new JMenuItem("Reset value")); myResetItem.setVisible(false); }
/** * 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); }
private static void fixGtkPopupStyle() { if (!UIUtil.isUnderGTKLookAndFeel()) return; final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory(); SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() { @Override public SynthStyle getStyle(final JComponent c, final Region id) { final SynthStyle style = original.getStyle(c, id); if (id == Region.POPUP_MENU) { try { Field f = style.getClass().getDeclaredField("xThickness"); f.setAccessible(true); final Object x = f.get(style); if (x instanceof Integer && (Integer)x == 0) { // workaround for Sun bug #6636964 f.set(style, 1); f = style.getClass().getDeclaredField("yThickness"); f.setAccessible(true); f.set(style, 3); } } catch (Exception ignore) { } } return style; } }); new JBPopupMenu(); // invokes updateUI() -> updateStyle() SynthLookAndFeel.setStyleFactory(original); }
@Override @Nonnull public JPopupMenu makePopupMenu() { return new JBPopupMenu(); }