List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:com.mirth.connect.client.ui.Frame.java
/** * Creates the global scripts edit task pane. *///ww w . j a va 2 s. c o m private void createGlobalScriptsPane() { globalScriptsTasks = new JXTaskPane(); globalScriptsPopupMenu = new JPopupMenu(); globalScriptsTasks.setTitle("Script Tasks"); globalScriptsTasks.setName(TaskConstants.GLOBAL_SCRIPT_KEY); globalScriptsTasks.setFocusable(false); addTask(TaskConstants.GLOBAL_SCRIPT_SAVE, "Save Scripts", "Save all changes made to all scripts.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/disk.png")), globalScriptsTasks, globalScriptsPopupMenu); addTask(TaskConstants.GLOBAL_SCRIPT_VALIDATE, "Validate Script", "Validate the currently viewed script.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/accept.png")), globalScriptsTasks, globalScriptsPopupMenu); addTask(TaskConstants.GLOBAL_SCRIPT_IMPORT, "Import Scripts", "Import all global scripts from an XML file.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_go.png")), globalScriptsTasks, globalScriptsPopupMenu); addTask(TaskConstants.GLOBAL_SCRIPT_EXPORT, "Export Scripts", "Export all global scripts to an XML file.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_disk.png")), globalScriptsTasks, globalScriptsPopupMenu); setNonFocusable(globalScriptsTasks); taskPaneContainer.add(globalScriptsTasks); }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Creates the extensions task pane.// w w w .ja v a 2 s . c o m */ private void createExtensionsPane() { extensionsTasks = new JXTaskPane(); extensionsPopupMenu = new JPopupMenu(); extensionsTasks.setTitle("Extension Tasks"); extensionsTasks.setName(TaskConstants.EXTENSIONS_KEY); extensionsTasks.setFocusable(false); addTask(TaskConstants.EXTENSIONS_REFRESH, "Refresh", "Refresh loaded plugins.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_refresh.png")), extensionsTasks, extensionsPopupMenu); addTask(TaskConstants.EXTENSIONS_ENABLE, "Enable Extension", "Enable the currently selected extension.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/control_play_blue.png")), extensionsTasks, extensionsPopupMenu); addTask(TaskConstants.EXTENSIONS_DISABLE, "Disable Extension", "Disable the currently selected extension.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/control_stop_blue.png")), extensionsTasks, extensionsPopupMenu); addTask(TaskConstants.EXTENSIONS_SHOW_PROPERTIES, "Show Properties", "Display the currently selected extension properties.", "", new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/application_view_list.png")), extensionsTasks, extensionsPopupMenu); addTask(TaskConstants.EXTENSIONS_UNINSTALL, "Uninstall Extension", "Uninstall the currently selected extension", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/plugin_delete.png")), extensionsTasks, extensionsPopupMenu); setNonFocusable(extensionsTasks); taskPaneContainer.add(extensionsTasks); }
From source file:com.pironet.tda.TDA.java
/** * create a instance of this menu for a category *///w w w . ja va 2 s.com private PopupListener getCatPopupMenu() { if (catPopupListener == null) { //Create the popup menu. JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Search..."); menuItem.addActionListener(this); popup.add(menuItem); //Add listener to the text area so the popup menu can come up. catPopupListener = new PopupListener(popup); } return (catPopupListener); }
From source file:com.pironet.tda.TDA.java
/** * create a instance of this menu for a category *//*from w w w . ja v a 2 s. co m*/ private PopupListener getMonitorsPopupMenu() { if (monitorsPopupListener == null) { final JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Search..."); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem("Expand all nodes"); menuItem.addActionListener(this); popup.add(menuItem); menuItem = new JMenuItem("Collapse all nodes"); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem("Sort by thread count"); menuItem.addActionListener(this); popup.add(menuItem); //Add listener to the text area so the popup menu can come up. monitorsPopupListener = new PopupListener(popup); } return (monitorsPopupListener); }
From source file:base.BasePlayer.AddGenome.java
public void actionPerformed(ActionEvent event) { if (event.getSource() == download) { if (!downloading) { downloading = true;/*w w w. ja v a 2 s. co m*/ downloadGenome(genometable.getValueAt(genometable.getSelectedRow(), 0).toString()); downloading = false; } } else if (event.getSource() == getLinks) { URL[] urls = AddGenome.genomeHash .get(genometable.getValueAt(genometable.getSelectedRow(), 0).toString()); JPopupMenu menu = new JPopupMenu(); JTextArea area = new JTextArea(); JScrollPane menuscroll = new JScrollPane(); area.setFont(Main.menuFont); menu.add(menuscroll); menu.setPreferredSize(new Dimension( menu.getFontMetrics(Main.menuFont).stringWidth(urls[0].toString()) + Main.defaultFontSize * 10, (int) menu.getFontMetrics(Main.menuFont).getHeight() * 4)); //area.setMaximumSize(new Dimension(300, 600)); area.setLineWrap(true); area.setWrapStyleWord(true); for (int i = 0; i < urls.length; i++) { area.append(urls[i].toString() + "\n"); } area.setCaretPosition(0); area.revalidate(); menuscroll.getViewport().add(area); menu.pack(); menu.show(this, 0, 0); } else if (event.getSource() == checkEnsembl) { if (ensemblfetch) { menu.show(AddGenome.treescroll, 0, 0); } else { EnsemblFetch fetcher = new EnsemblFetch(); fetcher.execute(); } } else if (event.getSource() == checkUpdates) { URL testfile = null; try { // kattoo onko paivityksia annotaatioon String ref = selectedNode.toString(); if (AddGenome.genomeHash.get(ref) != null) { ArrayList<String> testfiles = new ArrayList<String>(); if (Main.drawCanvas != null) { for (int i = 0; i < Main.genomehash.get(ref).size(); i++) { testfiles.add(Main.genomehash.get(ref).get(i).getName().replace(".bed.gz", "")); } } testfile = AddGenome.genomeHash.get(ref)[1]; String result = Main.checkFile(testfile, testfiles); if (result.length() == 0) { Main.showError("You have newest annotation file.", "Note"); } else { int n = JOptionPane.showConfirmDialog(Main.drawCanvas, "New annotation file found: " + result + "\nDownload it now?", "Note", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { URL fileurl = new URL(testfile.getProtocol() + "://" + testfile.getHost() + testfile.getPath().substring(0, testfile.getPath().lastIndexOf("/") + 1) + result); OutputRunner runner = new OutputRunner(fileurl, ref); runner.downloadAnnotation = true; runner.execute(); } } } else { Main.showError("This genome is not from Ensembl list, could not check for updates.", "Note", AddGenome.genometable); } } catch (Exception e) { Main.showError("Cannot connect to " + testfile.getHost() + ".\nTry again later.", "Error"); e.printStackTrace(); } } else if (event.getSource() == remove) { if (!selectedNode.isLeaf()) { String removeref = selectedNode.toString(); // Boolean same = false; try { if (Main.drawCanvas != null) { if (removeref.equals(Main.refDropdown.getSelectedItem().toString())) { Main.referenceFile.close(); // same = true; if (ChromDraw.exonReader != null) { ChromDraw.exonReader.close(); } } } if (Main.genomehash.containsKey(removeref)) { for (int i = Main.genomehash.get(removeref).size() - 1; i >= 0; i--) { Main.genomehash.get(removeref).remove(i); } Main.genomehash.remove(removeref); } if (Main.drawCanvas != null) { Main.refModel.removeElement(removeref); Main.refDropdown.removeItem(removeref); Main.refDropdown.revalidate(); } for (int i = 0; i < Main.genome.getItemCount(); i++) { if (Main.genome.getItem(i).getName() != null) { if (Main.genome.getItem(i).getName().equals(removeref)) { Main.genome.remove(Main.genome.getItem(i)); break; } } } FileUtils.deleteDirectory(new File(Main.genomeDir.getCanonicalPath() + "/" + removeref)); checkGenomes(); Main.setAnnotationDrop(""); if (Main.genomehash.size() == 0) { Main.refDropdown.setSelectedIndex(0); Main.setChromDrop("-1"); } } catch (Exception e) { e.printStackTrace(); try { Main.showError("Could not delete genome folder.\nYou can do it manually by deleting folder " + Main.genomeDir.getCanonicalPath() + "/" + removeref, "Note"); } catch (IOException e1) { e1.printStackTrace(); } } } else { try { if (Main.drawCanvas != null) { if (ChromDraw.exonReader != null) { ChromDraw.exonReader.close(); } } Main.removeAnnotationFile(selectedNode.getParent().toString(), selectedNode.toString()); FileUtils.deleteDirectory(new File(Main.genomeDir.getCanonicalPath() + "/" + selectedNode.getParent().toString() + "/annotation/" + selectedNode.toString())); // root.remove(selectedNode.getParent().getIndex(selectedNode)); // root.remove // checkGenomes(); } catch (Exception e) { e.printStackTrace(); try { Main.showError("Could not delete genome folder.\nYou can do it manually by deleting folder " + Main.genomeDir.getCanonicalPath() + "/" + selectedNode.getParent().toString() + "/annotation/" + selectedNode.toString(), "Note"); } catch (IOException e1) { e1.printStackTrace(); } } treemodel.removeNodeFromParent(selectedNode); } } else if (event.getSource() == add) { if (genomeFile == null) { if (new File(genomeFileText.getText()).exists()) { genomeFile = new File(genomeFileText.getText()); } else { genomeFileText.setText("Select reference genome fasta-file."); genomeFileText.setForeground(Color.red); return; } } /*if(genomeName.getText().contains("Give name") || genomeName.getText().length() == 0) { genomeName.setText("Give name of the genome"); genomeName.setForeground(Color.red); genomeName.revalidate(); } else if(!annotation && new File(Main.userDir +"/genomes/"+genomeName.getText().trim().replace("\\s+", "_")).exists()) { genomeName.setText("This genome exists already."); genomeName.setForeground(Color.red); genomeName.revalidate(); } else */ if ((genomeFileText.getText().length() == 0 || genomeFileText.getText().startsWith("Select reference"))) { genomeFileText.setText("Select reference genome fasta-file."); genomeFileText.setForeground(Color.red); genomeFileText.revalidate(); } else { OutputRunner runner = new OutputRunner( genomeFile.getName().replace(".fasta", "").replace(".gz", ""), genomeFile, annotationFile); runner.execute(); } } else if (event.getSource() == openRef) { try { JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterFasta fastaFilter = new MyFilterFasta(); chooser.addChoosableFileFilter(fastaFilter); chooser.setDialogTitle("Select reference fasta-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { genomeFile = chooser.getSelectedFile(); Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); genomeFileText.setText(genomeFile.getName()); genomeFileText.revalidate(); frame.pack(); } } catch (Exception ex) { ex.printStackTrace(); } } else if (event.getSource() == openAnno) { try { JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterGFF gffFilter = new MyFilterGFF(); chooser.addChoosableFileFilter(gffFilter); chooser.setDialogTitle("Select annotation gff3-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { if (genomeFile == null) { genomeFile = Main.fastahash.get(Main.hoverGenome); } annotationFile = chooser.getSelectedFile(); Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner( genomeFile.getName().replace(".fasta", "").replace(".gz", ""), genomeFile, annotationFile); runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:edu.uara.gui.tableeditor.ChartGenerationFrame.java
private JPopupMenu createDataviewPopup() { JPopupMenu menu = new JPopupMenu(); JMenuItem addColGroup = new JMenuItem("Group Column"); JMenuItem addGroup = new JMenuItem("Group series"); JMenuItem addData = new JMenuItem("Edit dataset.."); menu.add(addColGroup);/*from ww w . ja v a 2 s . c o m*/ menu.add(addGroup); menu.add(addData); addColGroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { groupCategoryByCol(); refreshData(); } }); addGroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { groupCategory(); refreshData(); } }); addData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { new DatasetEditor(table, datasetTable, table.getName(), new IDataRefreshListener() { @Override public void refreshDataset() { refreshData(); } }).setVisible(true); } }); } }); return menu; }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void makePopupMenus(final PhylogenyNode node) { _node_popup_menu = new JPopupMenu(); final List<String> clickto_names = _main_panel.getControlPanel().getSingleClickToNames(); _node_popup_menu_items = new JMenuItem[clickto_names.size()]; for (int i = 0; i < clickto_names.size(); i++) { final String title = clickto_names.get(i); _node_popup_menu_items[i] = new JMenuItem(title); if (title.equals(Configuration.clickto_options[Configuration.open_seq_web][0])) { _node_popup_menu_items[i].setEnabled(isCanOpenSeqWeb(node)); } else if (title.equals(Configuration.clickto_options[Configuration.open_tax_web][0])) { _node_popup_menu_items[i].setEnabled(isCanOpenTaxWeb(node)); } else if (title.equals(Configuration.clickto_options[Configuration.blast][0])) { if (Constants.__RELEASE || Constants.__SNAPSHOT_RELEASE) { continue; }// ww w . j a va 2s.c o m _node_popup_menu_items[i].setEnabled(isCanBlast(node)); } else if (title.equals(Configuration.clickto_options[Configuration.delete_subtree_or_node][0])) { if (!getOptions().isEditable()) { continue; } _node_popup_menu_items[i].setEnabled(isCanDelete()); } else if (title.equals(Configuration.clickto_options[Configuration.cut_subtree][0])) { if (!getOptions().isEditable()) { continue; } _node_popup_menu_items[i].setEnabled(isCanCut(node)); } else if (title.equals(Configuration.clickto_options[Configuration.copy_subtree][0])) { if (!getOptions().isEditable()) { continue; } _node_popup_menu_items[i].setEnabled(isCanCopy()); } else if (title.equals(Configuration.clickto_options[Configuration.paste_subtree][0])) { if (!getOptions().isEditable()) { continue; } _node_popup_menu_items[i].setEnabled(isCanPaste()); } else if (title.equals(Configuration.clickto_options[Configuration.edit_node_data][0])) { if (!getOptions().isEditable()) { continue; } } else if (title.equals(Configuration.clickto_options[Configuration.add_new_node][0])) { if (!getOptions().isEditable()) { continue; } } // No rerooting option for nodes anymore // else if ( title.equals( Configuration.clickto_options[ Configuration.reroot ][ 0 ] ) ) { // _node_popup_menu_items[ i ].setEnabled( isCanReroot() ); //} else if (title.equals(Configuration.clickto_options[Configuration.collapse_uncollapse][0])) { _node_popup_menu_items[i].setEnabled(isCanCollapse()); } else if (title.equals(Configuration.clickto_options[Configuration.color_subtree][0])) { _node_popup_menu_items[i].setEnabled(isCanColorSubtree()); } else if (title.equals(Configuration.clickto_options[Configuration.subtree][0])) { _node_popup_menu_items[i].setEnabled(isCanSubtree(node)); } if (!title.equals(Configuration.clickto_options[Configuration.reroot][0]) && !title.equals(Configuration.clickto_options[Configuration.display_branch_data][0])) { _node_popup_menu_items[i].addActionListener(this); _node_popup_menu.add(_node_popup_menu_items[i]); } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected JPopupMenu createPopupMenu() { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem;/* w w w . j av a 2 s .c om*/ for (final Action action : actionList) { if (StringUtils.isNotBlank(action.getCaption()) && action.isVisible()) { menuItem = new JMenuItem(action.getCaption()); if (action.getIcon() != null) { menuItem.setIcon(AppBeans.get(IconResolver.class).getIconResource(action.getIcon())); } if (action.getShortcutCombination() != null) { menuItem.setAccelerator(convertKeyCombination(action.getShortcutCombination())); } menuItem.setEnabled(action.isEnabled()); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { action.actionPerform(DesktopAbstractTable.this); } }); popup.add(menuItem); } } return popup; }
From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java
private void createPopupMenu() { JMenuItem menuItem;// w w w. jav a 2s. c o m //Create the popup menu. JPopupMenu popup = new JPopupMenu(); /*menuItem = new JMenuItem("Constrain Item ..."); menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem);*/ menuItem = new JMenuItem("Delete Item"); menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); /*popup.add(new javax.swing.JSeparator()); menuItem = new JMenuItem("Exclude All Items"); menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem);*/ popup.add(new javax.swing.JSeparator()); menuItem = new JMenuItem("Set Value ..."); menuItem.setEnabled(false); menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); //Add listener to the tree MouseListener popupListener = new ConceptTreePopupListener(popup); jTree1.addMouseListener(popupListener); }
From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java
private void createPopupMenu() { JMenuItem menuItem;//from ww w. j av a 2 s . c o m // Create the popup menu. JPopupMenu popup = new JPopupMenu(); /* * menuItem = new JMenuItem("Constrain Item ..."); * menuItem.setAccelerator * (javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, * java.awt.event.InputEvent.CTRL_MASK)); * menuItem.addActionListener(this); popup.add(menuItem); */ menuItem = new JMenuItem("Delete Item"); // menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt. // event.KeyEvent.VK_X, // java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); /* * popup.add(new javax.swing.JSeparator()); * * menuItem = new JMenuItem("Exclude All Items"); * menuItem.setAccelerator * (javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, * java.awt.event.InputEvent.CTRL_MASK)); * menuItem.addActionListener(this); popup.add(menuItem); */ popup.add(new javax.swing.JSeparator()); menuItem = new JMenuItem("Set Value ..."); menuItem.setEnabled(false); // menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt. // event.KeyEvent.VK_S, // java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); // Add listener to the tree MouseListener popupListener = new ConceptTreePopupListener(popup); jTree1.addMouseListener(popupListener); }