Example usage for java.awt.event MouseEvent getButton

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

Introduction

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

Prototype

public int getButton() 

Source Link

Document

Returns which, if any, of the mouse buttons has changed state.

Usage

From source file:com.puzzle.gui.MainFrame.java

private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
    // TODO add your handling code here:
    if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
        int rowNumber = this.jTable2.getSelectedRow();
        String fileName = (String) this.jTable2.getValueAt(rowNumber, 1);

        String content = null;/*from  w ww  .  j av a 2  s.c o m*/
        try {
            content = org.apache.commons.io.FileUtils.readFileToString(new File(fileName), "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return;
        }
        //              String ll=this.readXML(workpath,ff);
        this.jDialog1.setTitle(fileName);
        //??
        textArea.setText(content);
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAutoscrolls(true);
        //            textArea.setBackground(Color.black);
        textArea.setEditable(false);
        //             textArea.setVisible(true);
        this.jPanel6.add(sp);

        this.jDialog1.setLocationRelativeTo(this);
        this.jDialog1.setVisible(true);
    }

}

From source file:com.puzzle.gui.MainFrame.java

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
    // TODO add your handling code here:
    if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
        int rowNumber = this.jTable1.getSelectedRow();
        String fileName = (String) this.jTable1.getValueAt(rowNumber, 1);
        String[] names = fileName.split("\\\\");
        String ff = names[names.length - 1];
        fileName = FileDto.getSingleInstance().fileSendBakPath + File.separator + DateUtil.getCurrDateMM()
                + File.separator + ff;
        String content = null;/* ww w  .j  a va 2 s.c o m*/
        try {
            content = org.apache.commons.io.FileUtils.readFileToString(new File(fileName), "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return;
        }
        //              String ll=this.readXML(workpath,ff);
        this.jDialog1.setTitle(fileName);
        //??
        textArea.setText(content);
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAutoscrolls(true);
        //            textArea.setBackground(Color.black);
        textArea.setEditable(false);
        //             textArea.setVisible(true);
        this.jPanel6.add(sp);

        this.jDialog1.setLocationRelativeTo(this);
        this.jDialog1.setVisible(true);
    }
}

From source file:edmondskarp.Gui.EdmondsKarpGui.java

private void myPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_myPanelMouseClicked
    if (evt.getButton() == MouseEvent.BUTTON1) {

        if (MODE == ERASE) {
            eraseShape(evt.getPoint());/*from w  w  w  . ja v a  2  s .co  m*/
        } else if (MODE == DRAW) {

            if (isSecond) {
                Circle circ = getSelectedCircle(evt.getPoint());
                if (circ != null && circ != shapeTmp) {
                    addArrow(circ);
                    shapeTmp.setSelect(false);
                    isSecond = false;
                    update();
                    return;
                }
            } else {
                Circle circ = getSelectedCircle(evt.getPoint());
                if (circ != null) {
                    shapeTmp = circ;
                    shapeTmp.setSelect(true);
                    isSecond = true;
                    update();
                    return;
                }

            }

            if (getSelectedCircle(evt.getPoint()) == null && !isSecond) {
                addCircle(evt.getPoint());
            } else {
                isSecond = false;
                shapeTmp.setSelect(false);
                update();
            }
        }
    } else if (evt.getButton() == MouseEvent.BUTTON3) {
        if (getSelectedCircle(evt.getPoint()) != null) {
            pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY());
            jPopupMenu1.show(myPanel, evt.getX(), evt.getY());
        } else if (getSelectedArrow(evt.getPoint()) != null) {
            pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY());
            jPopupMenu2.show(myPanel, evt.getX(), evt.getY());
        }
    }
}

From source file:oct.analysis.application.OCTAnalysisUI.java

