Example usage for javax.swing JOptionPane OK_OPTION

List of usage examples for javax.swing JOptionPane OK_OPTION

Introduction

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

Prototype

int OK_OPTION

To view the source code for javax.swing JOptionPane OK_OPTION.

Click Source Link

Document

Return value form class method if OK is chosen.

Usage

From source file:captureplugin.drivers.defaultdriver.CaptureExecute.java

/**
 * Add a Program// w  ww  .  j  a v a  2  s . c  o m
 *
 * @param programTime
 *          Program to add
 * @return Success?
 */
public boolean addProgram(ProgramTime programTime) {
    if (StringUtils.isBlank(mData.getParameterFormatAdd())) {
        JOptionPane.showMessageDialog(mParent,
                mLocalizer.msg("NoParamsAdd", "Please specify parameters for adding of the program!"),
                mLocalizer.msg("CapturePlugin", "Capture Plugin"), JOptionPane.OK_OPTION);
        createDialog().show(DefaultKonfigurator.TAB_PARAMETER);
        return false;
    }
    return execute(programTime, mData.getParameterFormatAdd());
}

From source file:gov.nih.nci.nbia.StandaloneDMV3.java

void checkCompatibility() {
    if (serverUrl.endsWith("DownloadServlet")) {
        this.serverUrl = serverUrl.concat("V3");
    }/*from  w  w  w .j a  va 2  s .com*/

    if (!serverUrl.endsWith("DownloadServletV3")) {
        Object[] options = { "OK" };

        int n = JOptionPane.showOptionDialog(frame, serverVersionMsg, "Incompatible Server Notification",
                JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
        System.exit(n);
    }
}

From source file:net.pms.newgui.Wizard.java

public static void run(final PmsConfiguration configuration) {
    // Total number of questions
    int numberOfQuestions = Platform.isMac() ? 4 : 5;

    // The current question number
    int currentQuestionNumber = 1;

    String status = new StringBuilder().append(Messages.getString("Wizard.2")).append(" %d ")
            .append(Messages.getString("Wizard.4")).append(" ").append(numberOfQuestions).toString();

    Object[] okOptions = { Messages.getString("Dialog.OK") };

    Object[] yesNoOptions = { Messages.getString("Dialog.YES"), Messages.getString("Dialog.NO") };

    Object[] networkTypeOptions = { Messages.getString("Wizard.8"), Messages.getString("Wizard.9"),
            Messages.getString("Wizard.10") };

    if (!Platform.isMac()) {
        // Ask if they want UMS to start minimized
        int whetherToStartMinimized = JOptionPane.showOptionDialog(null, Messages.getString("Wizard.3"),
                String.format(status, currentQuestionNumber++), JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, yesNoOptions, yesNoOptions[1]);

        if (whetherToStartMinimized == JOptionPane.YES_OPTION) {
            configuration.setMinimized(true);
        } else if (whetherToStartMinimized == JOptionPane.NO_OPTION) {
            configuration.setMinimized(false);
        }//from w ww.  j  a va 2 s  . c o  m
    }

    // Ask if their network is wired, etc.
    int networkType = JOptionPane.showOptionDialog(null, Messages.getString("Wizard.7"),
            String.format(status, currentQuestionNumber++), JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, null, networkTypeOptions, networkTypeOptions[1]);

    switch (networkType) {
    case JOptionPane.YES_OPTION:
        // Wired (Gigabit)
        configuration.setMaximumBitrate("0");
        configuration.setMPEG2MainSettings("Automatic (Wired)");
        configuration.setx264ConstantRateFactor("Automatic (Wired)");
        break;
    case JOptionPane.NO_OPTION:
        // Wired (100 Megabit)
        configuration.setMaximumBitrate("90");
        configuration.setMPEG2MainSettings("Automatic (Wired)");
        configuration.setx264ConstantRateFactor("Automatic (Wired)");
        break;
    case JOptionPane.CANCEL_OPTION:
        // Wireless
        configuration.setMaximumBitrate("30");
        configuration.setMPEG2MainSettings("Automatic (Wireless)");
        configuration.setx264ConstantRateFactor("Automatic (Wireless)");
        break;
    default:
        break;
    }

    // Ask if they want to hide advanced options
    int whetherToHideAdvancedOptions = JOptionPane.showOptionDialog(null, Messages.getString("Wizard.11"),
            String.format(status, currentQuestionNumber++), JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE, null, yesNoOptions, yesNoOptions[0]);

    if (whetherToHideAdvancedOptions == JOptionPane.YES_OPTION) {
        configuration.setHideAdvancedOptions(true);
    } else if (whetherToHideAdvancedOptions == JOptionPane.NO_OPTION) {
        configuration.setHideAdvancedOptions(false);
    }

    // Ask if they want to scan shared folders
    int whetherToScanSharedFolders = JOptionPane.showOptionDialog(null,
            Messages.getString("Wizard.IsStartupScan"), String.format(status, currentQuestionNumber++),
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, yesNoOptions, yesNoOptions[0]);

    if (whetherToScanSharedFolders == JOptionPane.YES_OPTION) {
        configuration.setScanSharedFoldersOnStartup(true);
    } else if (whetherToScanSharedFolders == JOptionPane.NO_OPTION) {
        configuration.setScanSharedFoldersOnStartup(false);
    }

    // Ask to set at least one shared folder
    JOptionPane.showOptionDialog(null, Messages.getString("Wizard.12"),
            String.format(status, currentQuestionNumber++), JOptionPane.OK_OPTION,
            JOptionPane.INFORMATION_MESSAGE, null, okOptions, okOptions[0]);

    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                JFileChooser chooser;
                try {
                    chooser = new JFileChooser();
                } catch (Exception ee) {
                    chooser = new JFileChooser(new RestrictedFileSystemView());
                }

                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                chooser.setDialogTitle(Messages.getString("Wizard.12"));
                chooser.setMultiSelectionEnabled(false);
                if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
                    configuration.setOnlySharedDirectory(chooser.getSelectedFile().getAbsolutePath());
                } else {
                    // If the user cancels this option, the default directories will be used.
                }
            }
        });
    } catch (InterruptedException | InvocationTargetException e) {
        LOGGER.error("Error when saving folders: ", e);
    }

    // The wizard finished, do not ask them again
    configuration.setRunWizard(false);

    // Save all changes
    try {
        configuration.save();
    } catch (ConfigurationException e) {
        LOGGER.error("Error when saving changed configuration: ", e);
    }
}

