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:com.clough.android.adbv.view.UpdateTableDialog.java

private void resultTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_resultTableMouseClicked
    // TODO add your handling code here:
    if (evt.getButton() == MouseEvent.BUTTON3) {
        int rowIndex;
        if ((rowIndex = validateRowSelection()) != -1) {
            showTableChangeOptionMenu(evt.getLocationOnScreen().x - getX(),
                    evt.getLocationOnScreen().y - getY(), rowIndex);
        }/*from w w  w  . j  a  va  2s. c o m*/
    }
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseMoved(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        _cp.mouseMoved(e);/*from w  w  w  .j  a v a 2 s  .  c  om*/
    } else {
        _cp.mouseMoved(e);
    }
}

From source file:org.jopenray.server.thinclient.DisplayReaderThread.java

private void processMouseEvent(int buttons, int mouseX, int mouseY) {
    buttons = buttons - 64;/*w  ww.  j  a v a2  s  . co  m*/
    if (this.lastMouseState == Integer.MIN_VALUE) {
        this.lastMouseState = buttons;
        this.lastMouseX = mouseX;
        this.lastMouseY = mouseY;
        return;
    }

    // Mouse move
    if (lastMouseX != mouseX || lastMouseY != mouseY) {
        sendMouseMoved(mouseX, mouseY);
    }

    // Mouse pressed/released

    int change = buttons ^ this.lastMouseState;

    if ((change & 1) > 0) {
        if ((buttons & 1) > 0) {
            System.out.println("DisplayReaderThread.processMouseEvent() BUTTON1 pressed");
            sendMousePressed(MouseEvent.BUTTON1, mouseX, mouseY);
        } else {
            System.out.println("DisplayReaderThread.processMouseEvent() BUTTON1 released");
            sendMouseReleased(MouseEvent.BUTTON1, mouseX, mouseY);
        }
    }
    if ((change & 2) > 0) {
        if ((buttons & 2) > 0) {
            System.out.println("DisplayReaderThread.processMouseEvent() BUTTON2 pressed");
            sendMousePressed(MouseEvent.BUTTON2, mouseX, mouseY);
        } else {
            sendMouseReleased(MouseEvent.BUTTON2, mouseX, mouseY);
        }
    }
    if ((change & 4) > 0) {
        if ((buttons & 4) > 0) {
            System.out.println("DisplayReaderThread.processMouseEvent() BUTTON3 pressed");
            sendMousePressed(MouseEvent.BUTTON3, mouseX, mouseY);
        } else {
            sendMouseReleased(MouseEvent.BUTTON3, mouseX, mouseY);
        }
    }
    if ((change & 8) > 0) {
        if ((buttons & 8) > 0) {
            System.out.println("DisplayReaderThread.processMouseEvent() mouse wheel up");
            sendMouseWheelUp(mouseX, mouseY);
        } else {
            // sendMouseReleased(MouseEvent.BUTTON3, mouseX, mouseY);
        }
    }
    if ((change & 16) > 0) {
        if ((buttons & 16) > 0) {
            System.out.println("DisplayReaderThread.processMouseEvent() mouse wheel down");
            sendMouseWheelDown(mouseX, mouseY);
        } else {
            // sendMouseReleased(MouseEvent.BUTTON3, mouseX, mouseY);
        }
    }

    this.lastMouseState = buttons;
    this.lastMouseX = mouseX;
    this.lastMouseY = mouseY;

}

From source file:pts4.googlemaps.Gmaps.java

