List of usage examples for java.awt.event MouseEvent getComponent
public Component getComponent()
From source file:op.care.nursingprocess.DlgNursingProcess.java
private void tblPlanungMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblPlanungMousePressed if (!SwingUtilities.isRightMouseButton(evt)) { return;//from ww w . ja v a 2 s . c o m } Point p = evt.getPoint(); ListSelectionModel lsm = tblPlanung.getSelectionModel(); int row = tblPlanung.rowAtPoint(p); if (lsm.isSelectionEmpty() || (lsm.getMinSelectionIndex() == lsm.getMaxSelectionIndex())) { lsm.setSelectionInterval(row, row); } menu = new JPopupMenu(); /*** * _ _ ____ ____ _ _ * (_) |_ ___ _ __ ___ | _ \ ___ _ __ _ _ _ __ | _ \ ___| | ___| |_ ___ * | | __/ _ \ '_ ` _ \| |_) / _ \| '_ \| | | | '_ \| | | |/ _ \ |/ _ \ __/ _ \ * | | || __/ | | | | | __/ (_) | |_) | |_| | |_) | |_| | __/ | __/ || __/ * |_|\__\___|_| |_| |_|_| \___/| .__/ \__,_| .__/|____/ \___|_|\___|\__\___| * |_| |_| */ JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.commands.delete"), SYSConst.icon22delete); itemPopupDelete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { for (int row : tblPlanung.getSelectedRows()) { listInterventionSchedule2Remove .add(((TMPlan) tblPlanung.getModel()).getInterventionSchedule(row)); nursingProcess.getInterventionSchedule() .remove(((TMPlan) tblPlanung.getModel()).getInterventionSchedule(row)); } ((TMPlan) tblPlanung.getModel()).fireTableDataChanged(); } }); menu.add(itemPopupDelete); /*** * _ _ ____ ____ _ _ _ * (_) |_ ___ _ __ ___ | _ \ ___ _ __ _ _ _ __/ ___| ___| |__ ___ __| |_ _| | ___ * | | __/ _ \ '_ ` _ \| |_) / _ \| '_ \| | | | '_ \___ \ / __| '_ \ / _ \/ _` | | | | |/ _ \ * | | || __/ | | | | | __/ (_) | |_) | |_| | |_) |__) | (__| | | | __/ (_| | |_| | | __/ * |_|\__\___|_| |_| |_|_| \___/| .__/ \__,_| .__/____/ \___|_| |_|\___|\__,_|\__,_|_|\___| * |_| |_| */ final JMenuItem itemPopupSchedule = new JMenuItem(SYSTools.xx("misc.commands.editsheduling"), SYSConst.icon22clock); itemPopupSchedule.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { final JidePopup popup = new JidePopup(); /** * This routine uses the <b>first</b> element of the selection as the template for editing * the schedule. After the edit it clones this "template", removes the original * InterventionSchedules (copying the apropriate Intervention of every single * Schedule first) and finally creates new schedules and adds them to * the CareProcess in question. */ int row = tblPlanung.getSelectedRows()[0]; InterventionSchedule firstInterventionScheduleWillBeTemplate = ((TMPlan) tblPlanung.getModel()) .getInterventionSchedule(row); JPanel dlg = new PnlSchedule(firstInterventionScheduleWillBeTemplate, new Closure() { @Override public void execute(Object o) { if (o != null) { InterventionSchedule template = (InterventionSchedule) o; ArrayList<InterventionSchedule> listInterventionSchedule2Add = new ArrayList(); for (int row : tblPlanung.getSelectedRows()) { InterventionSchedule oldTermin = ((TMPlan) tblPlanung.getModel()) .getInterventionSchedule(row); InterventionSchedule newTermin = template.clone(); newTermin.setIntervention(oldTermin.getIntervention()); listInterventionSchedule2Remove.add(oldTermin); listInterventionSchedule2Add.add(newTermin); } nursingProcess.getInterventionSchedule().removeAll(listInterventionSchedule2Remove); nursingProcess.getInterventionSchedule().addAll(listInterventionSchedule2Add); popup.hidePopup(); Collections.sort(nursingProcess.getInterventionSchedule()); ((TMPlan) tblPlanung.getModel()).fireTableDataChanged(); } } }); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(dlg); popup.setOwner(jspPlanung); popup.removeExcludedComponent(jspPlanung); popup.setDefaultFocusComponent(dlg); GUITools.showPopup(popup, SwingConstants.SOUTH_WEST); } }); menu.add(itemPopupSchedule); menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY()); }
From source file:op.care.sysfiles.PnlFiles.java
private void tblFilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblFilesMousePressed Point p = evt.getPoint();/*from w w w .j av a 2s . c o m*/ ListSelectionModel lsm = tblFiles.getSelectionModel(); Point p2 = evt.getPoint(); SwingUtilities.convertPointToScreen(p2, tblFiles); final Point screenposition = p2; boolean singleRowSelected = lsm.getMaxSelectionIndex() == lsm.getMinSelectionIndex(); final int row = tblFiles.rowAtPoint(p); final int col = tblFiles.columnAtPoint(p); if (singleRowSelected) { lsm.setSelectionInterval(row, row); } final TMSYSFiles tm = (TMSYSFiles) tblFiles.getModel(); final SYSFiles sysfile = tm.getRow(tblFiles.convertRowIndexToModel(row)); if (SwingUtilities.isRightMouseButton(evt)) { SYSTools.unregisterListeners(menu); menu = new JPopupMenu(); // SELECT JMenuItem itemPopupShow = new JMenuItem(SYSTools.xx("misc.commands.show"), SYSConst.icon22magnify1); itemPopupShow.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN); } }); menu.add(itemPopupShow); if (col == TMSYSFiles.COL_DESCRIPTION && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { final JMenuItem itemPopupEdit = new JMenuItem(SYSTools.xx("misc.commands.edit"), SYSConst.icon22edit3); itemPopupEdit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { final JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane() .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); final JComponent editor = new JTextArea(sysfile.getBeschreibung(), 10, 40); ((JTextArea) editor).setLineWrap(true); ((JTextArea) editor).setWrapStyleWord(true); ((JTextArea) editor).setEditable(true); popup.getContentPane().add(new JScrollPane(editor)); final JButton saveButton = new JButton(SYSConst.icon22apply); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); popup.hidePopup(); SYSFiles mySysfile = em.merge(sysfile); mySysfile.setBeschreibung(((JTextArea) editor).getText().trim()); em.getTransaction().commit(); tm.setSYSFile(tblFiles.convertRowIndexToModel(row), mySysfile); } catch (Exception e) { em.getTransaction().rollback(); OPDE.fatal(e); } finally { em.close(); } } }); saveButton.setHorizontalAlignment(SwingConstants.RIGHT); JPanel pnl = new JPanel(new BorderLayout(10, 10)); JScrollPane pnlEditor = new JScrollPane(editor); pnl.add(pnlEditor, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(saveButton); pnl.setBorder(new EmptyBorder(10, 10, 10, 10)); pnl.add(buttonPanel, BorderLayout.SOUTH); popup.setOwner(tblFiles); popup.removeExcludedComponent(tblFiles); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(editor); popup.showPopup(screenposition.x, screenposition.y); } }); menu.add(itemPopupEdit); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) { JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.commands.delete"), SYSConst.icon22delete); itemPopupDelete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgYesNo( SYSTools.xx("misc.questions.delete1") + "<br/><b>" + sysfile.getFilename() + "</b><br/>" + SYSTools.xx("misc.questions.delete2"), new ImageIcon(getClass().getResource("/artwork/48x48/bw/trashcan_empty.png")), new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { SYSFilesTools.deleteFile(sysfile); reloadTable(); } } }); } }); menu.add(itemPopupDelete); itemPopupDelete.setEnabled(singleRowSelected); } menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY()); } else if (evt.getClickCount() == 2) { SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN); } }
From source file:base.BasePlayer.Main.java
@Override public void mouseEntered(MouseEvent event) { if (event.getComponent().getName() != null) { if (event.getComponent() instanceof JMenu) { hoverGenome = event.getComponent().getName(); hoverAnnotation = ""; } else if (event.getComponent() instanceof JMenuItem) { hoverAnnotation = event.getComponent().getName(); }// www .j a va 2s . c o m } // if(event.getSource() == manage) { //Logo.frame.setVisible(false); //Syste //filemenu.setSelected(false); //toolmenu.setSelected(false); //help.setSelected(false); //filemenu.getPopupMenu().setVisible(false); //toolmenu.getPopupMenu().setVisible(false); //help.getPopupMenu().setVisible(false); //manage.setFocusPainted(true); // } /*if(event.getSource() == filemenu) { //Logo.frame.setVisible(false); filemenu.doClick(); } else if(event.getSource() == toolmenu) { //Logo.frame.setVisible(false); toolmenu.doClick(); } else if(event.getSource() == help) { // Logo.frame.setVisible(false); help.doClick(); }*/ }
From source file:maltcms.ui.fileHandles.csv.CSVTableView.java
private void createAndShowPopupMenu(MouseEvent me) { if (me.getButton() == MouseEvent.BUTTON3 && this.jTable1.getSelectedRowCount() > 0 && this.jfctc != null) { JPopupMenu jpm = new JPopupMenu(); //more than one column selected if (jTable1.getSelectedColumnCount() > 0) { jpm.add(new AbstractAction("Add as y-values") { @Override//from w ww . j a v a2 s . c om public void actionPerformed(ActionEvent ae) { for (int col : jTable1.getSelectedColumns()) { columnsToPlot.add(col); jTable1.getColumnModel().getColumn(col).setCellRenderer(new ColorColumnRenderer( new Color(238, 187, 0, 255), jTable1.getSelectedRows())); } jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); //selected rows for (final int col : jTable1.getSelectedColumns()) { if (columnsToPlot.contains(col)) { jpm.add(new AbstractAction("Remove y-values from chart") { @Override public void actionPerformed(ActionEvent ae) { jTable1.getColumnModel().getColumn(col).setCellRenderer( new ColorColumnRenderer(Color.WHITE, jTable1.getSelectedRows())); columnsToPlot.remove(col); jfctc.setChart(buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); break; } } jpm.add(new JPopupMenu.Separator()); jpm.add(new AbstractAction("Log10 transform") { @Override public void actionPerformed(ActionEvent ae) { final int[] cols = jTable1.getSelectedColumns(); for (int i = 0; i < jTable1.getSelectedColumnCount(); i++) { logTransformColumn(cols[i], 10.0d); } } }); jpm.add(new AbstractAction("Inverse Log10 transform") { @Override public void actionPerformed(ActionEvent ae) { final int[] cols = jTable1.getSelectedColumns(); for (int i = 0; i < jTable1.getSelectedColumnCount(); i++) { inverseLogTransformColumn(cols[i], 10.0d); } } }); } jpm.add(new JPopupMenu.Separator()); //exactly one selected column, no domain column if (jTable1.getSelectedColumnCount() == 1 && domainColumn == -1) { jpm.add(new AbstractAction("Set as x-values") { @Override public void actionPerformed(ActionEvent ae) { domainColumn = jTable1.getSelectedColumn(); jTable1.getColumnModel().getColumn(domainColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 0, 0, 255), jTable1.getSelectedRows())); jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } //one domainColumn if (domainColumn != -1) { jpm.add(new AbstractAction("Reset x-axis values") { @Override public void actionPerformed(ActionEvent ae) { jTable1.getColumnModel().getColumn(domainColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 255, 255, 255), jTable1.getSelectedRows())); domainColumn = -1; jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } jpm.add(new JPopupMenu.Separator()); if (jTable1.getSelectedColumnCount() == 1 && labelColumn == -1) { jpm.add(new AbstractAction("Set as series labels") { @Override public void actionPerformed(ActionEvent ae) { labelColumn = jTable1.getSelectedColumn(); jTable1.getColumnModel().getColumn(labelColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 255, 0, 255), jTable1.getSelectedRows())); jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } if (jTable1.getSelectedColumnCount() == 1 && labelColumn != -1) { jpm.add(new AbstractAction("Reset series labels") { @Override public void actionPerformed(ActionEvent ae) { jTable1.getColumnModel().getColumn(labelColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 255, 255, 255), jTable1.getSelectedRows())); labelColumn = -1; jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } jpm.show(me.getComponent(), me.getX(), me.getY()); } }
From source file:view.MainWindow.java
private void setupTreePopups() { jtOpenedDocuments.addMouseListener(new MouseAdapter() { @Override//from ww w . j a v a 2s . c o m public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { JPopupMenu popup = new JPopupMenu(); if (null != jtOpenedDocuments.getSelectionRows()) { if (1 >= jtOpenedDocuments.getSelectionRows().length) { int row = jtOpenedDocuments.getClosestRowForLocation(e.getX(), e.getY()); jtOpenedDocuments.setSelectionRow(row); } else { int row = jtOpenedDocuments.getClosestRowForLocation(e.getX(), e.getY()); boolean selected = false; for (int i : jtOpenedDocuments.getSelectionRows()) { if (i == row) { selected = true; break; } } if (!selected) { jtOpenedDocuments.setSelectionRow(row); } } JMenuItem m = null; ActionListener open = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadPdf(getSelectedFile(jtOpenedDocuments), true); } }; ActionListener remove = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeDocument(true); } }; ActionListener removeOthers = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ArrayList<File> alFilesToClose = new ArrayList<>(); boolean showDialog = false; for (File file : getOpenedFiles()) { if (!getSelectedOpenedFiles().contains(file)) { alFilesToClose.add(file); if (file.equals(openedFile)) { showDialog = true; } } } closeDocuments(alFilesToClose, showDialog); } }; ActionListener removeAll = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeDocuments(getOpenedFiles(), true); } }; ActionListener show = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().open(getSelectedFile(jtOpenedDocuments).getParentFile()); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } } }; if (!openedFile.equals(getSelectedFile(jtOpenedDocuments))) { m = new JMenuItem(Bundle.getBundle().getString("menuItem.open")); m.addActionListener(open); popup.add(m); } m = new JMenuItem(getSelectedOpenedFiles().size() > 1 ? Bundle.getBundle().getString("menuItem.removeTheseLoadedDocuments") : Bundle.getBundle().getString("menuItem.removeThisLoadedDocument")); m.addActionListener(remove); popup.add(m); if (getOpenedFiles().size() > 1) { m = new JMenuItem(Bundle.getBundle().getString("menuItem.removeOtherLoadedDocuments")); m.addActionListener(removeOthers); popup.add(m); m = new JMenuItem(Bundle.getBundle().getString("menuItem.removeAllLoadedDocuments")); m.addActionListener(removeAll); popup.add(m); } if (getSelectedOpenedFiles().size() == 1) { m = new JMenuItem(Bundle.getBundle().getString("menuItem.showInExplorer")); m.addActionListener(show); popup.add(m); } popup.show(e.getComponent(), e.getX(), e.getY()); } } } }); jtExplorer.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { JPopupMenu popup = new JPopupMenu(); if (null != jtExplorer.getSelectionRows()) { if (1 >= jtExplorer.getSelectionRows().length) { int row = jtExplorer.getClosestRowForLocation(e.getX(), e.getY()); jtExplorer.setSelectionRow(row); } else { int row = jtExplorer.getClosestRowForLocation(e.getX(), e.getY()); boolean selected = false; for (int i : jtExplorer.getSelectionRows()) { if (i == row) { selected = true; break; } } if (!selected) { jtExplorer.setSelectionRow(row); } } JMenuItem m = null; ActionListener loadFile = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (jtExplorer.getSelectionRows().length == 1) { loadPdf(getSelectedFile(jtExplorer), true); } else { ArrayList<File> sl = getMultipleSelectedFiles(jtExplorer); for (File f : sl) { loadPdf(f, false); } } } }; ActionListener loadFolder = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (jtExplorer.getSelectionRows().length == 1) { File f = getSelectedFile(jtExplorer); loadFolder(f, false); } else { ArrayList<File> sl = getMultipleSelectedFiles(jtExplorer); for (File f : sl) { loadFolder(f, false); } } } }; ActionListener loadFolderRecursively = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (jtExplorer.getSelectionRows().length == 1) { File f = getSelectedFile(jtExplorer); loadFolder(f, true); } else { ArrayList<File> sl = getMultipleSelectedFiles(jtExplorer); for (File s : sl) { loadFolder(s, true); } } } }; ActionListener remove = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<File> listaF = getMultipleSelectedFiles(jtExplorer); closeDocuments(listaF, true); } }; ActionListener show = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop() .open(getSelectedFile(jtExplorer).isFile() ? getSelectedFile(jtExplorer).getParentFile() : getSelectedFile(jtExplorer)); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } } }; if (files.isEmpty()) { if (jtExplorer.getSelectionRows().length <= 1) { File f = getSelectedFile(jtExplorer); if (f.isDirectory()) { m = new JMenuItem( Bundle.getBundle().getString("menuItem.openDocumentsInThisFolder")); m.addActionListener(loadFolder); popup.add(m); m = new JMenuItem(Bundle.getBundle() .getString("menuItem.openDocumentsThisFolderRecursive")); m.addActionListener(loadFolderRecursively); popup.add(m); m = new JMenuItem(Bundle.getBundle().getString("menuItem.showInExplorer")); m.addActionListener(show); popup.add(m); } else { m = new JMenuItem(Bundle.getBundle().getString("menuItem.openDocument")); m.addActionListener(loadFile); popup.add(m); m = new JMenuItem(Bundle.getBundle().getString("menuItem.showInExplorer")); m.addActionListener(show); popup.add(m); } } else { ArrayList<File> l = getMultipleSelectedFiles(jtExplorer); boolean file = l.get(0).isFile(); boolean allSame = true; for (File f : l) { if (file != f.isFile()) { allSame = false; break; } } if (allSame) { if (file) { m = new JMenuItem(Bundle.getBundle().getString("menuItem.openDocuments")); m.addActionListener(loadFile); popup.add(m); } else { m = new JMenuItem(Bundle.getBundle() .getString("menuItem.openDocumentsInTheseFolders")); m.addActionListener(loadFolder); popup.add(m); } } } } else { File f = getSelectedFile(jtExplorer); if (f.isDirectory()) { m = new JMenuItem( Bundle.getBundle().getString("menuItem.openDocumentsInThisFolder")); m.addActionListener(loadFolder); popup.add(m); m = new JMenuItem( Bundle.getBundle().getString("menuItem.openDocumentsThisFolderRecursive")); m.addActionListener(loadFolderRecursively); popup.add(m); } else if (files.contains(getSelectedFile(jtExplorer))) { m = new JMenuItem( Bundle.getBundle().getString("menuItem.removeFromLoadedDocuments")); m.addActionListener(remove); popup.add(m); } else { m = new JMenuItem(Bundle.getBundle().getString("menuItem.addToLoadedDocuments")); m.addActionListener(loadFile); popup.add(m); } } popup.show(e.getComponent(), e.getX(), e.getY()); } } } }); jtExplorer.setCellRenderer(new TooltipTreeCellRenderer()); ToolTipManager.sharedInstance().registerComponent(jtExplorer); FileListTreeCellRenderer renderer1 = new FileListTreeCellRenderer((MainWindow) this); jtOpenedDocuments.setCellRenderer(renderer1); ToolTipManager.sharedInstance().registerComponent(jtOpenedDocuments); }
From source file:base.BasePlayer.Main.java
@Override public void mouseClicked(MouseEvent event) { if (cancelhover && drawCanvas.loading) { cancel();/* www .j a v a 2 s . co m*/ } if (event.getComponent().getName() != null && genomehash.containsKey(event.getComponent().getName())) { changeRef(event.getComponent().getName()); } /*if(event.getSource() == drawScroll.getVerticalScrollBar()) { drawCanvas.drawVariables.visiblestart = (short)(drawScroll.getVerticalScrollBar().getValue()/drawCanvas.sampleHeight); drawCanvas.drawVariables.visibleend = (short)((drawCanvas.drawVariables.visiblestart + drawScroll.getHeight()/drawCanvas.sampleHeight)); drawCanvas.scrollbar = true; Draw.updatevars = true; drawCanvas.repaint(); drawCanvas.scrollbar = false; }*/ if (event.getSource() == searchField) { searchField.setFocusable(true); searchField.requestFocus(); if (event.getClickCount() == 2) { searchField.setText(""); } } else { searchField.setFocusable(false); } if (event.getSource() == back && back.isEnabled()) { undoPointer--; if (undoPointer < 1) { undoPointer = 0; back.setEnabled(false); } forward.setEnabled(true); returnlist = parseSearch(undoList.get(undoPointer)); searchField.setText(undoList.get(undoPointer)); FileRead.search = true; drawCanvas.gotoPos(returnlist[0], Integer.parseInt(returnlist[1]), Integer.parseInt(returnlist[2])); } if (event.getSource() == forward && forward.isEnabled()) { undoPointer++; if (undoPointer >= undoList.size() - 1) { undoPointer = undoList.size() - 1; forward.setEnabled(false); } back.setEnabled(true); returnlist = parseSearch(undoList.get(undoPointer)); FileRead.search = true; searchField.setText(undoList.get(undoPointer)); drawCanvas.gotoPos(returnlist[0], Integer.parseInt(returnlist[1]), Integer.parseInt(returnlist[2])); } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_node.java
@Override public void doPopup(final MouseEvent e, final int row, final Object itemId) { JPopupMenu popup = new JPopupMenu(); final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter(); final List<Node> rowsInTheTable = getVisibleElementsInTable(); /* Add the popup menu option of the filters */ final List<Node> selectedNodes = (List<Node>) (List<?>) getSelectedElements().getFirst(); if (!selectedNodes.isEmpty()) { final JMenu submenuFilters = new JMenu("Filters"); final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem( "This layer: Keep elements associated to this node traffic"); final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem( "All layers: Keep elements associated to this node traffic"); submenuFilters.add(filterKeepElementsAffectedThisLayer); if (callback.getDesign().getNumberOfLayers() > 1) submenuFilters.add(filterKeepElementsAffectedAllLayers); filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() { @Override/*from w w w . j a va 2s . c o m*/ public void actionPerformed(ActionEvent e) { if (selectedNodes.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedNodes.get(0), callback.getDesign().getNetworkLayerDefault(), true); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selectedNodes.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedNodes.get(0), callback.getDesign().getNetworkLayerDefault(), false); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); popup.add(submenuFilters); popup.addSeparator(); } if (callback.getVisualizationState().isNetPlanEditable()) { popup.add(getAddOption()); for (JComponent item : getExtraAddOptions()) popup.add(item); } if (!rowsInTheTable.isEmpty()) { if (callback.getVisualizationState().isNetPlanEditable()) { if (row != -1) { if (popup.getSubElements().length > 0) popup.addSeparator(); JMenuItem removeItem = new JMenuItem("Remove " + networkElementType); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { callback.getDesign().getNodeFromId((long) itemId).remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, getClass()); ErrorHandling.showErrorDialog("Unable to remove " + networkElementType); } } }); popup.add(removeItem); addPopupMenuAttributeOptions(e, row, itemId, popup); } JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in the table"); removeItems.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { if (rf == null) netPlan.removeAllNodes(); else for (Node n : rowsInTheTable) n.remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ex.printStackTrace(); ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to remove all " + networkElementType + "s"); } } }); popup.add(removeItems); 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()); }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java
public void doPopup(final MouseEvent e, final int row, final Object itemId) { JPopupMenu popup = new JPopupMenu(); final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter(); final List<Demand> demandRowsInTheTable = getVisibleElementsInTable(); /* Add the popup menu option of the filters */ final List<Demand> selectedDemands = (List<Demand>) (List<?>) getSelectedElements().getFirst(); if (!selectedDemands.isEmpty()) { final JMenu submenuFilters = new JMenu("Filters"); final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem( "This layer: Keep elements associated to this demand traffic"); final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem( "All layers: Keep elements associated to this demand traffic"); submenuFilters.add(filterKeepElementsAffectedThisLayer); if (callback.getDesign().getNumberOfLayers() > 1) submenuFilters.add(filterKeepElementsAffectedAllLayers); filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() { @Override//from w w w .j a v a2 s. c om public void actionPerformed(ActionEvent e) { if (selectedDemands.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), true); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selectedDemands.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), false); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); popup.add(submenuFilters); popup.addSeparator(); } if (callback.getVisualizationState().isNetPlanEditable()) { popup.add(getAddOption()); for (JComponent item : getExtraAddOptions()) popup.add(item); } if (!demandRowsInTheTable.isEmpty()) { if (callback.getVisualizationState().isNetPlanEditable()) { if (row != -1) { if (popup.getSubElements().length > 0) popup.addSeparator(); JMenuItem removeItem = new JMenuItem("Remove " + networkElementType); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { final Demand demand = netPlan.getDemandFromId((long) itemId); demand.remove(); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, getClass()); ErrorHandling.showErrorDialog("Unable to remove " + networkElementType); } } }); popup.add(removeItem); addPopupMenuAttributeOptions(e, row, itemId, popup); } JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in the table"); removeItems.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { if (rf == null) netPlan.removeAllDemands(); else for (Demand d : demandRowsInTheTable) d.remove(); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ex.printStackTrace(); ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to remove all " + networkElementType + "s"); } } }); popup.add(removeItems); 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()); }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Shows Parent Form's Context Menu./*from w ww. j a va2 s.c o m*/ * @param e the mouse event */ protected void showContextMenu(MouseEvent e) { if (e.isPopupTrigger() && mvParent != null && mvParent.isTopLevel() && isEditing) { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("CONFIG_CARRY_FORWARD_MENU")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { configureCarryForward(); } }); popup.add(menuItem); JCheckBoxMenuItem chkMI = new JCheckBoxMenuItem( UIRegistry.getResourceString("CARRY_FORWARD_CHECKED_MENU")); chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleCarryForward(); } }); chkMI.setSelected(isCarryForwardConfgured() && isDoCarryForward()); chkMI.setEnabled(isCarryForwardConfgured()); popup.add(chkMI); popup.addSeparator(); chkMI = new JCheckBoxMenuItem(UIRegistry.getAction(AUTO_NUM)); /*chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleAutoNumberOnOffState(); } });*/ chkMI.setSelected(isAutoNumberOn); popup.add(chkMI); popup.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_link.java
@Override public void doPopup(final MouseEvent e, final int row, final Object itemId) { JPopupMenu popup = new JPopupMenu(); final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter(); final List<Link> linkRowsInTheTable = getVisibleElementsInTable(); /* Add the popup menu option of the filters */ final List<Link> selectedLinks = (List<Link>) (List<?>) getSelectedElements().getFirst(); if (!selectedLinks.isEmpty()) { final JMenu submenuFilters = new JMenu("Filters"); final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem( "This layer: Keep elements associated to this link traffic"); final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem( "All layers: Keep elements associated to this link traffic"); submenuFilters.add(filterKeepElementsAffectedThisLayer); if (callback.getDesign().getNumberOfLayers() > 1) submenuFilters.add(filterKeepElementsAffectedAllLayers); filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() { @Override/*from w w w.j a va2s . c om*/ public void actionPerformed(ActionEvent e) { if (selectedLinks.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedLinks.get(0), true); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selectedLinks.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedLinks.get(0), false); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); popup.add(submenuFilters); popup.addSeparator(); } if (callback.getVisualizationState().isNetPlanEditable()) { popup.add(getAddOption()); for (JComponent item : getExtraAddOptions()) popup.add(item); } if (!linkRowsInTheTable.isEmpty()) { if (callback.getVisualizationState().isNetPlanEditable()) { if (row != -1) { if (popup.getSubElements().length > 0) popup.addSeparator(); JMenuItem removeItem = new JMenuItem("Remove " + networkElementType); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { Link link = netPlan.getLinkFromId((long) itemId); link.remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, getClass()); ErrorHandling.showErrorDialog("Unable to remove " + networkElementType); } } }); popup.add(removeItem); } addPopupMenuAttributeOptions(e, row, itemId, popup); JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in table"); removeItems.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { if (rf == null) netPlan.removeAllLinks(); else for (Link ee : linkRowsInTheTable) ee.remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ex.printStackTrace(); ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to remove all " + networkElementType + "s"); } } }); popup.add(removeItems); 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()); }