Example usage for java.awt.event MouseEvent getModifiers

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

Introduction

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

Prototype

@Deprecated(since = "9")
public int getModifiers() 

Source Link

Document

Returns the modifier mask for this event.

Usage

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

/**
 * This method initializes treeSite/*w  w w  .j av a  2  s  .  c o  m*/
 * 
 * @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.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  ava  2s. 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.zest_owtf.mainclass.ZestZapUtils.java

public static MouseAdapter stdMenuAdapter() {
    return new java.awt.event.MouseAdapter() {
        @Override//from  ww w  .  j  a  v a2s  .  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   w  w w.ja  va 2 s . c  o m
            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: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/*ww w .  ja va2  s.c  om*/
        // 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()

}