List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:es.emergya.ui.gis.FleetControlMapViewer.java
@Override protected JPopupMenu getContextMenu() { JPopupMenu menu = new JPopupMenu(); menu.setBackground(Color.decode("#E8EDF6")); // Ttulo/* w ww. j av a 2 s .com*/ final JMenuItem titulo = new JMenuItem(i18n.getString("map.menu.titulo.puntoGenerico")); titulo.setFont(LogicConstants.deriveBoldFont(10.0f)); titulo.setBackground(Color.decode("#A4A4A4")); titulo.setFocusable(false); menu.add(titulo); menu.addSeparator(); // Actualizar posicin final JMenuItem gps = new JMenuItem(i18n.getString("map.menu.gps"), KeyEvent.VK_P); gps.setIcon(LogicConstants.getIcon("menucontextual_icon_actualizargps")); menu.add(gps); gps.addActionListener(this); gps.setEnabled(false); menu.addSeparator(); // Mostrar ms cercanos final JMenuItem mmc = new JMenuItem(i18n.getString("map.menu.showNearest"), KeyEvent.VK_M); mmc.setIcon(LogicConstants.getIcon("menucontextual_icon_mascercano")); mmc.addActionListener(this); menu.add(mmc); // Centrar aqui final JMenuItem cent = new JMenuItem(i18n.getString("map.menu.centerHere"), KeyEvent.VK_C); cent.setIcon(LogicConstants.getIcon("menucontextual_icon_centrar")); cent.addActionListener(this); menu.add(cent); // Nueva Incidencia final JMenuItem newIncidence = new JMenuItem(i18n.getString("map.menu.newIncidence"), KeyEvent.VK_I); newIncidence.setIcon(LogicConstants.getIcon("menucontextual_icon_newIncidence")); newIncidence.addActionListener(this); menu.add(newIncidence); // Calcular ruta desde aqui final JMenuItem from = new JMenuItem(i18n.getString("map.menu.route.from"), KeyEvent.VK_D); from.setIcon(LogicConstants.getIcon("menucontextual_icon_origenruta")); from.addActionListener(this); menu.add(from); // Calcular ruta hasta aqui final JMenuItem to = new JMenuItem(i18n.getString("map.menu.route.to"), KeyEvent.VK_H); to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta")); to.addActionListener(this); menu.add(to); menu.addSeparator(); // Ver ficha [recurso / incidencia] final JMenuItem summary = new JMenuItem(i18n.getString("map.menu.summary"), KeyEvent.VK_F); summary.setIcon(LogicConstants.getIcon("menucontextual_icon_ficha")); summary.addActionListener(this); menu.add(summary); summary.setEnabled(false); menu.addPopupMenuListener(new PopupMenuListener() { @SuppressWarnings("unchecked") @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { eventOriginal = FleetControlMapViewer.this.mapView.lastMEvent; gps.setEnabled(false); summary.setEnabled(false); titulo.setText(i18n.getString("map.menu.titulo.puntoGenerico")); menuObjective = null; Point p = new Point(mapView.lastMEvent.getX(), mapView.lastMEvent.getY()); for (Layer l : mapView.getAllLayers()) { // por cada capa... if (l instanceof MarkerLayer) { // ...de marcadores for (Marker marker : ((MarkerLayer) l).data) { // miramos // los // marcadores if ((marker instanceof CustomMarker) && marker.containsPoint(p)) { // y si // estamos // pinchando // en uno CustomMarker m = (CustomMarker) marker; log.trace("Hemos pinchado en " + marker); switch (m.getType()) { case RESOURCE: Recurso r = (Recurso) m.getObject(); log.trace("Es un recurso: " + r); if (r != null) { menuObjective = r; if (r.getPatrullas() != null) { titulo.setText( i18n.getString(Locale.ROOT, "map.menu.titulo.recursoPatrulla", r.getIdentificador(), r.getPatrullas())); } else { titulo.setText(r.getIdentificador()); } gps.setEnabled(true); summary.setEnabled(true); } break; case INCIDENCE: Incidencia i = (Incidencia) m.getObject(); log.trace("Es una incidencia: " + i); if (i != null) { menuObjective = i; titulo.setText(i.getTitulo()); gps.setEnabled(false); summary.setEnabled(true); } break; case UNKNOWN: log.trace("Hemos pinchado en un marcador desconocido"); break; } } } } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); return menu; }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
public void fileTableClicked(FileObjectTableModel fileObjectTableModel, JTableX<FileObject> table, MouseEvent e) {/*w ww . ja v a 2 s . c om*/ int row = table.convertRowIndexToModel(table.rowAtPoint(e.getPoint())); //int column = table.convertColumnIndexToModel(table.columnAtPoint(e.getPoint())); final Collection<FileObject> selectedFileObjects = table.getSelectedObjects(); final FileObject f = fileObjectTableModel.getRowObjects().get(row); if (SwingUtilities.isRightMouseButton(e)) { JPopupMenu m = new JPopupMenu(); { JMenuItem menuitem = new JMenuItem("ffnen"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(f); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("Ordner ffnen"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFolder(f); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("Herunterladen (ber SOAP)"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { downloadFiles(selectedFileObjects, DownloadMethod.WEBSERVICE); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("Herunterladen (ber WEBDAV)"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!syncService.getIliasSoapService().isWebdavAuthenticationActive()) { syncService.getIliasSoapService().enableWebdavAuthentication( mainFrame.getFieldLogin().getText(), mainFrame.getFieldPassword().getPassword()); } downloadFiles(selectedFileObjects, DownloadMethod.WEBDAV); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("In Ilias ffnen"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openInIlias(f); } }); m.add(menuitem); } { m.add(new JSeparator()); } { JCheckBoxMenuItem menuitem = new JCheckBoxMenuItem("Ignorieren"); menuitem.setSelected(iliasProperties.getBlockedFiles().contains(f.getRefId())); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { switchIgnoreState(selectedFileObjects); } }); m.add(menuitem); } { m.add(new JSeparator()); } { JMenuItem menuitem = new JMenuItem("Fehler anzeigen"); menuitem.setEnabled(f.getException() != null); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showError("Fehler bei " + f.getTargetFile().getAbsolutePath(), f.getException()); } }); m.add(menuitem); } m.show(table, e.getX(), e.getY()); } if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) { openFile(f); } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java
private JPopupMenu createPopupMenu(boolean over_peak) { JPopupMenu menu = new JPopupMenu(); if (over_peak) { updatePeakActions();/* w ww .j a v a 2 s.co m*/ menu.add(theActionManager.get("addpeaks")); ButtonGroup group = new ButtonGroup(); if (shown_mslevel.equals("ms")) { for (GlycanAction a : theApplication.getPluginManager().getMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == ms_action); group.add(last); } } else { for (GlycanAction a : theApplication.getPluginManager().getMsMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == msms_action); group.add(last); } } menu.addSeparator(); } menu.add(theActionManager.get("zoomnone")); menu.add(theActionManager.get("zoomin")); menu.add(theActionManager.get("zoomout")); return menu; }
From source file:velocitekProStartAnalyzer.MainWindow.java
private void initialize() { JDBCPointDao jdbcPointDao = new JDBCPointDao(); //SQLiteDB.createNewDatabase(dbName); jdbcPointDao.getConnection(dbName);// w w w . j av a2s .c o m SQLiteDB.createNewTable(dbName); frame = new JFrame(); frame.setBounds(1, 1, 1280, 720); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.getContentPane().setLayout(new BorderLayout(0, 0)); setScrollTable(new JScrollPane()); frame.getContentPane().add(copyrightLabel, BorderLayout.PAGE_END); btnPanel = new JPanel(); frame.getContentPane().add(btnPanel, BorderLayout.NORTH); frame.addWindowStateListener(new WindowStateListener() { @Override public void windowStateChanged(WindowEvent event) { boolean isMaximized = isMaximized(event.getNewState()); boolean wasMaximized = isMaximized(event.getOldState()); if (isMaximized && !wasMaximized) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { defaultSize(); } }); } else if (wasMaximized && !isMaximized) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { defaultSize(); } }); } } }); ReadXMLFile readXmlFile = new ReadXMLFile(); btnLoadRouteData = new JButton("Reload"); btnPanel.add(btnLoadRouteData); if (getFilePath() == null) { btnLoadRouteData.setEnabled(false); } btnLoadRouteData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { readXmlFile.ReadXmlFile(getFilePath()); loadDataFromDB(); } }); btnPanel.add(btnShowFileDialogButton); tableContainer = new JScrollPane(pointTable); frame.getContentPane().add(tableContainer, BorderLayout.SOUTH); graphMapSplitPanel = new JSplitPane(); tableGraphMapSplitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); graphMapSplitPanel.setResizeWeight(.5d); frame.getContentPane().add(tableGraphMapSplitPanel, BorderLayout.CENTER); JPanel dataAnalysisPanel = new JPanel(); dataAnalysisPanel.add(dataAnalysisLabel); JPanel tableContainerPanel = new JPanel(new BorderLayout()); tableContainerPanel.add(dataAnalysisPanel, BorderLayout.NORTH); tableContainerPanel.add(tableContainer); tableGraphMapSplitPanel.setTopComponent(graphMapSplitPanel); tableGraphMapSplitPanel.setBottomComponent(tableContainerPanel); graphMapSplitPanel.setLeftComponent(graphPanel); //mapPanel.setVisible(true); graphMapSplitPanel.setRightComponent(mapPanel); btnPanel.add(statusLabel); statusLabel.setVisible(true); //frame.add(statusLabel); openFile(); loadDataFromDB(); pointTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent event) { if (!JDBCPointDao.points.isEmpty()) { getMapPanel().map().removeAllMapMarkers(); for (int pointTableID : pointTable.getSelectedRows()) { MapMarkerDot mapPoint = new MapMarkerDot(null, null, (double) pointTable.getValueAt(pointTableID, 4), (double) pointTable.getValueAt(pointTableID, 5)); if (!getMapPanel().map().getMapMarkerList().contains(mapPoint)) { getMapPanel().map().addMapMarker(mapPoint); } // mapPanel.map().setDisplayToFitMapMarkers(); } int index = 0; for (int pointTableID : pointTable.getSelectedRows()) { index = pointTableID; } Double x = Double.valueOf(pointTable.getValueAt(index, 0).toString()); Double y = Double.valueOf(pointTable.getValueAt(index, 3).toString()); //int test2 = (int) pointTable.getValueAt(pointTable.getSelectedRow(), 3); xCrosshair.setValue(x); yCrosshair.setValue(y); } } }); popup = new JPopupMenu(); btnDeleteSelected = new JMenuItem("Delete Selected"); popup.add(btnDeleteSelected); btnDeleteSelected.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteSelected(); loadDataFromDB(); } }); btnDeleteAllButNotSelected = new JMenuItem("Set Selected as New Database"); popup.add(btnDeleteAllButNotSelected); btnDeleteAllButNotSelected.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteAllButNotSelected(); loadDataFromDB(); setStartFinishMapMarkers(); } }); btnSetStartTime = new JMenuItem("Set Race Time"); popup.add(btnSetStartTime); btnSetStartTime.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JDBCPointDao.pointsOld.clear(); JDBCPointDao.pointsOld.addAll(JDBCPointDao.points); setStartTime(showSetStartTimeDialog()); loadDataFromDB(); setEndTime(showSetEndTimeDialog()); loadDataFromDB(); setStartFinishMapMarkers(); } catch (NullPointerException exception) { return; } } }); btnSetStartFinishMapMarkers = new JMenuItem("Show Start Finish"); popup.add(btnSetStartFinishMapMarkers); popup.addSeparator(); btnSetStartFinishMapMarkers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setStartFinishMapMarkers(); } }); btnMenuSaveSubmenu.add(btnSaveChartAsPng); btnSaveMapAsPng = new JMenuItem("Save Map as PNG"); btnMenuSaveSubmenu.add(btnSaveMapAsPng); btnSaveTableAsPng = new JMenuItem("Save Table as PNG"); btnMenuSaveSubmenu.add(btnSaveTableAsPng); btnMenuSaveSubmenu.add(btnSaveMapAsPng); btnMenuSaveSubmenu.addSeparator(); btnMenuSaveSubmenu.add(btnSaveAsVCCForChart); if (JDBCPointDao.points.isEmpty()) { btnSaveAsVCC.setEnabled(false); btnSaveAsVCCForChart.setEnabled(false); } btnBackData = new JMenuItem("Back"); popup.add(btnBackData); popup.addSeparator(); if (JDBCPointDao.pointsOld.isEmpty()) { btnBackData.setEnabled(false); } JMenuItem btnResizeWindow = new JMenuItem("Resize Windows"); popup.add(btnResizeWindow); popup.addSeparator(); btnResizeWindow.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { defaultSize(); } catch (NullPointerException exception) { return; } } }); popup.add(btnMenuSaveSubmenu); popup.addSeparator(); popup.add(btnAbout); btnAbout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(frame, "Velocitek Prostart Analyser v.1.4 - Copyright (C) 2017 Maciej Jdrzejko" + "\n\nThis program is free software: you can redistribute it and/or modify" + "\nit under the terms of the GNU General Public License as published by " + "\nthe Free Software Foundation, either version 3 of the License, or" + "\n(at your option) any later version." + "\n\nThis program is distributed in the hope that it will be useful," + "\nbut WITHOUT ANY WARRANTY; without even the implied warranty of" + "\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" + "\nGNU General Public License for more details." + "\n\nYou should have received a copy of the GNU General Public License" + "\nalong with this program. If not, see http://www.gnu.org/licenses/ "); } }); btnResetSpeedChart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadDataFromDB(); } }); btnMedianSpeedChart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int howManyTimes = selectHowManyTimes(); for (int i = 0; i < howManyTimes; i++) { int iterator = 1; JDBCPointDao.dataSet.removeAllSeries(); JDBCPointDao.speedTimeSeries.clear(); for (Double medianSpeed : dataAnalysis.getMedianForChart()) { JDBCPointDao.speedTimeSeries.add(iterator, medianSpeed); iterator++; } JDBCPointDao.dataSet.addSeries(JDBCPointDao.speedTimeSeries); createChartPanel(); } } }); btnAvgSpeedChart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int howManyTimes = selectHowManyTimes(); for (int i = 0; i < howManyTimes; i++) { int iterator = 1; JDBCPointDao.dataSet.removeAllSeries(); JDBCPointDao.speedTimeSeries.clear(); for (Double avgSpeed : dataAnalysis.getAvgSpeedForChart()) { JDBCPointDao.speedTimeSeries.add(iterator, avgSpeed); iterator++; } JDBCPointDao.dataSet.addSeries(JDBCPointDao.speedTimeSeries); createChartPanel(); } } }); //Add listener to components that can bring up popup menus. frame.addMouseListener(popupListener); graphMapSplitPanel.addMouseListener(popupListener); tableContainer.addMouseListener(popupListener); pointTable.addMouseListener(popupListener); mapPanel.addMouseListener(popupListener); saveMapAsPng(mapPanel); saveTableAsPng(tableContainer); saveNewVCC(); backData(); }
From source file:net.itransformers.topologyviewer.gui.GraphViewerPanel.java
private AbstractModalGraphMouse createModalGraphMouse() { final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse<String, String>(); graphMouse.add(new AbstractPopupGraphMousePlugin() { @Override/*from w w w. j ava 2 s . c o m*/ protected void handlePopup(final MouseEvent e) { GraphElementAccessor<String, String> pickSupport = vv.getPickSupport(); // final String v = pickSupport.getVertex(vv.getGraphLayout(), e.getX(), e.getY()); Collection<String> picked = new HashSet(getPickedVerteces()); final String[] varr = picked.toArray(new String[picked.size()]); final java.util.List<RightClickItemType> rightClickItem = GraphViewerPanel.this.viewerConfig .getRightClickItem(); JPopupMenu popup = new JPopupMenu(); fillRightClickMenu(varr, rightClickItem, popup); JMenuItem remove = new JMenuItem("remove"); popup.add(remove); remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { for (String v : varr) { currentGraph.removeVertex(v); } vv.repaint(); } }); popup.show(vv, e.getX(), e.getY()); } }); return graphMouse; }
From source file:biz.wolschon.finance.jgnucash.panels.WritableTransactionsPanel.java
/** * @return the context-menu for the transactionTable. * @see #getTransactionTable()//from ww w .j ava 2 s . c o m */ private Component getTransactionTableContextMenu() { if (myContextMenu == null) { myContextMenu = new JPopupMenu(); PluginManager manager = getPluginManager(); // if we are configured for the plugin-api if (manager != null) { ExtensionPoint toolExtPoint = manager.getRegistry().getExtensionPoint(getPluginDescriptor().getId(), "TransactionMenuAction"); for (Iterator<Extension> it = toolExtPoint.getConnectedExtensions().iterator(); it.hasNext();) { Extension ext = it.next(); String pluginName = "unknown"; try { pluginName = ext.getParameter("name").valueAsString(); JMenuItem newMenuItem = new JMenuItem(); newMenuItem.putClientProperty("extension", ext); newMenuItem.setText(pluginName); newMenuItem.addActionListener(new TransactionMenuActionMenuAction(ext, pluginName)); myContextMenu.add(newMenuItem); } catch (Exception e) { LOG.log(Level.SEVERE, "cannot load TransactionMenuAction-Plugin '" + pluginName + "'", e); JOptionPane.showMessageDialog(this, "Error", "Cannot load TransactionMenuAction-Plugin '" + pluginName + "'", JOptionPane.ERROR_MESSAGE); } } } } return myContextMenu; }
From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java
/** * This method is called from within the constructor to initialize the form. *//*from w ww . java2 s . c o m*/ public void initComponents() { // the available panels (cards) rulePanel = new BasePanel(); blankPanel = new BasePanel(); scriptTextArea = new MirthRTextScrollPane(null, true, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, false); scriptTextArea.setBackground(new Color(204, 204, 204)); scriptTextArea.setBorder(BorderFactory.createEtchedBorder()); scriptTextArea.getTextArea().setEditable(false); scriptTextArea.getTextArea().setDropTarget(null); generatedScriptPanel = new JPanel(); generatedScriptPanel.setBackground(Color.white); generatedScriptPanel.setLayout(new CardLayout()); generatedScriptPanel.add(scriptTextArea, ""); tabbedPane = new JTabbedPane(); tabbedPane.addTab("Rule", rulePanel); tabbedPane.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { switchTab = (lastSelectedIndex == 0 && tabbedPane.getSelectedIndex() == 1) ? true : false; updateCodePanel(null); } }); for (FilterRulePlugin filterRulePlugin : LoadedExtensions.getInstance().getFilterRulePlugins().values()) { filterRulePlugin.initialize(this); } // establish the cards to use in the Transformer rulePanel.addCard(blankPanel, BLANK_TYPE); for (FilterRulePlugin plugin : LoadedExtensions.getInstance().getFilterRulePlugins().values()) { rulePanel.addCard(plugin.getPanel(), plugin.getPluginPointName()); } filterTablePane = new JScrollPane(); viewTasks = new JXTaskPane(); viewTasks.setTitle("Mirth Views"); viewTasks.setFocusable(false); filterPopupMenu = new JPopupMenu(); viewTasks.add(initActionCallback("accept", "Return back to channel.", ActionFactory.createBoundAction("accept", "Back to Channel", "B"), new ImageIcon(Frame.class.getResource("images/resultset_previous.png")))); parent.setNonFocusable(viewTasks); viewTasks.setVisible(false); parent.taskPaneContainer.add(viewTasks, parent.taskPaneContainer.getComponentCount() - 1); filterTasks = new JXTaskPane(); filterTasks.setTitle("Filter Tasks"); filterTasks.setFocusable(false); // add new rule task filterTasks.add(initActionCallback("addNewRule", "Add a new filter rule.", ActionFactory.createBoundAction("addNewRule", "Add New Rule", "N"), new ImageIcon(Frame.class.getResource("images/add.png")))); JMenuItem addNewRule = new JMenuItem("Add New Rule"); addNewRule.setIcon(new ImageIcon(Frame.class.getResource("images/add.png"))); addNewRule.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addNewRule(); } }); filterPopupMenu.add(addNewRule); // delete rule task filterTasks.add(initActionCallback("deleteRule", "Delete the currently selected filter rule.", ActionFactory.createBoundAction("deleteRule", "Delete Rule", "X"), new ImageIcon(Frame.class.getResource("images/delete.png")))); JMenuItem deleteRule = new JMenuItem("Delete Rule"); deleteRule.setIcon(new ImageIcon(Frame.class.getResource("images/delete.png"))); deleteRule.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { deleteRule(); } }); filterPopupMenu.add(deleteRule); filterTasks.add(initActionCallback("doImport", "Import a filter from an XML file.", ActionFactory.createBoundAction("doImport", "Import Filter", "I"), new ImageIcon(Frame.class.getResource("images/report_go.png")))); JMenuItem importFilter = new JMenuItem("Import Filter"); importFilter.setIcon(new ImageIcon(Frame.class.getResource("images/report_go.png"))); importFilter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doImport(); } }); filterPopupMenu.add(importFilter); filterTasks.add(initActionCallback("doExport", "Export the filter to an XML file.", ActionFactory.createBoundAction("doExport", "Export Filter", "E"), new ImageIcon(Frame.class.getResource("images/report_disk.png")))); JMenuItem exportFilter = new JMenuItem("Export Filter"); exportFilter.setIcon(new ImageIcon(Frame.class.getResource("images/report_disk.png"))); exportFilter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doExport(); } }); filterPopupMenu.add(exportFilter); filterTasks.add(initActionCallback("doValidate", "Validate the currently viewed script.", ActionFactory.createBoundAction("doValidate", "Validate Script", "V"), new ImageIcon(Frame.class.getResource("images/accept.png")))); JMenuItem validateStep = new JMenuItem("Validate Script"); validateStep.setIcon(new ImageIcon(Frame.class.getResource("images/accept.png"))); validateStep.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doValidate(); } }); filterPopupMenu.add(validateStep); // move rule up task filterTasks.add(initActionCallback("moveRuleUp", "Move the currently selected rule up.", ActionFactory.createBoundAction("moveRuleUp", "Move Rule Up", "P"), new ImageIcon(Frame.class.getResource("images/arrow_up.png")))); JMenuItem moveRuleUp = new JMenuItem("Move Rule Up"); moveRuleUp.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_up.png"))); moveRuleUp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { moveRuleUp(); } }); filterPopupMenu.add(moveRuleUp); // move rule down task filterTasks.add(initActionCallback("moveRuleDown", "Move the currently selected rule down.", ActionFactory.createBoundAction("moveRuleDown", "Move Rule Down", "D"), new ImageIcon(Frame.class.getResource("images/arrow_down.png")))); JMenuItem moveRuleDown = new JMenuItem("Move Rule Down"); moveRuleDown.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_down.png"))); moveRuleDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { moveRuleDown(); } }); filterPopupMenu.add(moveRuleDown); // add the tasks to the taskpane, and the taskpane to the mirth client parent.setNonFocusable(filterTasks); filterTasks.setVisible(false); parent.taskPaneContainer.add(filterTasks, parent.taskPaneContainer.getComponentCount() - 1); makeFilterTable(); // BGN LAYOUT filterTablePane.setBorder(BorderFactory.createEmptyBorder()); rulePanel.setBorder(BorderFactory.createEmptyBorder()); hSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, filterTablePane, tabbedPane); hSplitPane.setContinuousLayout(true); hSplitPane.setOneTouchExpandable(true); vSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, hSplitPane, refPanel); vSplitPane.setContinuousLayout(true); vSplitPane.setOneTouchExpandable(true); this.setLayout(new BorderLayout()); this.add(vSplitPane, BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder()); vSplitPane.setBorder(BorderFactory.createEmptyBorder()); hSplitPane.setBorder(BorderFactory.createEmptyBorder()); resizePanes(); // END LAYOUT }
From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java
private void valueLeafActionEdit(final MouseEvent mouseEvent, final TreePath selectedPath, final XmlDomAdapterNode clickedItem, final JTree tree) { final JPopupMenu popup = new JPopupMenu(); // Basic type : edit final JMenuItem menuItem = new JMenuItem(ResourceUtils.getI18n("EDIT")); menuItem.addActionListener(new ActionListener() { @Override//w w w. ja va2s . com public void actionPerformed(ActionEvent actionEvent) { final String newValue = JOptionPane.showInputDialog(ResourceUtils.getI18n("EDIT"), clickedItem.node.getNodeValue()); if (newValue != null) { try { if (clickedItem.node instanceof Attr) { ((Attr) clickedItem.node).setValue(newValue); } else { clickedItem.node.setNodeValue(newValue); } //clickedItem.setNewValue(newValue); } catch (NumberFormatException e) { showErrorMessage(newValue, tree); } validationPolicyTreeModel.fireTreeChanged(selectedPath); } } }); popup.add(menuItem); popup.show(tree, mouseEvent.getX(), mouseEvent.getY()); }
From source file:de.codesourcery.jasm16.ide.ui.views.WorkspaceExplorer.java
protected JPopupMenu createPopupMenu(final WorkspaceTreeNode selectedNode) { final JPopupMenu popup = new JPopupMenu(); int openProjects = 0; int closedProjects = 0; for (IAssemblyProject p : workspace.getAllProjects()) { if (p.isOpen()) { openProjects++;//ww w . j a v a 2 s . c o m } else { closedProjects++; } } // open debugger final IAssemblyProject project = getProject(selectedNode); if (project != null) { if (project.isOpen()) { addMenuEntry(popup, "Close project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { workspace.closeProject(project); } }); } else { addMenuEntry(popup, "Open project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { workspace.openProject(project); } }); } addMenuEntry(popup, "Build project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { project.getProjectBuilder().build(); } catch (Exception ex) { LOG.error("Failed to build " + project, ex); UIUtils.showErrorDialog(null, "Building project '" + project.getName() + "' failed", "Building the project failed: " + ex.getMessage(), ex); } } }); if (project.getProjectBuilder() == null) { throw new RuntimeException("Internal error, project " + project.getName() + " has no builder ??"); } final IResource executable = project.getProjectBuilder().getExecutable(); if (executable != null) { addMenuEntry(popup, "Open in debugger", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { openDebugPerspective(project, executable, perspectivesManager); } catch (IOException e1) { LOG.error( "Failed to open debug perspective for " + project + " , resource " + executable, e1); } } }); } } if (canCreateFileIn(selectedNode)) { addMenuEntry(popup, "New source file...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { createNewSourceFile(selectedNode); } catch (IOException e1) { LOG.error("actionPerformed(): ", e1); } } }); } addMenuEntry(popup, "New project...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { createNewProject(); } catch (Exception e1) { LOG.error("actionPerformed(): ", e1); UIUtils.showErrorDialog(panel, "Failed to create project", "Project creation failed: " + e1.getMessage()); } } }); if (selectedNode != null) { addMenuEntry(popup, "Delete...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteResource(selectedNode); } }); } addMenuEntry(popup, "Refresh", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshWorkspace(project); } }); addMenuEntry(popup, "Import existing project...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser fc = new JFileChooser(workspace.getBaseDirectory()); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); final int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { final File directory = fc.getSelectedFile(); try { workspace.importProject(directory); } catch (Exception e1) { UIUtils.showErrorDialog(null, "Failed to import project", "Error while importing project: " + e1.getMessage()); } } } }); if (project != null) { addMenuEntry(popup, "Project properties...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProjectConfigurationView view = (ProjectConfigurationView) getViewContainer() .getViewByID(ProjectConfigurationView.ID); if (view == null) { view = new ProjectConfigurationView() { @Override protected void onSave() { apply(project.getConfiguration()); try { project.getConfiguration().save(); } catch (IOException e) { UIUtils.showErrorDialog(null, "Error", "Failed to save project options", e); } finally { getViewContainer().disposeView(this); } } @Override protected void onCancel() { getViewContainer().disposeView(this); } }; getViewContainer().addView(view); } view.setProject(project); view.getViewContainer().toFront(view); } }); } if (closedProjects > 0) { addMenuEntry(popup, "Open ALL projects", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openAllProjects(); } }); } if (openProjects > 0) { addMenuEntry(popup, "Close ALL projects", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeAllProjects(); } }); } return popup; }
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
protected void displaySeriesPopup(final JFreeChart chart, final String label, final int series, final ColorButton button) { JPopupMenu p = new JPopupMenu(); JMenuItem color = new JMenuItem("Color..."); p.add(color);/*from www . jav a 2 s . c om*/ color.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayColorPicker(chart, label, series, button); } }); JMenuItem remove = new JMenuItem("Remove"); p.add(remove); remove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeSeries(chart, series); } }); p.show(button, 4, 4); }