private void octAnalysisPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_octAnalysisPanelMouseClicked
    octAnalysisPanel.requestFocus();//ww  w  .ja v a2  s  . co  m
    //only perform actions when mouse click occurs over image area
    if (analysisMngr.getAnalysisMode() != null
            && octAnalysisPanel.coordinateOverlapsOCT(evt.getX(), evt.getY())) {
        switch (evt.getButton()) {
        case MouseEvent.BUTTON1:
            switch (analysisMngr.getAnalysisMode()) {
            case SINGLE:
                switch (toolMode) {
                case SELECT_SINGLE:
                    //clear out any current analysis selection
                    selectionLRPManager.removeSelections(false);
                    octAnalysisPanel.repaint();
                    //add new selections and redraw panel
                    selectionLRPManager.addOrUpdateSelection(selectionLRPManager.getSelection(
                            octAnalysisPanel.translatePanelPointToOctPoint(evt.getPoint()).x, "Selection",
                            SelectionType.NONFOVEAL, true));
                    octAnalysisPanel.repaint();
                    break;
                case SCREEN_SELECT:
                    selectSelection(evt.getPoint());
                    break;
                }
                break;
            case MIRROR:
                switch (toolMode) {
                case SELECT_SINGLE:
                    //clear out any current analysis selection
                    selectionLRPManager.removeNonfovealSelections(false);
                    octAnalysisPanel.repaint();
                    //add new selections and redraw panel
                    int distFromFovea = Math.abs(analysisMngr.getFoveaCenterXPosition()
                            - octAnalysisPanel.translatePanelPointToOctPoint(evt.getPoint()).x);
                    selectionLRPManager.addOrUpdateSelection(selectionLRPManager.getSelection(
                            analysisMngr.getFoveaCenterXPosition() - distFromFovea, "Left",
                            SelectionType.NONFOVEAL, true));
                    selectionLRPManager.addOrUpdateSelection(selectionLRPManager.getSelection(
                            analysisMngr.getFoveaCenterXPosition() + distFromFovea, "Right",
                            SelectionType.NONFOVEAL, true));
                    octAnalysisPanel.repaint();
                    break;
                case SCREEN_SELECT:
                    selectSelection(evt.getPoint());
                    break;
                }
                break;
            case EZ:
                //allow user to select and change position of the EZ edge selections after the fact
                switch (toolMode) {
                case SCREEN_SELECT:
                    selectSelection(evt.getPoint());
                default:
                    break;
                }
                break;
            case EQUIDISTANT:
                //allow user to change placement of fovea after the fact
                if (toolMode == ToolMode.SELECT_FOVEA) {
                    //clear out any current analysis information
                    selectionLRPManager.removeSelections(true);
                    octAnalysisPanel.repaint();
                    //add new selections and redraw panel
                    selectionLRPManager.addOrUpdateEquidistantSelections(evt.getX(),
                            analysisMngr.getMicronsBetweenSelections());
                    octAnalysisPanel.repaint();
                }
                break;
            default:
                break;
            }
            break;
        case MouseEvent.BUTTON3:
            selectionLRPManager.removeSelections(true);
            octAnalysisPanel.repaint();
            break;
        default:
            break;
        }
    }
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

@Override
public void mouseClicked(final MouseEvent e) {
    if (this.application != null) {
        if (e.getButton() == MouseEvent.BUTTON1) {
            final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint());
            this.hexMapPanel.setToolTipText(
                    this.application.processHexAction(this.hexMapPanel, e, HexAction.CLICK, hexNumber));
        }//from  w ww  .  j  av  a  2s.c o m
    } else {
        switch (e.getButton()) {
        case MouseEvent.BUTTON1: {
            final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint());
            useCurrentToolAtPosition(hexNumber);
        }
            break;
        }
    }
}

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.j  a v  a  2s  .  co m
        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:gtu._work.ui.DirectoryCompareUI.java

