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:org.pmedv.blackboard.components.BoardEditor.java

private void handleMouseReleased(MouseEvent e) {

    ArrayList<UndoableEdit> edits = new ArrayList<UndoableEdit>();

    for (Item item : selectedItems) {

        Line currentLine = null;/*  w  ww  . j ava  2  s.  c o  m*/

        if (item instanceof Line) {
            currentLine = (Line) item;
        }
        // just add edit if item or line has been moved
        if (item.getOldXLoc() > 0
                || (currentLine != null && !currentLine.getOldstart().equals(currentLine.getStart()))) {
            if (item instanceof Line) {
                Line l = (Line) item;
                MoveLineEdit ml = new MoveLineEdit(l, l.getOldstart().x, l.getOldstart().y, l.getStart().x,
                        l.getStart().y, l.getOldEnd().x, l.getOldEnd().y, l.getEnd().x, l.getEnd().y, true);
                edits.add(ml);

                for (WireConnection wc : l.getWireConnections()) {
                    Line l1 = wc.getLine();
                    ml = new MoveLineEdit(l1, l1.getOldstart().x, l1.getOldstart().y, l1.getStart().x,
                            l1.getStart().y, l1.getOldEnd().x, l1.getOldEnd().y, l1.getEnd().x, l1.getEnd().y,
                            true);
                    edits.add(ml);
                    l1.setOldstart(new Point(l1.getStart()));
                    l1.setOldEnd(new Point(l1.getEnd()));
                }

            } else {
                MoveItemEdit me = new MoveItemEdit(item, item.getOldXLoc(), item.getOldYLoc(), item.getXLoc(),
                        item.getYLoc(), true);

                if (item instanceof Part) {

                    Part part = (Part) item;

                    for (WireConnection wc : part.getWireConnections()) {
                        Line l1 = wc.getLine();
                        MoveLineEdit m = new MoveLineEdit(l1, l1.getOldstart().x, l1.getOldstart().y,
                                l1.getStart().x, l1.getStart().y, l1.getOldEnd().x, l1.getOldEnd().y,
                                l1.getEnd().x, l1.getEnd().y, true);
                        edits.add(m);
                        l1.setOldstart(new Point(l1.getStart()));
                        l1.setOldEnd(new Point(l1.getEnd()));
                    }

                    edits.add(me);

                }

            }
            setFileState(FileState.DIRTY);
        }

    }

    if (edits.size() > 0) {
        MoveMultipleItemsEdit mme = new MoveMultipleItemsEdit(edits);

        if (!undoManager.addEdit(mme)) {
            log.error("could not add edit to undo manager");
        } else {
            log.info("added edit : " + this.getClass());
        }
    }

    if (editorMode.equals(EditorMode.SELECT)) {
        if (selectedItem != null)
            state = SelectionState.SINGLE_ITEM_SELECTED;
        else
            state = SelectionState.NOTHING_SELECTED;
    }
    if (e.isPopupTrigger()) {
        handleContextClick(e);
    }
    if (e.getButton() == 1) {
        button1Pressed = false;
        if (editorMode.equals(EditorMode.SELECT)) {
            // handleClickSelectionEvent(e);
            handleReleaseSelectionEvent(e, edits);
        }
    } else if (e.getButton() == 2) {
        button2Pressed = false;
    } else if (e.getButton() == 3) {
        button3Pressed = false;
    }
    refresh();
}

From source file:org.pmedv.blackboard.components.PartView.java

private void handlePopupTrigger(MouseEvent e) {
    if (e.isPopupTrigger() && model.getParts().size() >= 1) {

        Point p = e.getPoint();/*from www  .j  a v  a2  s . c o m*/
        // get the row index that contains that coordinate
        int rowNumber = partPanel.getPartTable().rowAtPoint(p);
        // Get the ListSelectionModel of the JTable
        ListSelectionModel model = partPanel.getPartTable().getSelectionModel();
        // set the selected interval of rows. Using the "rowNumber"
        // variable for the beginning and end selects only that one row.
        model.setSelectionInterval(rowNumber, rowNumber);
        tablePopupMenu.show(e.getComponent(), e.getX(), e.getY());
    }
}

From source file:org.pmedv.blackboard.dialogs.PartDialog.java

