List of usage examples for javax.swing SwingUtilities isRightMouseButton
public static boolean isRightMouseButton(MouseEvent anEvent)
From source file:op.care.prescription.DlgRegular.java
private void tblDosisMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblDosisMousePressed if (!SwingUtilities.isRightMouseButton(evt)) { return;// www .j a v a 2s. c o m } final TMDose tm = (TMDose) tblDosis.getModel(); if (tm.getRowCount() == 0) { return; } Point p = evt.getPoint(); Point p2 = evt.getPoint(); // Convert a coordinate relative to a component's bounds to screen coordinates SwingUtilities.convertPointToScreen(p2, tblDosis); // final Point screenposition = p2; final int row = tblDosis.rowAtPoint(p); ListSelectionModel lsm = tblDosis.getSelectionModel(); lsm.setSelectionInterval(row, row); // Meneintrge SYSTools.unregisterListeners(menu); menu = new JPopupMenu(); //----------------------------------------- JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.msg.delete"), SYSConst.icon22delete); itemPopupDelete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PrescriptionSchedule schedule = prescription.getPrescriptionSchedule().get(row); prescription.getPrescriptionSchedule().remove(schedule); schedules2delete.add(schedule); reloadTable(); } }); menu.add(itemPopupDelete); 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();/* ww w .j a va2s.co 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:org.alex73.skarynka.scan.ui.book.BooksController.java
public BooksController() { try {// ww w. j a v a 2 s. c om panel = new BooksPanel(); ((AbstractDocument) panel.txtNewName.getDocument()).setDocumentFilter(bookNameFilter); listScanDirs(); panel.table.setModel(model()); panel.table.setRowSelectionAllowed(true); panel.table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { BookRow b = books.get(panel.table.getSelectedRow()); DataStorage.openBook(b.bookName, true); } } @Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { for (int i = 0; i < panel.menuProcess.getComponentCount(); i++) { Component item = panel.menuProcess.getComponent(i); if ((item instanceof JMenuItem) && (item.getName() != null)) { panel.menuProcess.remove(i); i--; } } if (Context.getPermissions().BookControl) { for (int scale : new int[] { 25, 50, 75, 100, 200 }) { JMenuItem item = new JMenuItem(scale + "%"); item.setName(scale + "%"); item.addActionListener(new ChangeScale(scale)); panel.menuProcess.add(item); } } currentBooksNames.clear(); int[] selected = panel.table.getSelectedRows(); boolean allLocals = true; boolean processAllowed = Context.getPermissions().BookControl; for (int row : selected) { BookRow b = books.get(panel.table.convertRowIndexToModel(row)); currentBooksNames.add(b.bookName); if (!b.local) { allLocals = false; } } panel.itemFinish.setVisible(allLocals); if (processAllowed) { for (Map.Entry<String, String> en : Context.getProcessCommands().entrySet()) { JMenuItem item = new JMenuItem(en.getValue()); item.setName(en.getKey()); item.addActionListener(commandListener); panel.menuProcess.add(item); } } panel.menuProcess.show(panel.table, e.getX(), e.getY()); } } }); panel.btnCreate.setEnabled(false); panel.btnCreate.addActionListener( new ActionErrorListener(panel, "ERROR_BOOK_CREATE", LOG, "Error create book") { protected void action(ActionEvent e) throws Exception { File bookDir = new File(Context.getBookDir(), panel.txtNewName.getText()); if (bookDir.exists()) { JOptionPane.showMessageDialog(panel, Messages.getString("PANEL_BOOK_NEW_BOOK_EXIST"), Messages.getString("PANEL_BOOK_TITLE"), JOptionPane.WARNING_MESSAGE); return; } DataStorage.openBook(panel.txtNewName.getText(), true); } }); setMenuListeners(); } catch (Throwable ex) { LOG.error("Error list books", ex); JOptionPane.showMessageDialog(DataStorage.mainFrame, "Error: " + ex.getClass() + " / " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:org.domainmath.gui.FileTreePanel.java
/** * Add popup menu./* w w w .ja v a2 s .c om*/ */ private void addPopupMenuToFileTree() { refreshItem = new JMenuItem(bundle.getString("fileTreeRefreshItem.text")); fileTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { addGlobalAction(e); if (SwingUtilities.isRightMouseButton(e)) { TreePath path = fileTree.getPathForLocation(e.getX(), e.getY()); Rectangle pathBounds = fileTree.getUI().getPathBounds(fileTree, path); if (pathBounds != null && pathBounds.contains(e.getX(), e.getY())) { JPopupMenu menu = new JPopupMenu(); File file = (File) fileTree.getLastSelectedPathComponent(); openItem = new JMenuItem(bundle.getString("fileTreeOpenItem.text")); runScriptItem = new JMenuItem(bundle.getString("fileTreeRunItem.text")); openOutsideItem = new JMenuItem(bundle.getString("fileTreeOpenOutsideItem.text")); renameItem = new JMenuItem(bundle.getString("fileTreeRenameItem.text")); deleteItem = new JMenuItem(bundle.getString("fileTreeDeleteItem.text")); openItem.setAccelerator(keyOpenItem); renameItem.setAccelerator(keyRenameItem); deleteItem.setAccelerator(keyDeleteItem); refreshItem.setAccelerator(keyRefreshItem); menu.add(openItem); menu.add(runScriptItem); menu.add(openOutsideItem); menu.addSeparator(); menu.add(renameItem); menu.add(deleteItem); menu.addSeparator(); menu.add(refreshItem); fileTreeOpenItemActionPerformed(file); fileTreeRunItemActionPerformed(file); fileTreeOpenOutsideItemActionPerformed(file); fileTreeRenameItemActionPerformed(fileTree.getSelectionPath()); fileTreeDeleteItemActionPerformed(fileTree.getSelectionModel().getSelectionPaths()); fileTreeRefreshItemActionPerformed((File) fileTree.getModel().getRoot()); if (file.isDirectory()) { runScriptItem.setEnabled(false); } else { String name = file.getName(); if (!name.endsWith(".m")) { runScriptItem.setEnabled(false); } } menu.show(fileTree, e.getX(), e.getY()); } if (pathBounds == null) { JPopupMenu menu = new JPopupMenu(); newFolderItem = new JMenuItem(bundle.getString("fileTreeNewFolderItem.text")); File file = (File) fileTree.getModel().getRoot(); menu.add(newFolderItem); menu.add(refreshItem); fileTreeNewFolderItemActionPerformed(file); fileTreeRefreshItemActionPerformed(file); menu.show(fileTree, e.getX(), e.getY()); } } } }); }
From source file:org.fhaes.gui.AnalysisResultsPanel.java
/** * Set up the AnalysisResults GUI//from w w w .j a v a 2s. c o m */ private void initGUI() { setLayout(new BorderLayout(0, 0)); if (Platform.isOSX()) setBackground(MainWindow.MAC_BACKGROUND_COLOR); ImageIcon iconMultipleTables = Builder.getImageIcon("multipletables16.png"); ImageIcon iconTable = Builder.getImageIcon("table16.png"); // ImageIcon iconChart = Builder.getImageIcon("chart16.png"); // Categories rootNode = new FHAESCategoryTreeNode("FHAES analysis results"); categoryGeneral = new FHAESCategoryTreeNode("Descriptive summaries", Builder.getImageIcon("interval16.png")); categoryInterval = new FHAESCategoryTreeNode("Interval analysis", Builder.getImageIcon("interval16.png")); categorySeasonality = new FHAESCategoryTreeNode("Seasonality", Builder.getImageIcon("seasonality16.png")); categoryBinarySummaryMatrices = new FHAESCategoryTreeNode("Binary summary matrices", Builder.getImageIcon("matrix16.png")); categoryBinaryMatrices = new FHAESCategoryTreeNode("Binary comparison matrices", Builder.getImageIcon("matrix16.png")); categorySimMatrices = new FHAESCategoryTreeNode("Similarity matrices", Builder.getImageIcon("matrix16.png")); categoryDisSimMatrices = new FHAESCategoryTreeNode("Dissimilarity matrices", Builder.getImageIcon("matrix16.png")); // Menu actions // Results itemJaccard = new FHAESResultTreeNode(FHAESResult.JACCARD_SIMILARITY_MATRIX, iconMultipleTables); itemJaccard.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(SJACFile, new CSVFileFilter()); } }); itemCohen = new FHAESResultTreeNode(FHAESResult.COHEN_SIMILARITITY_MATRIX, iconMultipleTables); itemCohen.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(SCOHFile, new CSVFileFilter()); } }); itemJaccardD = new FHAESResultTreeNode(FHAESResult.JACCARD_SIMILARITY_MATRIX_D, iconMultipleTables); itemJaccardD.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(DSJACFile, new CSVFileFilter()); } }); itemCohenD = new FHAESResultTreeNode(FHAESResult.COHEN_SIMILARITITY_MATRIX_D, iconMultipleTables); itemCohenD.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(DSCOHFile, new CSVFileFilter()); } }); itemIntervalSummary = new FHAESResultTreeNode(FHAESResult.INTERVAL_SUMMARY, iconMultipleTables); itemIntervalSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(intervalsSummaryFile, new CSVFileFilter()); } }); itemExceedence = new FHAESResultTreeNode(FHAESResult.INTERVAL_EXCEEDENCE_TABLE, iconMultipleTables); itemExceedence.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(intervalsExceedenceFile, new CSVFileFilter()); } }); itemSeasonalitySummary = new FHAESResultTreeNode(FHAESResult.SEASONALITY_SUMMARY, iconMultipleTables); itemSeasonalitySummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(seasonalitySummaryFile, new CSVFileFilter()); } }); itemBin00 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_00, iconMultipleTables); itemBin00.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin00File, new CSVFileFilter()); } }); itemBin01 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_01, iconMultipleTables); itemBin01.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin01File, new CSVFileFilter()); } }); itemBin10 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_10, iconMultipleTables); itemBin10.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin10File, new CSVFileFilter()); } }); itemBin11 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_11, iconMultipleTables); itemBin11.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin11File, new CSVFileFilter()); } }); itemBinSum = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_SUM, iconMultipleTables); itemBinSum.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(binSumFile, new CSVFileFilter()); } }); itemBinSiteSummary = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_SITE, iconMultipleTables); itemBinSiteSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(siteSummaryFile, new CSVFileFilter()); } }); itemBinSiteSummary.addAction(new FHAESAction("Export to shapefile", "formatshp.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { new ShapeFileDialog(App.mainFrame, fhm); } }); itemBinTreeSummary = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_TREE, iconMultipleTables); itemBinTreeSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(treeSummaryFile, new CSVFileFilter()); } }); itemNTP = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_NTP, iconMultipleTables); itemNTP.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(NTPFile, new CSVFileFilter()); } }); this.itemGeneralSummary = new FHAESResultTreeNode(FHAESResult.GENERAL_SUMMARY, iconMultipleTables); itemGeneralSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(generalSummaryFile, new CSVFileFilter()); } }); this.itemSingleFileSummary = new FHAESResultTreeNode(FHAESResult.SINGLE_FILE_SUMMARY, iconTable); itemSingleFileSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(singleFileSummaryFile, new CSVFileFilter()); } }); this.itemSingleEventSummary = new FHAESResultTreeNode(FHAESResult.SINGLE_EVENT_SUMMARY, iconTable); itemSingleEventSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(singleEventSummaryFile, new CSVFileFilter()); } }); // Add results to categories categoryGeneral.add(itemGeneralSummary); categoryGeneral.add(itemSingleFileSummary); categoryGeneral.add(itemSingleEventSummary); categorySimMatrices.add(itemJaccard); categorySimMatrices.add(itemCohen); categoryDisSimMatrices.add(itemJaccardD); categoryDisSimMatrices.add(itemCohenD); categoryInterval.add(itemIntervalSummary); categoryInterval.add(itemExceedence); categorySeasonality.add(itemSeasonalitySummary); categoryBinaryMatrices.add(itemBin11); categoryBinaryMatrices.add(itemBin01); categoryBinaryMatrices.add(itemBin10); categoryBinaryMatrices.add(itemBin00); categoryBinaryMatrices.add(itemBinSum); categoryBinarySummaryMatrices.add(itemBinSiteSummary); categoryBinarySummaryMatrices.add(itemBinTreeSummary); categoryBinarySummaryMatrices.add(itemNTP); // Add categories to root of tree rootNode.add(categoryGeneral); rootNode.add(categoryInterval); rootNode.add(categorySeasonality); rootNode.add(categoryBinarySummaryMatrices); rootNode.add(categoryBinaryMatrices); rootNode.add(categorySimMatrices); rootNode.add(categoryDisSimMatrices); treeModel = new DefaultTreeModel(rootNode); splitPane = new JSplitPane(); if (Platform.isOSX()) splitPane.setBackground(MainWindow.MAC_BACKGROUND_COLOR); splitPane.setResizeWeight(0.9); add(splitPane, BorderLayout.CENTER); JPanel panelTree = new JPanel(); splitPane.setRightComponent(panelTree); panelTree.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panelTree.setLayout(new BorderLayout(0, 0)); // Build tree treeResults = new JTree(); panelTree.add(treeResults); treeResults.setModel(treeModel); treeResults.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); treeResults.setCellRenderer(new FHAESResultTreeRenderer()); pickResultPanel = new PickResultPanel(); runAnalysisPanel = new RunAnalysisPanel(); cards = new JPanel(); cl = new CardLayout(); cards.setLayout(cl); cards.add(pickResultPanel, PICKRESULTPANEL); cards.add(runAnalysisPanel, RUNANALYSIS); cards.add(emptyPanel, EMPTYPANEL); splitPane.setLeftComponent(cards); cl.show(cards, RUNANALYSIS); splitPaneResult = new JSplitPane(); splitPaneResult.setOneTouchExpandable(true); splitPaneResult.setOrientation(JSplitPane.VERTICAL_SPLIT); cards.add(splitPaneResult, RESULTSPANEL); panelResult = new JPanel(); panelResult.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelResult.setLayout(new BorderLayout(0, 0)); goldFishPanel = new GoldFishPanel(); splitPaneResult.setRightComponent(goldFishPanel); // Build table scrollPane = new JScrollPane(); panelResult.add(scrollPane); table = new JXTable(); adapter = new JTableSpreadsheetByRowAdapter(table); table.setModel(new DefaultTableModel()); table.setHorizontalScrollEnabled(true); scrollPane.setViewportView(table); splitPaneResult.setLeftComponent(panelResult); // OSX Style hack if (Platform.isOSX()) panelResult.setBackground(MainWindow.MAC_BACKGROUND_COLOR); if (Platform.isOSX()) scrollPane.setBackground(MainWindow.MAC_BACKGROUND_COLOR); // Expand all nodes for (int i = 0; i < treeResults.getRowCount(); i++) { treeResults.expandRow(i); } treeResults.addTreeSelectionListener(this); treeResults.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { int x = e.getX(); int y = e.getY(); JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(x, y); if (path == null) return; if (!tree.isEnabled()) return; tree.setSelectionPath(path); Component mc = e.getComponent(); if (path != null && path.getLastPathComponent() instanceof FHAESResultTreeNode) { FHAESResultTreeNode node = (FHAESResultTreeNode) path.getLastPathComponent(); if (!node.isEnabled()) return; FHAESResultPopupMenu popupMenu = new FHAESResultPopupMenu(node.getArrayOfActions()); popupMenu.show(mc, e.getX(), e.getY()); } } } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mousePressed(MouseEvent arg0) { } @Override public void mouseReleased(MouseEvent arg0) { } }); this.splitPaneResult.setDividerLocation(10000); this.splitPaneResult.setDividerSize(3); this.splitPaneResult.setResizeWeight(1); }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
public void mousePressed(MouseEvent event) { if (event.getSource() instanceof JLabel) { } else {//from ww w . j av a 2 s . co m if (SwingUtilities.isRightMouseButton(event)) { String columnName = table.getColumnModel().getColumn(table.columnAtPoint(event.getPoint())) .getHeaderValue().toString(); SwingUtilities.convertPointFromScreen(event.getPoint(), table); spreadsheetPopups.popupMenu(table, event.getX() + 10, event.getY() + 10, columnName); } if (SwingUtilities.isLeftMouseButton(event)) { startRow = table.rowAtPoint(event.getPoint()); startCol = table.columnAtPoint(event.getPoint()); } } }
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
private void createMouseListener() { graphComponent.getGraphControl().addMouseListener(new MouseAdapter() { @Override//from w w w . j a v a2 s .c o m public void mousePressed(MouseEvent e) { if (isPopupShown) { isPopupShown = false; mxCell cell = (mxCell) graphComponent.getGraph().getSelectionModel().getCell(); getGraphModel().remove(cell); return; } if (SwingUtilities.isRightMouseButton(e)) { xPos = e.getX(); yPos = e.getY(); Object obj = graphComponent.getCellAt(e.getX(), e.getY()); if (obj instanceof mxCell) { mxCell cell = (mxCell) obj; if (cell.getStyle() != null && cell.getStyle().indexOf(ENTITYSTYLE) >= 0 && cell.getValue() instanceof EntityMetaDataVO) { JPopupMenu pop = createPopupMenuEntity(cell, false); pop.show(e.getComponent(), e.getX(), e.getY()); } else if (cell.getStyle() != null && cell.getStyle().indexOf(ENTITYSTYLE) >= 0) { JPopupMenu pop = createPopupMenuEntity(cell, true); pop.show(e.getComponent(), e.getX(), e.getY()); } else { if (cell.getStyle() != null && cell.getStyle().indexOf("oval") >= 0) { JPopupMenu pop = createRelationPopupMenu(cell, true, true); pop.show(e.getComponent(), e.getX(), e.getY()); } else { JPopupMenu pop = createRelationPopupMenu(cell, true, false); pop.show(e.getComponent(), e.getX(), e.getY()); } } } else { JPopupMenu pop = createPopupMenu(); pop.show(e.getComponent(), e.getX(), e.getY()); } } else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { mxCell cell = (mxCell) graphComponent.getGraph().getSelectionModel().getCell(); if (cell == null) return; if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) { EntityMetaDataVO voMeta = (EntityMetaDataVO) cell.getValue(); EntityMetaDataVO vo = MetaDataClientProvider.getInstance().getEntity(voMeta.getEntity()); new ShowNuclosWizard.NuclosWizardEditRunnable(false, mf.getHomePane(), vo).run(); } else if (cell.getValue() != null && cell.getValue() instanceof EntityFieldMetaDataVO) { if (cell.getStyle() != null && cell.getStyle().indexOf(OPENARROW) >= 0) editMasterdataRelation(cell); else if (cell.getStyle() != null && cell.getStyle().indexOf(DIAMONDARROW) >= 0) { editSubformRelation(cell); } } else if (cell.getValue() != null) { if (cell.getStyle() != null && cell.getStyle().indexOf(OVALARROW) >= 0) { try { mxCell cellSource = (mxCell) cell.getSource(); mxCell cellTarget = (mxCell) cell.getTarget(); EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue(); EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue(); String sSourceModule = sourceModule.getEntity(); String sTargetModule = targetModule.getEntity(); boolean blnFound = false; for (MasterDataVO voGeneration : MasterDataCache.getInstance() .get(NuclosEntity.GENERATION.getEntityName())) { String sSource = (String) voGeneration.getField("sourceModule"); String sTarget = (String) voGeneration.getField("targetModule"); if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule) && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); gcc.runViewSingleCollectableWithId(voGeneration.getId()); blnFound = true; break; } } if (!blnFound) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); Map<String, Object> mp = new HashMap<String, Object>(); mp.put("sourceModule", sSourceModule); mp.put("sourceModuleId", new Integer(MetaDataClientProvider.getInstance() .getEntity(sSourceModule).getId().intValue())); mp.put("targetModule", sTargetModule); mp.put("targetModuleId", new Integer(MetaDataClientProvider.getInstance() .getEntity(sTargetModule).getId().intValue())); MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(), null, null, null, null, null, null, mp); gcc.runWithNewCollectableWithSomeFields(vo); } } catch (NuclosBusinessException e1) { LOG.warn("mousePressed failed: " + e1, e1); } catch (CommonPermissionException e1) { LOG.warn("mousePressed failed: " + e1, e1); } catch (CommonFatalException e1) { LOG.warn("mousePressed failed: " + e1, e1); } catch (CommonBusinessException e1) { LOG.warn("mousePressed failed: " + e1, e1); } } } } } }); }
From source file:org.nuclos.client.ui.collect.SubForm.java
/** * @Deprecated Never use this directly, instead use {@link #addToolbarMenuItems(List)}. *//*ww w .ja va 2s.c o m*/ private MouseListener newToolbarContextMenuListener(final JComponent parent, final JTable table) { MouseListener res = new MouseAdapter() { @Override public void mouseClicked(MouseEvent mev) { if (SwingUtilities.isRightMouseButton(mev)) { List<JComponent> items = new ArrayList<JComponent>(); addToolbarMenuItems(items); if (items.isEmpty()) return; JPopupMenu popup = new JPopupMenu(); for (JComponent c : items) popup.add(c); popup.show(parent, mev.getX(), mev.getY()); } if (SwingUtilities.isLeftMouseButton(mev) && mev.getClickCount() == 2) { int row = table.rowAtPoint(mev.getPoint()); int column = table.columnAtPoint(mev.getPoint()); LOG.info(StringUtils.concat("Doubleclick on subform: column=", column, ",row=", row)); if (row == -1 || column == -1) { if (toolbarMenuItems.get(ToolbarFunction.NEW.name()).isEnabled()) { actionPerformed(ToolbarFunction.NEW.name()); } } } } }; return res; }
From source file:org.openehealth.coms.cc.consent_applet.applet.ConsentApplet.java
/** * MouseListener used to select items from the list of Rule descriptions, allows for deletion of Rules * //from w ww .j a v a2 s. c o m * @return */ private MouseListener getRuleListMouseAdapter() { return new MouseListener() { private JList list; public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { list = ((JList) e.getSource()); list.setSelectedIndex(getRow(e.getPoint())); JPopupMenu menu = new JPopupMenu(); menu.add(new RemoveRule(list)); Point pt = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), list); menu.show(list, pt.x, pt.y); } } private int getRow(Point point) { return list.locationToIndex(point); } public void mouseClicked(MouseEvent arg0) { } public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { } public void mouseReleased(MouseEvent arg0) { } }; }
From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java
/** * Helper method to create the trees hosting the display. * //from w ww . j a va2 s . c o m * @param exp The logged in experimenter. */ private void createTrees(ExperimenterData exp) { treeDisplay = new DnDTree(model.getUserID(), TreeViewerAgent.isAdministrator()); treeDisplay.addPropertyChangeListener(this); String key = "meta pressed A"; if (UIUtilities.isWindowsOS()) key = "ctrl pressed A"; KeyStroke ks = KeyStroke.getKeyStroke(key); treeDisplay.getInputMap().put(ks, "none"); treeDisplay.setVisible(true); treeDisplay.setRootVisible(false); ToolTipManager.sharedInstance().registerComponent(treeDisplay); treeDisplay.setCellRenderer(new TreeCellRenderer(model.getUserID())); treeDisplay.setShowsRootHandles(true); TreeImageSet root = new TreeImageSet(""); treeDisplay.setModel(new DefaultTreeModel(root)); if (model.getBrowserType() != Browser.ADMIN_EXPLORER) { TreeImageDisplay node = buildTreeNodes(exp); if (node != null) treeDisplay.collapsePath(new TreePath(node.getPath())); } //Add Listeners //treeDisplay.requestFocus(); treeDisplay.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { mousePressedTime = e.getWhen(); rightClickPad = UIUtilities.isMacOS() && SwingUtilities.isLeftMouseButton(e) && e.isControlDown(); rightClickButton = SwingUtilities.isRightMouseButton(e); ctrl = e.isControlDown(); if (UIUtilities.isMacOS()) ctrl = e.isMetaDown(); leftMouseButton = SwingUtilities.isLeftMouseButton(e); if (UIUtilities.isMacOS() || UIUtilities.isLinuxOS()) onClick(e, false); } public void mouseReleased(MouseEvent e) { leftMouseButton = SwingUtilities.isLeftMouseButton(e); if (UIUtilities.isWindowsOS()) onClick(e, true); } // public void mouseMoved(MouseEvent e) { rollOver(e); } }); treeDisplay.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent e) { rollOver(e); } }); treeDisplay.addTreeExpansionListener(listener); selectionListener = new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { event = e; eventHandledTime = System.currentTimeMillis(); if (delayedHandlingTreeSelection) /* mouse click delayed handling until this event occurred */ handleTreeSelection(); switch (keyEvent) { case KeyEvent.VK_DOWN: case KeyEvent.VK_UP: TreePath[] paths = treeDisplay.getSelectionPaths(); if (paths != null) controller.onClick(Arrays.asList(paths)); else controller.onClick(new ArrayList<TreePath>()); break; } } }; treeDisplay.addTreeSelectionListener(selectionListener); //remove standard behaviour treeDisplay.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { ctrl = false; switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: ViewCmd cmd = new ViewCmd(model.getParentModel(), true); cmd.execute(); break; case KeyEvent.VK_DELETE: switch (model.getState()) { case Browser.LOADING_DATA: case Browser.LOADING_LEAVES: //case Browser.COUNTING_ITEMS: break; default: model.delete(); } break; case KeyEvent.VK_CONTROL: if (!UIUtilities.isMacOS()) ctrl = true; break; case KeyEvent.VK_META: if (UIUtilities.isMacOS()) ctrl = true; break; case KeyEvent.VK_A: if (UIUtilities.isWindowsOS() && e.isControlDown() || !UIUtilities.isWindowsOS() && e.isMetaDown()) { handleMultiSelection(); } break; case KeyEvent.VK_DOWN: case KeyEvent.VK_UP: case KeyEvent.VK_RIGHT: keyEvent = e.getKeyCode(); break; case KeyEvent.VK_LEFT: TreePath[] paths = treeDisplay.getSelectionPaths(); TreeImageDisplay node; Object o; for (int i = 0; i < paths.length; i++) { o = paths[i].getLastPathComponent(); if (o instanceof TreeImageDisplay) { node = (TreeImageDisplay) o; if (node.isExpanded()) node.setExpanded(false); } } } } public void keyReleased(KeyEvent e) { ctrl = false; keyEvent = -1; } }); }