Example usage for java.awt.event MouseEvent BUTTON1

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

Introduction

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

Prototype

int BUTTON1

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

Click Source Link

Document

Indicates mouse button #1; used by #getButton .

Usage

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 va  2 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:com.tocea.scertify.eclipse.scertifycode.ui.stats.views.GraphStatsView.java

/**
 * Creates the master view containing the chart.
 * //from  w  ww .ja  v  a2  s  .c  o  m
 * @param parent
 *            the parent composite
 * @return the chart composite
 */
public Composite createMasterView(final Composite parent) {

    // create the date set for the chart
    this.mPieDataset = new GraphPieDataset();
    // this.mPieDataset.setShowAllCategories(this.mShowAllCategoriesAction.isChecked());
    this.mPieDataset.setShowAllCategories(true);
    this.mGraph = createChart(this.mPieDataset);

    // creates the chart component
    // final Composite embeddedComposite = new Composite(parent, SWT.EMBEDDED);
    // embeddedComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    // experimental usage of JFreeChart SWT
    // the composite to harbor the Swing chart control
    ChartComposite embeddedComposite = new ChartComposite(parent, SWT.NONE, mGraph, true);
    embeddedComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    embeddedComposite.addChartMouseListener(new ChartMouseListener() {

        public void chartMouseClicked(final ChartMouseEvent event) {

            final MouseEvent trigger = event.getTrigger();
            if (trigger.getButton() == MouseEvent.BUTTON1 && event.getEntity() instanceof PieSectionEntity) {

                // && trigger.getClickCount() == 2 //doubleclick not correctly detected with the SWT composite

                GraphStatsView.this.mMasterComposite.getDisplay().syncExec(new Runnable() {

                    public void run() {

                        GraphStatsView.this.mIsDrilledDown = true;
                        GraphStatsView.this.mCurrentDetailCategory = (String) ((PieSectionEntity) event
                                .getEntity()).getSectionKey();
                        GraphStatsView.this.mStackLayout.topControl = GraphStatsView.this.mDetailViewer
                                .getTable();
                        GraphStatsView.this.mMainSection.layout();
                        GraphStatsView.this.mDetailViewer
                                .setInput(GraphStatsView.this.mDetailViewer.getInput());

                        GraphStatsView.this.updateActions();
                        GraphStatsView.this.updateLabel();
                    }
                });
            } else {
                event.getTrigger().consume();
            }
        }

        public void chartMouseMoved(final ChartMouseEvent event) {

            // NOOP
        }
    });

    return embeddedComposite;
}

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

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

    } else if (button == MouseEvent.BUTTON3) {
        robot.mousePress(InputEvent.BUTTON3_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_MASK);
    }/* w  w  w . ja v  a2  s  . c  om*/
}

From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java

/**
 * Creates new form Display3DPanel//from www  .jav a 2 s . c  o  m
 */
