List of usage examples for java.awt.event MouseEvent getSource
public Object getSource()
From source file:gdsc.smlm.ij.plugins.PeakFit.java
public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) // Double-click {/*w w w. j av a2s. co m*/ if (e.getSource() == textConfigFile) { String[] path = Utils.decodePath(textConfigFile.getText()); OpenDialog chooser = new OpenDialog("Config_File", path[0], path[1]); if (chooser.getFileName() != null) { String newFilename = chooser.getDirectory() + chooser.getFileName(); textConfigFile.setText(newFilename); } } else if (e.getSource() == textResultsDirectory) { String directory = Utils.getDirectory("Results_dir", textResultsDirectory.getText()); if (directory != null) textResultsDirectory.setText(directory); } } }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionViewsGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;//from w w w .ja v a 2 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:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionTablesGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;//w w w . ja va 2 s . 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:org.photovault.swingui.PhotoCollectionThumbView.java
protected void handleDnDDragEvent(MouseEvent e) { //Don't bother to drag if no photo is selected if (selection.isEmpty()) { return;/*from w w w. j a va 2s . co m*/ } if (firstMouseEvent != null) { log.debug("considering drag"); e.consume(); //If they are holding down the control key, COPY rather than MOVE int ctrlMask = InputEvent.CTRL_DOWN_MASK; int action = e.isControlDown() ? TransferHandler.COPY : TransferHandler.MOVE; int dx = Math.abs(e.getX() - firstMouseEvent.getX()); int dy = Math.abs(e.getY() - firstMouseEvent.getY()); //Arbitrarily define a 5-pixel shift as the //official beginning of a drag. if (dx > 5 || dy > 5) { log.debug("Start a drag"); //This is a drag, not a click. JComponent c = (JComponent) e.getSource(); //Tell the transfer handler to initiate the drag. TransferHandler handler = c.getTransferHandler(); handler.exportAsDrag(c, firstMouseEvent, action); firstMouseEvent = null; } } }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionQuery(DBBrowserNode selectedNode, MouseEvent e, boolean pressed) { OpenQueryAction openAction = new OpenQueryAction(); openAction.setQueryName(selectedNode.getDBObject().getName()); openAction.setQueryPath(selectedNode.getDBObject().getAbsolutePath()); if (e.getClickCount() == 2) { if (pressed) { openAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "")); }/* w w w . jav a2 s .c om*/ } else { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(openAction); popupMenu.add(menuItem); NewReportFromQueryAction newReportQAction = new NewReportFromQueryAction(); newReportQAction.setQueryName(selectedNode.getDBObject().getName()); newReportQAction.setQueryPath(selectedNode.getDBObject().getAbsolutePath()); JMenuItem menuItem3 = new JMenuItem(newReportQAction); popupMenu.add(menuItem3); NewChartFromQueryAction newChartQAction = new NewChartFromQueryAction(); newChartQAction.setQueryName(selectedNode.getDBObject().getName()); newChartQAction.setQueryPath(selectedNode.getDBObject().getAbsolutePath()); JMenuItem menuItem6 = new JMenuItem(newChartQAction); popupMenu.add(menuItem6); DeleteQueryAction deleteAction = new DeleteQueryAction(instance, selectedNode); JMenuItem menuItem2 = new JMenuItem(deleteAction);// popupMenu.add(menuItem2); RenameQueryAction renameAction = new RenameQueryAction(instance, selectedNode); JMenuItem menuItem4 = new JMenuItem(renameAction); popupMenu.add(menuItem4); ExportQueryAction exportAction = new ExportQueryAction(instance, selectedNode); JMenuItem menuItem5 = new JMenuItem(exportAction); popupMenu.add(menuItem5); JMenuItem menuItem7 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject())); popupMenu.add(menuItem7); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); } }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionChart(DBBrowserNode selectedNode, MouseEvent e, boolean pressed) { OpenChartAction openAction = new OpenChartAction(); openAction.setChartName(selectedNode.getDBObject().getName()); openAction.setChartPath(selectedNode.getDBObject().getAbsolutePath()); if (e.getClickCount() == 2) { if (pressed) { openAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "")); }//from ww w . j ava 2s .c o m } else { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(openAction); popupMenu.add(menuItem); DeleteChartAction deleteAction = new DeleteChartAction(instance, selectedNode); JMenuItem menuItem2 = new JMenuItem(deleteAction); popupMenu.add(menuItem2); RenameChartAction renameAction = new RenameChartAction(instance, selectedNode); JMenuItem menuItem3 = new JMenuItem(renameAction); popupMenu.add(menuItem3); ExportChartAction exportAction = new ExportChartAction(instance, selectedNode); JMenuItem menuItem4 = new JMenuItem(exportAction); popupMenu.add(menuItem4); Chart chart = ChartUtil.loadChart(selectedNode.getDBObject().getAbsolutePath()); PreviewChartAction previewHTML5Action = new PreviewChartAction(ChartRunner.GRAPHIC_FORMAT, ChartRunner.HTML5_TYPE, I18NSupport.getString("preview.html5")); previewHTML5Action.setChart(chart); popupMenu.add(previewHTML5Action); PreviewChartAction previewFlashAction = new PreviewChartAction(ChartRunner.GRAPHIC_FORMAT, ChartRunner.FLASH_TYPE, I18NSupport.getString("preview.flash")); previewFlashAction.setChart(chart); popupMenu.add(previewFlashAction); previewFlashAction.setEnabled(!ChartType.hasNoFlashSupport(chart.getType().getType())); PreviewChartAction previewImageAction = new PreviewChartAction(ChartRunner.IMAGE_FORMAT, ChartRunner.NO_TYPE, I18NSupport.getString("preview.image")); previewImageAction.setChart(chart); popupMenu.add(previewImageAction); PublishChartAction publishAction = new PublishChartAction(selectedNode.getDBObject().getAbsolutePath()); JMenuItem menuItem5 = new JMenuItem(publishAction); popupMenu.add(menuItem5); JMenuItem menuItem6 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject())); popupMenu.add(menuItem6); JMenuItem menuItem7 = new JMenuItem(new AddToFavoritesAction(selectedNode.getDBObject())); popupMenu.add(menuItem7); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); } }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionReport(DBBrowserNode selectedNode, MouseEvent e, boolean pressed) { OpenReportAction openAction = new OpenReportAction(); openAction.setReportName(selectedNode.getDBObject().getName()); openAction.setReportPath(selectedNode.getDBObject().getAbsolutePath()); if (e.getClickCount() == 2) { if (pressed) { openAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "")); }/*from w w w .ja v a 2 s .co m*/ } else { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(openAction); popupMenu.add(menuItem); DeleteReportAction deleteAction = new DeleteReportAction(instance, selectedNode); JMenuItem menuItem2 = new JMenuItem(deleteAction); popupMenu.add(menuItem2); RenameReportAction renameAction = new RenameReportAction(instance, selectedNode); JMenuItem menuItem3 = new JMenuItem(renameAction); popupMenu.add(menuItem3); ExportReportAction exportAction = new ExportReportAction(instance, selectedNode); JMenuItem menuItem4 = new JMenuItem(exportAction); popupMenu.add(menuItem4); Report report = FormLoader.getInstance().load(selectedNode.getDBObject().getAbsolutePath(), false); JMenu runMenu = new JMenu(I18NSupport.getString("export")); Globals.setTreeReportAbsolutePath(selectedNode.getDBObject().getAbsolutePath()); runMenu.add(new JMenuItem(new ExportToHtmlAction(report))); runMenu.add(new JMenuItem(new ExportToExcelAction(report))); runMenu.add(new JMenuItem(new ExportToPdfAction(report))); runMenu.add(new JMenuItem(new ExportToDocxAction(report))); runMenu.add(new JMenuItem(new ExportToRtfAction(report))); runMenu.add(new JMenuItem(new ExportToCsvAction(report))); runMenu.add(new JMenuItem(new ExportToTsvAction(report))); runMenu.add(new JMenuItem(new ExportToXmlAction(report))); runMenu.add(new JMenuItem(new ExportToTxtAction(report))); popupMenu.add(runMenu); PublishReportAction publishAction = new PublishReportAction( selectedNode.getDBObject().getAbsolutePath()); JMenuItem menuItem5 = new JMenuItem(publishAction); popupMenu.add(menuItem5); JMenuItem menuItem6 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject())); popupMenu.add(menuItem6); JMenuItem menuItem7 = new JMenuItem(new AddToFavoritesAction(selectedNode.getDBObject())); popupMenu.add(menuItem7); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); } }
From source file:tauargus.gui.PanelTable.java
private void initTableSelectionListeners() { table.getTableHeader().addMouseListener(new MouseAdapter() { @Override// w ww.j ava 2 s.c om public void mouseClicked(MouseEvent e) { if (e.getSource() != table.getTableHeader()) return; int col = table.getTableHeader().columnAtPoint(e.getPoint()); if (col >= 1) { // column header is selected Code code = getColumnCode(col); if (code.state != Code.NODE) { if (code.state == Code.EXPANDED) { code.state = Code.COLLAPSED; } else { code.state = Code.EXPANDED; } createColumnIndices(); ((AbstractTableModel) table.getModel()).fireTableStructureChanged(); adjustColumnWidths(); } } } }); ListSelectionListener listSelectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int row = table.getSelectedRow(); int col = table.getSelectedColumn(); if (row >= 0 && col >= 0) { if (col == 0) { Code code = getRowCode(row); if (code.state != Code.NODE) { if (code.state == Code.EXPANDED) { code.state = Code.COLLAPSED; } else { code.state = Code.EXPANDED; } createRowIndices(); ((AbstractTableModel) table.getModel()).fireTableDataChanged(); adjustColumnWidths(); } } else { // cell is selected Cell cell = getCell(row, col); panelCellInformation.update(tableSet, cell, integerFormatter, doubleFormatter); organiseSafetyButtons(cell.status); } } } } }; // react on row changes table.getSelectionModel().addListSelectionListener(listSelectionListener); // .. and react on column changes table.getColumnModel().getSelectionModel().addListSelectionListener(listSelectionListener); }
From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java
/** * Wenn sich die Maus ber was bewegt.../*from w w w . ja va 2 s . c o m*/ */ @Override public void mouseMoved(MouseEvent ev) { // Ist die Maus da irgendwo hingefahren? if (ev.getSource() instanceof JButton) { setStatus(((JButton) ev.getSource()).getToolTipText()); } else if (ev.getSource() instanceof JComboBox<?>) { setStatus(((JComboBox<?>) ev.getSource()).getToolTipText()); } else if (ev.getSource() instanceof JMenuItem) { setStatus(((JMenuItem) ev.getSource()).getToolTipText()); } else if (ev.getSource() instanceof JSpinner) { setStatus(((JSpinner) ev.getSource()).getToolTipText()); } else if (ev.getSource() instanceof JCheckBox) { setStatus(((JCheckBox) ev.getSource()).getToolTipText()); } else if (ev.getSource() instanceof JTable) { setStatus(((JTable) ev.getSource()).getToolTipText()); } else { setStatus(""); } }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionProcedureGroup(DBBrowserNode selectedNode, MouseEvent e) { if (e.getClickCount() == 2) { return;/*ww w . j a v a2s.co m*/ } 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()); }