List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java
/** * Brings up the <code>ManagePopupMenu</code>on top of the specified * component at the specified location./*from w w w .ja va 2 s .c o m*/ * * @param c The component that requested the po-pup menu. * @param p The point at which to display the menu, relative to the * <code>component</code>'s coordinates. */ private void showPersonalMenu(Component c, Point p) { if (p == null) return; if (c == null) throw new IllegalArgumentException("No component."); personalMenu = new JPopupMenu(); personalMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); List<GroupSelectionAction> l = controller.getUserGroupAction(); Iterator<GroupSelectionAction> i = l.iterator(); GroupSelectionAction a; JCheckBoxMenuItem item; ButtonGroup buttonGroup = new ButtonGroup(); long id = model.getGroupId(); while (i.hasNext()) { a = i.next(); item = new JCheckBoxMenuItem(a); item.setEnabled(true); item.setSelected(a.isSameGroup(id)); initMenuItem(item); buttonGroup.add(item); personalMenu.add(item); } personalMenu.show(c, p.x, p.y); }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Creates the menus corresponding to the passed id and brings it on screen. * /*from w w w.j a va 2s . co m*/ * @param menuID The id of the menu. One out of the following constants: * {@link ImViewer#COLOR_PICKER_MENU}, * {@link ImViewer#CATEGORY_MENU}. * @param source The component that requested the popup menu. * @param location The point at which to display the menu, relative to the * <code>component</code>'s coordinates. */ void showMenu(int menuID, Component source, Point location) { switch (menuID) { case ImViewer.COLOR_PICKER_MENU: List<ChannelData> data = model.getChannelData(); ChannelData d; JPopupMenu menu = new JPopupMenu(); ChannelColorMenuItem item; Iterator<ChannelData> i = data.iterator(); int index; while (i.hasNext()) { d = i.next(); index = d.getIndex(); item = new ChannelColorMenuItem(d.getChannelLabeling(), model.getChannelColor(index), index); menu.add(item); item.addPropertyChangeListener(controller); } menu.show(source, location.x, location.y); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** * Creates and displays the menu /* w w w .j a v a 2 s . com*/ * @param src The invoker. * @param p The location where to show the menu. */ private void displayMenu(Component src, Point p) { JPopupMenu menu = new JPopupMenu(); ButtonGroup group = new ButtonGroup(); JCheckBoxMenuItem item = createMenuItem(SHOW_ALL); group.add(item); menu.add(item); item = createMenuItem(ADDED_BY_ME); group.add(item); menu.add(item); item = createMenuItem(ADDED_BY_OTHERS); group.add(item); menu.add(item); menu.show(src, p.x, p.y); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** * Creates the selection menu./*from w w w . j ava 2s . c om*/ * * @return See above. */ private JPopupMenu createDocSelectionMenu() { if (docSelectionMenu != null) return docSelectionMenu; docSelectionMenu = new JPopupMenu(); JMenuItem item = new JMenuItem("Local document..."); item.setToolTipText("Import a local document to the server " + "and attach it."); item.addActionListener(controller); item.setActionCommand("" + EditorControl.ADD_LOCAL_DOCS); docSelectionMenu.add(item); item = new JMenuItem("Uploaded document..."); item.setToolTipText("Attach a document already uploaded " + "to the server."); item.addActionListener(controller); item.setActionCommand("" + EditorControl.ADD_UPLOADED_DOCS); docSelectionMenu.add(item); return docSelectionMenu; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java
/** * Brings up the menu. /*w w w . j av a 2 s . c om*/ * * @param invoker The component where the clicks occurred. * @param p The location of the mouse pressed. */ private void showMenu(JComponent invoker, Point p) { if (popMenu == null) { popMenu = new JPopupMenu(); if (editButton != null) popMenu.add(editButton); if (unlinkButton != null) popMenu.add(unlinkButton); if (downloadButton != null) popMenu.add(downloadButton); if (openButton != null) popMenu.add(openButton); if (infoButton != null) popMenu.add(infoButton); } popMenu.show(invoker, p.x, p.y); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java
/** * Creates or recycles the menu.// ww w . j a v a2 s . c o m * * @param invoker The component invoking the menu. * @param loc The location of the mouse clicked. */ private void showViewMenu(JComponent invoker, Point loc) { if (viewMenu == null) { viewMenu = new JPopupMenu(); IconManager icons = IconManager.getInstance(); JMenuItem button = new JMenuItem(icons.getIcon(IconManager.VIEW)); button.setText(ViewAction.NAME); button.setToolTipText(ViewAction.DESCRIPTION); button.setActionCommand("" + EditorControl.VIEW_IMAGE); button.addActionListener(controller); viewMenu.add(button); button = new JMenuItem(icons.getIcon(IconManager.VIEWER_IJ)); button.setText(ViewAction.NAME_IJ); button.setToolTipText(ViewAction.DESCRIPTION_IJ); button.setActionCommand("" + EditorControl.VIEW_IMAGE_IN_IJ); button.addActionListener(controller); viewMenu.add(button); } viewMenu.show(invoker, loc.x, loc.y); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java
/** * Creates or recycles the link menu./*from w w w. ja va 2s . com*/ * * @return See above. */ private JPopupMenu createLinkMenu() { if (linkMenu != null) return linkMenu; linkMenu = new JPopupMenu(); IconManager icons = IconManager.getInstance(); pathButton = new JMenuItem(icons.getIcon(IconManager.FILE_PATH)); pathButton.setText("Show File Paths..."); pathButton.setToolTipText("Show file paths on the server."); pathButton.addActionListener(controller); pathButton.setActionCommand("" + EditorControl.FILE_PATH_TOOLBAR); pathButton.setEnabled(model.isSingleMode() && model.getImage() != null); linkMenu.add(pathButton); return linkMenu; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java
/** Creates or recycles the save as menu. */ private JPopupMenu createSaveAsMenu() { saveAsMenu = new JPopupMenu(); IconManager icons = IconManager.getInstance(); downloadItem = new JMenuItem(icons.getIcon(IconManager.DOWNLOAD)); downloadItem.setToolTipText("Download the Archived File(s)."); downloadItem.setText("Download..."); downloadItem.addActionListener(controller); downloadItem.setActionCommand("" + EditorControl.DOWNLOAD); downloadItem.setBackground(UIUtilities.BACKGROUND_COLOR); List<DataObject> nodes = model.getSelectedObjects(); boolean b = false; if (!CollectionUtils.isEmpty(nodes)) { Iterator<DataObject> i = nodes.iterator(); while (i.hasNext()) { if (model.isArchived(i.next())) { b = true;/*from w w w .ja v a 2 s.c o m*/ break; } } } downloadItem.setEnabled(b); saveAsMenu.add(downloadItem); downloadOriginalMetadataItem = new JMenuItem(icons.getIcon(IconManager.DOWNLOAD)); downloadOriginalMetadataItem.setToolTipText("Download the " + "metadata read from the image files."); downloadOriginalMetadataItem.setText("Download Original metadata..."); downloadOriginalMetadataItem.addActionListener(controller); downloadOriginalMetadataItem.setActionCommand("" + EditorControl.DOWNLOAD_METADATA); downloadOriginalMetadataItem.setBackground(UIUtilities.BACKGROUND_COLOR); downloadOriginalMetadataItem.setEnabled(model.hasOriginalMetadata()); saveAsMenu.add(downloadOriginalMetadataItem); exportAsOmeTiffItem = new JMenuItem(icons.getIcon(IconManager.EXPORT_AS_OMETIFF)); exportAsOmeTiffItem.setText("Export as OME-TIFF..."); exportAsOmeTiffItem.setToolTipText(EXPORT_AS_OME_TIFF_TOOLTIP); exportAsOmeTiffItem.addActionListener(controller); exportAsOmeTiffItem.setActionCommand("" + EditorControl.EXPORT_AS_OMETIFF); if (model.isMultiSelection()) b = false; else { b = model.getRefObject() instanceof ImageData && !model.isLargeImage(); } exportAsOmeTiffItem.setEnabled(b); saveAsMenu.add(exportAsOmeTiffItem); JMenu menu = new JMenu(); menu.setIcon(icons.getIcon(IconManager.SAVE_AS)); menu.setText("Save as..."); menu.setToolTipText("Save the images at full size as JPEG. PNG or" + "TIFF."); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent e) { int index = Integer.parseInt(e.getActionCommand()); controller.saveAs(index); } }; Map<Integer, String> formats = FigureParam.FORMATS; Entry<Integer, String> e; Iterator<Entry<Integer, String>> i = formats.entrySet().iterator(); JMenuItem item; Object ho = model.getRefObject(); boolean enabled = (ho instanceof ImageData || ho instanceof WellSampleData || ho instanceof DatasetData); while (i.hasNext()) { e = i.next(); item = new JMenuItem(); item.setText(e.getValue()); item.addActionListener(l); item.setActionCommand("" + e.getKey()); item.setEnabled(enabled); menu.add(item); } saveAsMenu.add(menu); setRootObject(); return saveAsMenu; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java
/** * Creates or recycles the view menu.//from w w w. j a v a2 s .c o m * * @param source The source of the mouse event. * @param p The location of the mouse pressed. */ private void showViewMenu(Component source, Point p) { JPopupMenu menu = new JPopupMenu(); IconManager icons = IconManager.getInstance(); JMenuItem item = new JMenuItem(icons.getIcon(IconManager.VIEWER)); item.setText("View..."); item.setActionCommand("" + EditorControl.VIEW_IMAGE); item.addActionListener(controller); menu.add(item); item = new JMenuItem(icons.getIcon(IconManager.VIEWER_IJ)); item.setText("View in ImageJ..."); item.setActionCommand("" + EditorControl.VIEW_IMAGE_IN_IJ); item.addActionListener(controller); menu.add(item); menu.show(source, p.x, p.y); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java
/** * Builds the menu displaying the available scripts. * /* w w w. ja v a 2 s .c om*/ * @return See above. */ private JPopupMenu getScriptsMenu() { JPopupMenu menu = new JPopupMenu(); Collection<ScriptObject> scripts = model.getScripts(); //Scripts are sorted. if (scripts == null || scripts.size() == 0) return menu; IconManager icons = IconManager.getInstance(); JMenuItem refresh = new JMenuItem(icons.getIcon(IconManager.REFRESH)); refresh.setText("Reload Scripts"); refresh.setToolTipText("Reloads the existing scripts."); refresh.addActionListener(controller); refresh.setActionCommand("" + EditorControl.RELOAD_SCRIPT); menu.add(refresh); menu.add(new JSeparator()); Iterator<ScriptObject> i = scripts.iterator(); ScriptObject so; Map<String, ScriptSubMenu> menus = new HashMap<String, ScriptSubMenu>(); String path; ScriptSubMenu subMenu; List<ScriptSubMenu> others = new ArrayList<ScriptSubMenu>(); List<String> formattedName = new ArrayList<String>(); while (i.hasNext()) { so = i.next(); setScriptIcon(so); path = so.getPath(); subMenu = menus.get(path); if (subMenu == null) { subMenu = new ScriptSubMenu(path, formattedName); //formattedName.add(subMenu.getUnformattedText()); menus.put(path, subMenu); if (so.isOfficialScript()) menu.add(subMenu); else others.add(subMenu); } //if (!ScriptMenuItem.isScriptWithUI(so.getScriptLabel())) subMenu.addScript(so).addActionListener(controller); } if (others.size() > 0) { menu.add(new JSeparator()); JMenu uploadedMenu = new JMenu("User Scripts"); menu.add(uploadedMenu); Iterator<ScriptSubMenu> j = others.iterator(); while (j.hasNext()) uploadedMenu.add(j.next()); } return menu; }