Example usage for java.awt.event MouseEvent isPopupTrigger

List of usage examples for java.awt.event MouseEvent isPopupTrigger

Introduction

In this page you can find the example usage for java.awt.event MouseEvent isPopupTrigger.

Prototype

public boolean isPopupTrigger() 

Source Link

Document

Returns whether or not this mouse event is the popup menu trigger event for the platform.

Usage

From source file:com.hp.alm.ali.idea.content.taskboard.TaskBoardPanel.java

public TaskBoardPanel(final Project project) {
    super(new BorderLayout());

    this.project = project;

    status = new EntityStatusPanel(project);
    queue = new QueryQueue(project, status, false);

    entityService = project.getComponent(EntityService.class);
    entityService.addEntityListener(this);
    sprintService = project.getComponent(SprintService.class);
    sprintService.addListener(this);

    loadTasks();//  w  w  w.j av a2s . c  o  m

    header = new Header();
    columnHeader = new ColumnHeader();

    content = new Content();
    add(content, BorderLayout.NORTH);

    header.assignedTo.reload();

    // force mouse-over task as visible (otherwise events are captured by the overlay and repaint quirks)
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent event) {
            if (isShowing() && event.getID() == MouseEvent.MOUSE_MOVED) {
                MouseEvent m = (MouseEvent) event;
                TaskPanel currentPanel = locateContainer(m, TaskPanel.class);
                if (currentPanel != null) {
                    if (forcedTaskPanel == currentPanel) {
                        return;
                    } else if (forcedTaskPanel != null) {
                        forcedTaskPanel.removeForcedMatch(this);
                    }
                    forcedTaskPanel = currentPanel;
                    forcedTaskPanel.addForcedMatch(this);
                } else if (forcedTaskPanel != null) {
                    forcedTaskPanel.removeForcedMatch(this);
                    forcedTaskPanel = null;
                }
            }
        }
    }, AWTEvent.MOUSE_MOTION_EVENT_MASK);

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent event) {
            if (isShowing()) {
                MouseEvent m = (MouseEvent) event;
                switch (event.getID()) {
                case MouseEvent.MOUSE_PRESSED:
                case MouseEvent.MOUSE_RELEASED:
                    // implement backlog item popup
                    if (m.isPopupTrigger()) {
                        final BacklogItemPanel itemPanel = locateContainer(m, BacklogItemPanel.class);
                        if (itemPanel != null) {
                            ActionPopupMenu popupMenu = ActionUtil.createEntityActionPopup("taskboard");
                            Point p = SwingUtilities.convertPoint(m.getComponent(), m.getPoint(), itemPanel);
                            popupMenu.getComponent().show(itemPanel, p.x, p.y);
                        }
                    }
                    break;

                case MouseEvent.MOUSE_CLICKED:
                    // implement backlog item double click
                    if (m.getClickCount() > 1) {
                        BacklogItemPanel itemPanel = locateContainer(m, BacklogItemPanel.class);
                        if (itemPanel != null) {
                            Entity backlogItem = itemPanel.getItem();
                            Entity workItem = new Entity(backlogItem.getPropertyValue("entity-type"),
                                    Integer.valueOf(backlogItem.getPropertyValue("entity-id")));
                            AliContentFactory.loadDetail(project, workItem, true, true);
                        }
                    }
                }
            }

        }
    }, AWTEvent.MOUSE_EVENT_MASK);
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;// w ww  .  j ava2s  . com
            threeBstate = s;
            return;
        }
        if (threeBstate == sp) {
            procPressed(threeBPressed);
            threeBPressed = null;
            threeBstate = s;
        } else if (threeBstate == spp) {
            threeBPressed = null;
            threeBstate = sppr;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }

    procReleased(e);
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;//  w w  w  .  ja  v  a2s.c  om
            threeBstate = s;
            return;
        }
        if (threeBstate == sp) {
            procPressed(threeBPressed);
            threeBPressed = null;
            threeBstate = s;
        } else if (threeBstate == spp) {
            threeBPressed = null;
            threeBstate = sppr;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }
    try {
        procReleased(e);
    } catch (Exception ee) {
    }
}

From source file:canreg.client.gui.dataentry.PDSEditorInternalFrame.java

private void pdsTableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pdsTableMousePressed
    if (evt.isPopupTrigger()) {
        copyMenuItem.setEnabled(!pdsTable.getSelectionModel().isSelectionEmpty());
        Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
        pasteMenuItem.setEnabled(contents.isDataFlavorSupported(DataFlavor.stringFlavor));
        tablePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    }/* w  w w. ja  va2s  .  co m*/
}