public Display3DPanel() {
    initComponents();
    effectiveHeight = getHeight();
    effectiveWidth = getWidth();
    logger.debug("creating Display3DPanel");
    this.setMinimumSize(new Dimension(200, 200));
    this.setPreferredSize(new Dimension(800, 600));
    GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
    template.setStereo(GraphicsConfigTemplate3D.PREFERRED);

    // Get the GraphicsConfiguration that best fits our needs.
    logger.debug("getting config");
    GraphicsConfiguration gcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
            .getBestConfiguration(template);
    logger.debug("creating canvas");
    canvas = new Canvas3D(gcfg) {
        @Override
        public void postRender() {
            vGraphics = super.getGraphics2D();
            vGraphics.setFont(new Font("sans-serif", Font.PLAIN, 10));
            vGraphics.setColor(Color.YELLOW);
            locToWin.update();
            fireProjectionChanged(new ProjectionEvent(this, locToWin));
            draw2D(vGraphics, locToWin, effectiveWidth, effectiveHeight);
            vGraphics.flush(false);
        }

        @Override
        public void postSwap() {
            if (postRenderSilent || waitForExternalTrigger) {
                return;
            }
            if (!(storingJPEG || storingPNG || storingFrames)) {
                fireFrameRendered();
            }
            if (storingFrames) {
                if (storingJPEG) {
                    writeImage(new File(controlsPanel.getMovieCreationPanel().getCurrentFrameFileName()));
                } else {
                    writeYUV(controlsPanel.getMovieCreationPanel().getGenericFrameFileName());
                }
            }
        }
    };
    canvas.setStereoEnable(false);
    add("Center", canvas);

    pickObject = new PickObject(canvas, objScene, rootObject.getGeometryObj(), objRotate);

    canvas.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.isShiftDown()) {
                //              if (e.isShiftDown())
                //                 System.out.println(""+e.getX() + " " + e.getY());
            }
            if (evt.getButton() == MouseEvent.BUTTON1) {
                if (evt.getClickCount() > 1) {
                    reset();
                } else if (pickObject.consumeEmulated3DPick(evt.getX(), evt.getY())) {
                    /* Nothing must be done - everything was done in consumeEmulated3DPick() */
                } else {
                    pickObject.consume2DSelectModule(evt.getX(), evt.getY());
                }
                rootObject.firePickChanged(evt, locToWin);
            }
            if (evt.getButton() == MouseEvent.BUTTON3) {
                if (getControlsFrame() != null) {
                    getControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240, 500);
                    getControlsFrame().setVisible(true);
                } else if (getTransientControlsFrame() != null) {
                    getTransientControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240,
                            500);
                    getTransientControlsFrame().setVisible(true);
                } else if (application != null) {
                    application.getFrames().getGuiPanel().selectModule(name);
                }
            }
            if (evt.getButton() == MouseEvent.BUTTON2) {
                reset();
            }
        }

        @Override
        public void mouseEntered(java.awt.event.MouseEvent evt) {
            mouseOn = true;
            mouseObserverThread = new Thread(new MouseObserver());
            mouseObserverThread.start();
        }

        @Override
        public void mouseExited(java.awt.event.MouseEvent evt) {
            mouseObserverThread = null;
            mouseOn = false;
        }
    });

    canvas.addMouseMotionListener(new java.awt.event.MouseMotionListener() {
        @Override
        public void mouseDragged(MouseEvent e) {
            //              if (e.isShiftDown())
            //                 System.out.println(""+e.getX() + " " + e.getY());
        }

        @Override
        public void mouseMoved(MouseEvent e) {
        }
    });

    canvas.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
        @Override
        public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
            rescaleFromMouseWheel(evt);
        }
    });

    canvas.addKeyListener(new java.awt.event.KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent evt) {
            formKeyTyped(evt);
        }

        @Override
        public void keyPressed(KeyEvent evt) {
            formKeyPressed(evt);
        }

        @Override
        public void keyReleased(KeyEvent evt) {
            formKeyReleased(evt);
        }
    });

    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true);
    universe = new SimpleUniverse(canvas);
    view = canvas.getView();
    view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
    view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);

    objScene.addChild(rootObject.getGeometryObj());
    rootObject.setRenderingWindow(this);
    rootObject.getGeometryObj().setUserData(null);

    bg.setCapability(Background.ALLOW_COLOR_WRITE);
    bg.setCapability(Background.ALLOW_COLOR_READ);
    bg.setCapability(Background.ALLOW_IMAGE_WRITE);
    bg.setCapability(Background.ALLOW_IMAGE_READ);
    bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_READ);
    bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_WRITE);
    bg.setImageScaleMode(Background.SCALE_FIT_ALL);
    bg.setApplicationBounds(bounds);

    myFog.setCapability(LinearFog.ALLOW_DISTANCE_WRITE);
    myFog.setCapability(LinearFog.ALLOW_COLOR_WRITE);
    myFog.setInfluencingBounds(bounds);
    myFog.setFrontDistance(1.);
    myFog.setBackDistance(4.);
    myFogGroup.addChild(myFog);

    mouseRotate.setTransformGroup(objRotate);
    mouseRotate.setSchedulingBounds(bounds);
    mouseRotate.setFactor(mouseRotateSensitivity);

    mouseTranslate.setTransformGroup(objRotate);
    mouseTranslate.setSchedulingBounds(bounds);
    mouseTranslate.setFactor(mouseTranslateSensitivity);

    mouseZoom.setTransformGroup(objRotate);
    mouseZoom.setSchedulingBounds(bounds);

    windowRootObject.addChild(mouseRotate);
    windowRootObject.addChild(mouseTranslate);
    windowRootObject.addChild(mouseZoom);

    objTranslate.addChild(objScene);
    objScale.addChild(objTranslate);
    objRotate.addChild(bg);
    objRotate.addChild(objScale);
    windowRootObject.addChild(objRotate);

    ambientLight = new EditableAmbientLight(new Color3f(.25f, .25f, .25f), bounds, "ambient light", true);
    windowRootObject.addChild(ambientLight.getLight());

    directionalLights.add(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f),
            new Vector3f(.1f, .08f, -.5f), bounds, "light 1", true, true));
    directionalLights.add(new EditableDirectionalLight(new Color3f(0.2f, 0.15f, 0.1f),
            new Vector3f(-1.f, -0.4f, -.5f), bounds, "light 2", true, false));
    directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f),
            new Vector3f(0.f, 0.6f, -1.f), bounds, "light 3", true, false));
    directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f),
            new Vector3f(0.f, -0.6f, -1.f), bounds, "light 3", false, false));
    for (int i = 0; i < directionalLights.size(); i++) {
        TransformGroup lightTransform = new TransformGroup();
        lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        lightTransform.setName("light" + i + "Transform");
        directionalLightTransforms.add(lightTransform);
        OpenBranchGroup lightGroup = new OpenBranchGroup();
        EditableDirectionalLight light = directionalLights.get(i);
        lightGroup.addChild(light.getLight());
        lightGroup.addChild(light.getBackLight());
        lightTransform.addChild(lightGroup);
        windowRootObject.addChild(lightTransform);
    }
    modelClip.setCapability(ModelClip.ALLOW_ENABLE_READ);
    modelClip.setCapability(ModelClip.ALLOW_ENABLE_WRITE);
    modelClip.setCapability(ModelClip.ALLOW_PLANE_READ);
    modelClip.setCapability(ModelClip.ALLOW_PLANE_WRITE);
    modelClip.setInfluencingBounds(bounds);
    objScene.addChild(modelClip);

    pointLights
            .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false));
    pointLights
            .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false));
    pointLights
            .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false));
    for (int i = 0; i < pointLights.size(); i++) {
        TransformGroup lightTransform = new TransformGroup();
        lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        lightTransform.setName("light" + i + "Transform");
        pointLightTransforms.add(lightTransform);
        OpenBranchGroup lightGroup = new OpenBranchGroup();
        EditablePointLight light = pointLights.get(i);
        lightGroup.addChild(light.getLight());
        lightTransform.addChild(lightGroup);
        windowRootObject.addChild(lightTransform);
    }
    alternateTransformObj.addChild(alternateRootObj);
    alternateTransormBranch.addChild(alternateTransformObj);
    windowRootObject.addChild(alternateTransormBranch);

    universe.getViewingPlatform().setNominalViewingTransform();
    universe.addBranchGraph(windowRootObject);

    view.getPhysicalBody().getLeftEyePosition(defaultLeftEye);
    view.getPhysicalBody().getRightEyePosition(defaultRightEye);
    controlsFrame = new Display3DControlsFrame(this);
    controlsPanel = controlsFrame.getControlPanel();
    universe.getViewingPlatform().getViewPlatformTransform().getTransform(initialCameraTransform);

    objReper.addChild(reper.getGeometryObj());
    positionedReper.addChild(objReper);
    positionedReper.setTransform(
            new Transform3D(new float[] { .15f, 0, 0, -.8f, 0, .15f, 0, .76f, 0, 0, .15f, 0, 0, 0, 0, 1 }));
    reperGroup.addChild(positionedReper);
    OpenBranchGroup reperLightGroup = new OpenBranchGroup();
    reperLightGroup.addChild(new AmbientLight(new Color3f(.6f, .6f, .6f)));
    reperLightGroup.addChild(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f),
            new Vector3f(.1f, .08f, -1f), bounds, "light 1", true, true).getLight());
    reperGroup.addChild(reperLightGroup);
    universe.addBranchGraph(reperGroup);
    locToWin = new LocalToWindow(rootObject.getGeometryObj(), canvas);

    /**
     * The line below binds reper with scene rotation when using any method that calls
     * objRotate.setTransform(), so: keyboard (explicitly calling), mouse (Java3D is calling
     * setTransform) and some custom ways (e.g. in haptic pointer)
     */
    objRotate.addTransformListener(objReper);
    //        mouseRotate.setupCallback(objReper); // it is not needed, because Java3D calls objRotate.setTranform which fires callback to the reper
}

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

