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.openmicroscopy.shoola.agents.fsimporter.util.FileImportComponent.java

/**
 * Creates or recycles the menu corresponding to the import status.
 * /*from   www  .  ja  v a  2  s.  c  o  m*/
 * @return See above.
 */
private JPopupMenu createActionMenu() {
    if (menu != null)
        return menu;
    menu = new JPopupMenu();
    JMenuItem item;
    String logText = "View Import Log";
    String checksumText = "View Checksum";
    String exceptionText = "View Exception";
    Object result = statusLabel.getImportResult();
    switch (resultIndex) {
    case FAILURE_LIBRARY:
        menu.add(new JMenuItem(new AbstractAction(exceptionText) {
            public void actionPerformed(ActionEvent e) {
                viewError();
            }
        }));
        break;
    case FAILURE:
        menu.add(new JMenuItem(new AbstractAction("Submit") {
            public void actionPerformed(ActionEvent e) {
                submitError();
            }
        }));
        menu.add(new JMenuItem(new AbstractAction(exceptionText) {
            public void actionPerformed(ActionEvent e) {
                viewError();
            }
        }));
        break;
    case UPLOAD_FAILURE:
        menu.add(new JMenuItem(new AbstractAction("Retry") {
            public void actionPerformed(ActionEvent e) {
                retry();
            }
        }));
        break;
    case SUCCESS:
        logText = "Import Log";
        checksumText = "Checksum";
        item = new JMenuItem(new AbstractAction("In Full Viewer") {
            public void actionPerformed(ActionEvent e) {
                launchFullViewer();
            }
        });
        boolean b = false;
        if (result instanceof Collection)
            b = ((Collection) result).size() == 1;
        item.setEnabled(b && !statusLabel.isHCS());
        menu.add(item);
        item = new JMenuItem(new AbstractAction("In Data Browser") {
            public void actionPerformed(ActionEvent e) {
                browse();
            }
        });
        item.setEnabled(browsable);
        menu.add(item);
    }
    item = new JMenuItem(new AbstractAction(logText) {
        public void actionPerformed(ActionEvent e) {
            displayLogFile();
        }
    });
    item.setEnabled(statusLabel.getLogFileID() > 0 || statusLabel.getFileset() != null);
    menu.add(item);

    item = new JMenuItem(new AbstractAction(checksumText) {
        public void actionPerformed(ActionEvent e) {
            showChecksumDetails();
        }
    });
    item.setEnabled(statusLabel.hasChecksum());
    menu.add(item);
    return menu;
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java

private Component createEditorButton() {
    JButton button = new I18nButton(new AbstractAction("profile.edit") {

        private static final long serialVersionUID = 489467930584458674L;

        @Override//from www. j  a  va 2 s . c  om
        public void actionPerformed(ActionEvent arg0) {
            DiveProfileEditorDialog editor = new DiveProfileEditorDialog();
            if (diveProfile != null) {
                editor.setDiveProfile(diveProfile);
            }

            int i = editor.showDialog(800, 600);
            if (i == DiveProfileEditorDialog.OPTION_OK) {
                DiveProfile dp = editor.getDiveProfile();
                currentDive.setDiveProfile(dp);
                setDiveProfile(dp, currentDive);
                logBookManagerFacade.setDiveChanged(currentDive);
            }
        }
    });
    return button;
}

From source file:org.pegadi.client.ApplicationLauncher.java

private void jbInit() {
    ImageIcon icon = new ImageIcon(getClass().getResource("/images/pegadi.gif"));
    setIconImage(icon.getImage());//from   w w w  .  j  ava2 s .  c o  m

    this.getContentPane().setLayout(borderLayout1);
    jPanel1.setLayout(flowLayout1);
    listerButton.setEnabled(false);
    publicationButton.setEnabled(false);
    tetrisButton.setEnabled(false);

    // ImageIcon reportBugIcon = new
    // ImageIcon(getClass().getResource(appStrings.getString("icon_open")));

    reportBugAction = new AbstractAction(str.getString("menu_help_report")) {
        public void actionPerformed(ActionEvent e) {
            reportBug_actionPerformed(e);
        }
    };

    prefsMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            prefsMenuItem_actionPerformed(e);
        }
    });

    listerMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(76, java.awt.event.KeyEvent.CTRL_MASK, false));
    listerMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            listerButton_actionPerformed(e);
        }
    });

    sourcesMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(73, java.awt.event.KeyEvent.CTRL_MASK, false));
    sourcesMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            sourcesButton_actionPerformed();
        }
    });

    tetrisMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(84, java.awt.event.KeyEvent.CTRL_MASK, false));
    tetrisMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tetrisButton_actionPerformed(e);
        }
    });

    logoutMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(87, java.awt.event.KeyEvent.CTRL_MASK, false));
    logoutMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            logoutMenuItem_actionPerformed(e);
        }
    });

    quitMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(81, java.awt.event.KeyEvent.CTRL_MASK, false));
    quitMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            quitMenuItem_actionPerformed(e);
        }
    });

    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(listerButton, null);

    listerButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            listerButton_actionPerformed(e);
        }
    });

    publicationButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            publicationButton_actionPerformed(e);
        }
    });

    sourcesButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            sourcesButton_actionPerformed();
        }
    });

    tetrisButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tetrisButton_actionPerformed(e);
        }
    });

    logoutButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            logoutButton_actionPerformed(e);
        }
    });

    quitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            quitButton_actionPerformed(e);
        }
    });

    jPanel1.add(publicationButton, null);
    jPanel1.add(sourcesButton, null);
    jPanel1.add(tetrisButton, null);
    this.getContentPane().add(jPanel2, BorderLayout.EAST);
    jPanel2.add(usrlabel, null);
    jPanel2.add(logoutButton, null);
    jPanel2.add(quitButton, null);
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(helpMenu);
    editMenu.add(prefsMenuItem);
    fileMenu.add(listerMenuItem);
    fileMenu.add(sourcesMenuItem);
    fileMenu.add(tetrisMenuItem);
    fileMenu.add(logoutMenuItem);
    fileMenu.add(quitMenuItem);
    helpMenu.add(reportBugAction);
    this.setJMenuBar(menuBar);
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            conditionalExit();
        }
    });
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

}