public void createStage() {

    GeoPosition Utrecht = new GeoPosition(52.0907370, 5.1214200);
    /*// Create a waypoint painter that takes all the waypoints
     WaypointPainter<Waypoint> waypointPainter = new WaypointPainter<Waypoint>();
     waypointPainter.setWaypoints(waypoints);*/
    // Set the focus
    mapViewer.setZoom(10);//from   w  w  w. j a v a  2 s .c o m
    mapViewer.setAddressLocation(Utrecht);

    // Add interactions
    MouseInputListener mia = new PanMouseInputListener(mapViewer);

    mapViewer.addMouseListener(sa);
    mapViewer.addMouseMotionListener(sa);
    mapViewer.setOverlayPainter(sp);
    mapViewer.addMouseListener(mia);
    mapViewer.addMouseMotionListener(mia);
    //mapViewer.addMouseListener(new CenterMapListener(mapViewer));
    mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCenter(mapViewer));
    mapViewer.addKeyListener(new PanKeyListener(mapViewer));

    mapViewer.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent me) {

            //Rechter muisknop klik
            if (me.getButton() == MouseEvent.BUTTON3) {
                GeoPosition mousepoint = mapViewer.convertPointToGeoPosition(me.getPoint());
                Double lat1 = mousepoint.getLatitude();
                Double lng1 = mousepoint.getLongitude();
                Double lat2;
                Double lng2;

                for (MyWaypoint u : units) {
                    lat2 = u.getPosition().getLatitude();
                    lng2 = u.getPosition().getLongitude();

                    if (UnitControl.distFrom(lat1.floatValue(), lng1.floatValue(), lat2.floatValue(),
                            lng2.floatValue()) < (mapViewer.getZoom() * mapViewer.getZoom()
                                    * mapViewer.getZoom() * 2)) {
                        Platform.runLater(new Runnable() {

                            @Override
                            public void run() {

                                MessageBox msg = new MessageBox("Send message to unit " + u.getLabel() + "?",
                                        MessageBoxType.YES_NO);
                                msg.showAndWait();

                                if (msg.getMessageBoxResult() == MessageBoxResult.YES) {

                                    try {
                                        if (gui.messageToUnit(u.getLabel()) == false) {
                                            MessageBox msg2 = new MessageBox("Error connecting to unit",
                                                    MessageBoxType.OK_ONLY);
                                            msg2.show();

                                        }
                                    } catch (IOException ex) {
                                        Logger.getLogger(Gmaps.class.getName()).log(Level.SEVERE, null, ex);
                                    }

                                } else {
                                    //msg.close();
                                }
                            }

                        });
                    }
                }

            } else {
                if (createUnit == true) {
                    Color kleur = null;
                    if (type == 1) {
                        kleur = Color.cyan;
                    }
                    if (type == 2) {
                        kleur = Color.YELLOW;
                    }
                    if (type == 3) {
                        kleur = Color.RED;
                    }
                    GeoPosition plek = mapViewer.convertPointToGeoPosition(me.getPoint());
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            gui.setUnit(plek.getLongitude(), plek.getLatitude());
                        }
                    });

                    for (MyWaypoint p : orders) {
                        if (p.getLabel().equals(id)) {
                            orders.remove(p);
                        }
                    }
                    orders.add(new MyWaypoint(id, kleur, plek));
                    for (Unit a : EmergencyUnits) {
                        if (a.getName().equals(id)) {
                            GeoPosition plek2 = new GeoPosition(a.getLatidude(), a.getLongitude());
                            ChatMessage chat = new ChatMessage(
                                    gui.getIncidentorder() + "\n" + gui.getUnitDescription(), "Meldkamer", id);
                            server.sendMessage(chat);
                            a.setIncident(incidentstring);
                            new Animation(plek, plek2, id, orders, units, Gmaps.this, waypointPainter3);
                        }
                    }
                    createUnit = false;
                    // Create a waypoint painter that takes all the waypoints
                    waypointPainter3.setWaypoints(orders);
                    waypointPainter3.setRenderer(new FancyWaypointRenderer());
                    draw();
                }

                if (simulation == true) {
                    Color kleur = null;
                    if (type == 1) {
                        kleur = Color.cyan;
                    }
                    if (type == 2) {
                        kleur = Color.YELLOW;
                    }
                    if (type == 3) {
                        kleur = Color.RED;
                    }
                    GeoPosition plek = mapViewer.convertPointToGeoPosition(me.getPoint());
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            gui.setUnit(plek.getLongitude(), plek.getLatitude());
                        }
                    });

                    for (MyWaypoint p : orders) {
                        if (p.getLabel().equals(id)) {
                            orders.remove(p);
                        }
                    }
                    orders.add(new MyWaypoint(id, kleur, plek));
                    for (Unit a : EmergencyUnits) {
                        if (a.getName().equals(id)) {
                            GeoPosition plek2 = new GeoPosition(a.getLatidude(), a.getLongitude());
                            ChatMessage chat = new ChatMessage(
                                    gui.getIncidentorder() + "\n" + gui.getUnitDescription(), "Meldkamer", id);
                            server.sendMessage(chat);
                            a.setIncident(incidentstring);
                            Point2D fire = mapViewer.getTileFactory().geoToPixel(plek, mapViewer.getZoom());
                            simulations = new Simulation(plek, plek2, id, orders, units, Gmaps.this,
                                    waypointPainter3);
                            new SimulationAnimation(simulations, plek, plek2, id, orders, units, Gmaps.this,
                                    waypointPainter3);

                        }
                    }
                    createUnit = false;
                    // Create a waypoint painter that takes all the waypoints
                    waypointPainter3.setWaypoints(orders);
                    waypointPainter3.setRenderer(new FancyWaypointRenderer());
                    /*
                     List<Painter<JXMapViewer>> painters = new ArrayList<Painter<JXMapViewer>>();
                     painters.add(simulations);
                     CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(painters);
                                
                     mapViewer.setOverlayPainter(painter);*/
                    draw();
                    simulation = false;
                }

                if (weather == true) {
                    GeoPosition mousepoint = mapViewer.convertPointToGeoPosition(me.getPoint());
                    Double lat1 = mousepoint.getLatitude();
                    Double lng1 = mousepoint.getLongitude();
                    try {
                        new Weather(lng1, lat1);
                    } catch (IOException ex) {
                        Logger.getLogger(Gmaps.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (JSONException ex) {
                        Logger.getLogger(Gmaps.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    }); // end MouseAdapter

}

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

private JTable createTable(final ViewState state) {
    JTable table;//from   ww w.ja  va2  s.  c om
    final ModelGraph selected = state.getSelected();
    if (selected != null) {
        final Vector<Vector<String>> rows = new Vector<Vector<String>>();
        ConcurrentHashMap<String, String> keyToGroupMap = new ConcurrentHashMap<String, String>();
        Metadata staticMet = selected.getModel().getStaticMetadata();
        Metadata inheritedMet = selected.getInheritedStaticMetadata(state);
        Metadata completeMet = new Metadata();
        if (staticMet != null) {
            completeMet.replaceMetadata(staticMet.getSubMetadata(state.getCurrentMetGroup()));
        }
        if (selected.getModel().getExtendsConfig() != null) {
            for (String configGroup : selected.getModel().getExtendsConfig()) {
                Metadata extendsMetadata = state.getGlobalConfigGroups().get(configGroup).getMetadata()
                        .getSubMetadata(state.getCurrentMetGroup());
                for (String key : extendsMetadata.getAllKeys()) {
                    if (!completeMet.containsKey(key)) {
                        keyToGroupMap.put(key, configGroup);
                        completeMet.replaceMetadata(key, extendsMetadata.getAllMetadata(key));
                    }
                }
            }
        }
        if (inheritedMet != null) {
            Metadata inheritedMetadata = inheritedMet.getSubMetadata(state.getCurrentMetGroup());
            for (String key : inheritedMetadata.getAllKeys()) {
                if (!completeMet.containsKey(key)) {
                    keyToGroupMap.put(key, "__inherited__");
                    completeMet.replaceMetadata(key, inheritedMetadata.getAllMetadata(key));
                }
            }
        }
        List<String> keys = completeMet.getAllKeys();
        Collections.sort(keys);
        for (String key : keys) {
            if (key.endsWith("/envReplace")) {
                continue;
            }
            String values = StringUtils.join(completeMet.getAllMetadata(key), ",");
            Vector<String> row = new Vector<String>();
            row.add(keyToGroupMap.get(key));
            row.add(key);
            row.add(values);
            row.add(Boolean.toString(Boolean.parseBoolean(completeMet.getMetadata(key + "/envReplace"))));
            rows.add(row);
        }
        table = new JTable();// rows, new Vector<String>(Arrays.asList(new
                             // String[] { "key", "values", "envReplace" })));
        table.setModel(new AbstractTableModel() {
            public String getColumnName(int col) {
                switch (col) {
                case 0:
                    return "group";
                case 1:
                    return "key";
                case 2:
                    return "values";
                case 3:
                    return "envReplace";
                default:
                    return null;
                }
            }

            public int getRowCount() {
                return rows.size() + 1;
            }

            public int getColumnCount() {
                return 4;
            }

            public Object getValueAt(int row, int col) {
                if (row >= rows.size()) {
                    return null;
                }
                String value = rows.get(row).get(col);
                if (value == null && col == 3) {
                    return "false";
                }
                if (value == null && col == 0) {
                    return "__local__";
                }
                return value;
            }

            public boolean isCellEditable(int row, int col) {
                if (row >= rows.size()) {
                    return selected.getModel().getStaticMetadata().containsGroup(state.getCurrentMetGroup());
                }
                if (col == 0) {
                    return false;
                }
                String key = rows.get(row).get(1);
                return key == null || (selected.getModel().getStaticMetadata() != null
                        && selected.getModel().getStaticMetadata().containsKey(getKey(key, state)));
            }

            public void setValueAt(Object value, int row, int col) {
                if (row >= rows.size()) {
                    Vector<String> newRow = new Vector<String>(
                            Arrays.asList(new String[] { null, null, null, null }));
                    newRow.add(col, (String) value);
                    rows.add(newRow);
                } else {
                    Vector<String> rowValues = rows.get(row);
                    rowValues.add(col, (String) value);
                    rowValues.remove(col + 1);
                }
                this.fireTableCellUpdated(row, col);
            }

        });
        MyTableListener tableListener = new MyTableListener(state);
        table.getModel().addTableModelListener(tableListener);
        table.getSelectionModel().addListSelectionListener(tableListener);
    } else {
        table = new JTable(new Vector<Vector<String>>(),
                new Vector<String>(Arrays.asList(new String[] { "key", "values", "envReplace" })));
    }

    // table.setFillsViewportHeight(true);
    table.setSelectionBackground(Color.cyan);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableCellRenderer cellRenderer = new TableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            JLabel field = new JLabel((String) value);
            if (column == 0) {
                field.setForeground(Color.gray);
            } else {
                if (isSelected) {
                    field.setBorder(new EtchedBorder(1));
                }
                if (table.isCellEditable(row, 1)) {
                    field.setForeground(Color.black);
                } else {
                    field.setForeground(Color.gray);
                }
            }
            return field;
        }

    };
    TableColumn groupCol = table.getColumnModel().getColumn(0);
    groupCol.setPreferredWidth(75);
    groupCol.setCellRenderer(cellRenderer);
    TableColumn keyCol = table.getColumnModel().getColumn(1);
    keyCol.setPreferredWidth(200);
    keyCol.setCellRenderer(cellRenderer);
    TableColumn valuesCol = table.getColumnModel().getColumn(2);
    valuesCol.setPreferredWidth(300);
    valuesCol.setCellRenderer(cellRenderer);
    TableColumn envReplaceCol = table.getColumnModel().getColumn(3);
    envReplaceCol.setPreferredWidth(75);
    envReplaceCol.setCellRenderer(cellRenderer);

    table.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3 && DefaultPropView.this.table.getSelectedRow() != -1) {
                int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition());
                String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state);
                Metadata staticMet = state.getSelected().getModel().getStaticMetadata();
                override.setVisible(staticMet == null || !staticMet.containsKey(key));
                delete.setVisible(staticMet != null && staticMet.containsKey(key));
                tableMenu.show(DefaultPropView.this.table, e.getX(), e.getY());
            }
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });

    return table;
}

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

