List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionTablesGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;/*from www . ja v a2s . co m*/ } JPopupMenu popupMenu = new JPopupMenu(); NamePatternAction patternAction = new NamePatternAction(NamePatternAction.TABLE_NAME_PATTERN); JMenuItem menuItem = new JMenuItem(patternAction); popupMenu.add(menuItem); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionViewsGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;/*from w ww. j a v a2 s. c o m*/ } JPopupMenu popupMenu = new JPopupMenu(); NamePatternAction patternAction = new NamePatternAction(NamePatternAction.VIEW_NAME_PATTERN); JMenuItem menuItem = new JMenuItem(patternAction); popupMenu.add(menuItem); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.QueryAuthoringTreePanel.java
/** * Creates the tree interface.//w w w . j av a 2 s .co m */ private void createTreeInterface() { reportingQueryTreeModel = new ReportingQueryStatementTreeModel(activeQuery); queryInterfaceTree = new JXTree(reportingQueryTreeModel); // queryInterfaceTree.setCellRenderer(new ReportingQueryStatementTreeCellRenderer(humanReadableRender)); queryInterfaceTree.setCellRenderer(new StyledQueryStatementTreeCellRenderer(humanReadableRender)); queryInterfaceTree.addHighlighter(HighlighterFactory.createAlternateStriping()); // add listener for mouse events queryInterfaceTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { evaluatePopupAction(e); } @Override public void mouseReleased(MouseEvent e) { evaluatePopupAction(e); } private void evaluatePopupAction(MouseEvent e) { // get node selected int row = queryInterfaceTree.getRowForLocation(e.getX(), e.getY()); if (row > -1) { TreePath selectedPath = queryInterfaceTree.getPathForLocation(e.getX(), e.getY()); Object node = selectedPath.getLastPathComponent(); if (node != null && node instanceof QueryExpression) { QueryExpression expression = (QueryExpression) node; // set selected expression selectedExpression = expression; // check if right click if (expression instanceof QueryIntersectionExpression || expression instanceof QueryUnionExpression || expression instanceof QueryStatement) { if (e.isPopupTrigger()) { queryActionsMenu.show(e.getComponent(), e.getX(), e.getY()); } } else if (expression instanceof QueryComponentExpression) { if (e.getClickCount() == 2) { QueryComponentExpression componentExpression = (QueryComponentExpression) expression; // get selected sub query and display it in a dialog queryComponentExpressionPanel.setComponentExpression(componentExpression); // queryComponentExpressionDialog.setTitle("Author Component Query"); queryComponentExpressionDialog.setVisible(true); } else if (e.isPopupTrigger()) { toggleStatusMenu.show(e.getComponent(), e.getX(), e.getY()); } } } } else { if (queryActionsMenu.isVisible()) { queryActionsMenu.setVisible(false); } if (toggleStatusMenu.isVisible()) { toggleStatusMenu.setVisible(false); } } } }); }
From source file:gtu._work.ui.DirectoryCompareUI.java
private void dirCompareTableMouseClicked(MouseEvent evt) { try {/*from ww w . j av a2s . c o m*/ final JTableUtil util = JTableUtil.newInstance(dirCompareTable); InfoObj obj = getInfoObj(util.getSelectedRow(), util); if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) { File mainFile = obj.mainFile.getFile().exists() ? obj.mainFile.getFile() : NOT_EXIST_FILE; File compareFile = obj.compareToFile.getFile().exists() ? obj.compareToFile.getFile() : NOT_EXIST_FILE; File fileA = mainFile; File fileB = compareFile; if (mergeSwap) { File tempFile = fileA; fileA = fileB; fileB = tempFile; } DiffMergeCommand diffCommand = (DiffMergeCommand) diffToolComboBox.getSelectedItem(); String command = diffCommand.getCommand(this, fileA, fileB); System.out.println(command); ProcessWatcher.newInstance(Runtime.getRuntime().exec(command)).getStreamSync(); } if (evt.getClickCount() == 1 && evt.getButton() == MouseEvent.BUTTON3) { final File mainFile = obj.mainFile.getFile(); final File compareToFile = obj.compareToFile.getFile(); JPopupMenuUtil.newInstance(dirCompareTable).applyEvent(evt)// .addJMenuItem("", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCommonUtil._jOptionPane_showMessageDialog_info(// ": " + (mainFile.exists() ? mainFile.getAbsolutePath() : "?") + // "\n?: " + (compareToFile.exists() ? compareToFile.getAbsolutePath() : "?"), // mainFile.getName()); } })// .addJMenuItem("merge??:" + (!mergeSwap ? "(?)" : "(?)"), new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mergeSwap = !mergeSwap; } })// .addJMenuItem(" [open file]", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(mainFile); } })// .addJMenuItem(" [open dir]", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(mainFile.getParentFile()); } })// .addJMenuItem("? [open file]", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(compareToFile); } })// .addJMenuItem("? [open dir]", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(compareToFile.getParentFile()); } })// .addJMenuItem(" -> ? ()", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = util.getSelectedRows(); if (rows != null && rows.length >= 1) { if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "?" + rows.length + ", ?!", "")) { List<File> fileList = new ArrayList<File>(); for (int ii = 0; ii < rows.length; ii++) { InfoObj obj = getInfoObj(rows[ii], util); File mainFile = obj.mainFile.getFile(); File compareToFile = obj.compareToFile.getFile(); overwriteFile(mainFile, compareToFile, fileList); } StringBuilder sb = new StringBuilder(); for (File f : fileList) { sb.append(f + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info(sb, "?"); } } else { overwriteFile(mainFile, compareToFile, null); } } })// .addJMenuItem("? -> ()", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = util.getSelectedRows(); if (rows != null && rows.length >= 1) { if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "?" + rows.length + ", ?!", "")) { List<File> fileList = new ArrayList<File>(); for (int ii = 0; ii < rows.length; ii++) { InfoObj obj = getInfoObj(rows[ii], util); File mainFile = obj.mainFile.getFile(); File compareToFile = obj.compareToFile.getFile(); overwriteFile(compareToFile, mainFile, fileList); } StringBuilder sb = new StringBuilder(); for (File f : fileList) { sb.append(f + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info(sb, "?"); } } else { overwriteFile(compareToFile, mainFile, null); } } })// .addJMenuItem("(?)", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pourOutFilesByOrignPath(true); } })// .addJMenuItem("?(?)", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pourOutFilesByOrignPath(false); } }).show(); } } catch (Exception e) { JCommonUtil.handleException(e, false); } }
From source file:org.archiviststoolkit.mydomain.DomainTableWorkSurface.java
/** * Deals with a double click and therefore edit event on the table. * * @param e the mouse event// w w w . j a v a 2s. com */ public final void mouseClicked(final MouseEvent e) { if (debug) { System.out.println("click from:" + this); } if (e.getClickCount() == 2) { onUpdate(); } }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionProcedureGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;/*from w ww . j a v a2s. c om*/ } ValidateProceduresAction validateAction = new ValidateProceduresAction(); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(validateAction); popupMenu.add(menuItem); NamePatternAction patternAction = new NamePatternAction(NamePatternAction.PROCEDURE_NAME_PATTERN); JMenuItem menuItem2 = new JMenuItem(patternAction); popupMenu.add(menuItem2); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionQueryGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;//w ww .j a v a 2 s . c o m } ImportQueryAction importAction = new ImportQueryAction(); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(importAction); popupMenu.add(menuItem); JMenuItem menuItem2 = new JMenuItem(new AddFolderAction(this, selectedNode, DBObject.FOLDER_QUERY)); popupMenu.add(menuItem2); JMenuItem menuItem3 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject())); popupMenu.add(menuItem3); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionReportGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;/*from ww w .ja va2s .co m*/ } ImportReportAction importAction = new ImportReportAction(); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(importAction); popupMenu.add(menuItem); JMenuItem menuItem2 = new JMenuItem(new AddFolderAction(this, selectedNode, DBObject.FOLDER_REPORT)); popupMenu.add(menuItem2); JMenuItem menuItem3 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject())); popupMenu.add(menuItem3); JMenuItem menuItem4 = new JMenuItem(new PublishBulkReportAction()); popupMenu.add(menuItem4); JMenuItem menuItem5 = new JMenuItem( new DownloadBulkReportAction(FileReportPersistence.getReportsAbsolutePath())); popupMenu.add(menuItem5); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionChartGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;/*from w ww. j a v a 2 s . c o m*/ } JPopupMenu popupMenu = new JPopupMenu(); ImportChartAction importAction = new ImportChartAction(); JMenuItem menuItem = new JMenuItem(importAction); popupMenu.add(menuItem); JMenuItem menuItem2 = new JMenuItem(new AddFolderAction(this, selectedNode, DBObject.FOLDER_CHART)); popupMenu.add(menuItem2); JMenuItem menuItem3 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject())); popupMenu.add(menuItem3); JMenuItem menuItem4 = new JMenuItem(new PublishBulkChartAction()); popupMenu.add(menuItem4); JMenuItem menuItem5 = new JMenuItem( new DownloadBulkChartAction(FileReportPersistence.getChartsAbsolutePath())); popupMenu.add(menuItem5); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:cz.muni.fi.pv168.MainForm.java
public MainForm() { initComponents();//from ww w .jav a2 s. co m carManager.setDataSource(dataSource); customerManager.setDataSource(dataSource); rentManager.setDataSource(dataSource); FileOutputStream fs = null; try { fs = new FileOutputStream("main.log", true); } catch (FileNotFoundException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } carManager.setLogger(fs); customerManager.setLogger(fs); rentManager.setLogger(fs); final SortFilterModel sorter = new SortFilterModel(rentTable.getModel()); rentTable.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { // check for double click if (event.getClickCount() < 2) { return; } // find column of click and int tableColumn = rentTable.columnAtPoint(event.getPoint()); // translate to table model index and sort int modelColumn = rentTable.convertColumnIndexToModel(tableColumn); sorter.sort(modelColumn); } }); jTabbedPane1.setTitleAt(0, localization.getString("cars")); jTabbedPane1.setTitleAt(1, localization.getString("customers")); jTabbedPane1.setTitleAt(2, localization.getString("rents")); carTable.setModel(new CarsTableModel(localization)); customerTable.setModel(new CustomersTableModel(localization)); rentTable.setModel(new RentsTableModel(localization)); jMenu1.setText(localization.getString("file")); jMenu2.setText(localization.getString("data")); jMenu3.setText(localization.getString("new")); jMenu4.setText(localization.getString("help")); jMenuItem1.setText(localization.getString("db_connect")); jMenuItem2.setText(localization.getString("db_disconnect")); jMenuItem9.setText(localization.getString("help")); jMenuItem10.setText(localization.getString("credits")); jMenuItem3.setAction(new ExitAction(localization.getString("exit"))); jMenuItem7.setAction(new AddRentAction(localization.getString("rent"))); jMenuItem8.setAction(new AddCarAction(localization.getString("car"))); jMenuItem11.setAction(new CommitAction(localization.getString("commit"))); jMenuItem18.setAction(new AddCustomerAction(localization.getString("customer"))); jButton1.setAction(new CommitAction(localization.getString("commit"))); jButton2.setAction(new AddCarAction(localization.getString("new_car"))); jButton3.setAction(new AddCustomerAction(localization.getString("new_customer"))); jButton4.setAction(new AddRentAction(localization.getString("new_rent"))); jMenuItem5.setText(localization.getString("find")); jButton9.setText(localization.getString("search")); jMenu6.setText(localization.getString("remove")); jMenuItem19.setText(localization.getString("car")); jMenuItem20.setText(localization.getString("customer")); jMenuItem21.setText(localization.getString("rent")); jMenuItem23.setAction(new CopyAction(localization.getString("copy"))); jMenuItem24.setAction(new CutAction(localization.getString("cut"))); jMenuItem25.setAction(new PasteAction(localization.getString("paste"))); }