List of usage examples for javax.swing JPopupMenu add
public JMenuItem add(Action a)
Action
object. From source file:gdt.jgui.entity.contact.JContactFacetOpenItem.java
@Override public JPopupMenu getPopupMenu(final String digestLocator$) { JPopupMenu popup = new JPopupMenu(); JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override//from w ww. ja v a 2s . c om public void actionPerformed(ActionEvent e) { //System.out.println("JContactFacetOpenItem:edit:digest locator="+digestLocator$); try { Properties locator = Locator.toProperties(digestLocator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); JContactEditor ce = new JContactEditor(); String ceLocator$ = ce.getLocator(); ceLocator$ = Locator.append(ceLocator$, Entigrator.ENTIHOME, entihome$); ceLocator$ = Locator.append(ceLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, ceLocator$); } catch (Exception ee) { Logger.getLogger(JContactFacetOpenItem.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:com.univocity.app.swing.DataAnalysisWindow.java
private void addPopupMenuToTable(DaoTable daoTable, boolean isSourceTable) { String engineName = isSourceTable ? config.getSourceEngineName() : config.getDestinationEngineName(); if (engineName == null) { return;//from w w w . ja va2 s .co m } final JTable table = daoTable.getDataTable(); final JPopupMenu menu = new JPopupMenu(); menu.add(newJMenuItem("Disable updates", daoTable, engineName, false, false)); menu.add(newJMenuItem("Enable updates", daoTable, engineName, true, false)); menu.add(new JSeparator()); menu.add(newJMenuItem("Disable updates on all rows", daoTable, engineName, false, true)); menu.add(newJMenuItem("Enable updates on all rows", daoTable, engineName, true, true)); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { int rowNumber = table.rowAtPoint(e.getPoint()); if (rowNumber != -1) { table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber); menu.show(table, e.getX(), e.getY()); } } }; }); }
From source file:net.sf.jabref.gui.PreviewPanel.java
private JPopupMenu createPopupMenu() { JPopupMenu menu = new JPopupMenu(); menu.add(this.printAction); menu.add(this.copyPreviewAction); this.basePanel.ifPresent(p -> menu.add(p.frame().getSwitchPreviewAction())); return menu;/* ww w . j a v a 2 s . c o m*/ }
From source file:gdt.jgui.entity.email.JEmailFacetOpenItem.java
@Override public JPopupMenu getPopupMenu(final String digestLocator$) { JPopupMenu popup = new JPopupMenu(); JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override//from www . j a v a 2 s . c o m public void actionPerformed(ActionEvent e) { //System.out.println("JEmailFacetOpenItem:edit:digest locator="+digestLocator$); try { Properties locator = Locator.toProperties(digestLocator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); String email$ = entity.getProperty("email"); JTextEditor te = new JTextEditor(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, email$); String foiLocator$ = getLocator(); foiLocator$ = Locator.append(foiLocator$, BaseHandler.HANDLER_METHOD, METHOD_RESPONSE); foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_ACTION, ACTION_DIGEST_CALL); foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(digestLocator$)); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(foiLocator$)); //System.out.println("JEmailFacetOpenItem:edit:text editor="+teLocator$); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { Logger.getLogger(JEmailFacetOpenItem.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:gdt.jgui.entity.phone.JPhoneFacetOpenItem.java
@Override public JPopupMenu getPopupMenu(final String digestLocator$) { JPopupMenu popup = new JPopupMenu(); JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override//from w ww .ja v a 2 s .com public void actionPerformed(ActionEvent e) { System.out.println("JPhoneFacetOpenItem:edit:digest locator=" + digestLocator$); try { Properties locator = Locator.toProperties(digestLocator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); String phone$ = entity.getProperty("phone"); JTextEditor te = new JTextEditor(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, phone$); String foiLocator$ = getLocator(); foiLocator$ = Locator.append(foiLocator$, BaseHandler.HANDLER_METHOD, METHOD_RESPONSE); foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_ACTION, ACTION_DIGEST_CALL); foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(digestLocator$)); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(foiLocator$)); System.out.println("JPhoneFacetOpenItem:edit:text editor=" + teLocator$); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { Logger.getLogger(JPhoneFacetOpenItem.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:net.landora.video.ui.UIAddon.java
public JPopupMenu createPopupMenu(Collection<?> context) { MultiValueMap valuesByClass = UIUtils.createCompleteContextByClass(context); List<UIAction<?>> actionsToUse = new ArrayList(); for (UIAction<?> action : actions) { Class<?> clazz = action.getRequiredClass(); Collection<?> col = valuesByClass.getCollection(clazz); if (col == null || col.isEmpty()) { continue; }/*www.j a v a2s. co m*/ if (action.isMultipuleObjectSupport() || col.size() == 1) { actionsToUse.add(action); } } if (actionsToUse.isEmpty()) { return null; } JPopupMenu menu = new JPopupMenu(); for (UIAction<?> action : actionsToUse) { JMenuItem item = new JMenuItem(action.getName()); item.addActionListener( new UIActionAction(action, valuesByClass.getCollection(action.getRequiredClass()))); menu.add(item); } return menu; }
From source file:gdt.jgui.entity.bookmark.JBookmarksFacetOpenItem.java
/** * Get the popup menu for the child node of the facet node * in the digest view./* w ww .j a v a 2s .co m*/ * @return the popup menu. */ @Override public JPopupMenu getPopupMenu(final String digestLocator$) { JPopupMenu popup = new JPopupMenu(); JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem); openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { // System.out.println("JBookmarkFacetOpenItem:open:digest locator="+digestLocator$); Properties locator = Locator.toProperties(digestLocator$); String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION); byte[] ba = Base64.decodeBase64(encodedSelection$); String selection$ = new String(ba, "UTF-8"); // System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$); locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String type$ = locator.getProperty(Locator.LOCATOR_TYPE); if (JFolderPanel.LOCATOR_TYPE_FILE.equals(type$)) { String filePath$ = locator.getProperty(JFolderPanel.FILE_PATH); File file = new File(filePath$); Desktop.getDesktop().open(file); return; } if (JEntityDigestDisplay.LOCATOR_FACET_COMPONENT.equals(type$)) { String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JBookmarksEditor be = new JBookmarksEditor(); String beLocator$ = be.getLocator(); beLocator$ = Locator.append(beLocator$, Entigrator.ENTIHOME, entihome$); beLocator$ = Locator.append(beLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, beLocator$); return; } String bookmarkKey$ = locator.getProperty(JBookmarksEditor.BOOKMARK_KEY); Entigrator entigrator = console.getEntigrator(entihome$); String componentKey$ = locator.getProperty(JEntityDigestDisplay.COMPONENT_KEY); Sack entity = entigrator.getEntityAtKey(componentKey$); Core bookmark = entity.getElementItem("jbookmark", bookmarkKey$); // System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$); JConsoleHandler.execute(console, bookmark.value); } catch (Exception ee) { Logger.getLogger(JBookmarksFacetOpenItem.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:hermes.browser.components.ClasspathGroupTable.java
private void init() { final JPopupMenu popupMenu = new JPopupMenu(); final JMenuItem addItem = new JMenuItem("Add Group"); final JMenuItem removeItem = new JMenuItem("Remove Group"); final JMenuItem renameItem = new JMenuItem("Rename"); popupMenu.add(addItem); popupMenu.add(removeItem);//from ww w. j av a 2 s . c om popupMenu.add(renameItem); addItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { doAddGroup(); dialog.setDirty(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } } }); removeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (getSelectedRowCount() > 0) { for (int row : getSelectedRows()) { getClasspathGroupTableModel().removeRow(row); } dialog.setDirty(); } } }); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (getSelectedRow() != -1) { doRename(); } } }); mouseAdapter = new MouseAdapter() { public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { removeItem.setEnabled(getClasspathGroupTableModel().getRowCount() != 0); renameItem.setEnabled(getClasspathGroupTableModel().getRowCount() != 0); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }; addMouseListener(mouseAdapter); getTableHeader().addMouseListener(mouseAdapter); if (dialog != null) { addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // // Think this is ok, seems 2 do the job. if (evt.getPropertyName().equals("tableCellEditor")) { dialog.setDirty(); } } }); } }
From source file:org.eevolution.form.VCRPDetail.java
protected JPopupMenu createPopup(JTree tree) { JPopupMenu pm = new JPopupMenu(); PopupAction action = null;/*from w w w .ja v a2 s. c om*/ try { action = new ZoomMenuAction(tree); pm.add(action); } catch (Exception e) { e.printStackTrace(); } return pm; }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_layer.java
@Override public void doPopup(MouseEvent e, int row, final Object itemId) { JPopupMenu popup = new JPopupMenu(); if (callback.getVisualizationState().isNetPlanEditable()) { popup.add(getAddOption()); for (JComponent item : getExtraAddOptions()) popup.add(item);/*from ww w . j a va2 s . co m*/ } if (!isTableEmpty()) { if (callback.getVisualizationState().isNetPlanEditable()) { if (row != -1) { if (popup.getSubElements().length > 0) popup.addSeparator(); if (networkElementType == NetworkElementType.LAYER && callback.getDesign().getNumberOfLayers() == 1) { } else { JMenuItem removeItem = new JMenuItem("Remove " + networkElementType); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { netPlan.removeNetworkLayer(netPlan.getNetworkLayerFromId((long) itemId)); final VisualizationState vs = callback.getVisualizationState(); Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = vs .suggestCanvasUpdatedVisualizationLayerInfoForNewDesign( new HashSet<>(callback.getDesign().getNetworkLayers())); vs.setCanvasLayerVisibilityAndOrder(callback.getDesign(), res.getFirst(), res.getSecond()); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LAYER)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, getClass()); ErrorHandling.showErrorDialog("Unable to remove " + networkElementType); } } }); popup.add(removeItem); } addPopupMenuAttributeOptions(e, row, itemId, popup); } List<JComponent> extraOptions = getExtraOptions(row, itemId); if (!extraOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : extraOptions) popup.add(item); } } List<JComponent> forcedOptions = getForcedOptions(); if (!forcedOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : forcedOptions) popup.add(item); } } popup.show(e.getComponent(), e.getX(), e.getY()); }