public JTable creerJTable(ClasseCompte ccTmp) { // NO_UCD

    final PlanComptableGModel model;
    if (this.radioCompteDeveloppe.isSelected()) {
        model = new PlanComptableGModel(ccTmp, 3);
    } else if (this.radioCompteAbrege.isSelected()) {
        model = new PlanComptableGModel(ccTmp, 2);
    } else {//w w w.  ja v a 2  s  .  com
        model = new PlanComptableGModel(ccTmp, 1);
    }

    final JTable table = new JTable(model) {
        public JToolTip createToolTip() {
            JMultiLineToolTip t = new JMultiLineToolTip();
            t.setFixedWidth(500);
            return t;
        }
    };

    table.getColumnModel().getColumn(0).setCellRenderer(new PlanComptableCellRenderer(0));
    table.getColumnModel().getColumn(1).setCellRenderer(new PlanComptableCellRenderer(0));

    // TODO calcul de la taille de la colone numero de compte
    table.getColumnModel().getColumn(0).setMaxWidth(90);

    table.getTableHeader().setReorderingAllowed(false);

    table.addMouseMotionListener(new MouseMotionAdapter() {
        int lastRow = -1;

        public void mouseMoved(final MouseEvent e) {

            final Point p = new Point(e.getX(), e.getY());

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    final int row = table.rowAtPoint(p);
                    if (lastRow != row) {
                        lastRow = row;
                        String strTmp = ((Compte) (model.getComptes().get(lastRow))).getInfos();

                        if (strTmp.length() != 0) {
                            table.setToolTipText(strTmp);
                        } else {
                            table.setToolTipText(null);
                        }

                    }
                }
            });

        }
    });

    if (this.actionClickDroit != null) {
        // System.out.println("Ajout menu droit");
        table.addMouseListener(new MouseAdapter() {

            public void mousePressed(MouseEvent e) {

                if (e.getButton() == MouseEvent.BUTTON3) {
                    actionDroitTable(e, table);
                }
            }
        });
    }

    // Enable row selection (default)
    /**
     * table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true);
     * 
     * table.setSelectionMode(table.getSelectionModel().MULTIPLE_INTERVAL_SELECTION);
     */

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            int selectedRow = table.getSelectedRow();
            if (selectedRow < 0) {
                // Pas de selection
                textInfos.setText("Pas de compte slctionn");
            } else {
                textInfos.setText(((Compte) (model.getComptes().get(selectedRow))).getInfos());
            }
        }
    });

    return table;
}