From source file:io.github.jeremgamer.editor.panels.Actions.java

public Actions(final JFrame frame, final ActionPanel ap) {
    this.frame = frame;

    this.setBorder(BorderFactory.createTitledBorder(""));
    JButton add = null;/*from w  w w  .j a v a 2s. co m*/
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog(null, "Nommez l'action :", "Crer une action",
                        JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new ActionSave(name);
                    OtherPanel.updateLists();
                    ButtonPanel.updateLists();
                    ActionPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (actionList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/actions/"
                            + actionList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog(null,
                            "tes-vous sr de vouloir supprimer cette action?", "Avertissement",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        if (actionList.getSelectedValue().equals(ap.getFileName())) {
                            ap.setFileName("");
                        }
                        ap.hide();
                        file.delete();
                        data.remove(actionList.getSelectedIndex());
                        OtherPanel.updateLists();
                        ButtonPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    actionList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(actionList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);
    OtherPanel.updateLists();
}

From source file:com.mirth.connect.client.ui.dependencies.ChannelDependenciesWarningDialog.java

private void initComponents(final ChannelTask task, Set<ChannelDependency> dependencies,
        final Set<String> selectedChannelIds, Set<String> additionalChannelIds)
        throws ChannelDependencyException {
    additionalChannelIds.removeAll(selectedChannelIds);
    final OrderedChannels orderedChannels = ChannelDependencyUtil.getOrderedChannels(dependencies,
            new HashSet<String>(CollectionUtils.union(selectedChannelIds, additionalChannelIds)));
    final List<Set<String>> orderedChannelIds = orderedChannels.getOrderedIds();
    if (task.isForwardOrder()) {
        Collections.reverse(orderedChannelIds);
    }/* w w  w  . j a va2s  .  com*/

    descriptionLabel = new JLabel(
            "<html>There are additional channels in the dependency chain.<br/><b>Bolded</b> channels will be "
                    + task.getFuturePassive() + " in the following order:</html>");

    channelsPane = new JTextPane();
    channelsPane.setContentType("text/html");
    HTMLEditorKit editorKit = new HTMLEditorKit();
    StyleSheet styleSheet = editorKit.getStyleSheet();
    styleSheet.addRule("div {font-family:\"Tahoma\";font-size:11;text-align:top}");
    channelsPane.setEditorKit(editorKit);
    channelsPane.setEditable(false);
    channelsPane.setBackground(getBackground());

    setTextPane(task, orderedChannels, orderedChannelIds, selectedChannelIds, false);

    descriptionScrollPane = new JScrollPane(channelsPane);

    includeCheckBox = new JCheckBox(WordUtils.capitalize(task.toString()) + " " + additionalChannelIds.size()
            + " additional channel" + (additionalChannelIds.size() == 1 ? "" : "s"));
    includeCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            setTextPane(task, orderedChannels, orderedChannelIds, selectedChannelIds,
                    includeCheckBox.isSelected());
        }
    });

    okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            result = JOptionPane.OK_OPTION;
            dispose();
        }
    });

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            result = JOptionPane.CANCEL_OPTION;
            dispose();
        }
    });
}

