Example usage for java.awt.event MouseEvent BUTTON3

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

Introduction

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

Prototype

int BUTTON3

To view the source code for java.awt.event MouseEvent BUTTON3.

Click Source Link

Document

Indicates mouse button #3; used by #getButton .

Usage

From source file:org.accada.hal.impl.sim.multi.GraphicSimulatorServer.java

/**
 * creates the layered pane if it does not already exists
 * /*from w w  w .jav a  2 s .  co  m*/
 * @return layered pane
 */
private JLayeredPane getJLayeredPane() {
    if (jLayeredPane == null) {
        jLayeredPane = new JLayeredPane();
        jLayeredPane.setLayout(null);
        jLayeredPane.setOpaque(true);
        jLayeredPane.setBackground(Color.WHITE);
        //jLayeredPane.add(getReader(), new Integer(0));

        // add readers
        createReaders(controller.getReaderIds());

        // add context menu
        jLayeredPane.add(getContextMenu());

        // add mouse listener
        jLayeredPane.addMouseListener(new MouseAdapter() {

            // context menu
            public void mouseReleased(MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON3) {
                    Point posOnScreen = getJLayeredPane().getLocationOnScreen();
                    contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY());
                    contextMenu.setVisible(true);
                    setActiveContextMenu(contextMenu);
                } else {
                    contextMenu.setVisible(false);
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        selection.select(tags);
                    }
                }
            }

            // selection
            public void mousePressed(final MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON1) {
                    selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight"));
                    selection.setStartPoint(e.getPoint());
                    jLayeredPane.add(selection, new Integer(2));
                }
            }
        });

        // add drag listener
        jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent e) {
                if (selection.isActive()) {
                    selection.setCurrentPoint(e.getPoint());
                }
            }
        });
    }
    return jLayeredPane;
}

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

/**
 * @param dataButton/*  w ww  . j a  v a2 s. c  o  m*/
 * @return
 */