From source file:de.codesourcery.jasm16.ide.ui.MenuManager.java

protected JMenuBar createMenuBar() {
    final List<MenuEntry> copy;
    synchronized (entriesList) {
        copy = new ArrayList<MenuEntry>(entriesList);
    }/*from w  w  w  .j  av  a 2  s.c om*/

    // collect distinct parent paths
    final List<MenuPath> paths = new ArrayList<MenuPath>();
    for (MenuEntry e : copy) {
        if (!e.isVisible()) {
            continue;
        }
        final MenuPath parentPath = e.getPath().getParentPath();
        if (parentPath == null) {
            continue;
        }
        for (MenuPath p : parentPath.getAllPaths()) {
            if (!paths.contains(p)) {
                paths.add(p);
            }
        }
    }

    // sort paths ascending by length
    Collections.sort(paths, new Comparator<MenuPath>() {

        @Override
        public int compare(MenuPath o1, MenuPath o2) {
            final int len1 = o1.toString().length();
            final int len2 = o2.toString().length();
            if (len1 < len2) {
                return -1;
            } else if (len1 > len2) {
                return 1;
            }
            return 0;
        }
    });

    /*
     * - a
     *   |
     *   +-- b
     *       |
     *       + c  
     */

    // create menu for each path
    final Map<MenuPath, JMenu> menuesByPath = new HashMap<MenuPath, JMenu>();
    for (MenuPath path : paths) {
        final JMenu menu = new JMenu(path.getLastPathComponent());
        menuesByPath.put(path, menu);
        JMenu parentMenu = menuesByPath.get(path.getParentPath());
        if (parentMenu != null) {
            parentMenu.add(menu);
        }
    }

    // setup menu bar

    //Where the GUI is created:
    final JMenuBar menuBar = new JMenuBar();

    final Set<MenuPath> topLevelMenues = new HashSet<MenuPath>();

    for (final MenuEntry e : copy) {

        if (!e.isVisible()) {
            continue;
        }

        final MenuPath parentPath = e.getPath().getParentPath();
        final JMenu menu = menuesByPath.get(parentPath);
        if (menu == null) {
            throw new RuntimeException("Internal error, failed to create menu for path: " + e.getPath());
        }

        // register top-level menues
        if (parentPath.length() == 1) {
            if (!topLevelMenues.contains(parentPath)) {
                menuBar.add(menu);
                topLevelMenues.add(parentPath);
            }
        }

        final Action action;
        action = new AbstractAction(e.getLabel()) {

            @Override
            public void actionPerformed(ActionEvent event) {
                e.onClick();
            }

            @Override
            public boolean isEnabled() {
                return e.isEnabled();
            }

        };

        final JMenuItem item = new JMenuItem(action) {

            @Override
            public boolean isEnabled() {
                return action.isEnabled();
            }
        };

        if (e.hasMnemonic()) {
            item.setMnemonic(e.getMnemonic());
        }
        e.setMenuItem(item);
        menu.add(item);
    }

    return menuBar;
}

From source file:com.jpetrak.gate.scala.ScalaScriptPR.java