private void dirCompareTableMouseClicked(MouseEvent evt) {
    try {/*w  w  w. jav a  2  s.  c  o m*/
        final JTableUtil util = JTableUtil.newInstance(dirCompareTable);
        InfoObj obj = getInfoObj(util.getSelectedRow(), util);

        if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
            File mainFile = obj.mainFile.getFile().exists() ? obj.mainFile.getFile() : NOT_EXIST_FILE;
            File compareFile = obj.compareToFile.getFile().exists() ? obj.compareToFile.getFile()
                    : NOT_EXIST_FILE;

            File fileA = mainFile;
            File fileB = compareFile;
            if (mergeSwap) {
                File tempFile = fileA;
                fileA = fileB;
                fileB = tempFile;
            }

            DiffMergeCommand diffCommand = (DiffMergeCommand) diffToolComboBox.getSelectedItem();
            String command = diffCommand.getCommand(this, fileA, fileB);
            System.out.println(command);
            ProcessWatcher.newInstance(Runtime.getRuntime().exec(command)).getStreamSync();
        }
        if (evt.getClickCount() == 1 && evt.getButton() == MouseEvent.BUTTON3) {
            final File mainFile = obj.mainFile.getFile();
            final File compareToFile = obj.compareToFile.getFile();

            JPopupMenuUtil.newInstance(dirCompareTable).applyEvent(evt)//
                    .addJMenuItem("", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            JCommonUtil._jOptionPane_showMessageDialog_info(//
                                    ": " + (mainFile.exists() ? mainFile.getAbsolutePath() : "?")
                                            + //
                            "\n?: " + (compareToFile.exists() ? compareToFile.getAbsolutePath()
                                    : "?"), //
                                    mainFile.getName());
                        }
                    })//
                    .addJMenuItem("merge??:" + (!mergeSwap ? "(?)" : "(?)"),
                            new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    mergeSwap = !mergeSwap;
                                }
                            })//
                    .addJMenuItem(" [open file]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(mainFile);
                        }
                    })//
                    .addJMenuItem(" [open dir]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(mainFile.getParentFile());
                        }
                    })//
                    .addJMenuItem("? [open file]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(compareToFile);
                        }
                    })//
                    .addJMenuItem("? [open dir]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(compareToFile.getParentFile());
                        }
                    })//
                    .addJMenuItem(" -> ? ()", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            int[] rows = util.getSelectedRows();
                            if (rows != null && rows.length >= 1) {
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?" + rows.length + ", ?!", "")) {
                                    List<File> fileList = new ArrayList<File>();
                                    for (int ii = 0; ii < rows.length; ii++) {
                                        InfoObj obj = getInfoObj(rows[ii], util);
                                        File mainFile = obj.mainFile.getFile();
                                        File compareToFile = obj.compareToFile.getFile();
                                        overwriteFile(mainFile, compareToFile, fileList);
                                    }
                                    StringBuilder sb = new StringBuilder();
                                    for (File f : fileList) {
                                        sb.append(f + "\n");
                                    }
                                    JCommonUtil._jOptionPane_showMessageDialog_info(sb, "?");
                                }
                            } else {
                                overwriteFile(mainFile, compareToFile, null);
                            }
                        }
                    })//
                    .addJMenuItem("? ->  ()", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            int[] rows = util.getSelectedRows();
                            if (rows != null && rows.length >= 1) {
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?" + rows.length + ", ?!", "")) {
                                    List<File> fileList = new ArrayList<File>();
                                    for (int ii = 0; ii < rows.length; ii++) {
                                        InfoObj obj = getInfoObj(rows[ii], util);
                                        File mainFile = obj.mainFile.getFile();
                                        File compareToFile = obj.compareToFile.getFile();
                                        overwriteFile(compareToFile, mainFile, fileList);
                                    }
                                    StringBuilder sb = new StringBuilder();
                                    for (File f : fileList) {
                                        sb.append(f + "\n");
                                    }
                                    JCommonUtil._jOptionPane_showMessageDialog_info(sb, "?");
                                }
                            } else {
                                overwriteFile(compareToFile, mainFile, null);
                            }
                        }
                    })//
                    .addJMenuItem("(?)", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            pourOutFilesByOrignPath(true);
                        }
                    })//
                    .addJMenuItem("?(?)", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            pourOutFilesByOrignPath(false);
                        }
                    }).show();
        }
    } catch (Exception e) {
        JCommonUtil.handleException(e, false);
    }
}

From source file:net.ytbolg.mcxa.MCLaucherXA.java