From source file:captureplugin.drivers.defaultdriver.CaptureExecute.java

/**
 * Remove a Program/*w  w  w. j  av a2s .co  m*/
 *
 * @param programTime
 *          Program to remove
 * @return Success?
 */
public boolean removeProgram(ProgramTime programTime) {
    if (StringUtils.isBlank(mData.getParameterFormatAdd())
            || (StringUtils.isBlank(mData.getParameterFormatRem()))) {
        JOptionPane.showMessageDialog(mParent,
                mLocalizer.msg("NoParams", "Please specify Parameters for the Program!"),
                mLocalizer.msg("CapturePlugin", "Capture Plugin"), JOptionPane.OK_OPTION);
        createDialog().show(DefaultKonfigurator.TAB_PARAMETER);
        return false;
    }

    return execute(programTime, mData.getParameterFormatRem());
}

From source file:com.sittinglittleduck.DirBuster.CheckForUpdates.java

public void run() {
    try {/*from   w w  w  .  j  a va2  s.  c o m*/
        GetMethod httpget = new GetMethod(updateURL);
        int responseCode = httpclient.executeMethod(httpget);

        if (responseCode == 200) {
            if (httpget.getResponseContentLength() > 0) {

                // get the http body
                String response = "";
                try (BufferedReader input = new BufferedReader(
                        new InputStreamReader(httpget.getResponseBodyAsStream()))) {
                    String line;

                    StringBuffer buf = new StringBuffer();
                    while ((line = input.readLine()) != null) {
                        buf.append("\r\n" + line);
                    }
                    response = buf.toString();
                }

                Matcher versionMatcher = VERSION_PATTERN.matcher(response);
                if (versionMatcher.find()) {
                    String latestversion = versionMatcher.group(1);
                    if (latestversion.equalsIgnoreCase("Running - latest")) {
                        showAlreadyLatestVersionMessage();
                    } else {
                        Matcher changelogMatcher = CHANGELOG_PATTERN.matcher(response);
                        if (changelogMatcher.find()) {
                            String changelog = changelogMatcher.group(1);

                            if (!manager.isHeadLessMode()) {
                                if (showUpdateToLatestVersionConfirmDialog(latestversion,
                                        changelog) == JOptionPane.OK_OPTION) {
                                    BrowserLauncher launcher;
                                    try {
                                        launcher = new BrowserLauncher(null);
                                        launcher.openURLinBrowser(DIRBUSTER_SOURCEFORGE_URL);
                                    } catch (BrowserLaunchingInitializingException
                                            | UnsupportedOperatingSystemException ex) {
                                        showErrorMessage(BROWSER_ERROR_MESSAGE + ex.getMessage());
                                    }
                                }
                            } else {
                                printUpdateMessageOnConsole(latestversion);
                            }
                        } else {
                            showErrorMessage(CHANGELOG_ERROR_MESSAGE);
                        }

                    }
                } else {
                    showErrorMessage(VERSION_ERROR_MESSAGE);
                }

            } else {
                showErrorMessage(OTHER_ERROR_MESSAGE);
            }

        } else {
            showErrorMessage(SERVER_ERROR_MESSAGE);
        }
    } catch (IOException ex) {
        showErrorMessage(DEFAULT_ERROR_MESSAGE + ex.getMessage());
    }
}

