List of usage examples for java.awt.event MouseEvent isPopupTrigger
public boolean isPopupTrigger()
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void addMouseDoubleClickListener() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { job(e, true);//from w w w . j a v a 2 s. co m } public void mouseReleased(MouseEvent e) { job(e, false); } private void job(MouseEvent e, boolean pressed) { if (e.isPopupTrigger() || (e.getClickCount() == 2)) { final TreePath selPath = getPathForLocation(e.getX(), e.getY()); if (selPath == null) { return; } setSelectionPath(selPath); try { final DBBrowserNode selectedNode = (DBBrowserNode) selPath.getLastPathComponent(); if (selectedNode != null) { if (selectedNode.getDBObject().getType() == DBObject.DATASOURCE) { selectionDataSource(e); } else if (selectedNode.getDBObject().getType() == DBObject.QUERIES_GROUP) { selectionQueryGroup(selectedNode, e); } else if (selectedNode.getDBObject().getType() == DBObject.QUERIES) { selectionQuery(selectedNode, e, pressed); } else if (selectedNode.getDBObject().getType() == DBObject.REPORTS_GROUP) { selectionReportGroup(selectedNode, e); } else if (selectedNode.getDBObject().getType() == DBObject.REPORTS) { selectionReport(selectedNode, e, pressed); } else if (selectedNode.getDBObject().getType() == DBObject.CHARTS_GROUP) { selectionChartGroup(selectedNode, e); } else if (selectedNode.getDBObject().getType() == DBObject.CHARTS) { selectionChart(selectedNode, e, pressed); } else if (selectedNode.getDBObject().getType() == DBObject.DATABASE) { selectionDatabase(selPath, selectedNode, e); } else if ((selectedNode.getDBObject().getType() == DBObject.TABLE) || (selectedNode.getDBObject().getType() == DBObject.VIEW)) { selectionTableOrView(selectedNode, e); } else if (selectedNode.getDBObject().getType() == DBObject.PROCEDURES) { selectionProcedure(selectedNode, e); } else if (selectedNode.getDBObject().getType() == DBObject.PROCEDURES_GROUP) { selectionProcedureGroup(selectedNode, e); } else if (selectedNode.getDBObject().getType() == DBObject.TABLES_GROUP) { selectionTablesGroup(selectedNode, e); } else if (selectedNode.getDBObject().getType() == DBObject.VIEWS_GROUP) { selectionViewsGroup(selectedNode, e); } else if (selectedNode.getDBObject().isFolder()) { selectionFolder(selectedNode, e); } } } catch (Exception ex) { Show.error(ex); } } } }); }
From source file:ro.nextreports.designer.wizpublish.JcrBrowserTree.java
public JcrBrowserTree(final byte typeRoot, WebServiceClient client) { super();//from w w w .ja va 2 s. c om this.client = client; populateTree(typeRoot); setCellRenderer(new JcrBrowserTreeRenderer()); getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); instance = this; addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { job(e, true); } public void mouseReleased(MouseEvent e) { job(e, false); } private void job(MouseEvent e, boolean pressed) { if (e.isPopupTrigger()) { final TreePath selPath = getPathForLocation(e.getX(), e.getY()); if (selPath == null) { return; } setSelectionPath(selPath); try { final DBBrowserNode selectedNode = (DBBrowserNode) selPath.getLastPathComponent(); if (selectedNode != null) { JPopupMenu popupMenu = new JPopupMenu(); boolean show = false; if ((selectedNode.getDBObject().getType() == DBObject.FOLDER_REPORT) || (selectedNode.getDBObject().getType() == DBObject.DATABASE) || (selectedNode.getDBObject().getType() == DBObject.REPORTS_GROUP) || (selectedNode.getDBObject().getType() == DBObject.CHARTS_GROUP)) { JMenuItem menuItem = new JMenuItem(new PublishFolderAction(selectedNode)); popupMenu.add(menuItem); show = true; } if ((typeRoot == DBObject.DATABASE) && ((selectedNode.getDBObject().getType() == DBObject.FOLDER_REPORT) || (selectedNode.getDBObject().getType() == DBObject.DATABASE))) { PublishDataSourceAction publishDSAction = new PublishDataSourceAction(selectedNode); JMenuItem menuItem2 = new JMenuItem(publishDSAction); popupMenu.add(menuItem2); show = true; } if (show) { popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); } } } catch (Exception ex) { Show.error(ex); } } } }); }
From source file:statechum.analysis.learning.Visualiser.java
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) popupMenu.show(e.getComponent(), e.getX(), e.getY()); else/*from ww w . j a v a 2 s .co m*/ // attempt the popup for the diff if (currentGraph >= 0) {// if there are any graphs in this frame JPopupMenu diffMenu = new JPopupMenu(); final LearnerGraphND ourGraph = graphsOrig.get(currentGraph); if (ourGraph != null) {// if this is a real graph for (Visualiser viz : framesVisible) { final Visualiser fViz = viz; if (fViz.currentGraph >= 0) { final LearnerGraphND otherGr = fViz.graphsOrig.get(fViz.currentGraph); if (ourGraph != otherGr && otherGr != null) {// only if this is a real graph JMenuItem menuitem = new JMenuItem(new AbstractAction() { /** * ID for serialization */ private static final long serialVersionUID = 6840129509410881970L; {// Constructor putValue(Action.NAME, otherGr.getNameNotNull()); putValue(SHORT_DESCRIPTION, otherGr.getNameNotNull()); } @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent ev) { GD<List<CmpVertex>, List<CmpVertex>, LearnerGraphNDCachedData, LearnerGraphNDCachedData> gd = new GD<List<CmpVertex>, List<CmpVertex>, LearnerGraphNDCachedData, LearnerGraphNDCachedData>(); DirectedSparseGraph gr = //gd.showGD(ourGraph,otherGr,ExperimentRunner.getCpuNumber()); ChangesToGraph.computeVisualisationParameters( Synapse.StatechumProcess.constructFSM(ourGraph), ChangesToGraph.computeGD(ourGraph, otherGr, ourGraph.config)); Visualiser.updateFrame(gr, null); } }); diffMenu.add(menuitem); } } // if otherGr != null } // if fViz.graphs.size() > 0 if (diffMenu.getComponentCount() > 0) diffMenu.show(e.getComponent(), e.getX(), e.getY()); } // if ourGraph != null } // if graphs.size() > 0 } // e.isPopupTrigger() }
From source file:tvbrowser.ui.mainframe.MainFrame.java
private void addContextMenuMouseListener(final JComponent c) { c.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { ContextMenu menu = new ContextMenu(c); menu.show(e.getX(), e.getY()); }// ww w .ja v a 2 s.com } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { ContextMenu menu = new ContextMenu(c); menu.show(e.getX(), e.getY()); } } }); }
From source file:uk.co.modularaudio.util.swing.dndtable.layeredpane.LayeredPaneDndTableMouseListener.java
@Override public void mousePressed(final MouseEvent e) { // Popup test if (e.isPopupTrigger()) { final Point dragStartPoint = e.getPoint(); final boolean foundIt = table.getComponentAtWithLocalPoint(dragStartPoint, componentAndLocalPoint); Point localPoint = null;/*from w ww.j a va 2 s .c om*/ C component = null; if (foundIt) { localPoint = componentAndLocalPoint.getHead(); component = componentAndLocalPoint.getTail(); } if (dndPolicy.isMouseOverPopupSource(table, component, localPoint, dragStartPoint)) { try { dndState.changeTo(State.POPUP); dndPolicy.doPopup(table, component, localPoint, dragStartPoint); dndState.changeTo(State.BROWSING); } catch (final BadStateTransitionException bste) { final String msg = "Bad state transition attempting to perform popup"; log.error(msg, bste); } } } else { // log.debug(e); try { final State currentState = dndState.getCurrentState(); switch (currentState) { case MOUSE_OVER_DRAGGABLE_AREA: // Begin a drag final Point dragStartPoint = e.getPoint(); final boolean foundIt = table.getComponentAtWithLocalPoint(dragStartPoint, componentAndLocalPoint); Point localPoint = null; C component = null; if (foundIt) { localPoint = componentAndLocalPoint.getHead(); component = componentAndLocalPoint.getTail(); dndPolicy.startDrag(table, component, localPoint, dragStartPoint); dndState.changeTo(State.DURING_DRAG); decorationManager.setMouseLocation(dragStartPoint); } else { log.error("Failed to find drag source when clicked over a drag area."); dndState.changeTo(State.BROWSING); } break; default: break; } } catch (final Exception e1) { final String msg = "Exception caught processing mouse press: " + e1.toString(); log.error(msg, e1); } } }
From source file:uk.co.modularaudio.util.swing.dndtable.layeredpane.LayeredPaneDndTableMouseListener.java
@Override public void mouseReleased(final MouseEvent e) { // log.debug("Mouse released."); // Popup test if (e.isPopupTrigger()) { final Point dragStartPoint = e.getPoint(); final boolean foundIt = table.getComponentAtWithLocalPoint(dragStartPoint, componentAndLocalPoint); Point localPoint = null;//from ww w . j a v a 2 s .c o m C component = null; if (foundIt) { localPoint = componentAndLocalPoint.getHead(); component = componentAndLocalPoint.getTail(); } if (dndPolicy.isMouseOverPopupSource(table, component, localPoint, dragStartPoint)) { dndPolicy.doPopup(table, component, localPoint, dragStartPoint); } } else { // log.debug(e); try { final State curState = dndState.getCurrentState(); final Point tablePoint = e.getPoint(); final boolean foundIt = table.getComponentAtWithLocalPoint(tablePoint, componentAndLocalPoint); Point point = null; C component = null; if (foundIt) { point = componentAndLocalPoint.getHead(); component = componentAndLocalPoint.getTail(); } switch (curState) { case DURING_DRAG: if (dndPolicy.isValidDragTarget(table, component, point, tablePoint)) { dndPolicy.endDrag(table, component, point, tablePoint); // log.debug("Ended drag."); } else { dndPolicy.endInvalidDrag(table, component, point, tablePoint); // log.debug("Is not over valid drag!"); } // Now fall back into the browsing state case BROWSING: case MOUSE_OVER_DRAGGABLE_AREA: // Reset the state dndState.changeTo(State.BROWSING); break; default: break; } // decorationManager.setMouseLocation( tablePoint ); // log.debug("Synthesising mouse move."); synthesiseMouseMove(e); } catch (final Exception e1) { final String msg = "Exception caught during mouse release processing: " + e1.toString(); log.error(msg, e1); } } }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.QueryAuthoringTreePanel.java
/** * Creates the tree interface./*from w w w . j av a2s . c om*/ */ 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); } } } }); }