@Override
public List<Action> getActions() {
    if (actions == null) {
        actions = new ArrayList<Action>();
        actions.add(new AbstractAction("Re-initialize the Scala Compiler") {
            {//from  w w w  .j av  a2s  . co  m
                putValue(SHORT_DESCRIPTION, "Throw away the existing Scala Compiler and create a new one");
                putValue(GateConstants.MENU_PATH_KEY, new String[] { "Scala" });
            }
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent evt) {
                Runnable runnableAction = new Runnable() {
                    @Override
                    public void run() {
                        try {
                            MainFrame.lockGUI("Re-initializing the Scala compiler ...");
                            tryInitCompiler(false);
                        } finally {
                            MainFrame.unlockGUI();
                        }
                    }
                };
                Thread thread = new Thread(runnableAction, "Scala Compiler Re-Initialization");
                thread.start();
            };
        });
    }
    return actions;
}

From source file:feedsplugin.FeedsPlugin.java

@Override
public ActionMenu getButtonAction() {
    if (mSettings == null) {
        return null;
    }//  ww w  . j  av a  2  s. c o  m
    ArrayList<String> feedTitles = mSettings.getCachedFeedTitles();
    if (feedTitles.isEmpty()) {
        return null;
    }
    ContextMenuAction mainAction = new ContextMenuAction(mLocalizer.msg("name", "Feeds"), getPluginIcon());
    ArrayList<AbstractAction> list = new ArrayList<AbstractAction>(feedTitles.size());
    for (int i = 0; i < feedTitles.size(); i++) {
        final String title = feedTitles.get(i);
        final int feedIndex = i;
        list.add(new AbstractAction(title) {

            public void actionPerformed(ActionEvent e) {
                SyndFeed selectedFeed = mFeeds.get(feedIndex);
                if (selectedFeed != null) {
                    List entries = selectedFeed.getEntries();
                    showFeedsDialog(new FeedsDialog(getParentFrame(), entries));
                }
            }
        });
    }
    Collections.sort(list, new Comparator<AbstractAction>() {

        public int compare(AbstractAction o1, AbstractAction o2) {
            return ((String) o1.getValue(AbstractAction.NAME))
                    .compareTo((String) o2.getValue(AbstractAction.NAME));
        }
    });
    return new ActionMenu(mainAction, list.toArray(new AbstractAction[list.size()]));
}

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

public SQLComponent createComponent() {

    return new BaseSQLComponent(this) {

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

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

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

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

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

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

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

                        final Object obj = path.getLastPathComponent();

                        if ((obj == null) || !(obj instanceof VariableRowTreeNode)) {
                            return;
                        }/*w  ww  .j a  va  2  s  . c o m*/

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    setFormuleEnabled(true);
                }
            });

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

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

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

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

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

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

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

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

        private void setFormuleEnabled(boolean b) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        @Override
        public void select(SQLRowAccessor r) {

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

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

            this.updateValidVarName();
        }
    };
}

From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.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);/*from   w w w.java  2  s . co  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) {
            ResidualPlotPanel.this.chartConfigurationDialog.setVisible(true);
        }
    });
    toolsMenu.add(configureGraphItem);
    toolsMenu.addSeparator();

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

    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) {
            ResidualPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED;
            ResidualPlotPanel.this.clearProbePopup();
        }
    });
    toolsMenu.add(showTooltipCheckbox);
    menuBar.add(toolsMenu);

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

    return menuBar;
}

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

private void actionDroitTable(MouseEvent e, final JTable table) {
    JPopupMenu menuDroit = new JPopupMenu();

    for (int i = 0; i < this.actionClickDroit.size(); i++) {
        menuDroit.add((AbstractAction) this.actionClickDroit.get(i));
    }/*w w w .j a  v  a2s.  c  o  m*/

    menuDroit.add(new AbstractAction("Tout slectionner") {

        public void actionPerformed(ActionEvent e) {
            table.selectAll();
        }
    });

    menuDroit.show(e.getComponent(), e.getX(), e.getY());

    System.out.println("Click droit sur JTable");
}

From source file:org.interreg.docexplore.GeneralConfigPanel.java