From source file:com.cch.aj.entryrecorder.frame.CheckJFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    boolean result = true;
    int count = this.tblCheck.getRowCount();
    TableModel model = tblCheck.getModel();
    for (int i = 0; i < count; i++) {
        Boolean isChecked = (Boolean) model.getValueAt(i, 1);
        if (!isChecked) {
            result = false;//  w  ww .  j  av  a  2 s  . c  om
            break;
        }
    }

    if (result) {
        AppHelper.currentEntry.setIsChecked(true);
        this.entryService.UpdateEntity(AppHelper.currentEntry);
        this.setVisible(false);
        this.dispose();
    } else {
        JOptionPane.showMessageDialog(this, "Please check all items", "Warming", JOptionPane.OK_OPTION);
    }
}

From source file:com.sec.ose.osi.ui.frm.main.identification.JComboProjectName.java

public JComboProjectName() {

    this.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    this.setEditable(true);
    this.setPreferredSize(new Dimension(400, 27));
    this.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            long start = System.currentTimeMillis();
            actionOnProjectSelectedonProjectComboBox();
            long end = System.currentTimeMillis();
            log.debug(// w  ww  . j ava 2s  .  c o  m
                    "[JComboProjectName.addActionListener()] Project Loding TIME : " + (end - start) / 1000.0);
        }
    });

    final JTextField editor = (JTextField) this.getEditor().getEditorComponent();
    editor.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {

            char ch = e.getKeyChar();
            int count = 0;
            String newProjectName = editor.getText();

            if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE
                    && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) {
                return;
            }

            if (newProjectName.length() <= 0 && ch == KeyEvent.VK_BACK_SPACE) {
                count++;
                if (count >= 2) {
                    String projectName = IdentifyMediator.getInstance().getSelectedProjectName();
                    ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText(projectName);
                    count = 0;
                    return;
                }
            }
            if (JComboProjectName.this.getComponentCount() > 0) {
                JComboProjectName.this.removeAllItems();
            }

            JComboProjectName.this.addItem(newProjectName);
            try {
                Collection<OSIProjectInfo> ProjectsInfo = OSIProjectInfoMgr.getInstance().getAllProjects();

                String tmpProName = null;
                boolean bAnalysis = false;
                if (newProjectName.length() > 0) {
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        tmpProName = projectInfo.getProjectName();
                        bAnalysis = projectInfo.isAnalyzed();
                        if (tmpProName.toLowerCase().contains(newProjectName.toLowerCase()) && bAnalysis)
                            JComboProjectName.this.addItem(tmpProName);
                    }
                    if (JComboProjectName.this.getItemCount() <= 1) {
                        JComboProjectName.this.removeAllItems();
                        JOptionPane.showOptionDialog(null, "There is no project.", "Project Filter",
                                JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK");
                    }
                } else {
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        if (projectInfo.isManaged() == true && projectInfo.isAnalyzed()) {
                            JComboProjectName.this.addItem(projectInfo.getProjectName());
                        }
                    }
                    JComboProjectName.this.addItem(DIVIDER_LINE);
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        if (projectInfo.isManaged() == false && projectInfo.isAnalyzed()) {
                            JComboProjectName.this.addItem(projectInfo.getProjectName());
                        }
                    }
                    ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText("");
                }
            } catch (Exception e1) {
                log.warn(e1.getMessage());
            }

            JComboProjectName.this.hidePopup();
            if (newProjectName.length() > 0)
                JComboProjectName.this.showPopup();
        }
    });

}

From source file:org.cds06.speleograph.graph.SeriesMenu.java