From source file:canreg.client.gui.dataentry.PDSEditorInternalFrame.java

private void pdsTableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pdsTableMouseReleased
    if (evt.isPopupTrigger()) {
        copyMenuItem.setEnabled(!pdsTable.getSelectionModel().isSelectionEmpty());
        Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
        pasteMenuItem.setEnabled(contents.isDataFlavorSupported(DataFlavor.stringFlavor));
        tablePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    }/*from ww w  .j a va  2  s.  c  om*/
}

From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java

@Override
public void processMouseEvent(MouseEvent ev) {
    int type = ev.getID();
    //int modifiers = ev.getModifiers();

    mouseDown = type == MouseEvent.MOUSE_PRESSED;

    // XXX For Java 5 Bug
    // I am not sure if we still need this
    if (mouseDown && UIHelper.getOSType() == UIHelper.OSTYPE.MacOSX) {
        int rowIndexStart = rowAtPoint(ev.getPoint());
        int colIndexStart = columnAtPoint(ev.getPoint());

        //System.out.println(isEditing()+"  "+rowIndexStart+" "+colIndexStart+" "+prevRowSelInx+" "+prevColSelInx+" ");
        if (isEditing() && (prevRowSelInx != rowIndexStart || prevColSelInx != colIndexStart)) {
            getCellEditor().stopCellEditing();
        }//w  w w . j a  v a 2s  . c om
    }
    // Done - For Java 5 Bug

    if (ev.isPopupTrigger()) {
        // No matter what, stop editing if we are editing
        if (isEditing()) {
            getCellEditor().stopCellEditing();
        }

        // Now check to see if we right clicked on a different rowor column
        boolean isOnSelectedCell = false;
        int rowIndexStart = rowAtPoint(ev.getPoint());
        int colIndexStart = columnAtPoint(ev.getPoint());

        // Check to see if we are in the selection of mulitple rows and cols
        if (getSelectedRowCount() > 0) {
            int[] cols = getSelectedColumns();
            for (int r : getSelectedRows()) {
                if (r == rowIndexStart) {
                    for (int c : cols) {
                        if (c == colIndexStart) {
                            isOnSelectedCell = true;
                            break;
                        }
                    }
                }
            }
        }
        if (!isOnSelectedCell) {
            setRowSelectionInterval(rowIndexStart, rowIndexStart);
            setColumnSelectionInterval(colIndexStart, colIndexStart);
        }

        if (popupMenu != null) {
            popupMenu.setVisible(false);
        }

        popupMenu = createMenuForSelection(ev.getPoint());

        if (popupMenu.isVisible()) {
            popupMenu.setVisible(false);

        } else {
            //popupMenu.setTargetCells(_selection);
            Point p = getLocationOnScreen();
            popupMenu.setLocation(p.x + ev.getX() + 1, p.y + ev.getY() + 1);
            popupMenu.setVisible(true);
        }
    }
    super.processMouseEvent(ev);
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected void initTabContextMenu(JComponent tabComponent) {
    tabComponent.addMouseListener(new MouseAdapter() {
        @Override/*from   w  w  w  .ja v  a  2s.  c om*/
        public void mousePressed(MouseEvent e) {
            dispatchToParent(e);
            if (e.isPopupTrigger()) {
                showTabPopup(e);
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            dispatchToParent(e);
            if (e.isPopupTrigger()) {
                showTabPopup(e);
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            dispatchToParent(e);
        }

        @Override
        public void mouseMoved(MouseEvent e) {
            dispatchToParent(e);
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            dispatchToParent(e);
        }

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            dispatchToParent(e);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            dispatchToParent(e);
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            dispatchToParent(e);
        }

        public void dispatchToParent(MouseEvent e) {
            tabsPane.dispatchEvent(SwingUtilities.convertMouseEvent(e.getComponent(), e, tabsPane));
        }
    });
}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

public void mousePressed(final MouseEvent e) {
    prePos = e.getPoint();/*from   ww w.  j  a v a  2  s.c om*/
    float sp[] = { 0.0f, 0.0f };
    this.convertMousePointToSceneSpace(prePos, scenePos);

    PAN_MODE = 0;
    ZOOM_MODE = 0;
    MANIPULATE_MODE = 0;

    // For mouse right-click or Ctrl-Left-Click
    if (e.isPopupTrigger()) {
        this.handleRightMouseClick(e);

        return;
    }

    switch (e.getButton()) {
    case MouseEvent.BUTTON1:

        if (canvasMode == CorelyzerApp.APP_MEASURE_MODE) {
            return;
        } else if (canvasMode == CorelyzerApp.APP_MARKER_MODE) {

            // the first check up: focused marker manipulation
            if (SceneGraph.focusedMarker > -1) {
                if (SceneGraph.hitMarker(canvasId, scenePos[0], scenePos[1])) {
                    MANIPULATE_MODE = 1;

                    /*
                     * System.out.println(
                     * "---- Left button pressed down at: " + prePos.x +
                     * ", " + prePos.y); System.out.println(
                     * "Converted to Scene Space: " + scenePos[0] + ", "
                     * + sp[1]);
                     * System.out.println("Marker manipulator hit!");
                     */

                    prescenePos[0] = scenePos[0];
                    prescenePos[1] = scenePos[1];

                    return;
                }
            }
        } else if (canvasMode == CorelyzerApp.APP_CLAST_MODE || canvasMode == CorelyzerApp.APP_CUT_MODE)

        {
            determineSelectedSceneComponents(scenePos, e);

            if (selectedTrackSection != -1) {
                if (!SceneGraph.getDepthOrientation()) {
                    float t = scenePos[0];
                    scenePos[0] = scenePos[1];
                    scenePos[1] = -t;
                }

                SceneGraph.addClastPoint1(scenePos[0], scenePos[1]);
                this.convertScenePointToAbsolute(scenePos, sp);

                CorelyzerApp.getApp().getToolFrame().setClastUpperLeft(sp);
            }

            PAN_MODE = 0;
            return;
        }

        PAN_MODE = 1;

        // System.out.println("---- Left button pressed down at: " +
        // prePos.x + ", " + prePos.y);
        // System.out.println("Converted to Scene Space: " +
        // scenePos[0] + ", " + sp[1]);

        determineSelectedSceneComponents(scenePos, e);

        break;
    case MouseEvent.BUTTON2:
        // System.out.println("MOUSE BUTTON 2!!!???");
        break;
    case MouseEvent.BUTTON3:
        // System.out.println("---- Right button clicked at: " +
        // prePos.x + ", " + prePos.y);
        // System.out.println("Converted to Scene Space: " +
        // scenePos[0] + ", " + sp[1]);
        this.handleRightMouseClick(e);
        break;
    default:
        // more reliable than BUTTON3 (ctrl-click)
        if (e.isPopupTrigger()) {
            this.handleRightMouseClick(e);
        }
    }
}

From source file:neembuu.uploader.NeembuuUploader.java

/**
 * Opens up the Popup Menu/*  w  ww.  j  a  v  a  2s . com*/
 *
 * @param evt
 */
private void openPopup(MouseEvent evt) {
    //The above three mouse events call this method.
    //So check which one will trigger Rightclick menu depending on os and use it.
    if (evt.isPopupTrigger()) {
        //Check if it is right click.
        if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
            NULogger.getLogger().info("RightClick event");
            //if already 2 or more rows selected, leave it.
            //EDIT: After some days I forgot what this code does,.. This is copied from a stackoverflow post actually..
            //But it's an unchangeable code and will just work forever, so I'm not gonna mess with it.
            if (neembuuUploaderTable.getSelectedRowCount() < 2) {
                int r = neembuuUploaderTable.rowAtPoint(evt.getPoint());
                if (r >= 0 && r < neembuuUploaderTable.getRowCount()) {
                    neembuuUploaderTable.setRowSelectionInterval(r, r);
                } else {
                    neembuuUploaderTable.clearSelection();
                }

                int rowindex = neembuuUploaderTable.getSelectedRow();
                if (rowindex < 0) {
                    return;
                }
            }
            //Display the popup menu on the exact point of right click.
            PopupBuilder.getInstance().show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Handles a 'mouse pressed' event.//from  w w w . j  a  v  a 2  s .co m
 * <P>
 * This event is the popup trigger on Unix/Linux. For Windows, the popup trigger is the 'mouse
 * released' event.
 * 
 * @param e
 *            The mouse event.
 */
public void mousePressed(MouseEvent e) {
    if (this.zoomRectangle == null) {
        Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());
        if (screenDataArea != null) {
            this.zoomPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea);
        } else {
            this.zoomPoint = null;
        }
        if (e.isPopupTrigger()) {
            if (this.popup != null) {
                displayPopupMenu(e.getX(), e.getY());
            }
        }
    }
}