private void handlePopupTrigger(MouseEvent e) {
    if (e.isPopupTrigger() && model.getParts().size() >= 1) {
        Point p = e.getPoint();// w w w. j  a  v  a2s  .  co  m
        // get the row index that contains that coordinate
        int rowNumber = partPanel.getPartTable().rowAtPoint(p);
        // Get the ListSelectionModel of the JTable
        ListSelectionModel model = partPanel.getPartTable().getSelectionModel();
        // set the selected interval of rows. Using the "rowNumber"
        // variable for the beginning and end selects only that one row.
        model.setSelectionInterval(rowNumber, rowNumber);
        tablePopupMenu.show(e.getComponent(), e.getX(), e.getY());
    }
}

From source file:org.spoutcraft.launcher.skin.ConsoleFrame.java

public void mousePressed(MouseEvent e) {
    if (e.isPopupTrigger())
        doPop(e);
}

From source file:org.spoutcraft.launcher.skin.ConsoleFrame.java

public void mouseReleased(MouseEvent e) {
    if (e.isPopupTrigger())
        doPop(e);
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Initialize the contents of the frame.
 *//*from  w  w  w.  j a v a2 s.  co  m*/
private void initialize() {
    // set the logo
    setIconImages(LOGOS);
    setBounds(5, 5, 1100, 727);
    // do nothing, we have our own windowClosing() listener
    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    JLayeredPane content = new JLayeredPane();
    content.setLayout(new FormLayout(
            new ColumnSpec[] { ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("right:270px"), },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow"), }));
    getContentPane().add(content, BorderLayout.CENTER);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow") },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow") }));
    content.add(mainPanel, "1, 1, 3, 1, fill, fill");
    content.setLayer(mainPanel, 1);

    JTabbedPane tabbedPane = VerticalTextIcon.createTabbedPane(JTabbedPane.LEFT);
    tabbedPane.setTabPlacement(JTabbedPane.LEFT);
    mainPanel.add(tabbedPane, "1, 1, fill, fill");
    // getContentPane().add(tabbedPane, "1, 2, fill, fill");

    panelStatusBar = new StatusBar();
    getContentPane().add(panelStatusBar, BorderLayout.SOUTH);

    panelMovies = new MoviePanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.movies"), panelMovies); //$NON-NLS-1$

    panelMovieSets = new MovieSetPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.moviesets"), panelMovieSets); //$NON-NLS-1$

    panelTvShows = new TvShowPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.tvshows"), panelTvShows); //$NON-NLS-1$

    // shutdown listener - to clean database connections safely
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            closeTmm();
        }
    });

    MessageManager.instance.addListener(TmmUIMessageCollector.instance);

    // mouse event listener for context menu
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent arg0) {
            if (arg0 instanceof MouseEvent && MouseEvent.MOUSE_RELEASED == arg0.getID()
                    && arg0.getSource() instanceof JTextComponent) {
                MouseEvent me = (MouseEvent) arg0;
                JTextComponent tc = (JTextComponent) arg0.getSource();
                if (me.isPopupTrigger() && tc.getComponentPopupMenu() == null) {
                    TextFieldPopupMenu.buildCutCopyPaste().show(tc, me.getX(), me.getY());
                }
            }
        }
    }, AWTEvent.MOUSE_EVENT_MASK);

    // temp info for users using Java 6
    if (SystemUtils.IS_JAVA_1_6) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("tmm.java6")); //$NON-NLS-1$
            }
        });
    }

    // inform user is MI could not be loaded
    if (Platform.isLinux() && StringUtils.isBlank(MediaInfo.version())) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("mediainfo.failed.linux")); //$NON-NLS-1$
            }
        });
    }
}

From source file:org.zaproxy.zap.extension.httppanelviews.syntaxhighlight.HttpPanelSyntaxHighlightTextView.java

private void init() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    httpPanelTextArea = createHttpPanelTextArea();
    httpPanelTextArea.setEditable(false);
    httpPanelTextArea.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override/*from   w  w w .j av  a2s . c  o m*/
        public void mouseReleased(java.awt.event.MouseEvent e) {
            // right mouse button action
            if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || e.isPopupTrigger()) {
                if (!httpPanelTextArea.isFocusOwner()) {
                    httpPanelTextArea.requestFocusInWindow();
                }

                View.getSingleton().getPopupMenu().show(httpPanelTextArea, e.getX(), e.getY());
            }
        }
    });

    JScrollPane scrollPane = new RTextScrollPane(httpPanelTextArea, false);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    mainPanel.add(scrollPane, BorderLayout.CENTER);
}