public IData process(DataButton dataButton) {
    if (dataButton.getButtonType() == DataButton.BUTTON_1) {
        setMouseStatus(MouseEvent.BUTTON1, dataButton.getFlag());
    }
    if (dataButton.getButtonType() == DataButton.BUTTON_2) {
        if (middleDoubleClick) {
            setMouseStatus(MouseEvent.BUTTON1, true);
            setMouseStatus(MouseEvent.BUTTON1, false);
            setMouseStatus(MouseEvent.BUTTON1, true);
            setMouseStatus(MouseEvent.BUTTON1, false);
        } else {
            setMouseStatus(MouseEvent.BUTTON2, dataButton.getFlag());
        }
    }
    if (dataButton.getButtonType() == DataButton.BUTTON_3) {
        setMouseStatus(MouseEvent.BUTTON3, dataButton.getFlag());
        // if (dataButton.getFlag()) {
        // setSingleMousePress(DataButton.BUTTON_3);
        // }
    }

    return dataButton;
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java

private JPanel creerJournalMoisPanel(final Date date, long debit, long credit, final Journal jrnl) {

    final JPanel panelMoisCompte = new JPanel();
    panelMoisCompte.setLayout(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;/*ww w .jav  a  2  s  .c om*/
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    panelMoisCompte.setBorder(BorderFactory.createTitledBorder(dateFormat.format(date)));

    // Date du mois
    panelMoisCompte.add(new JLabel(dateFormat.format(date)), c);

    // Totaux du mois
    c.gridx++;
    panelMoisCompte.add(new JLabel(" dbit : " + GestionDevise.currencyToString(debit)), c);
    c.gridx++;
    panelMoisCompte.add(new JLabel(" crdit : " + GestionDevise.currencyToString(credit)), c);

    // Bouton dtails
    JButton boutonShow = new JButton("+/-");
    boutonShow.setOpaque(false);
    boutonShow.setHorizontalAlignment(SwingConstants.LEFT);

    c.weightx = 0;
    c.gridx++;
    panelMoisCompte.add(boutonShow, c);

    boutonShow.addActionListener(new ActionListener() {
        private boolean isShow = false;
        private ListPanelEcritures listEcriture;

        public void actionPerformed(ActionEvent e) {

            System.err.println(this.isShow);

            // Afficher la JTable du compte
            if (!this.isShow) {
                final SQLElement element = Configuration.getInstance().getDirectory().getElement("ECRITURE");
                final SQLTable ecrTable = element.getTable();

                Calendar cal = Calendar.getInstance();

                cal.setTime(date);
                cal.set(Calendar.DATE, 1);
                Date inf = cal.getTime();

                cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));
                Date sup = cal.getTime();

                System.out.println("Inf : " + inf + " Sup : " + sup);
                Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", jrnl.getId());
                Where w2 = new Where(ecrTable.getField("DATE"), inf, sup);

                if (!UserManager.getInstance().getCurrentUser().getRights()
                        .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
                    // TODO Show Restricted acces in UI
                    w = w.and(new Where(ecrTable.getField("COMPTE_NUMERO"), "LIKE", "411%"));
                }

                this.listEcriture = new ListPanelEcritures(element, w.and(w2));
                this.listEcriture.setModificationVisible(false);
                this.listEcriture.setAjoutVisible(false);
                this.listEcriture.setSuppressionVisible(false);
                this.listEcriture.getListe().setSQLEditable(false);

                Dimension d;
                // Taille limite  200 maximum
                if (this.listEcriture.getListe().getPreferredSize().height > 200) {
                    d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, 200);
                } else {
                    d = new Dimension(this.listEcriture.getListe().getPreferredSize().width,
                            this.listEcriture.getListe().getPreferredSize().height + 30);
                }
                this.listEcriture.getListe().setPreferredSize(d);

                // c.gridy = 2;
                c.gridx = 0;
                c.gridy = 1;

                c.gridwidth = 4;
                c.weightx = 1;
                c.weighty = 1;
                c.fill = GridBagConstraints.BOTH;

                this.listEcriture.getListe().setSQLEditable(false);

                panelMoisCompte.add(this.listEcriture, c);
                this.listEcriture.getListe().getJTable().addMouseListener(new MouseAdapter() {
                    public void mousePressed(MouseEvent e) {
                        if (e.getButton() == MouseEvent.BUTTON3) {
                            JPopupMenu menu = new JPopupMenu();
                            menu.add(new AbstractAction("Voir la source") {
                                public void actionPerformed(ActionEvent e) {

                                    SQLRow row = base.getTable("ECRITURE")
                                            .getRow(listEcriture.getListe().getSelectedId());

                                    MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
                                }
                            });

                            menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y);

                        }
                    }
                });

            } else {

                panelMoisCompte.remove(this.listEcriture);
                System.out.println("Hide ListEcriture");

                panelMoisCompte.repaint();
                panelMoisCompte.revalidate();
            }

            this.isShow = !this.isShow;
            SwingUtilities.getRoot(panelMoisCompte).repaint();
        }
    });

    return panelMoisCompte;
}

From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java

/**
 * creates the layered pane if it does not already exists
 * //from  www  . j ava2 s .c om
 * @return layered pane
 */
private JLayeredPane getJLayeredPane() {
    if (jLayeredPane == null) {
        jLayeredPane = new JLayeredPane();
        jLayeredPane.setLayout(null);
        jLayeredPane.setOpaque(true);
        jLayeredPane.setBackground(Color.WHITE);
        jLayeredPane.add(getReader(), new Integer(0));

        // add antennas
        String[] antennaIds = null;
        try {
            antennaIds = controller.getReadPointNames();
        } catch (HardwareException ignored) {
        }
        for (int i = 0; i < antennaIds.length; i++) {
            createNewAntenna(antennaIds[i]);
        }
        jLayeredPane.add(getContextMenu());
        jLayeredPane.add(getMgmtSimMenu());

        // add mouse listener
        jLayeredPane.addMouseListener(new MouseAdapter() {

            // context menu
            public void mouseReleased(MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON3) {
                    Point posOnScreen = getJLayeredPane().getLocationOnScreen();
                    contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY());
                    contextMenu.setVisible(true);
                    mgmtSimMenu.setVisible(false);
                    setActiveContextMenu(contextMenu);
                } else {
                    contextMenu.setVisible(false);
                    mgmtSimMenu.setVisible(false);
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        selection.select(tags);
                    }
                }
            }

            // selection
            public void mousePressed(final MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON1) {
                    selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight"));
                    selection.setStartPoint(e.getPoint());
                    jLayeredPane.add(selection, new Integer(2));
                }
            }
        });

        // add drag listener
        jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent e) {
                if (selection.isActive()) {
                    selection.setCurrentPoint(e.getPoint());
                }
            }
        });
    }
    return jLayeredPane;
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView.java

