Example usage for java.awt.event InputEvent BUTTON3_MASK

List of usage examples for java.awt.event InputEvent BUTTON3_MASK

Introduction

In this page you can find the example usage for java.awt.event InputEvent BUTTON3_MASK.

Prototype

int BUTTON3_MASK

To view the source code for java.awt.event InputEvent BUTTON3_MASK.

Click Source Link

Document

The Mouse Button3 modifier constant.

Usage

From source file:org.parosproxy.paros.view.SiteMapPanel.java

/**
 * This method initializes treeSite/*from  w  w  w. j a v a  2 s . com*/
 * 
 * @return JTree
 */
public JTree getTreeSite() {
    if (treeSite == null) {
        treeSite = new JTree();
        treeSite.setShowsRootHandles(true);
        treeSite.setName("treeSite");
        treeSite.setToggleClickCount(1);
        treeSite.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
                    // ZAP: Select site list item on right click
                    TreePath tp = treeSite.getPathForLocation(e.getPoint().x, e.getPoint().y);
                    if (tp != null) {
                        boolean select = true;
                        // Only select a new item if the current item is not
                        // already selected - this is to allow multiple items
                        // to be selected
                        if (treeSite.getSelectionPaths() != null) {
                            for (TreePath t : treeSite.getSelectionPaths()) {
                                if (t.equals(tp)) {
                                    select = false;
                                    break;
                                }
                            }
                        }
                        if (select) {
                            treeSite.getSelectionModel().setSelectionPath(tp);
                        }
                    }

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

        treeSite.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                HttpMessage msg = null;
                SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent();
                if (node == null) {
                    return;
                }
                if (!node.isRoot()) {
                    try {
                        msg = node.getHistoryReference().getHttpMessage();
                    } catch (Exception e1) {
                        // ZAP: Log exceptions
                        log.warn(e1.getMessage(), e1);
                        return;
                    }

                    HttpPanel reqPanel = getView().getRequestPanel();
                    HttpPanel resPanel = getView().getResponsePanel();
                    reqPanel.setMessage(msg, true);
                    resPanel.setMessage(msg, false);

                    // ZAP: Call SiteMapListenners
                    for (SiteMapListener listener : listenners) {
                        listener.nodeSelected(node);
                    }
                }
            }
        });
    }
    return treeSite;
}

From source file:org.squidy.nodes.MouseIO.java

protected void setSingleMousePress(int button) {
    if (button == MouseEvent.BUTTON1) {
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
    } else if (button == MouseEvent.BUTTON2) {
        robot.mousePress(InputEvent.BUTTON2_MASK);
        robot.mouseRelease(InputEvent.BUTTON2_MASK);

    } else if (button == MouseEvent.BUTTON3) {
        robot.mousePress(InputEvent.BUTTON3_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_MASK);
    }/*from  w ww.j  av  a2s .c o  m*/
}

From source file:org.squidy.nodes.MouseIO.java

protected void setMouseStatus(int button, boolean status) {
    if (button == MouseEvent.BUTTON1) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON1_MASK);
        } else {//from   w  ww.j  av a  2 s .  com
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        }
    } else if (button == MouseEvent.BUTTON2) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON2_MASK);
        } else {
            robot.mouseRelease(InputEvent.BUTTON2_MASK);
        }
    } else if (button == MouseEvent.BUTTON3) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON3_MASK);
        } else {
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
        }
    }
}

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// w  w  w  .jav  a  2  s.c om
        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.zest_owtf.mainclass.ZestZapUtils.java