private JPopupMenu createPopupMenuForSeries(final Series series) {

    if (series == null)
        return new JPopupMenu();

    final JPopupMenu menu = new JPopupMenu(series.getName());

    menu.removeAll();/*  w w w. j a v a  2s  . c o  m*/

    menu.add(new AbstractAction() {
        {
            putValue(NAME, "Renommer la srie");
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            menu.setVisible(false);
            String newName = "";
            while (newName == null || newName.equals("")) {
                newName = (String) JOptionPane.showInputDialog(application,
                        "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null,
                        series.getName());
            }
            series.setName(newName);
        }
    });

    if (series.hasOwnAxis()) {
        menu.add(new AbstractAction() {

            {
                putValue(NAME, "Supprimer l'axe spcifique");
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?",
                        "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
                    series.setAxis(null);
                }
            }
        });
    } else {
        menu.add(new JMenuItem(new AbstractAction() {

            {
                putValue(NAME, "Crer un axe spcifique pour la srie");
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?",
                        series.getAxis().getLabel());
                if (name == null || "".equals(name))
                    return; // User has canceled
                series.setAxis(new NumberAxis(name));
            }
        }));
    }

    menu.add(new SetTypeMenu(series));

    if (series.isWater()) {
        menu.addSeparator();
        menu.add(new SumOnPeriodAction(series));
        menu.add(new CreateCumulAction(series));
    }
    if (series.isWaterCumul()) {
        menu.addSeparator();
        menu.add(new SamplingAction(series));
    }

    if (series.isPressure()) {
        menu.addSeparator();
        menu.add(new CorrelateAction(series));
        menu.add(new WaterHeightAction(series));
    }

    menu.addSeparator();

    menu.add(new AbstractAction() {
        {
            String name;
            if (series.canUndo())
                name = "Annuler " + series.getItemsName();
            else
                name = series.getLastUndoName();

            putValue(NAME, name);

            if (series.canUndo())
                setEnabled(true);
            else {
                setEnabled(false);
            }

        }

        @Override
        public void actionPerformed(ActionEvent e) {
            series.undo();
        }
    });

    menu.add(new AbstractAction() {
        {
            String name;
            if (series.canRedo()) {
                name = "Refaire " + series.getNextRedoName();
                setEnabled(true);
            } else {
                name = series.getNextRedoName();
                setEnabled(false);
            }

            putValue(NAME, name);
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            series.redo();
        }
    });

    menu.add(new AbstractAction() {
        {
            putValue(NAME, I18nSupport.translate("menus.serie.resetSerie"));
            if (series.canUndo())
                setEnabled(true);
            else
                setEnabled(false);
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            series.reset();
        }
    });

    menu.add(new LimitDateRangeAction(series));

    menu.add(new HourSettingAction(series));

    menu.addSeparator();

    {
        JMenuItem deleteItem = new JMenuItem("Supprimer la srie");
        deleteItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (JOptionPane.showConfirmDialog(application,
                        "tes-vous sur de vouloir supprimer cette srie ?\n"
                                + "Cette action est dfinitive.",
                        "Confirmation", JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
                    series.delete();
                }
            }
        });
        menu.add(deleteItem);
    }

    menu.addSeparator();

    {
        final JMenuItem up = new JMenuItem("Remonter dans la liste"),
                down = new JMenuItem("Descendre dans la liste");
        ActionListener listener = new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (e.getSource().equals(up)) {
                    series.upSeriesInList();
                } else {
                    series.downSeriesInList();
                }
            }
        };
        up.addActionListener(listener);
        down.addActionListener(listener);
        if (series.isFirst()) {
            menu.add(down);
        } else if (series.isLast()) {
            menu.add(up);
        } else {
            menu.add(up);
            menu.add(down);
        }
    }

    menu.addSeparator();

    {
        menu.add(new SeriesInfoAction(series));
    }

    {
        JMenuItem colorItem = new JMenuItem("Couleur de la srie");
        colorItem.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                series.setColor(JColorChooser.showDialog(application,
                        I18nSupport.translate("actions.selectColorForSeries"), series.getColor()));
            }
        });
        menu.add(colorItem);
    }

    {
        JMenu plotRenderer = new JMenu("Affichage de la srie");
        final ButtonGroup modes = new ButtonGroup();
        java.util.List<DrawStyle> availableStyles;
        if (series.isMinMax()) {
            availableStyles = DrawStyles.getDrawableStylesForHighLow();
        } else {
            availableStyles = DrawStyles.getDrawableStyles();
        }
        for (final DrawStyle s : availableStyles) {
            final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s));
            item.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    if (item.isSelected())
                        series.setStyle(s);
                }
            });
            modes.add(item);
            if (s.equals(series.getStyle())) {
                modes.setSelected(item.getModel(), true);
            }
            plotRenderer.add(item);
        }
        menu.add(plotRenderer);
    }
    menu.addSeparator();

    menu.add(new AbstractAction() {
        {
            putValue(Action.NAME, "Fermer le fichier");
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(application,
                    "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
                final File f = series.getOrigin();
                for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) {
                    if (s.getOrigin().equals(f))
                        s.delete();
                }
            }
        }
    });

    return menu;
}