Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

In this page you can find the example usage for javax.swing AbstractAction AbstractAction.

Prototype

public AbstractAction(String name) 

Source Link

Document

Creates an Action with the specified name.

Usage

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

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

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

    if (tableTmp != null) {

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

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

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

            public void mousePressed(final MouseEvent mE) {

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

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

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

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

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

                            MouvementSQLElement.showSource(ecriture.getIdMvt());

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

    }
    return tableTmp;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Creates the action for the inplace import icon tooltip
 * @return/*from w  w  w . j  a  v  a2 s .c  o m*/
 */
private Action createInplaceIconAction() {
    Action inplaceIconAction = new AbstractAction(INPLACE_IMPORT_TOOLTIP_ACTION_TEXT) {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            // Just pass this on to the controller
            controller.actionPerformed(arg0);
        }
    };
    inplaceIconAction.putValue(Action.ACTION_COMMAND_KEY, "" + EditorControl.FILE_PATH_INPLACE_ICON);
    return inplaceIconAction;
}

From source file:com.diversityarrays.kdxplore.curate.TraitsAndInstancesPanel2.java

private void showContextMenu(MouseEvent me) {

    Map<SimpleStatistics<?>, TraitInstance> tiByStat = new HashMap<>();

    List<SimpleStatistics<?>> statsList = new ArrayList<>();
    List<TraitInstance> selectedInstances = new ArrayList<>();

    Set<Integer> rowSet = new HashSet<>();

    for (int row : traitInstanceStatsTable.getSelectedRows()) {
        rowSet.add(row);/*from   ww w.  j  av a2s.  co m*/
    }

    // Include the right-click one too
    int row = traitInstanceStatsTable.rowAtPoint(me.getPoint());
    if (row >= 0) {
        rowSet.add(row);
    }

    List<Integer> vrows = new ArrayList<>(rowSet);
    Collections.sort(vrows);
    for (Integer vrow : vrows) {
        collectInfoFromRow(vrow, selectedInstances, tiByStat, statsList);
    }

    List<TraitInstance> checkedInstances = tiStatsModel.getCheckedTraitInstances();

    Action action = null;
    if (!statsList.isEmpty()) {
        String label = statsList.size() == 1 ? "Show Outliers"
                : "Show Outliers for " + statsList.size() + " Traits";
        action = new AbstractAction(label) {
            @Override
            public void actionPerformed(ActionEvent e) {
                StringBuilder html = new StringBuilder();
                html.append("<HTML><TABLE><TR>");

                outlierSelections.clear();

                for (SimpleStatistics<?> stat : statsList) {
                    html.append("<TH>");
                    html.append(StringUtil.htmlEscape(stat.getStatsName()));
                    html.append("</TH>");
                }

                html.append("</TR><TR>");

                for (SimpleStatistics<?> stat : statsList) {
                    TraitInstance ti = tiByStat.get(stat);
                    html.append("<TD valign='top'>");
                    describeStats(stat, html, ti);
                    html.append("</TD>");

                    outlierSelections.add(createOutlierSelection(stat, ti));
                }
                html.append("</TR></TABLE>");

                outlierConsumer.accept(outlierSelections);

                JOptionPane.showMessageDialog(TraitsAndInstancesPanel2.this, html.toString(), "Outliers",
                        JOptionPane.INFORMATION_MESSAGE);

            }
        };
    }

    curationMenuProvider.showTraitInstanceTableToolMenu(me, checkedInstances, selectedInstances, action);
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * // ww w  .  j a v  a 2s .c  o m
 * @return
 */
public Action getSelectTankAction() {
    Action ret = actionMap.get(ACTION_SELECT_TANK);
    if (ret == null) {
        ret = new AbstractAction(ACTION_SELECT_TANK) {
            private static final long serialVersionUID = 1L;
            final JComboBox cb = getComboBox();

            @Override
            public void actionPerformed(ActionEvent event) {
                try {
                    int selected = JOptionPane.showConfirmDialog(debuggerFrame, cb,
                            "Enter the base URL to Tank:", JOptionPane.OK_CANCEL_OPTION,
                            JOptionPane.QUESTION_MESSAGE);
                    if (selected == JOptionPane.OK_OPTION) {
                        String url = (String) cb.getSelectedItem();
                        if (url != null) {
                            int startInd = url.indexOf('(');
                            int endInd = url.indexOf(')');
                            if (startInd != -1 && endInd != -1) {
                                url = url.substring(startInd + 1, endInd);
                            }
                            url = StringUtils.removeEndIgnoreCase(url, "/");
                            if (!url.startsWith("http")) {
                                url = "http://" + url;
                            }
                            try {
                                new ScriptServiceClient(url).ping();
                                setServiceUrl(url);
                            } catch (Exception e) {
                                showError("Cannot connect to Tank at the url " + url
                                        + ". \nExample: http://tank.mysite.com/");
                            }
                        }
                    }
                } catch (HeadlessException e) {
                    showError("Error opening file: " + e);
                }
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, "Enter a Tank URL.");
        actionMap.put(ACTION_SELECT_TANK, ret);
    }
    return ret;
}

From source file:feedsplugin.FeedsPlugin.java

private void updateFeedsInternal() {
    synchronized (mFeeds) {
        mFeeds = new ArrayList<SyndFeed>();
    }//from w w w . jav a  2 s  .c o m
    Hashtable<SyndFeed, PluginTreeNode> nodes = new Hashtable<SyndFeed, PluginTreeNode>();
    ArrayList<String> feedUrls = mSettings.getFeeds();
    if (!feedUrls.isEmpty()) {

        /* the class loader of the current thread must be manipulated because ROME searches its
         * properties files via Thread.currentThread.getContextClassLoader(). But that is not the
         * classloader used for ROME classes, so we fake it. */
        ClassLoader cl = SyndFeedImpl.class.getClassLoader();
        Thread.currentThread().setContextClassLoader(cl);

        final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
        final FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
        feedFetcher.setUserAgent("TV-Browser Feeds Plugin " + FeedsPlugin.getVersion().toString());
        for (String feedUrl : feedUrls) {
            try {
                final SyndFeed feed = feedFetcher.retrieveFeed(new URL(feedUrl));
                synchronized (mFeeds) {
                    mFeeds.add(feed);
                }
                mLog.info("Loaded " + feed.getEntries().size() + " feed entries from " + feedUrl);
            } catch (Exception e) {
                mLog.severe("Problems loading feed " + feedUrl);
                e.printStackTrace();
            }
        }
    }
    mKeywords = new HashMap<String, ArrayList<SyndEntryWithParent>>();
    if (!mFeeds.isEmpty()) {
        synchronized (mFeeds) {
            for (SyndFeed feed : mFeeds) {
                addFeedKeywords(feed);
            }
        }
        getRootNode().clear();
        ArrayList<String> titles = new ArrayList<String>(mFeeds.size());
        final Channel[] channels = devplugin.Plugin.getPluginManager().getSubscribedChannels();
        Date date = Date.getCurrentDate();
        final int maxDays = 7;
        synchronized (mFeeds) {
            Collections.sort(mFeeds, new Comparator<SyndFeed>() {
                public int compare(SyndFeed o1, SyndFeed o2) {
                    return o1.getTitle().compareToIgnoreCase(o2.getTitle());
                }
            });
            for (SyndFeed feed : mFeeds) {
                PluginTreeNode node = getRootNode().addNode(feed.getTitle());
                List<SyndEntryImpl> entries = feed.getEntries();
                titles.add(feed.getTitle());
                AbstractAction[] subActions = new AbstractAction[entries.size()];
                for (int i = 0; i < subActions.length; i++) {
                    final SyndEntryImpl entry = entries.get(i);
                    subActions[i] = new AbstractAction(entry.getTitle()) {
                        public void actionPerformed(ActionEvent e) {
                            showFeedsDialog(new FeedsDialog(getParentFrame(), entry));
                        }
                    };
                }
                ActionMenu menu = new ActionMenu(
                        new ContextMenuAction(mLocalizer.msg("readEntry", "Read entry")), subActions);
                node.addActionMenu(menu);
                nodes.put(feed, node);
            }
            mSettings.setCachedFeedTitles(titles);
            for (int days = 0; days < maxDays; days++) {
                for (Channel channel : channels) {
                    for (Iterator<Program> iter = devplugin.Plugin.getPluginManager().getChannelDayProgram(date,
                            channel); iter.hasNext();) {
                        final Program prog = iter.next();
                        ArrayList<SyndEntryWithParent> matchingEntries = getMatchingEntries(prog.getTitle());
                        if (!matchingEntries.isEmpty()) {
                            HashSet<SyndFeed> feeds = new HashSet<SyndFeed>();
                            for (SyndEntryWithParent entry : matchingEntries) {
                                feeds.add(entry.getFeed());
                            }
                            for (SyndFeed syndFeed : feeds) {
                                nodes.get(syndFeed).addProgramWithoutCheck(prog);
                                prog.validateMarking();
                            }
                        }
                    }
                }
                date = date.addDays(1);
            }
        }
        mRootNode.update();
    }
}

From source file:maltcms.ui.fileHandles.csv.CSVTableView.java

private void createAndShowPopupMenu(MouseEvent me) {
    if (me.getButton() == MouseEvent.BUTTON3 && this.jTable1.getSelectedRowCount() > 0 && this.jfctc != null) {

        JPopupMenu jpm = new JPopupMenu();

        //more than one column selected
        if (jTable1.getSelectedColumnCount() > 0) {
            jpm.add(new AbstractAction("Add as y-values") {

                @Override//  ww w . j  ava 2  s  .  c  om
                public void actionPerformed(ActionEvent ae) {
                    for (int col : jTable1.getSelectedColumns()) {
                        columnsToPlot.add(col);
                        jTable1.getColumnModel().getColumn(col).setCellRenderer(new ColorColumnRenderer(
                                new Color(238, 187, 0, 255), jTable1.getSelectedRows()));
                    }
                    jfctc.setChart(
                            buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows()));
                }
            });
            //selected rows
            for (final int col : jTable1.getSelectedColumns()) {
                if (columnsToPlot.contains(col)) {
                    jpm.add(new AbstractAction("Remove y-values from chart") {

                        @Override
                        public void actionPerformed(ActionEvent ae) {
                            jTable1.getColumnModel().getColumn(col).setCellRenderer(
                                    new ColorColumnRenderer(Color.WHITE, jTable1.getSelectedRows()));
                            columnsToPlot.remove(col);
                            jfctc.setChart(buildChart(labelColumn, domainColumn, columnsToPlot,
                                    jTable1.getSelectedRows()));
                        }
                    });
                    break;
                }
            }
            jpm.add(new JPopupMenu.Separator());
            jpm.add(new AbstractAction("Log10 transform") {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    final int[] cols = jTable1.getSelectedColumns();
                    for (int i = 0; i < jTable1.getSelectedColumnCount(); i++) {
                        logTransformColumn(cols[i], 10.0d);
                    }

                }
            });
            jpm.add(new AbstractAction("Inverse Log10 transform") {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    final int[] cols = jTable1.getSelectedColumns();
                    for (int i = 0; i < jTable1.getSelectedColumnCount(); i++) {
                        inverseLogTransformColumn(cols[i], 10.0d);
                    }

                }
            });
        }
        jpm.add(new JPopupMenu.Separator());
        //exactly one selected column, no domain column
        if (jTable1.getSelectedColumnCount() == 1 && domainColumn == -1) {
            jpm.add(new AbstractAction("Set as x-values") {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    domainColumn = jTable1.getSelectedColumn();
                    jTable1.getColumnModel().getColumn(domainColumn).setCellRenderer(
                            new ColorColumnRenderer(new Color(255, 0, 0, 255), jTable1.getSelectedRows()));
                    jfctc.setChart(
                            buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows()));
                }
            });

        }
        //one domainColumn
        if (domainColumn != -1) {
            jpm.add(new AbstractAction("Reset x-axis values") {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    jTable1.getColumnModel().getColumn(domainColumn).setCellRenderer(
                            new ColorColumnRenderer(new Color(255, 255, 255, 255), jTable1.getSelectedRows()));
                    domainColumn = -1;
                    jfctc.setChart(
                            buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows()));
                }
            });
        }
        jpm.add(new JPopupMenu.Separator());
        if (jTable1.getSelectedColumnCount() == 1 && labelColumn == -1) {
            jpm.add(new AbstractAction("Set as series labels") {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    labelColumn = jTable1.getSelectedColumn();
                    jTable1.getColumnModel().getColumn(labelColumn).setCellRenderer(
                            new ColorColumnRenderer(new Color(255, 255, 0, 255), jTable1.getSelectedRows()));
                    jfctc.setChart(
                            buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows()));
                }
            });
        }

        if (jTable1.getSelectedColumnCount() == 1 && labelColumn != -1) {
            jpm.add(new AbstractAction("Reset series labels") {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    jTable1.getColumnModel().getColumn(labelColumn).setCellRenderer(
                            new ColorColumnRenderer(new Color(255, 255, 255, 255), jTable1.getSelectedRows()));
                    labelColumn = -1;
                    jfctc.setChart(
                            buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows()));
                }
            });
        }

        jpm.show(me.getComponent(), me.getX(), me.getY());
    }
}