public static MouseAdapter stdMenuAdapter() {
    return new java.awt.event.MouseAdapter() {
        @Override//from w w w.  j ava2  s .  c  o 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:ro.nextreports.designer.querybuilder.SelectionColumnPanel.java

private void buildUI() {

    setLayout(new GridBagLayout());

    final DBViewer viewer = Globals.getDBViewer();

    schemaCombo = new JComboBox();
    schemaCombo.setPreferredSize(comboDim);

    schemaCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            String schema = (String) e.getItem();
            shownColumnModel.clear();/*from  ww  w  . j  av a  2  s  .c om*/
            columnModel.clear();
            tableModel.clear();
            try {
                DBInfo dbInfo = viewer.getDBInfo(schema, DBInfo.TABLES | DBInfo.VIEWS);
                List<DBTable> tables = dbInfo.getTables();
                Collections.sort(tables);
                for (DBTable table : tables) {
                    tableModel.addElement(table);
                }
            } catch (NextSqlException ex) {
                LOG.error(ex.getMessage(), ex);
                ex.printStackTrace();
            }
        }
    });

    try {
        List<String> schemas = viewer.getSchemas();
        String schemaName = viewer.getUserSchema();
        Collections.sort(schemas);
        boolean added = false;
        for (String schema : schemas) {
            if (DefaultSchemaManager.getInstance().isVisible(
                    DefaultDataSourceManager.getInstance().getConnectedDataSource().getName(), schema)) {
                added = true;
                schemaCombo.addItem(schema);
            }
        }

        if ((schema == null) || schema.equals(DefaultDBViewer.NO_SCHEMA_NAME)) {
            schema = DefaultDBViewer.NO_SCHEMA_NAME;//viewer.getUserSchema();
        }
        if (!added) {
            schemaCombo.addItem(schema);
        }
        schemaCombo.setSelectedItem(schema);
    } catch (NextSqlException e) {
        LOG.error(e.getMessage(), e);
        e.printStackTrace();
    }

    // create table list
    tableList = new JXList(tableModel);
    tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableList.setCellRenderer(new DBTableCellRenderer());

    // create column list
    columnList = new JXList(columnModel);
    if (singleSelection) {
        columnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    columnList.setCellRenderer(new DBColumnCellRenderer());

    shownColumnList = new JXList(shownColumnModel);
    if (singleSelection) {
        shownColumnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    addDoubleClick();

    shownColumnList.setCellRenderer(new DBColumnCellRenderer());
    shownColumnList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent mouseEvent) {
            if ((mouseEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {
                JPopupMenu popupMenu = new JPopupMenu();
                JMenuItem menuItem = new JMenuItem(new DeselectListAction(shownColumnList));
                popupMenu.add(menuItem);
                popupMenu.show((Component) mouseEvent.getSource(), mouseEvent.getX(), mouseEvent.getY());
            }
        }
    });

    tableList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                int index = tableList.getSelectedIndex();
                if (index == -1) {
                    return;
                }
                DBTable table = (DBTable) tableModel.getElementAt(index);
                try {
                    List<DBColumn> columns = null;
                    try {
                        columns = viewer.getColumns(table.getSchema(), table.getName());
                    } catch (MalformedTableNameException e1) {
                        Show.error("Malformed table name : " + table.getName());
                        return;
                    }
                    Collections.sort(columns);
                    columnModel.clear();
                    shownColumnModel.clear();
                    for (DBColumn column : columns) {
                        columnModel.addElement(column);
                        shownColumnModel.addElement(column);
                    }
                } catch (NextSqlException e1) {
                    LOG.error(e1.getMessage(), e1);
                    e1.printStackTrace();
                    Show.error(e1);
                }
            }
        }
    });

    columnList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            shownColumnList.clearSelection();
        }
    });

    scrTable = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrTable.setPreferredSize(scrDim);
    scrTable.setMinimumSize(scrDim);
    scrTable.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.tables")));
    scrColumn = new JScrollPane(columnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrColumn.setPreferredSize(scrDim);
    scrColumn.setMinimumSize(scrDim);
    scrColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.columns")));
    scrShownColumn = new JScrollPane(shownColumnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrShownColumn.setPreferredSize(scrDim);
    scrShownColumn.setMinimumSize(scrDim);
    scrShownColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.shown.columns")));

    JPanel schemaPanel = new JPanel();
    schemaPanel.setLayout(new BoxLayout(schemaPanel, BoxLayout.X_AXIS));
    schemaPanel.add(new JLabel("Schema"));
    schemaPanel.add(Box.createHorizontalStrut(5));
    schemaPanel.add(schemaCombo);

    add(schemaPanel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(scrTable, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5), 0, 0));
    add(scrColumn, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    if (show) {
        add(scrShownColumn, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }
}

From source file:sk.stuba.fiit.kvasnicka.topologyvisual.topology.Topology.java

/**
 * initializes mouse controls for topology creation
 *
 * @param mainFrame reference to MainFrame object
 */// www . java2s  . co  m
private void initMouseControlTopologyCreation(TopologyVisualisation topolElementTopComponent) {
    if (graphMouse == null) {
        graphMouse = new MyGraphMouse(vv.getRenderContext(), vertexFactory, this);
        graphMouse.addVertexCreatedListener(this);
        graphMouse.addVertexCreatedListener(topolElementTopComponent);
        graphMouse.add(new TranslatingGraphMousePlugin(InputEvent.BUTTON3_MASK));

        popupVertexMenuMousePlugin = new PopupVertexEdgeMenuMousePlugin(this);
        graphMouse.add(popupVertexMenuMousePlugin);
        graphMouse.setZoomAtMouse(true);
    }

    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    vv.setGraphMouse(graphMouse);
}

From source file:vnreal.gui.control.MyEditingPopupGraphMousePlugin.java

public MyEditingPopupGraphMousePlugin(final LayerViewer<V, E> vv) {
    super(InputEvent.BUTTON3_MASK, new Factory<V>() {
        private final int layer = vv.getLayer().getLayer();

        @SuppressWarnings("unchecked")
        @Override//from  w w w .  j  ava2s  .co  m
        public V create() {
            if (layer > 0)
                return (V) new VirtualNode(layer);
            else
                return (V) new SubstrateNode();
        }
    }, new Factory<E>() {
        private final int layer = vv.getLayer().getLayer();

        @SuppressWarnings("unchecked")
        @Override
        public E create() {
            if (layer > 0)
                return (E) new VirtualLink(layer);
            else
                return (E) new SubstrateLink();
        }
    });

    this.vv = vv;
}