public SQLComponent createComponent() {
    return new BaseSQLComponent(this) {

        private FichePayeModel model;
        private ElementComboBox comboSelProfil, selSalCombo;
        private EditFrame edit = null;
        private ElementComboBox selMois;
        private int dernMois, dernAnnee;
        private JTextField textAnnee;
        JDate dateDu, dateAu;/*from w w  w.jav  a2  s . c  om*/
        private JScrollPane paneTreeLeft;
        private JPanel pDate;
        private JButton buttonValider, buttonGenCompta;

        public void addViews() {

            this.dernMois = 0;
            this.dernAnnee = 0;

            this.setLayout(new GridBagLayout());

            final GridBagConstraints c = new DefaultGridBagConstraints();

            // Tree elt Fiche de Paye On the left
            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            c.gridheight = GridBagConstraints.REMAINDER;
            final RubriquePayeTree tree = new RubriquePayeTree();
            tree.expandRow(0);
            this.paneTreeLeft = new JScrollPane(tree);
            // this.add(this.paneTreeLeft, c);

            // Panel Fiche paye on the right
            // Salarie
            JPanel panelRight = new JPanel();
            panelRight.setLayout(new GridBagLayout());
            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 1;
            c.weighty = 0;
            c.gridheight = 1;
            c.gridwidth = 2;
            this.selSalCombo = new ElementComboBox();
            // c.gridx++;
            panelRight.add(this.selSalCombo, c);

            // Mois
            c.gridy++;
            // c.gridx++;
            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 1;
            c.weighty = 0;
            c.gridheight = 1;
            c.gridwidth = 3;
            JLabel labelMois = new JLabel("Fiche de paye du mois de");
            this.selMois = new ElementComboBox(true, 20);
            // this.selMois.setEditable(true);
            // /this.selMois.setEnabled(true);

            JLabel labelDu = new JLabel("Du");
            JLabel labelAu = new JLabel("Au");
            this.dateDu = new JDate();
            this.dateAu = new JDate();

            // JTextField textMois = new JTextField();
            JLabel labelAnnee = new JLabel("Anne");
            this.textAnnee = new JTextField();
            {
                this.pDate = new JPanel();
                this.pDate.setOpaque(false);
                this.pDate.add(labelMois);
                this.pDate.add(this.selMois);
                this.pDate.add(labelAnnee);
                this.pDate.add(this.textAnnee);
                this.pDate.add(labelDu);
                this.pDate.add(this.dateDu);
                this.pDate.add(labelAu);
                this.pDate.add(this.dateAu);
                panelRight.add(this.pDate, c);
            }
            c.gridx += 2;
            c.weightx = 1;
            c.gridwidth = 1;
            c.fill = GridBagConstraints.HORIZONTAL;
            panelRight.add(new JPanel(), c);

            // Action Button
            c.gridx++;
            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 0;
            c.weighty = 0;

            JPanel pButtons = new JPanel();
            pButtons.setOpaque(false);
            JButton buttonUp = new JNiceButton(IListFrame.class.getResource("fleche_haut.png"));
            JButton buttonDown = new JNiceButton(IListFrame.class.getResource("fleche_bas.png"));
            JButton buttonRemove = new JNiceButton(SQLComponent.class.getResource("delete.png"));
            {
                pButtons.add(buttonUp);
                pButtons.add(buttonDown);
                pButtons.add(buttonRemove);
            }
            panelRight.add(pButtons, c);

            // Table
            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            c.gridx = 1;
            c.gridy++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            this.model = new FichePayeModel(1);
            final JTable table = new JTable(this.model);
            panelRight.add(new JScrollPane(table), c);
            FichePayeRenderer rend = new FichePayeRenderer();
            table.setDefaultRenderer(String.class, rend);
            table.setDefaultRenderer(Float.class, rend);

            // Import profil
            c.gridx = 1;
            c.gridy++;
            c.weightx = 0;
            c.weighty = 0;
            c.gridwidth = 1;
            c.fill = GridBagConstraints.HORIZONTAL;
            JLabel labelProfil = new JLabel("Importer depuis un profil prdfini");
            panelRight.add(labelProfil, c);
            c.gridwidth = 1;

            this.comboSelProfil = new ElementComboBox();
            // this.comboSelProfil = new ElementComboBox();
            this.comboSelProfil.setListIconVisible(false);
            c.gridx++;
            c.gridwidth = 1;

            // this.comboSelProfil.init(eltProfil.getTable().getField("NOM"), null);
            panelRight.add(this.comboSelProfil, c);

            JButton buttonImportProfil = new JButton("Importer");
            c.gridx++;
            panelRight.add(buttonImportProfil, c);

            // Total Periode
            JPanel panelTotal = new JPanel();
            panelTotal.setBorder(BorderFactory.createTitledBorder("Total priode"));
            panelTotal.setLayout(new GridBagLayout());
            GridBagConstraints cPanel = new DefaultGridBagConstraints();

            // Salaire brut
            JLabel labelBrut = new JLabel(getLabelFor("SAL_BRUT"));
            panelTotal.add(labelBrut, cPanel);
            JTextField textSalBrut = new JTextField(10);
            cPanel.gridx++;
            cPanel.weightx = 0;
            panelTotal.add(textSalBrut, cPanel);
            textSalBrut.setEditable(false);
            textSalBrut.setEnabled(false);

            // acompte
            cPanel.gridx++;
            JLabel labelAcompte = new JLabel(getLabelFor("ACOMPTE"));
            panelTotal.add(labelAcompte, cPanel);
            JTextField textAcompte = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textAcompte, cPanel);
            // textAcompte.setEditable(false);
            // textAcompte.setEnabled(false);

            // Conges Acquis
            cPanel.gridx++;
            JLabel labelCongesAcquis = new JLabel(getLabelFor("CONGES_ACQUIS"));
            panelTotal.add(labelCongesAcquis, cPanel);
            JTextField textCongesAcquis = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCongesAcquis, cPanel);

            // cotisation salariale
            cPanel.gridx = 0;
            cPanel.gridy++;
            JLabel labelCotSal = new JLabel(getLabelFor("COT_SAL"));
            panelTotal.add(labelCotSal, cPanel);
            JTextField textCotSal = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCotSal, cPanel);
            textCotSal.setEditable(false);
            textCotSal.setEnabled(false);

            // cotisation patronale
            cPanel.gridx++;
            JLabel labelCotPat = new JLabel(getLabelFor("COT_PAT"));
            panelTotal.add(labelCotPat, cPanel);
            JTextField textCotPat = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCotPat, cPanel);
            textCotPat.setEditable(false);
            textCotPat.setEnabled(false);

            JLabel labelCSG = new JLabel(getLabelFor("CSG"));
            cPanel.gridx++;
            panelTotal.add(labelCSG, cPanel);
            JTextField textCSG = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCSG, cPanel);
            textCSG.setEditable(false);
            textCSG.setEnabled(false);

            // net imposable
            cPanel.gridx = 0;
            cPanel.gridy++;
            JLabel labelNetImp = new JLabel(getLabelFor("NET_IMP"));
            panelTotal.add(labelNetImp, cPanel);
            JTextField textNetImp = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textNetImp, cPanel);
            textNetImp.setEditable(false);
            textNetImp.setEnabled(false);

            cPanel.gridx++;
            JLabel labelNetAPayer = new JLabel(getLabelFor("NET_A_PAYER"));
            panelTotal.add(labelNetAPayer, cPanel);
            JTextField textNetAPayer = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textNetAPayer, cPanel);
            textNetAPayer.setEditable(false);
            textNetAPayer.setEnabled(false);

            c.gridx = 1;
            c.gridy++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelRight.add(panelTotal, c);

            // Cumuls

            c.gridx = 1;
            c.gridy++;
            c.gridwidth = 1;
            c.fill = GridBagConstraints.NONE;
            this.buttonValider = new JButton("Valider");
            // panelRight.add(buttonValider, c);

            c.gridx++;
            c.gridwidth = 1;
            this.buttonGenCompta = new JButton("Generer la comptabilit");
            // panelRight.add(buttonGenCompta, c);

            c.gridx = 0;
            c.gridy = 0;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), c);

            // Listeners
            this.buttonGenCompta.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int[] i = new int[1];
                    i[0] = getSelectedID();

                    SQLRow rowMois = getTable().getBase().getTable("MOIS").getRow(selMois.getSelectedId());

                    new GenerationMvtFichePaye(i, rowMois.getString("NOM"), textAnnee.getText());
                }
            });

            this.buttonValider.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.err.println("Validation de la fiche de paye");
                    validationFiche();
                }
            });

            buttonUp.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    int newRowSelected = model.upRow(table.getSelectedRow());
                    if (newRowSelected >= 0) {
                        table.setRowSelectionInterval(newRowSelected, newRowSelected);
                    }
                }
            });

            buttonDown.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    int newRowSelected = model.downRow(table.getSelectedRow());
                    if (newRowSelected >= 0) {
                        table.setRowSelectionInterval(newRowSelected, newRowSelected);
                    }
                }
            });

            buttonRemove.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    model.removeRow(table.getSelectedRow());
                }
            });

            tree.addMouseListener(new MouseAdapter() {

                public void mousePressed(MouseEvent mE) {

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

                    final Object obj = path.getLastPathComponent();

                    if (obj == null) {
                        return;
                    }

                    if (mE.getClickCount() == 2 && mE.getButton() == MouseEvent.BUTTON1) {

                        if (obj instanceof VariableRowTreeNode) {
                            model.addRowAt(((VariableRowTreeNode) obj).getRow(), table.getSelectedRow());
                        }
                    } else {

                        if (mE.getButton() == 3) {

                            if (obj instanceof VariableRowTreeNode) {

                                final SQLRow row = ((VariableRowTreeNode) obj).getRow();

                                JPopupMenu menuDroit = new JPopupMenu();

                                menuDroit.add(new AbstractAction("Editer") {
                                    public void actionPerformed(ActionEvent e) {

                                        if (edit != null) {
                                            edit.dispose();
                                        }
                                        edit = new EditFrame(Configuration.getInstance().getDirectory()
                                                .getElement(row.getTable()), EditFrame.MODIFICATION);
                                        edit.selectionId(row.getID(), 0);
                                        edit.pack();
                                        edit.setVisible(true);
                                    }
                                });

                                menuDroit.add(new AbstractAction("Nouvelle rubrique") {
                                    public void actionPerformed(ActionEvent e) {

                                        if (edit != null) {
                                            edit.dispose();
                                        }
                                        edit = new EditFrame(Configuration.getInstance().getDirectory()
                                                .getElement(row.getTable()));
                                        edit.pack();
                                        edit.setVisible(true);
                                    }
                                });

                                menuDroit.show(mE.getComponent(), mE.getPoint().x, mE.getPoint().y);

                            }
                        }
                    }
                }
            });

            this.dateDu.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if (!dateDu.isEmpty()) {
                        Date d = dateDu.getValue();

                        if (d != null) {
                            Calendar cal = Calendar.getInstance();
                            cal.setTime(d);
                            if (selMois.getSelectedId() > 1
                                    && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) {

                                cal.set(Calendar.DAY_OF_MONTH, 1);
                                cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
                                System.err.println("Du " + cal.getTime());
                                dateDu.setValue(cal.getTime());
                            }
                        }
                    }
                }
            });

            this.dateAu.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if (!dateAu.isEmpty()) {
                        Date d = dateAu.getValue();
                        if (d != null) {
                            Calendar cal = Calendar.getInstance();
                            cal.setTime(d);
                            if (selMois.getSelectedId() > 1
                                    && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) {

                                // TODO checker l'annee
                                // TODO ajouter dans le isValidated du au compris dans le mois
                                // selectionne

                                // Calendar.getInstance().set(Calendar.DAY_OF_MONTH, maxDay);
                                cal.set(Calendar.DAY_OF_MONTH, 1);
                                cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
                                cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
                                System.err.println("Au " + cal.getTime());
                                dateAu.setValue(cal.getTime());
                            }
                        }
                    }
                }
            });

            this.addRequiredSQLObject(this.textAnnee, "ANNEE");
            this.addRequiredSQLObject(this.selMois, "ID_MOIS");
            this.addSQLObject(this.comboSelProfil, "ID_PROFIL_PAYE");

            this.addSQLObject(textCongesAcquis, "CONGES_ACQUIS");
            this.addSQLObject(textCotPat, "COT_PAT");
            this.addSQLObject(textCotSal, "COT_SAL");
            this.addSQLObject(textCSG, "CSG");
            this.addSQLObject(textNetAPayer, "NET_A_PAYER");
            this.addSQLObject(textNetImp, "NET_IMP");
            this.addSQLObject(textSalBrut, "SAL_BRUT");
            this.addSQLObject(textAcompte, "ACOMPTE");
            this.addSQLObject(this.selSalCombo, "ID_SALARIE");

            this.addRequiredSQLObject(this.dateDu, "DU");
            this.addRequiredSQLObject(this.dateAu, "AU");

            this.selSalCombo.setEditable(false);
            this.selSalCombo.setEnabled(false);
            this.selSalCombo.setButtonsVisible(false);
            // this.selSalCombo.setVisible(false);

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

                    model.loadFromProfil(comboSelProfil.getSelectedId());
                }
            });
        }

        private boolean isDateValid() {

            String yearS = this.textAnnee.getText().trim();
            int annee = (yearS.length() == 0) ? 0 : Integer.parseInt(yearS);

            int mois = this.selMois.getSelectedId();
            // System.err.println("anne " + annee + " dernAnnee " + this.dernAnnee + " mois " +
            // mois + " dernMois " + this.dernMois);

            return ((this.dernAnnee == 0) ? true : annee > this.dernAnnee)
                    || ((this.dernMois == 0 || this.dernMois == 13) ? true : mois > this.dernMois);
        }

        @Override
        public synchronized ValidState getValidState() {
            // FIXME add fireValidChange()
            return super.getValidState().and(ValidState.createCached(isDateValid(), "Date invalide"));
        }

        public int insert(SQLRow order) {

            int id = super.insert(order);
            this.model.updateFields(id);
            return id;
        }

        @Override
        public void update() {
            super.update();
            this.model.updateFields(this.getSelectedID());
        }

        @Override
        public void select(SQLRowAccessor r) {

            // System.err.println("SELECT FICHE ID -> " + r.getID());
            super.select(r);

            if (r != null && r.getID() > 1) {
                this.model.setFicheID(r.getID());

                SQLTable tableSal = getTable().getBase().getTable("SALARIE");
                SQLRow rowSal = tableSal.getRow(r.getInt("ID_SALARIE"));

                this.dernMois = rowSal.getInt("DERNIER_MOIS");
                this.dernAnnee = rowSal.getInt("DERNIERE_ANNEE");

                this.selSalCombo.setVisible(((Boolean) r.getObject("VALIDE")).booleanValue());
                this.paneTreeLeft.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
                this.buttonValider.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
                setpDateEnabled(!((Boolean) r.getObject("VALIDE")).booleanValue());
            }
            this.selSalCombo.setEditable(false);
            this.selSalCombo.setEnabled(false);
            this.selMois.setButtonsVisible(false);
            this.selSalCombo.setButtonsVisible(false);
        }

        private void setpDateEnabled(boolean b) {

            // System.err.println("Set date enable --> " + b);
            this.selMois.setEditable(b);
            // this.selMois.setEnabled(b);

            this.textAnnee.setEditable(b);
            this.textAnnee.setEnabled(b);

            this.dateDu.setEditable(b);
            this.dateDu.setEnabled(b);

            this.dateAu.setEditable(b);
            this.dateAu.setEnabled(b);
        }

        private void validationFiche() {

            this.update();
            FichePayeSQLElement.validationFiche(this.getSelectedID());
        }

        protected SQLRowValues createDefaults() {

            System.err.println("**********Set Defaults on FichePaye.date");
            SQLRowValues rowVals = new SQLRowValues(getTable());
            Calendar cal = Calendar.getInstance();
            rowVals.put("ID_MOIS", cal.get(Calendar.MONTH) + 2);
            rowVals.put("ANNEE", cal.get(Calendar.YEAR));

            cal.set(Calendar.DAY_OF_MONTH, 1);
            rowVals.put("DU", new java.sql.Date(cal.getTime().getTime()));

            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
            rowVals.put("AU", new java.sql.Date(cal.getTime().getTime()));
            return rowVals;
        }

    };
}

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