private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
    if (jList1.getSelectedIndex() == -1) {
        return;/*from w  w  w  . j  av a2 s . c o m*/
    }

    try {
        if (MakeCmd.isChanged(
                new ZipFile(GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString()
                        + tpf + jList1.getSelectedValue().toString() + ".jar"))) {
            jComboBox1.setSelectedItem(
                    "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true");
        } else {
            jComboBox1.setSelectedItem("");
        }
    } catch (IOException ex) {
        Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex);
    }

    if (evt.getButton() == MouseEvent.BUTTON3 && jList1.getSelectedIndex() != -1) {
        jPopupMenu1.show(this, evt.getX() + 25, evt.getY() + 25);
    }
    if (evt.getButton() == MouseEvent.BUTTON2 && evt.getClickCount() == 2) {
        jButton1ActionPerformed(null);
    }
    try {
        BrushLabels(jList1.getSelectedIndex());
    } catch (JSONException e) {
    } catch (Exception ex) {
        Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex);
    }
    // TODO add your handling code here:
}

From source file:Clavis.Windows.WShedule.java

public synchronized void refreshTable(int val) {
    DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
    if (modelo.getRowCount() > 0) {
        int tam = modelo.getRowCount();
        for (int h = 0; h < tam; h++) {
            modelo.removeRow(0);//from  w  ww .  j  ava  2s  . co m
        }
    }

    java.util.List<Keys.Request> requisicoes = new java.util.ArrayList<>();
    if (DataBase.DataBase.testConnection(url)) {
        DataBase.DataBase db = new DataBase.DataBase(url);
        requisicoes = Clavis.RequestList
                .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim));
        db.close();
    }
    lista = new java.util.ArrayList<>();
    andamento = 0;
    switch (val) {
    case 0:
        estado = lingua.translate("Todos");
        for (Keys.Request req : requisicoes) {
            String[] multipla = req.getActivity().split(":::");
            String saux;
            if (multipla.length > 1) {
                saux = multipla[0];
                Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                pop.create();
                jTable1.addMouseListener(new MouseAdapter() {
                    int x = andamento;
                    int y = 3;

                    @Override
                    public void mousePressed(MouseEvent e) {
                        if (e.getButton() == MouseEvent.BUTTON1) {
                            int row = jTable1.rowAtPoint(e.getPoint());
                            int col = jTable1.columnAtPoint(e.getPoint());
                            if ((row == x) && (col == y)) {
                                pop.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    }

                    @Override
                    public void mouseReleased(MouseEvent e) {
                        if (e.getButton() == MouseEvent.BUTTON1) {
                            if (pop.isShowing()) {
                                pop.setVisible(false);
                            }
                        }
                    }
                });
            } else {
                saux = req.getActivity();
            }
            if (saux.equals("")) {
                saux = lingua.translate("Sem descrio");
            }
            if (mat.getMaterialTypeID() == 1) {
                Object[] ob = { req.getPerson().getName(),
                        req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                        req.getBeginDate().toString(), saux, req.getSubject().getName() };
                modelo.addRow(ob);
            } else {
                Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                        req.getEndDate().toString(), saux };
                modelo.addRow(ob);
            }
            lista.add(req);
            andamento++;
        }
        break;
    case 1:
        estado = lingua.translate("terminado");
        for (Keys.Request req : requisicoes) {
            if (req.isTerminated()) {
                String[] multipla = req.getActivity().split(":::");
                String saux;
                if (multipla.length > 1) {
                    saux = multipla[0];
                    Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                    pop.create();
                    jTable1.addMouseListener(new MouseAdapter() {
                        int x = andamento;
                        int y = 3;

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                int row = jTable1.rowAtPoint(e.getPoint());
                                int col = jTable1.columnAtPoint(e.getPoint());
                                if ((row == x) && (col == y)) {
                                    pop.show(e.getComponent(), e.getX(), e.getY());
                                }
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                if (pop.isShowing()) {
                                    pop.setVisible(false);
                                }
                            }
                        }
                    });
                } else {
                    saux = req.getActivity();
                }
                if (saux.equals("")) {
                    saux = lingua.translate("Sem descrio");
                }
                if (mat.getMaterialTypeID() == 1) {
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), saux, req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), saux };
                    modelo.addRow(ob);
                }
                lista.add(req);
                andamento++;
            }
        }
        break;
    case 2:
        estado = lingua.translate("no realizado");
        for (Keys.Request req : requisicoes) {
            if ((!req.isActive()) && ((req.getEndDate().isBigger(new TimeDate.Date()) > 0)
                    || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0)
                            && (req.getTimeEnd().compareTime(new TimeDate.Time()) > 0)))) {
                String[] multipla = req.getActivity().split(":::");
                String saux;
                if (multipla.length > 1) {
                    saux = multipla[0];
                    Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                    pop.create();
                    jTable1.addMouseListener(new MouseAdapter() {
                        int x = andamento;
                        int y = 3;

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                int row = jTable1.rowAtPoint(e.getPoint());
                                int col = jTable1.columnAtPoint(e.getPoint());
                                if ((row == x) && (col == y)) {
                                    pop.show(e.getComponent(), e.getX(), e.getY());
                                }
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                if (pop.isShowing()) {
                                    pop.setVisible(false);
                                }
                            }
                        }
                    });
                } else {
                    saux = req.getActivity();
                }
                if (saux.equals("")) {
                    saux = lingua.translate("Sem descrio");
                }
                if (mat.getMaterialTypeID() == 1) {
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), saux, req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), saux };
                    modelo.addRow(ob);
                }
                lista.add(req);
                andamento++;
            }
        }
        break;
    case 3:
        estado = lingua.translate("por realizar");
        for (Keys.Request req : requisicoes) {
            if ((!req.isActive()) && (!req.isTerminated())
                    && ((req.getEndDate().isBigger(new TimeDate.Date()) < 0)
                            || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0)
                                    && (req.getTimeEnd().compareTime(new TimeDate.Time()) < 0)))) {
                String[] multipla = req.getActivity().split(":::");
                String saux;
                if (multipla.length > 1) {
                    saux = multipla[0];
                    Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                    pop.create();
                    jTable1.addMouseListener(new MouseAdapter() {
                        int x = andamento;
                        int y = 3;

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                int row = jTable1.rowAtPoint(e.getPoint());
                                int col = jTable1.columnAtPoint(e.getPoint());
                                if ((row == x) && (col == y)) {
                                    pop.show(e.getComponent(), e.getX(), e.getY());
                                }
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                if (pop.isShowing()) {
                                    pop.setVisible(false);
                                }
                            }
                        }
                    });
                } else {
                    saux = req.getActivity();
                }
                if (saux.equals("")) {
                    saux = lingua.translate("Sem descrio");
                }
                if (mat.getMaterialTypeID() == 1) {
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), saux, req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), saux };
                    modelo.addRow(ob);
                }
                lista.add(req);
                andamento++;
            }
        }
        break;
    }
    valores = new String[lista.size()][4];
    for (int i = 0; i < lista.size(); i++) {
        String[] multipla = lista.get(i).getActivity().split(":::");
        String saux = multipla[0];
        if (saux.equals("")) {
            saux = lingua.translate("Sem descrio");
        }
        if (mat.getMaterialTypeID() == 1) {
            valores[i][0] = lista.get(i).getPerson().getName();
            valores[i][1] = lista.get(i).getTimeBegin().toString(0) + " - "
                    + lista.get(i).getTimeEnd().toString(0);
            valores[i][2] = lista.get(i).getBeginDate().toString();
            valores[i][3] = saux + " - " + lista.get(i).getSubject().getName();
        } else {
            valores[i][0] = lista.get(i).getPerson().getName();
            valores[i][1] = lista.get(i).getBeginDate().toString();
            valores[i][2] = lista.get(i).getEndDate().toString();
            valores[i][3] = saux;
        }
    }
}

From source file:org.smart.migrate.ui.MigrateMain.java

private void listPlanMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listPlanMouseReleased
    // TODO add your handling code here:
    if (evt.getButton() == 3 && listPlan.getSelectedIndex() >= 0) {
        popPlan.show(evt.getComponent(), evt.getX(), evt.getY());
    }/*from ww  w  . java 2  s  .  c om*/
}