From source file:com.clough.android.adbv.view.MainFrame.java

public MainFrame(IOManager ioManager, HistoryManager historyManager) {
    this();//from   w w w  .ja v a  2 s  .c  om
    this.ioManager = ioManager;
    this.historyManager = historyManager;
    ioManager.addConnectionLostListener(new IOManager.ConnectionLostListener() {
        @Override
        public void onDisconnect() {
            showDeviceDisconnectedDialog();
        }
    });

    new SwingWorker<Void, Void>() {
        @Override
        protected Void doInBackground() throws Exception {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
            try {
                applicationID = MainFrame.this.ioManager.getApplicationID();
                deviceName = MainFrame.this.ioManager.getDeviceName();
                databaseName = MainFrame.this.ioManager.getDatabaseName();
                setTitle(ValueHolder.WINDOW_TITLE + " - (" + deviceName + " - " + applicationID + ")");
            } catch (IOManagerException ex) {
                showDeviceDisconnectedDialog();
            }
            return null;
        }

        @Override
        protected void done() {
            closeProgressDialog();
        }

    }.execute();
    showProgressDialog(true, 0, "Waiting for device/app info");

    refreshDatabase();

    tableInfoTree.setCellRenderer(new DefaultTreeCellRenderer() {

        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
                boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
            DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) value;
            String nodeString = String.valueOf(dmtn.getUserObject());
            ImageIcon selectedImageIcon = null;
            if (nodeString.equals(databaseName)) {
                selectedImageIcon = ValueHolder.Icons.DATABASE;
            } else {
                l: for (int i = 0; i < tables.length; i++) {
                    String tableName = tables[i];
                    if (tableName.equals(nodeString)) {
                        selectedImageIcon = ValueHolder.Icons.TABLE;
                        break;
                    } else if (i == tables.length - 1) {
                        for (int p = 0; p < tables.length; p++) {
                            for (int j = 0; j < columns[p].length; j++) {
                                String columnName = columns[p][j];
                                if (columnName.equals(nodeString)) {
                                    selectedImageIcon = ValueHolder.Icons.PENCIL;
                                    break l;
                                } else if (j == columns[p].length - 1) {
                                    for (int q = 0; q < tables.length; q++) {
                                        for (int r = 0; r < columns[q].length; r++) {
                                            for (int k = 0; k < columnInfos[q][r].length; k++) {
                                                String columnInfo = columnInfos[q][r][k];
                                                if (columnInfo.equals(nodeString)) {
                                                    switch (k) {
                                                    case 0: {
                                                        selectedImageIcon = ValueHolder.Icons.HASH_TAG;
                                                        break l;
                                                    }
                                                    case 1: {
                                                        selectedImageIcon = ValueHolder.Icons.BLUE;
                                                        break l;
                                                    }
                                                    case 2: {
                                                        selectedImageIcon = ValueHolder.Icons.ORANGE;
                                                        break l;
                                                    }
                                                    case 3: {
                                                        selectedImageIcon = ValueHolder.Icons.GREEN;
                                                        break l;
                                                    }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            setIcon(selectedImageIcon);
            return this;
        }

    });

    tableInfoTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent evt) {
            Object[] data = evt.getPath().getPath();
            selectedTreeNodeValue = String.valueOf(data[data.length - 1]);
        }
    });

    tableInfoTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getButton() == MouseEvent.BUTTON3) {
                if (selectedTreeNodeValue.equals(databaseName)) {
                    showTreeNodePopup(evt.getX(), evt.getY(), true);
                } else {
                    for (String table : tables) {
                        if (table.equals(selectedTreeNodeValue)) {
                            showTreeNodePopup(evt.getX(), evt.getY(), false);
                            break;
                        }
                    }
                }
            } else if (evt.getClickCount() >= 2) {
                queryingTextArea.setText(queryingTextArea.getText() + "`" + selectedTreeNodeValue + "`");
            }
        }

    });

    currentHistoryList = historyManager.getHistoryList();
    for (int i = 0; i < currentHistoryList.size(); i++) {
        String[] history = currentHistoryList.get(i);
        historyContainingPanel.add(
                new HistoryItemPanel(i + 1, history[0].equals(applicationID), history[1], queryingTextArea));
    }
    adjustHistoryScrollbar();
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                MainFrame.this.historyManager.saveApplicationDb();
            } catch (HistoryManagerException ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage(), "Application history saving",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }));

}