@Override
public void refreshView(final ViewState state) {
    Rectangle visibleRect = null;
    if (this.tree != null) {
        visibleRect = this.tree.getVisibleRect();
    }/*from www . j  a  v a 2 s.  c o  m*/

    this.removeAll();

    this.actionsMenu = this.createPopupMenu(state);

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("WORKFLOWS");
    for (ModelGraph graph : state.getGraphs()) {
        root.add(this.buildTree(graph, state));
    }
    tree = new JTree(root);
    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    tree.add(this.actionsMenu);

    if (state.getSelected() != null) {
        // System.out.println("SELECTED: " + state.getSelected());
        TreePath treePath = this.getTreePath(root, state.getSelected());
        if (state.getCurrentMetGroup() != null) {
            treePath = this.getTreePath(treePath, state);
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_STATIC_METADATA))) {
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("static-metadata")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_PRECONDITIONS))) {
            if (treePath == null) {
                treePath = this.getTreePath(root, state.getSelected().getPreConditions());
            }
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("pre-conditions")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_POSTCONDITIONS))) {
            if (treePath == null) {
                treePath = this.getTreePath(root, state.getSelected().getPostConditions());
            }
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("post-conditions")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        }
        this.tree.expandPath(treePath);
        this.tree.setSelectionPath(treePath);
    }

    tree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            if (e.getPath().getLastPathComponent() instanceof DefaultMutableTreeNode) {
                DefaultTreeView.this.resetProperties(state);
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
                if (node.getUserObject() instanceof ModelGraph) {
                    state.setSelected((ModelGraph) node.getUserObject());
                    state.setCurrentMetGroup(null);
                    DefaultTreeView.this.notifyListeners();
                } else if (node.getUserObject().equals("static-metadata")
                        || node.getUserObject().equals("pre-conditions")
                        || node.getUserObject().equals("post-conditions")) {
                    state.setSelected((ModelGraph) ((DefaultMutableTreeNode) node.getParent()).getUserObject());
                    state.setCurrentMetGroup(null);
                    state.setProperty(EXPAND_STATIC_METADATA,
                            Boolean.toString(node.getUserObject().equals("static-metadata")));
                    state.setProperty(EXPAND_PRECONDITIONS,
                            Boolean.toString(node.getUserObject().equals("pre-conditions")));
                    state.setProperty(EXPAND_POSTCONDITIONS,
                            Boolean.toString(node.getUserObject().equals("post-conditions")));
                    DefaultTreeView.this.notifyListeners();
                } else if (node.getUserObject() instanceof ConcurrentHashMap) {
                    DefaultMutableTreeNode metNode = null;
                    String group = null;
                    Object[] path = e.getPath().getPath();
                    for (int i = path.length - 1; i >= 0; i--) {
                        if (((DefaultMutableTreeNode) path[i]).getUserObject() instanceof ModelGraph) {
                            metNode = (DefaultMutableTreeNode) path[i];
                            break;
                        } else if (((DefaultMutableTreeNode) path[i])
                                .getUserObject() instanceof ConcurrentHashMap) {
                            if (group == null) {
                                group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i])
                                        .getUserObject()).keySet().iterator().next();
                            } else {
                                group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i])
                                        .getUserObject()).keySet().iterator().next() + "/" + group;
                            }
                        }
                    }
                    ModelGraph graph = (ModelGraph) metNode.getUserObject();
                    state.setSelected(graph);
                    state.setCurrentMetGroup(group);
                    DefaultTreeView.this.notifyListeners();
                } else {
                    state.setSelected(null);
                    DefaultTreeView.this.notifyListeners();
                }
            }
        }

    });
    tree.setCellRenderer(new TreeCellRenderer() {

        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            if (node.getUserObject() instanceof String) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                JLabel label = new JLabel((String) node.getUserObject());
                label.setForeground(Color.blue);
                panel.add(label, BorderLayout.CENTER);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else if (node.getUserObject() instanceof ModelGraph) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                JLabel iconLabel = new JLabel(
                        ((ModelGraph) node.getUserObject()).getModel().getExecutionType() + ": ");
                iconLabel.setForeground(((ModelGraph) node.getUserObject()).getModel().getColor());
                iconLabel.setBackground(Color.white);
                JLabel idLabel = new JLabel(((ModelGraph) node.getUserObject()).getModel().getModelName());
                idLabel.setBackground(Color.white);
                panel.add(iconLabel, BorderLayout.WEST);
                panel.add(idLabel, BorderLayout.CENTER);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else if (node.getUserObject() instanceof ConcurrentHashMap) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                String group = (String) ((ConcurrentHashMap<String, String>) node.getUserObject()).keySet()
                        .iterator().next();
                JLabel nameLabel = new JLabel(group + " : ");
                nameLabel.setForeground(Color.blue);
                nameLabel.setBackground(Color.white);
                JLabel valueLabel = new JLabel(
                        ((ConcurrentHashMap<String, String>) node.getUserObject()).get(group));
                valueLabel.setForeground(Color.darkGray);
                valueLabel.setBackground(Color.white);
                panel.add(nameLabel, BorderLayout.WEST);
                panel.add(valueLabel, BorderLayout.EAST);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else {
                return new JLabel();
            }
        }

    });
    tree.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3 && DefaultTreeView.this.tree.getSelectionPath() != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) DefaultTreeView.this.tree
                        .getSelectionPath().getLastPathComponent();
                if (node.getUserObject() instanceof String && !(node.getUserObject().equals("pre-conditions")
                        || node.getUserObject().equals("post-conditions"))) {
                    return;
                }
                orderSubMenu.setEnabled(node.getUserObject() instanceof ModelGraph
                        && !((ModelGraph) node.getUserObject()).isCondition()
                        && ((ModelGraph) node.getUserObject()).getParent() != null);
                DefaultTreeView.this.actionsMenu.show(DefaultTreeView.this.tree, e.getX(), e.getY());
            }
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });
    this.scrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    this.add(this.scrollPane, BorderLayout.CENTER);
    if (visibleRect != null) {
        this.tree.scrollRectToVisible(visibleRect);
    }

    this.revalidate();
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