public GeneralConfigPanel(final File config) throws Exception {
    this.configFile = config;

    final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>";
    setLayout(new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP));

    //      JPanel ac = new JPanel(new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      ac.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgACLabel")));
    //      ac.add(useAutoConnect = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseACLabel")));
    //      JPanel typePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    //      typePanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTypeLabel")));
    //      typePanel.add(autoConnectType = new JComboBox(new Object [] {XMLResourceBundle.getBundledString("cfgFileLabel"), XMLResourceBundle.getBundledString("cfgMysqlLabel")}));
    //      ac.add(typePanel);
    //      ac.add(autoConnectSubPanel = new JPanel(new BorderLayout()));
    //      //from ww w.j  ava2  s .com
    //      fsSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      fsSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); fsSubPanel.add(acFSPath = new JTextField(40));
    //      
    //      dbSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); dbSubPanel.add(acDBPath = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgHostLabel"))); dbSubPanel.add(acDBHost = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDBLabel"))); dbSubPanel.add(acDBDatabase = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgUserLabel"))); dbSubPanel.add(acDBUser = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPasswordLabel"))); dbSubPanel.add(acDBPassword = new JTextField(40));
    //      
    //      Set<ConnectionHandler.PastConnection> cons = new ConnectionHandler().connections;
    //      if (cons != null)
    //      {
    //         Vector<Object> recentCons = new Vector<Object>();
    //         for (ConnectionHandler.PastConnection con : cons)
    //            if (con.source instanceof DataLinkMySQLSource || con.source instanceof DataLinkFS2Source)
    //               recentCons.add(con);
    //         
    //         if (!recentCons.isEmpty())
    //         {
    //            recentCons.insertElementAt(XMLResourceBundle.getBundledString("cfgCurrentLabel"), 0);
    //            JPanel recentPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    //            recentPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgRecentLabel")));
    //            JComboBox recentBox = new JComboBox(recentCons);
    //            recentPanel.add(recentBox);
    //            ac.add(recentPanel);
    //            
    //            recentBox.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e)
    //            {
    //               if (e.getStateChange() != ItemEvent.SELECTED)
    //                  return;
    //               if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgCurrentLabel")))
    //                  fillAutoConnect(xml);
    //               else fillAutoConnect((ConnectionHandler.PastConnection)e.getItem());
    //            }});
    //         }
    //      }

    JPanel display = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    display.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgDisplayLabel")));
    JPanel displayDims = new JPanel(
            new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgWidthLabel")));
    displayDims.add(displayWidth = new JTextField(5));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgHeightLabel")));
    displayDims.add(displayHeight = new JTextField(5));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgLanguageLabel")));
    displayDims.add(
            displayLang = new JComboBox(new Object[] { XMLResourceBundle.getBundledString("cfgEnglishLabel"),
                    XMLResourceBundle.getBundledString("cfgFrenchLabel") }));
    display.add(displayHelp = new JCheckBox(XMLResourceBundle.getBundledString("cfgHelpLabel")));
    display.add(displayFullscreen = new JCheckBox(XMLResourceBundle.getBundledString("cfgFullscreenLabel")));
    display.add(displayNativeCursor = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseCursorLabel")));
    display.add(displayDims);

    JPanel topPluginsPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP));
    topPluginsPanel
            .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgPluginsLabel")));
    pluginsPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));
    JScrollPane scrollPane = new JScrollPane(pluginsPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    topPluginsPanel.add(scrollPane);

    JPanel addPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgAddPluginLabel")) {
        public void actionPerformed(ActionEvent e) {
            try {
                JOptionPane.showMessageDialog(GeneralConfigPanel.this,
                        XMLResourceBundle.getBundledString("cfgAddPluginMessage").replace("%pdir",
                                DocExploreTool.getPluginDir().getAbsolutePath()));
                if (System.getProperty("os.name").toLowerCase().contains("win"))
                    Runtime.getRuntime()
                            .exec(new String[] { "explorer", DocExploreTool.getPluginDir().getAbsolutePath() });
                else if (System.getProperty("os.name").toLowerCase().contains("mac"))
                    Runtime.getRuntime()
                            .exec(new String[] { "open", DocExploreTool.getPluginDir().getAbsolutePath() });
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
            //         File jarFile = browsePlugins();
            //         if (jarFile == null)
            //            return;
            //         PluginPanel pluginPanel = new PluginPanel(GeneralConfigPanel.this, "yes", jarFile.getName(), "");
            //         pluginPanels.add(pluginPanel);
            //         pluginsPanel.add(pluginPanel);
            //         ((Window)getTopLevelAncestor()).pack();
        }
    }));
    addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgRefreshPluginsLabel")) {
        public void actionPerformed(ActionEvent e) {
            refreshPlugins(xml);
            ((Window) getTopLevelAncestor()).pack();
        }
    }));
    topPluginsPanel.add(addPanel);

    //      setAutoConnectSubPanel(fsSubPanel);

    //      add(ac);
    add(display);
    add(topPluginsPanel);

    add(safeMode = new JCheckBox(XMLResourceBundle.getBundledString("cfgSafeModeLabel")));

    //      autoConnectType.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e)
    //      {
    //         if (e.getStateChange() != ItemEvent.SELECTED)
    //            return;
    //         if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgFileLabel")))
    //            setAutoConnectSubPanel(fsSubPanel);
    //         else setAutoConnectSubPanel(dbSubPanel);
    //         Window top = (Window)getTopLevelAncestor();
    //         if (top != null)
    //            top.pack();
    //      }});

    if (xml != null)
        fill(xml);
}