From source file:idontwant2see.IDontWant2See.java

private AbstractAction getActionDontWantToSee(final Program p) {
    return new AbstractAction(mLocalizer.msg("menu.completeCaseSensitive", "Complete title case-sensitive")) {
        public void actionPerformed(final ActionEvent e) {
            mSettings.getSearchList().add(new IDontWant2SeeListEntry(p.getTitle(), true));
            mSettings.setLastEnteredExclusionString(p.getTitle());
            updateFilter(!mSettings.isSwitchToMyFilter());
        }/*from  w w  w  .  ja  v  a2 s  .  c  o m*/
    };
}

From source file:org.jax.maanova.madata.gui.ArrayScatterPlotPanel.java

@SuppressWarnings("serial")
private JMenuBar createMenu() {
    JMenuBar menuBar = new JMenuBar();

    // the file menu
    JMenu fileMenu = new JMenu("File");
    fileMenu.add(this.saveGraphImageAction);
    menuBar.add(fileMenu);/*ww w  .jav a 2 s . c o m*/

    // the tools menu
    JMenu toolsMenu = new JMenu("Tools");
    JMenuItem configureGraphItem = new JMenuItem("Configure Graph...");
    configureGraphItem.addActionListener(new ActionListener() {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            ArrayScatterPlotPanel.this.chartConfigurationDialog.setVisible(true);
        }
    });
    toolsMenu.add(configureGraphItem);
    toolsMenu.addSeparator();

    toolsMenu.add(new AbstractAction("Zoom Out") {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            ArrayScatterPlotPanel.this.autoRangeChart();
        }
    });

    JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point");
    showTooltipCheckbox.setSelected(true);
    this.showTooltip = true;
    showTooltipCheckbox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            ArrayScatterPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED;
            ArrayScatterPlotPanel.this.clearProbePopup();
        }
    });
    toolsMenu.add(showTooltipCheckbox);
    menuBar.add(toolsMenu);

    // the help menu
    JMenu helpMenu = new JMenu("Help");
    JMenuItem helpMenuItem = new JMenuItem("Help...");
    Icon helpIcon = new ImageIcon(ArrayScatterPlotPanel.class.getResource("/images/action/help-16x16.png"));
    helpMenuItem.setIcon(helpIcon);
    helpMenuItem.addActionListener(new ActionListener() {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            Maanova.getInstance().showHelp("array-scatter-plot", ArrayScatterPlotPanel.this);
        }
    });
    helpMenu.add(helpMenuItem);
    menuBar.add(helpMenu);

    return menuBar;
}

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;//  ww  w . j ava 2  s. c  o 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:com.intuit.tank.proxy.ProxyApp.java

@SuppressWarnings("serial")
public JMenuBar createMenu() {
    JMenuBar ret = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenu sessionMenu = new JMenu("Session");
    ret.add(fileMenu);// ww  w . j  av  a  2  s .c  om
    ret.add(sessionMenu);

    fileMenu.add(getMenuItem(openAction));
    fileMenu.add(getMenuItem(saveAction));
    fileMenu.addSeparator();
    fileMenu.add(getMenuItem(filterAction));
    fileMenu.add(getMenuItem(settingsAction));
    fileMenu.addSeparator();
    AbstractAction quitAction = new AbstractAction("Quit") {
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    };
    quitAction.putValue(javax.swing.Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask));
    quitAction.putValue(javax.swing.Action.MNEMONIC_KEY, KeyEvent.VK_Q);

    fileMenu.add(new JMenuItem(quitAction));
    sessionMenu.add(getMenuItem(startAction));
    sessionMenu.add(getMenuItem(stopAction));
    sessionMenu.add(getMenuItem(pauseAction));
    sessionMenu.addSeparator();
    sessionMenu.add(getMenuItem(showHostsAction));

    return ret;
}