/**
 * Cree un JTable contenant les ecritures du compte pass en argument
 * //  w w w. j  a va 2  s  .  c o m
 * @param compte
 * @return null si aucune ecriture
 */
private JTable createJTableCompte(Compte compte) {

    // on cree la JTable
    final JTable tableTmp = creerJTable(compte);

    if (tableTmp != null) {

        // On met en place le renderer
        EcritureGrandLivreRenderer ecritureRenderer = new EcritureGrandLivreRenderer(
                ((TableSorter) tableTmp.getModel()));

        for (int j = 0; j < tableTmp.getColumnCount(); j++) {
            tableTmp.getColumnModel().getColumn(j).setCellRenderer(ecritureRenderer);
        }

        // Gestion de la souris sur la JTable
        tableTmp.addMouseListener(new MouseAdapter() {

            public void mousePressed(final MouseEvent mE) {

                if (mE.getButton() == MouseEvent.BUTTON3) {
                    JPopupMenu menuDroit = new JPopupMenu();

                    menuDroit.add(new AbstractAction("Voir la source") {

                        public void actionPerformed(ActionEvent e) {
                            int row = tableTmp.rowAtPoint(mE.getPoint());

                            TableSorter s = (TableSorter) tableTmp.getModel();

                            int modelIndex = s.modelIndex(row);
                            ConsultCompteModel consultCompteModel = ((ConsultCompteModel) s.getTableModel());
                            Ecriture ecriture = consultCompteModel.getEcritures().get(modelIndex);

                            MouvementSQLElement.showSource(ecriture.getIdMvt());

                        }
                    });
                    menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
                }
            }
        });

    }
    return tableTmp;
}

From source file:org.accada.hal.impl.sim.GraphicSimulator.java

/**
 * creates the layered pane if it does not already exists
 * /*from   w  w w .j a v  a2  s .c  o m*/
 * @return layered pane
 */
private JLayeredPane getJLayeredPane() {
    if (jLayeredPane == null) {
        jLayeredPane = new JLayeredPane();
        jLayeredPane.setLayout(null);
        jLayeredPane.setOpaque(true);
        jLayeredPane.setBackground(Color.WHITE);
        jLayeredPane.add(getReader(), new Integer(0));

        // add antennas
        String[] antennaIds = null;
        antennaIds = controller.getReadPointNames();
        for (int i = 0; i < antennaIds.length; i++) {
            createNewAntenna(antennaIds[i]);
        }
        jLayeredPane.add(getContextMenu());
        jLayeredPane.add(getMgmtSimMenu());

        // add mouse listener
        jLayeredPane.addMouseListener(new MouseAdapter() {

            // context menu
            public void mouseReleased(MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON3) {
                    Point posOnScreen = getJLayeredPane().getLocationOnScreen();
                    contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY());
                    contextMenu.setVisible(true);
                    mgmtSimMenu.setVisible(false);
                    setActiveContextMenu(contextMenu);
                } else {
                    contextMenu.setVisible(false);
                    mgmtSimMenu.setVisible(false);
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        selection.select(tags);
                    }
                }
            }

            // selection
            public void mousePressed(final MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON1) {
                    selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight"));
                    selection.setStartPoint(e.getPoint());
                    jLayeredPane.add(selection, new Integer(2));
                }
            }
        });

        // add drag listener
        jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent e) {
                if (selection.isActive()) {
                    selection.setCurrentPoint(e.getPoint());
                }
            }
        });
    }
    return jLayeredPane;
}