From source file:edu.harvard.mcz.imagecapture.ImageZoomPanel.java

@Override
public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) {
        Point clickAt = e.getPoint();
        Dimension size = jLabel.getSize();
        jLabel.zoomIn();/*from  w  w w  .j  av  a  2  s.co m*/
        jLabel.repaint();
        jLabel.doLayout();
        jLabel.centerOn(clickAt);
        jLabel.invalidate();
        jScrollPane.revalidate();
        jScrollPane.getParent().validate();
        jScrollPane.setVisible(false);
        jScrollPane.setVisible(true);
        jScrollPane.validate();
        jScrollPane.doLayout();
        zoomIn();
        zoomOut();
    } else if (e.getButton() == MouseEvent.BUTTON3) {
        Point clickAt = e.getPoint();
        zoomOut();
        jLabel.centerOn(clickAt);
    }
}

From source file:org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement.java

public SQLComponent createComponent() {

    return new BaseSQLComponent(this) {

        private ValidState validVarName;
        private JRadioButton radioVal = new JRadioButton("Valeur");
        private JRadioButton radioFormule = new JRadioButton("Formule");

        private final JTextField textValeur = new JTextField();
        // private final ITextArea textFormule = new ITextArea();
        private final VariableTree treeVariable = new VariableTree();
        private final JTextField textNom = new JTextField();
        private final JLabel labelWarningBadVar = new JLabelWarning();
        private ElementComboBox comboSelSal;
        private EditFrame edit = null;
        private final SQLJavaEditor textFormule = new SQLJavaEditor(getMapTree());

        public void addViews() {
            this.setLayout(new GridBagLayout());
            final GridBagConstraints c = new DefaultGridBagConstraints();

            this.validVarName = null;
            this.textFormule.setEditable(false);

            // Arbre des variables
            JScrollPane sc = new JScrollPane(this.treeVariable);
            sc.setPreferredSize(new Dimension(150, sc.getPreferredSize().height));

            this.treeVariable.addMouseListener(new MouseAdapter() {
                public void mousePressed(final MouseEvent mE) {
                    if (mE.getButton() == MouseEvent.BUTTON3) {
                        JPopupMenu menuDroit = new JPopupMenu();

                        TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x,
                                mE.getPoint().y);

                        final Object obj = path.getLastPathComponent();

                        if ((obj == null) || !(obj instanceof VariableRowTreeNode)) {
                            return;
                        }/*ww  w  .j  av a2  s.co m*/

                        menuDroit.add(new AbstractAction("Editer") {
                            public void actionPerformed(ActionEvent e) {
                                if (edit == null) {
                                    edit = new EditFrame(getElement(), EditFrame.MODIFICATION);
                                }

                                System.err.println("Action performed");

                                if (obj != null) {
                                    System.err.println("Object not null --> " + obj.toString());
                                    if (obj instanceof VariableRowTreeNode) {
                                        System.err.println("Object VariableRowTreeNode");
                                        VariableRowTreeNode varNode = (VariableRowTreeNode) obj;

                                        edit.selectionId(varNode.getID(), 1);
                                        edit.setVisible(true);
                                    }
                                }
                            }
                        });
                        menuDroit.show((Component) mE.getSource(), mE.getPoint().x, mE.getPoint().y);
                    } else {
                        if (mE.getClickCount() == 2) {
                            TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x,
                                    mE.getPoint().y);
                            Object obj = path.getLastPathComponent();

                            if (obj != null) {
                                if (obj instanceof FormuleTreeNode) {
                                    final FormuleTreeNode n = (FormuleTreeNode) obj;

                                    int start = textFormule.getSelectionStart();
                                    String tmp = textFormule.getText();
                                    textFormule.setText(tmp.substring(0, start) + n.getTextValue()
                                            + tmp.substring(start, tmp.length()));
                                }
                            }
                        }
                    }
                }
            });

            JPanel panelDroite = new JPanel();
            panelDroite.setLayout(new GridBagLayout());

            // Categorie
            JTextField textCategorie = new JTextField();
            c.fill = GridBagConstraints.HORIZONTAL;
            c.gridheight = 1;
            c.gridx = 1;
            c.gridy = 0;
            JLabel labelCategorie = new JLabel("Catgorie");
            panelDroite.add(labelCategorie, c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(textCategorie, c);
            c.gridwidth = 1;

            // Nom
            c.fill = GridBagConstraints.HORIZONTAL;
            c.gridheight = 1;
            c.gridx = 1;
            c.gridy++;
            JLabel labelNom = new JLabel("Nom");
            panelDroite.add(labelNom, c);

            c.gridx++;
            c.weightx = 1;
            panelDroite.add(this.textNom, c);

            this.textNom.getDocument().addDocumentListener(new SimpleDocumentListener() {
                @Override
                public void update(DocumentEvent e) {
                    updateValidVarName();
                }
            });

            c.gridx++;
            c.weightx = 0;
            panelDroite.add(this.labelWarningBadVar, c);

            // Description
            JLabel labelInfos = new JLabel(getLabelFor("INFOS"));
            ITextArea textInfos = new ITextArea();
            c.gridy++;
            c.gridx = 1;
            c.gridwidth = 1;
            c.weightx = 0;
            panelDroite.add(labelInfos, c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1;
            c.weighty = 0;
            panelDroite.add(textInfos, c);

            // Valeur
            c.gridx = 1;
            c.gridy++;
            c.gridwidth = 1;
            c.weightx = 0;
            panelDroite.add(this.radioVal, c);

            c.gridx++;
            c.weightx = 1;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(this.textValeur, c);

            c.gridwidth = 1;
            c.gridx = 1;
            c.gridy++;
            panelDroite.add(this.radioFormule, c);

            c.gridx++;
            c.weightx = 1;
            c.weighty = 1;
            c.fill = GridBagConstraints.BOTH;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(this.textFormule, c);
            c.gridwidth = 1;

            ButtonGroup group = new ButtonGroup();
            group.add(this.radioVal);
            group.add(this.radioFormule);

            this.radioVal.setSelected(true);
            setFormuleEnabled(false);

            this.radioVal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    setFormuleEnabled(false);
                }
            });
            this.radioFormule.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    setFormuleEnabled(true);
                }
            });

            c.gridy++;
            c.gridx = 1;
            c.weighty = 0;
            c.weightx = 0;
            c.fill = GridBagConstraints.HORIZONTAL;

            this.comboSelSal = new ElementComboBox(false);
            this.comboSelSal.init(getDirectory().getElement(SalarieSQLElement.class));

            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 0;
            panelDroite.add(this.comboSelSal, c);
            c.gridwidth = 1;

            JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sc, panelDroite);

            c.fill = GridBagConstraints.BOTH;
            c.gridx = 0;
            c.gridy = 0;
            c.weightx = 1;
            c.weighty = 1;
            this.add(split, c);

            this.addRequiredSQLObject(this.textNom, "NOM");
            this.addSQLObject(this.textValeur, "VALEUR");
            this.addSQLObject(this.textFormule, "FORMULE");
            this.addSQLObject(textCategorie, "CATEGORIE");
            this.addSQLObject(textInfos, "INFOS");

            this.comboSelSal.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    // TODO Auto-generated method stub
                    textFormule.setSalarieID(comboSelSal.getSelectedId());
                }
            });
        }

        @Override
        public synchronized ValidState getValidState() {
            return super.getValidState().and(this.validVarName);
        }

        private void setFormuleEnabled(boolean b) {

            if (b) {
                this.textValeur.setText("");
            } else {
                this.textFormule.setText("");
            }

            this.textValeur.setEditable(!b);
            this.textValeur.setEnabled(!b);
            this.textFormule.setEditable(b);
            this.textFormule.setEnabled(b);
            this.treeVariable.setEnabled(b);
            this.treeVariable.setEditable(b);
        }

        private void setValidVarName(ValidState s) {
            if (!s.equals(this.validVarName)) {
                this.validVarName = s;
                final boolean warningVisible = !s.isValid();
                if (warningVisible)
                    this.labelWarningBadVar.setText(s.getValidationText());
                this.labelWarningBadVar.setVisible(warningVisible);
                this.fireValidChange();
            }
        }

        private void updateValidVarName() {
            this.setValidVarName(this.computeValidVarName());
        }

        private ValidState computeValidVarName() {
            // on vrifie si la syntaxe de la variable est correct (chiffre lettre et _)
            final String varName = this.textNom.getText().trim();

            System.err.println("Verification de la validit du nom de la variable.");

            if (varName.length() == 0) {
                return VAR_NO_NAME;
            }

            // ne contient que des chiffre lettre et _ et ne commence pas par un chiffre
            if (!isJavaVar(varName)) {
                return VAR_NAME_NOT_CORRECT;
            }

            // on vrifie que la variable n'existe pas dja
            SQLSelect selAllVarName = new SQLSelect(getTable().getBase());

            selAllVarName.addSelect(VariablePayeSQLElement.this.getTable().getField("ID"));
            Where w = new Where(VariablePayeSQLElement.this.getTable().getField("NOM"), "=", varName);
            w = w.and(new Where(VariablePayeSQLElement.this.getTable().getKey(), "!=", getSelectedID()));
            selAllVarName.setWhere(w);

            String reqAllVarName = selAllVarName.asString();// + " AND '" + varName.trim() + "'
            // REGEXP VARIABLE_PAYE.NOM";
            Object[] objKeysRowName = ((List) getTable().getBase().getDataSource().execute(reqAllVarName,
                    new ArrayListHandler())).toArray();

            if (objKeysRowName.length > 0) {
                return VAR_ALREADY_EXIST;
            } else {

                // Impossible de crer une variable du meme nom qu'un champ du salarie
                if (isForbidden(varName))
                    return VAR_ALREADY_EXIST;

                this.textFormule.setVarAssign(varName);
                return ValidState.getTrueInstance();
            }
        }

        private boolean isJavaVar(String s) {
            if ((s.charAt(0) >= '0') && ((s.charAt(0) <= '9'))) {
                System.err.println("Erreur la variable commence par un chiffre!!");
                return false;
            } else {
                for (int i = 0; i < s.length(); i++) {

                    if (!(((s.charAt(i) >= '0') && (s.charAt(i) <= '9'))
                            || (s.charAt(i) >= 'a') && (s.charAt(i) <= 'z')
                            || (s.charAt(i) >= 'A') && (s.charAt(i) <= 'Z') || (s.charAt(i) == '_'))) {
                        System.err.println("Erreur la variable contient un caractere incorrect!!");
                        return false;
                    }
                }

                return (!CTokenMarker.getKeywords().isExisting(s));
            }
        }

        @Override
        public void select(SQLRowAccessor r) {

            super.select(r);
            // System.err.println("Select RowAccess -------> " + r.getID() + " For Object " +
            // this.hashCode());
            if (r != null) {
                if (r.getString("FORMULE").trim().length() == 0) {
                    this.radioVal.setSelected(true);
                    setFormuleEnabled(false);
                } else {
                    this.radioFormule.setSelected(true);
                    setFormuleEnabled(true);
                }

                this.textFormule.setVarAssign(r.getString("NOM"));
            }

            this.updateValidVarName();
        }
    };
}