protected void setMouseStatus(int button, boolean status) {
    if (button == MouseEvent.BUTTON1) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON1_MASK);
        } else {/*from w w  w .ja v  a 2  s  .c o m*/
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        }
    } else if (button == MouseEvent.BUTTON2) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON2_MASK);
        } else {
            robot.mouseRelease(InputEvent.BUTTON2_MASK);
        }
    } else if (button == MouseEvent.BUTTON3) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON3_MASK);
        } else {
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
        }
    }
}

From source file:javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer.java

private void prepareDisplayToggleListener() {
    setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent pEvent) {
            if (pEvent.getButton() == MouseEvent.BUTTON1) {
                if (displayMode + 1 > 1) {
                    displayMode = 0;/*from   ww w .j  av  a 2 s.  co m*/
                } else {
                    displayMode++;
                }
            }
        }
    });
}

From source file:net.sf.jabref.gui.groups.GroupSelector.java

private void definePopup() {
    // These key bindings are just to have the shortcuts displayed
    // in the popup menu. The actual keystroke processing is in
    // BasePanel (entryTable.addKeyListener(...)).
    groupsContextMenu.add(editGroupPopupAction);
    groupsContextMenu.add(addGroupPopupAction);
    groupsContextMenu.add(addSubgroupPopupAction);
    groupsContextMenu.addSeparator();/*w w w .j  a v a2  s .  c om*/
    groupsContextMenu.add(removeGroupAndSubgroupsPopupAction);
    groupsContextMenu.add(removeGroupKeepSubgroupsPopupAction);
    groupsContextMenu.add(removeSubgroupsPopupAction);
    groupsContextMenu.addSeparator();
    groupsContextMenu.add(expandSubtreePopupAction);
    groupsContextMenu.add(collapseSubtreePopupAction);
    groupsContextMenu.addSeparator();
    groupsContextMenu.add(moveSubmenu);
    sortSubmenu.add(sortDirectSubgroupsPopupAction);
    sortSubmenu.add(sortAllSubgroupsPopupAction);
    groupsContextMenu.add(sortSubmenu);
    moveSubmenu.add(moveNodeUpPopupAction);
    moveSubmenu.add(moveNodeDownPopupAction);
    moveSubmenu.add(moveNodeLeftPopupAction);
    moveSubmenu.add(moveNodeRightPopupAction);
    groupsContextMenu.addSeparator();
    groupsContextMenu.add(addToGroup);
    groupsContextMenu.add(moveToGroup);
    groupsContextMenu.add(removeFromGroup);
    groupsTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            TreePath path = groupsTree.getPathForLocation(e.getPoint().x, e.getPoint().y);
            if (path == null) {
                return;
            }
            GroupTreeNodeViewModel node = (GroupTreeNodeViewModel) path.getLastPathComponent();
            // the root node is "AllEntries" and cannot be edited
            if (node.getNode().isRoot()) {
                return;
            }
            if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) { // edit
                editGroupAction.actionPerformed(null); // dummy event
            } else if ((e.getClickCount() == 1) && (e.getButton() == MouseEvent.BUTTON1)) {
                annotationEvent(node);
            }
        }
    });
    // be sure to remove a possible border highlight when the popup menu
    // disappears
    groupsContextMenu.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            // nothing to do
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            groupsTree.setHighlightBorderCell(null);
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            groupsTree.setHighlightBorderCell(null);
        }
    });
}