From source file:org.zaproxy.zap.extension.multiFuzz.impl.http.HttpFuzzerContentPanel.java

public JXTreeTable getFuzzResultTable() {
    if (fuzzResultTable == null) {
        resetFuzzResultTable();//from  w w  w  .  jav a  2  s  . c  o  m
        fuzzResultTable = new JXTreeTable(getResultsModel());
        fuzzResultTable.setName("HttpFuzzResultTable");
        fuzzResultTable.setDoubleBuffered(true);
        fuzzResultTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        fuzzResultTable.setFont(new java.awt.Font("Default", java.awt.Font.PLAIN, 12));
        fuzzResultTable.setDefaultRenderer(Pair.class, new IconTableCellRenderer());

        int[] widths = { 10, 25, 550, 30, 85, 55, 40, 70 };
        for (int i = 0, count = widths.length; i < count; i++) {
            TableColumn column = fuzzResultTable.getColumnModel().getColumn(i);
            column.setPreferredWidth(widths[i]);
        }
        fuzzResultTable.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            private void showPopupMenuIfTriggered(java.awt.event.MouseEvent e) {
                if (e.isPopupTrigger() && SwingUtilities.isRightMouseButton(e)) {
                    // Select list item on right click
                    JTable table = (JTable) e.getSource();
                    int row = table.rowAtPoint(e.getPoint());

                    if (!table.isRowSelected(row)) {
                        table.changeSelection(row, 0, false, false);
                    }
                    View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                }
            }

        });

        fuzzResultTable.getSelectionModel()
                .addListSelectionListener(new javax.swing.event.ListSelectionListener() {

                    @Override
                    public void valueChanged(javax.swing.event.ListSelectionEvent e) {
                        if (!e.getValueIsAdjusting()) {
                            if (fuzzResultTable.getSelectedRowCount() == 0) {
                                return;
                            }
                            final int row = fuzzResultTable.getSelectedRow();
                            if (getEntry(row) instanceof HttpFuzzRequestRecord) {
                                final HistoryReference historyReference = ((HttpFuzzRequestRecord) getEntry(
                                        row)).getHistory();
                                try {
                                    displayMessage(historyReference.getHttpMessage());
                                } catch (HttpMalformedHeaderException | SQLException ex) {
                                    logger.error(ex.getMessage(), ex);
                                }
                            }
                        }
                    }
                });
        fuzzResultTable.getTableHeader().addMouseListener(new MouseListener() {
            int sortedOn = -1;

            @Override
            public void mouseReleased(MouseEvent arg0) {
            }

            @Override
            public void mousePressed(MouseEvent arg0) {
            }

            @Override
            public void mouseExited(MouseEvent arg0) {
            }

            @Override
            public void mouseEntered(MouseEvent arg0) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {
                int index = fuzzResultTable.columnAtPoint(e.getPoint());
                List<HttpFuzzRecord> list = getResultsModel().getEntries();
                if (list.size() == 0) {
                    return;
                }
                HttpFuzzRecordComparator comp = new HttpFuzzRecordComparator();
                comp.setFeature(index);
                if (index == sortedOn) {
                    Collections.sort(list, comp);
                    Collections.reverse(list);
                    sortedOn = -1;
                } else {
                    Collections.sort(list, comp);
                    sortedOn = index;
                }
                fuzzResultTable.updateUI();
            }
        });
        fuzzResultTable.setRootVisible(false);
        fuzzResultTable.setVisible(true);
    }
    return fuzzResultTable;
}

From source file:org.zest_owtf.mainclass.ZestZapUtils.java

public static MouseAdapter stdMenuAdapter() {
    return new java.awt.event.MouseAdapter() {
        @Override/*from   w  ww .  j a v a  2s. co  m*/
        public void mousePressed(java.awt.event.MouseEvent e) {
            mouseAction(e);
        }

        @Override
        public void mouseReleased(java.awt.event.MouseEvent e) {
            mouseAction(e);
        }

        public void mouseAction(java.awt.event.MouseEvent e) {
            // right mouse button action
            if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || e.isPopupTrigger()) {
                View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    };
}

From source file:plugin.notes.gui.JIcon.java

private void buttonMouseReleased(MouseEvent evt) {
    //GEN-FIRST:event_buttonMouseReleased
    if (evt.isPopupTrigger()) {
        contextMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    }//from  www.j a  v  a  2s .  com
}