From source file:com.neurotec.samples.panels.EnrollFromScanner.java

@Override
protected void initGUI() {
    panelMain = new JPanel();
    panelScanners = new JPanel();
    scrollPaneList = new JScrollPane();
    scannerList = new JList();
    panelButtons = new JPanel();
    btnRefresh = new JButton();
    btnScan = new JButton();
    btnCancel = new JButton();
    btnForce = new JButton();
    cbAutomatic = new JCheckBox();
    scrollPane = new JScrollPane();
    panelSouth = new JPanel();
    panelInfo = new JPanel();
    lblInfo = new JLabel();
    panelSave = new JPanel();
    btnIdentifyPatient = new JButton();
    btnRegisterPatient = new JButton();
    cbShowProcessed = new JCheckBox();

    setLayout(new BorderLayout());

    panelMain.setLayout(new BorderLayout());

    panelScanners.setBorder(BorderFactory.createTitledBorder("Scanners list"));
    panelScanners.setLayout(new BorderLayout());

    scrollPaneList.setPreferredSize(new Dimension(0, 90));

    scannerList.setModel(new DefaultListModel());
    scannerList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scannerList.setBorder(LineBorder.createBlackLineBorder());
    scrollPaneList.setViewportView(scannerList);

    panelScanners.add(scrollPaneList, BorderLayout.CENTER);

    panelButtons.setLayout(new FlowLayout(FlowLayout.LEADING));

    btnRefresh.setText("Refresh list");
    panelButtons.add(btnRefresh);/*  w  w w .  ja  v a2s . c  o  m*/

    btnScan.setText("Scan");
    panelButtons.add(btnScan);

    btnCancel.setText("Cancel");
    btnCancel.setEnabled(false);
    panelButtons.add(btnCancel);

    btnForce.setText("Force");
    panelButtons.add(btnForce);

    cbAutomatic.setSelected(true);
    cbAutomatic.setText("Scan automatically");
    panelButtons.add(cbAutomatic);

    panelScanners.add(panelButtons, BorderLayout.SOUTH);

    panelMain.add(panelScanners, BorderLayout.NORTH);
    panelMain.add(scrollPane, BorderLayout.CENTER);

    panelSouth.setLayout(new BorderLayout());

    panelInfo.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
    panelInfo.setLayout(new GridLayout(1, 1));

    lblInfo.setText(" ");
    panelInfo.add(lblInfo);

    panelSouth.add(panelInfo, BorderLayout.NORTH);

    panelSave.setLayout(new FlowLayout(FlowLayout.LEADING));

    btnIdentifyPatient.setText("Identify Patient");
    btnIdentifyPatient.setEnabled(false);
    panelSave.add(btnIdentifyPatient);

    btnRegisterPatient.setText("Register Patient");
    btnRegisterPatient.setEnabled(false);
    panelSave.add(btnRegisterPatient);

    cbShowProcessed.setSelected(true);
    cbShowProcessed.setText("Show processed image");
    panelSave.add(cbShowProcessed);

    panelSouth.add(panelSave, BorderLayout.SOUTH);

    panelMain.add(panelSouth, BorderLayout.SOUTH);

    add(panelMain, BorderLayout.CENTER);

    panelLicensing = new LicensingPanel(requiredLicenses, optionalLicenses);
    add(panelLicensing, java.awt.BorderLayout.NORTH);

    fcImage = new JFileChooser();
    fcImage.setFileFilter(new Utils.ImageFileFilter(NImages.getSaveFileFilter()));
    fcTemplate = new JFileChooser();
    view = new NFingerView();
    view.setShownImage(ShownImage.RESULT);
    view.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent ev) {
            super.mouseClicked(ev);
            if (ev.getButton() == MouseEvent.BUTTON3) {
                cbShowProcessed.doClick();
            }
        }

    });
    scrollPane.setViewportView(view);

    btnRefresh.addActionListener(this);
    btnScan.addActionListener(this);
    btnCancel.addActionListener(this);
    btnForce.addActionListener(this);
    btnIdentifyPatient.addActionListener(this);
    btnRegisterPatient.addActionListener(this);
    cbShowProcessed.addActionListener(this);
    scannerList.addListSelectionListener(new ScannerSelectionListener());
}