From source file:org.rdv.viz.image.ImageViz.java

private void initRoboticMouseClickListener() {
    roboticMouseClickListener = new MouseInputAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                Point imagePoint = imagePanel.panelToScaledImagePoint(e.getPoint());
                if (imagePoint != null) {
                    center(imagePoint);//from   ww w  . j a v a  2s . c  om
                }
            }
        }
    };
}

From source file:uk.ac.lkl.cram.ui.ModuleFrame.java

private JXTaskPane createLearningTypeChartPane() {
    JXTaskPane typeChartPane = new JXTaskPane();
    typeChartPane.setTitle("Learning Types");
    typeChartPane.setScrollOnExpand(true);
    final LearningTypeChartMaker maker = new LearningTypeChartMaker(module);
    final ChartPanel chartPanel = maker.getChartPanel();
    //Add a mouse listener to the chart
    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override/* w w w  .  ja va 2 s  .  c  o  m*/
        public void chartMouseClicked(ChartMouseEvent cme) {
            //Get the mouse event
            MouseEvent trigger = cme.getTrigger();
            //Test if the mouse event is a left-button
            if (trigger.getButton() == MouseEvent.BUTTON1 && trigger.getClickCount() == 2) {
                //Check that the mouse click is on a segment of the pie
                if (cme.getEntity() instanceof PieSectionEntity) {
                    //Get the selected segment of the pie
                    PieSectionEntity pieSection = (PieSectionEntity) cme.getEntity();
                    //Get the key that corresponds to that segment--this is a learning type
                    String key = pieSection.getSectionKey().toString();
                    //Get the set of tlalineitems whose activity contains that learning type
                    Set<TLALineItem> relevantTLAs = maker.getLearningTypeMap().get(key);
                    //Create a pop up dialog containing that set of tlalineitems
                    LearningTypePopupDialog popup = new LearningTypePopupDialog(
                            (Frame) SwingUtilities.getWindowAncestor(chartPanel), true, relevantTLAs, key);
                    //Set the title of the popup to indicate which learning type was selected
                    popup.setTitle("Activities with \'" + key + "\'");
                    //Centre the popup at the location of the mouse click
                    Point location = trigger.getLocationOnScreen();
                    int w = popup.getWidth();
                    int h = popup.getHeight();
                    popup.setLocation(location.x - w / 2, location.y - h / 2);
                    popup.setVisible(true);
                    int returnStatus = popup.getReturnStatus();
                    if (returnStatus == LearningTypePopupDialog.RET_OK) {
                        modifyTLALineItem(popup.getSelectedTLALineItem(), 0);
                    }
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            //Set the cursor shape according to the location of the cursor
            if (cme.getEntity() instanceof PieSectionEntity) {
                chartPanel.setCursor(HAND);
            } else {
                chartPanel.setCursor(Cursor.getDefaultCursor());
            }
        }
    });
    chartPanel.setPreferredSize(new Dimension(150, 200));
    typeChartPane.add(chartPanel);
    return typeChartPane;
}