From source file:Filter3dTest.java

/**
 * Gets the mouse code for the button specified in this MouseEvent.
 *///  www .  j  a  va2s . com
public static int getMouseButtonCode(MouseEvent e) {
    switch (e.getButton()) {
    case MouseEvent.BUTTON1:
        return MOUSE_BUTTON_1;
    case MouseEvent.BUTTON2:
        return MOUSE_BUTTON_2;
    case MouseEvent.BUTTON3:
        return MOUSE_BUTTON_3;
    default:
        return -1;
    }
}

From source file:pt.lsts.neptus.plugins.sunfish.IridiumComms.java

@Override
public void mouseClicked(MouseEvent event, StateRenderer2D source) {
    if (event.getButton() != MouseEvent.BUTTON3) {
        super.mouseClicked(event, source);
        return;//from  w w  w  .  java 2  s  .co  m
    }

    final LocationType loc = source.getRealWorldLocation(event.getPoint());
    loc.convertToAbsoluteLatLonDepth();

    JPopupMenu popup = new JPopupMenu();

    if (IridiumManager.getManager().isActive()) {
        popup.add(I18n.text("Deactivate Polling")).addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                IridiumManager.getManager().stop();
            }
        });
    } else {
        popup.add(I18n.text("Activate Polling")).addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                IridiumManager.getManager().start();
            }
        });
    }

    popup.add(I18n.text("Select Iridium gateway")).addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            IridiumManager.getManager().selectMessenger(getConsole());
        }
    });

    popup.addSeparator();

    popup.add(I18n.textf("Send %vehicle a command via Iridium", getMainVehicleId()))
            .addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    sendIridiumCommand();
                }
            });

    popup.add(I18n.textf("Command %vehicle a plan via Iridium", getMainVehicleId()))
            .addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    commandPlanExecution();
                }
            });

    popup.add(I18n.textf("Subscribe to iridium device updates", getMainVehicleId()))
            .addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    ActivateSubscription activate = new ActivateSubscription();
                    activate.setDestination(0xFF);
                    activate.setSource(ImcMsgManager.getManager().getLocalId().intValue());
                    try {
                        IridiumManager.getManager().send(activate);
                        getConsole().post(Notification.success("Iridium message sent",
                                "1 Iridium messages were sent using "
                                        + IridiumManager.getManager().getCurrentMessenger().getName()));
                    } catch (Exception ex) {
                        GuiUtils.errorMessage(getConsole(), ex);
                    }
                }
            });

    popup.add(I18n.textf("Unsubscribe to iridium device updates", getMainVehicleId()))
            .addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    DeactivateSubscription deactivate = new DeactivateSubscription();
                    deactivate.setDestination(0xFF);
                    deactivate.setSource(ImcMsgManager.getManager().getLocalId().intValue());
                    try {
                        IridiumManager.getManager().send(deactivate);
                    } catch (Exception ex) {
                        GuiUtils.errorMessage(getConsole(), ex);
                    }
                }
            });

    popup.add("Set this as actual wave glider target").addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setWaveGliderTargetPosition(loc);
        }
    });

    popup.add("Set this as desired wave glider target").addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setWaveGliderDesiredPosition(loc);
        }
    });

    popup.addSeparator();

    popup.add(I18n.text("Send a text note")).addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            sendTextNote();
        }
    });

    popup.add("Add virtual drifter").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            VirtualDrifter d = new VirtualDrifter(loc, 0, 0.1);
            PropertiesEditor.editProperties(d, true);
            drifters.add(d);
            update();
        }
    });

    popup.show(source, event.getX(), event.getY());
}

From source file:ru.goodfil.catalog.ui.forms.OePanel.java

private void lstOesMouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3) {
        if (oes.size() > 0) {
            popupMenu1.show(lstOes, e.getX(), e.getY());
        }//  w w w  .j  a  va  2  s  .c  om
    }
}