List of usage examples for javax.swing JPopupMenu show
public void show(Component invoker, int x, int y)
From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphPanel.java
private void checkPopup(MouseEvent e) { if (e.isPopupTrigger()) { final JPopupMenu popup = new JPopupMenu(); popup.add(addMenu);/*w ww. j a v a 2 s. c o m*/ if (selectedNode != null) { final JMenuItem item = new JMenuItem("Delete"); popup.add(item); item.setHorizontalTextPosition(JMenuItem.RIGHT); item.addActionListener(this); final NodeSource[] sources = selectedNode.getNode().getSources(); if (sources.length > 0) { final JMenu removeSourcedMenu = new JMenu("Remove Source"); for (NodeSource ns : sources) { final JMenuItem nsItem = new JMenuItem(ns.getSourceNodeId()); removeSourcedMenu.add(nsItem); nsItem.setHorizontalTextPosition(JMenuItem.RIGHT); nsItem.addActionListener(removeSourceListener); } popup.add(removeSourcedMenu); } } if (!graphEx.getGraphNodeList().isGraphComplete()) { final JMenuItem connectItem = new JMenuItem("Connect Graph", null); connectItem.setHorizontalTextPosition(JMenuItem.RIGHT); connectItem.addActionListener(connectListener); popup.add(connectItem); } popup.setLabel("Justification"); popup.setBorder(new BevelBorder(BevelBorder.RAISED)); popup.addPopupMenuListener(this); popup.show(this, e.getX(), e.getY()); showRightClickHelp = false; } }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
/** * Create the Navigation Tree panel// ww w. j av a2 s. co m * * @return @see JPanel containing the navigation tree to browse a file system. */ private JPanel createNavTree() { JPanel treeContainer = new JPanel(new BorderLayout()); treeContainer.setBackground(UIHelper.BG_COLOR); treeContainer .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); JPanel navigationControls = new JPanel(); navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS)); navigationControls.setOpaque(false); final JLabel navToParentDir = new JLabel(upIcon); navToParentDir.setOpaque(false); navToParentDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToParentDir.setIcon(upIcon); try { updateTree(fileBrowser.getParentDirectory()); } catch (IOException e) { errorAction("problem occurred!"); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToParentDir.setIcon(upIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToParentDir.setIcon(upIcon); } }); navigationControls.add(navToParentDir); navigationControls.add(Box.createHorizontalStrut(5)); final JLabel navToHomeDir = new JLabel(homeIcon); navToHomeDir.setOpaque(false); navToHomeDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToHomeDir.setIcon(homeIcon); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { if (e instanceof ConnectionException) { status.setText("<html>status: not connected!</html>"); } FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToHomeDir.setIcon(homeIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToHomeDir.setIcon(homeIcon); } }); navigationControls.add(navToHomeDir); navigationControls.add(Box.createGlue()); treeContainer.add(navigationControls, BorderLayout.NORTH); try { treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory()); directoryTree = new JTree(treeModel); directoryTree.setFont(UIHelper.VER_11_PLAIN); directoryTree.setCellRenderer(new FileSystemTreeCellRenderer()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } directoryTree.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); int selRow = directoryTree.getRowForLocation(event.getX(), event.getY()); TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY()); if (selRow != -1) { final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent(); if (SwingUtilities.isLeftMouseButton(event)) { if (event.getClickCount() == 2) { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { String newPath; if (fileBrowser instanceof LocalBrowser) { newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath(); } else { newPath = node.toString(); } updateTree(fileBrowser.changeDirectory(newPath)); } // else, if a leaf node, then add file to to list if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) { String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1) .trim().toUpperCase(); FileChooserFile toAdd = null; for (Object o : fileBrowser.getFileMap().get(extension)) { String fileName; String filePath; if (fileBrowser instanceof LocalBrowser) { File file = (File) o; fileName = file.getName(); filePath = file.getPath(); if (fileName.equals(node.toString())) { toAdd = new CustomFile(filePath); break; } } else { FTPFile ftpFile = (FTPFile) o; fileName = ftpFile.getName(); filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); if (fileName.equals(node.toString())) { toAdd = new CustomFTPFile(ftpFile, filePath); break; } } } if (toAdd != null && !checkIfInList(toAdd)) { selectedFiles.addFileItem(toAdd); } } } } else { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { // show popup to add the directory to the selected files JPopupMenu popup = new JPopupMenu(); JMenuItem addDirectory = new JMenuItem("add directory"); addDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Object fileToAdd = fileBrowser.getDirFiles().get(node.toString()); FileChooserFile toAdd; if (fileToAdd instanceof File) { toAdd = new CustomFile(((File) fileToAdd).getPath()); } else { FTPFile ftpFile = (FTPFile) fileToAdd; String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); toAdd = new CustomFTPFile(ftpFile, filePath); } if (!checkIfInList(toAdd)) { selectedFiles.addDirectoryItem(toAdd); } } }); popup.add(addDirectory); popup.show(directoryTree, event.getX(), event.getY()); } } } } }); BasicTreeUI ui = new BasicTreeUI() { public Icon getCollapsedIcon() { return null; } public Icon getExpandedIcon() { return null; } }; directoryTree.setUI(ui); directoryTree.setFont(UIHelper.VER_12_PLAIN); JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroll.setPreferredSize(new Dimension(300, 200)); treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0)); treeContainer.add(treeScroll, BorderLayout.CENTER); IAppWidgetFactory.makeIAppScrollPane(treeScroll); return treeContainer; }
From source file:org.languagetool.gui.ConfigurationDialog.java
@NotNull private MouseAdapter getMouseAdapter() { return new MouseAdapter() { private void handlePopupEvent(MouseEvent e) { JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; }/* w w w . j ava 2s . c o m*/ DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); TreePath[] paths = tree.getSelectionPaths(); boolean isSelected = false; if (paths != null) { for (TreePath selectionPath : paths) { if (selectionPath.equals(path)) { isSelected = true; } } } if (!isSelected) { tree.setSelectionPath(path); } if (node.isLeaf()) { JPopupMenu popup = new JPopupMenu(); JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu")); aboutRuleMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent(); Rule rule = node.getRule(); Language lang = config.getLanguage(); if (lang == null) { lang = Languages.getLanguageForLocale(Locale.getDefault()); } Tools.showRuleInfoDialog(tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, rule.getUrl(), messages, lang.getShortCodeWithCountryAndVariant()); } }); popup.add(aboutRuleMenuItem); popup.show(tree, e.getX(), e.getY()); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } }; }
From source file:org.languagetool.gui.LanguageToolSupport.java
private void showPopup(MouseEvent event) { if (documentSpans.isEmpty() && languageTool.getDisabledRules().isEmpty()) { //No errors and no disabled Rules return;//ww w . j a va 2 s . co m } int offset = this.textComponent.viewToModel(event.getPoint()); Span span = getSpan(offset); JPopupMenu popup = new JPopupMenu("Grammar Menu"); if (span != null) { JLabel msgItem = new JLabel("<html>" + span.msg.replace("<suggestion>", "<b>").replace("</suggestion>", "</b>") + "</html>"); msgItem.setToolTipText(span.desc.replace("<suggestion>", "").replace("</suggestion>", "")); msgItem.setBorder(new JMenuItem().getBorder()); popup.add(msgItem); popup.add(new JSeparator()); for (String r : span.replacement) { ReplaceMenuItem item = new ReplaceMenuItem(r, span); popup.add(item); item.addActionListener(actionListener); } popup.add(new JSeparator()); JMenuItem moreItem = new JMenuItem(messages.getString("guiMore")); moreItem.addActionListener(e -> showDialog(textComponent, span.msg, span.desc, span.rule, span.url)); popup.add(moreItem); JMenuItem ignoreItem = new JMenuItem(messages.getString("guiTurnOffRule")); ignoreItem.addActionListener(e -> disableRule(span.rule.getId())); popup.add(ignoreItem); popup.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); } List<Rule> disabledRules = getDisabledRules(); if (!disabledRules.isEmpty()) { JMenu activateRuleMenu = new JMenu(messages.getString("guiActivateRule")); addDisabledRulesToMenu(disabledRules, activateRuleMenu); popup.add(activateRuleMenu); } if (span != null) { textComponent.setCaretPosition(span.start); textComponent.moveCaretPosition(span.end); } popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { if (span != null) { textComponent.setCaretPosition(span.start); } } }); popup.show(textComponent, event.getPoint().x, event.getPoint().y); }
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
private void createMouseListener() { graphComponent.getGraphControl().addMouseListener(new MouseAdapter() { @Override/*from w w w . j a va2 s. c o m*/ public void mousePressed(MouseEvent e) { if (isPopupShown) { isPopupShown = false; mxCell cell = (mxCell) graphComponent.getGraph().getSelectionModel().getCell(); getGraphModel().remove(cell); return; } if (SwingUtilities.isRightMouseButton(e)) { xPos = e.getX(); yPos = e.getY(); Object obj = graphComponent.getCellAt(e.getX(), e.getY()); if (obj instanceof mxCell) { mxCell cell = (mxCell) obj; if (cell.getStyle() != null && cell.getStyle().indexOf(ENTITYSTYLE) >= 0 && cell.getValue() instanceof EntityMetaDataVO) { JPopupMenu pop = createPopupMenuEntity(cell, false); pop.show(e.getComponent(), e.getX(), e.getY()); } else if (cell.getStyle() != null && cell.getStyle().indexOf(ENTITYSTYLE) >= 0) { JPopupMenu pop = createPopupMenuEntity(cell, true); pop.show(e.getComponent(), e.getX(), e.getY()); } else { if (cell.getStyle() != null && cell.getStyle().indexOf("oval") >= 0) { JPopupMenu pop = createRelationPopupMenu(cell, true, true); pop.show(e.getComponent(), e.getX(), e.getY()); } else { JPopupMenu pop = createRelationPopupMenu(cell, true, false); pop.show(e.getComponent(), e.getX(), e.getY()); } } } else { JPopupMenu pop = createPopupMenu(); pop.show(e.getComponent(), e.getX(), e.getY()); } } else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { mxCell cell = (mxCell) graphComponent.getGraph().getSelectionModel().getCell(); if (cell == null) return; if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) { EntityMetaDataVO voMeta = (EntityMetaDataVO) cell.getValue(); EntityMetaDataVO vo = MetaDataClientProvider.getInstance().getEntity(voMeta.getEntity()); new ShowNuclosWizard.NuclosWizardEditRunnable(false, mf.getHomePane(), vo).run(); } else if (cell.getValue() != null && cell.getValue() instanceof EntityFieldMetaDataVO) { if (cell.getStyle() != null && cell.getStyle().indexOf(OPENARROW) >= 0) editMasterdataRelation(cell); else if (cell.getStyle() != null && cell.getStyle().indexOf(DIAMONDARROW) >= 0) { editSubformRelation(cell); } } else if (cell.getValue() != null) { if (cell.getStyle() != null && cell.getStyle().indexOf(OVALARROW) >= 0) { try { mxCell cellSource = (mxCell) cell.getSource(); mxCell cellTarget = (mxCell) cell.getTarget(); EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue(); EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue(); String sSourceModule = sourceModule.getEntity(); String sTargetModule = targetModule.getEntity(); boolean blnFound = false; for (MasterDataVO voGeneration : MasterDataCache.getInstance() .get(NuclosEntity.GENERATION.getEntityName())) { String sSource = (String) voGeneration.getField("sourceModule"); String sTarget = (String) voGeneration.getField("targetModule"); if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule) && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); gcc.runViewSingleCollectableWithId(voGeneration.getId()); blnFound = true; break; } } if (!blnFound) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); Map<String, Object> mp = new HashMap<String, Object>(); mp.put("sourceModule", sSourceModule); mp.put("sourceModuleId", new Integer(MetaDataClientProvider.getInstance() .getEntity(sSourceModule).getId().intValue())); mp.put("targetModule", sTargetModule); mp.put("targetModuleId", new Integer(MetaDataClientProvider.getInstance() .getEntity(sTargetModule).getId().intValue())); MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(), null, null, null, null, null, null, mp); gcc.runWithNewCollectableWithSomeFields(vo); } } catch (NuclosBusinessException e1) { LOG.warn("mousePressed failed: " + e1, e1); } catch (CommonPermissionException e1) { LOG.warn("mousePressed failed: " + e1, e1); } catch (CommonFatalException e1) { LOG.warn("mousePressed failed: " + e1, e1); } catch (CommonBusinessException e1) { LOG.warn("mousePressed failed: " + e1, e1); } } } } } }); }
From source file:org.nuclos.client.relation.MyGraphModel.java
@Override public Object add(Object parent, Object child, int index) { Object obj = super.add(parent, child, index); if (obj instanceof mxCell) { mxCell cell = (mxCell) obj;//from w ww . j a v a2 s .c o m if (StringUtils.looksEmpty(cell.getStyle())) { JPopupMenu pop = createRelationPopupMenu(cell, false); editPanel.setIsPopupShown(true); pop.show(graphComponent, graphComponent.getGraphControl().getMousePosition().x, graphComponent.getGraphControl().getMousePosition().y); } else if (mxConstants.ARROW_DIAMOND.equals(cell.getStyle())) { Object cells[] = { cell }; mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_DIAMOND); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_STROKECOLOR, SYMBOLCOLOR); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); } else if (mxConstants.ARROW_OPEN.equals(cell.getStyle())) { Object cells[] = { cell }; mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OPEN); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_STROKECOLOR, SYMBOLCOLOR); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); } else if (mxConstants.ARROW_OVAL.equals(cell.getStyle())) { Object cells[] = { cell }; mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OVAL); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_STROKECOLOR, SYMBOLCOLOR); mxUtils.setCellStyles(this, cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); } else if (cell.getStyle() != null && cell.getStyle().indexOf(ENTITYSTYLE) >= 0) { try { if (cell.getValue() != null && cell.getValue() instanceof String) { String sEntity = (String) cell.getValue(); if (sEntity.length() == 0) { boolean blnNotSet = true; while (blnNotSet) { sEntity = JOptionPane.showInputDialog(editPanel, getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.20", "Bitte geben Sie den Namen der neuen Entit\u00e4t an!")); for (EntityMetaDataVO voMeta : MetaDataClientProvider.getInstance() .getAllEntities()) { if (voMeta.getEntity().equals(sEntity)) { JOptionPane.showMessageDialog(editPanel, getSpringLocaleDelegate().getMessage( "nuclos.entityrelation.editor.19", "Entit\u00e4t schon vorhanden")); blnNotSet = true; break; } blnNotSet = false; } } if (sEntity == null) { this.remove(cell); } if (sEntity.length() == 0) this.remove(cell); else { EntityMetaDataVO voEntity = new EntityMetaDataVO(); voEntity.setEntity(sEntity); voEntity.setDbEntity("V_EO_" + NuclosWizardUtils.replace(sEntity)); voEntity.setEditable(true); voEntity.setImportExport(true); voEntity.setSearchable(true); voEntity.setStateModel(false); voEntity.setTreeGroup(false); voEntity.setTreeRelation(false); voEntity.setLogBookTracking(true); voEntity.setCacheable(false); voEntity.setFieldValueEntity(false); EntityMetaDataTO toEntity = new EntityMetaDataTO(); toEntity.setTreeView(new ArrayList<EntityTreeViewVO>()); toEntity.setEntityMetaVO(voEntity); List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>(); for (LocaleInfo info : LocaleDelegate.getInstance().getAllLocales(false)) { Map<String, String> mpValues = new HashMap<String, String>(); mpValues.put(TranslationVO.labelsEntity[0], sEntity); mpValues.put(TranslationVO.labelsEntity[2], sEntity); TranslationVO vo = new TranslationVO(info.localeId, info.title, info.language, mpValues); lstTranslation.add(vo); } toEntity.setTranslation(lstTranslation); String sResult = MetaDataDelegate.getInstance().createOrModifyEntity(null, toEntity, null, new ArrayList<EntityFieldMetaDataTO>(), true, null, null); EntityMetaDataVO voEntityCreated = MetaDataDelegate.getInstance() .getEntityByName(sEntity); cell.setValue(voEntityCreated); editPanel.loadReferenz(); } } } } catch (Exception e) { LOG.warn("add: " + e); } } } return obj; }
From source file:org.nuclos.client.ui.collect.searcheditor.SearchEditorController.java
/** * event: a mouse event occured on a node in the <code>view</code> * @param selPath the path of the node where the mouse event occured. * @param ev//www . j ava2s . co m */ private void mouseEventOnNode(TreePath selPath, MouseEvent ev) { final SearchConditionTreeNode node = (SearchConditionTreeNode) selPath.getLastPathComponent(); final JTree tree = (JTree) ev.getComponent(); // select the node: tree.setSelectionPath(selPath); if (ev.isPopupTrigger()) { // show popup menu: final JPopupMenu popupMenu = this.getPopupMenu(node, tree); if (popupMenu != null) { popupMenu.show(ev.getComponent(), ev.getX(), ev.getY()); } } else if (ev.getID() == MouseEvent.MOUSE_CLICKED) { if (ev.getButton() == MouseEvent.BUTTON1) { if (ev.getClickCount() == 2) { if (this.clctfproviderfactory == null) { throw new IllegalStateException( "No CollectableFieldsProviderFactory was defined for the search editor."); } // perform the node's default action: final Action actDefault = node.getDefaultTreeNodeAction(tree, this.clcteRoot, this.clctfproviderfactory, this.additionalFields); if (actDefault != null) { actDefault.actionPerformed(null); } } } } }
From source file:org.nuclos.client.ui.collect.SubForm.java
/** * @Deprecated Never use this directly, instead use {@link #addToolbarMenuItems(List)}. */// w w w . j ava2 s .com private MouseListener newToolbarContextMenuListener(final JComponent parent, final JTable table) { MouseListener res = new MouseAdapter() { @Override public void mouseClicked(MouseEvent mev) { if (SwingUtilities.isRightMouseButton(mev)) { List<JComponent> items = new ArrayList<JComponent>(); addToolbarMenuItems(items); if (items.isEmpty()) return; JPopupMenu popup = new JPopupMenu(); for (JComponent c : items) popup.add(c); popup.show(parent, mev.getX(), mev.getY()); } if (SwingUtilities.isLeftMouseButton(mev) && mev.getClickCount() == 2) { int row = table.rowAtPoint(mev.getPoint()); int column = table.columnAtPoint(mev.getPoint()); LOG.info(StringUtils.concat("Doubleclick on subform: column=", column, ",row=", row)); if (row == -1 || column == -1) { if (toolbarMenuItems.get(ToolbarFunction.NEW.name()).isEnabled()) { actionPerformed(ToolbarFunction.NEW.name()); } } } } }; return res; }
From source file:org.omegat.gui.issues.IssuesPanelController.java
void showPopupMenu(Component source, Point p, IIssue issue) { List<? extends JMenuItem> items = issue.getMenuComponents(); if (items.isEmpty()) { return;//w w w . j a v a2 s .c o m } JPopupMenu menu = new JPopupMenu(); items.forEach(menu::add); menu.show(source, p.x, p.y); }
From source file:org.omegat.gui.properties.SegmentPropertiesArea.java
void showContextMenu(Point p) { JPopupMenu menu = new JPopupMenu(); populateLocalContextMenuOptions(menu, p); // populateGlobalContextMenuOptions(menu); try {/* w ww . j a v a 2 s . c o m*/ menu.show(scrollPane, p.x, p.y); } catch (IllegalComponentStateException ignore) { ignore.printStackTrace(); } }