Example usage for javax.swing JOptionPane WARNING_MESSAGE

List of usage examples for javax.swing JOptionPane WARNING_MESSAGE

Introduction

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

Prototype

int WARNING_MESSAGE

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

Click Source Link

Document

Used for warning messages.

Usage

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

public JFreeChart getChart(List<String> idsToPaint) {
    if (paramX == null || paramY == null) {
        return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, new XYPlot(), showLegend);
    }// w ww  . ja va 2s  . c o m

    NumberAxis xAxis = new NumberAxis(AttributeUtilities.getNameWithUnit(paramX, unitX, transformX));
    NumberAxis yAxis = new NumberAxis(AttributeUtilities.getNameWithUnit(paramY, unitY, transformY));
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    double usedMinX = Double.POSITIVE_INFINITY;
    double usedMaxX = Double.NEGATIVE_INFINITY;
    int index = 0;
    ColorAndShapeCreator colorAndShapeCreator = new ColorAndShapeCreator(idsToPaint.size());

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        try {
            if (plotable != null) {
                if (plotable.getType() == Plotable.BOTH || plotable.getType() == Plotable.BOTH_STRICT) {
                    Double minArg = Plotable.transform(
                            plotable.convertToUnit(paramX, plotable.getMinArguments().get(paramX), unitX),
                            transformX);
                    Double maxArg = Plotable.transform(
                            plotable.convertToUnit(paramX, plotable.getMaxArguments().get(paramX), unitX),
                            transformX);

                    if (isValid(minArg)) {
                        usedMinX = Math.min(usedMinX, minArg);
                    }

                    if (isValid(maxArg)) {
                        usedMaxX = Math.max(usedMaxX, maxArg);
                    }

                    for (Map<String, Integer> choice : plotable.getAllChoices()) {
                        double[][] points = plotable.getPoints(paramX, paramY, unitX, unitY, transformX,
                                transformY, choice);

                        if (points != null) {
                            for (int i = 0; i < points[0].length; i++) {
                                if (isValid(points[0][i])) {
                                    usedMinX = Math.min(usedMinX, points[0][i]);
                                    usedMaxX = Math.max(usedMaxX, points[0][i]);
                                }
                            }
                        }
                    }
                } else if (plotable.getType() == Plotable.DATASET
                        || plotable.getType() == Plotable.DATASET_STRICT) {
                    double[][] points = plotable.getPoints(paramX, paramY, unitX, unitY, transformX,
                            transformY);

                    if (points != null) {
                        for (int i = 0; i < points[0].length; i++) {
                            if (isValid(points[0][i])) {
                                usedMinX = Math.min(usedMinX, points[0][i]);
                                usedMaxX = Math.max(usedMaxX, points[0][i]);
                            }
                        }
                    }
                } else if (plotable.getType() == Plotable.FUNCTION) {
                    Double minArg = Plotable.transform(
                            plotable.convertToUnit(paramX, plotable.getMinArguments().get(paramX), unitX),
                            transformX);
                    Double maxArg = Plotable.transform(
                            plotable.convertToUnit(paramX, plotable.getMaxArguments().get(paramX), unitX),
                            transformX);

                    if (isValid(minArg)) {
                        usedMinX = Math.min(usedMinX, minArg);
                    }

                    if (isValid(maxArg)) {
                        usedMaxX = Math.max(usedMaxX, maxArg);
                    }
                } else if (plotable.getType() == Plotable.FUNCTION_SAMPLE) {
                    Double minArg = Plotable.transform(
                            plotable.convertToUnit(paramX, plotable.getMinArguments().get(paramX), unitX),
                            transformX);
                    Double maxArg = Plotable.transform(
                            plotable.convertToUnit(paramX, plotable.getMaxArguments().get(paramX), unitX),
                            transformX);

                    if (isValid(minArg)) {
                        usedMinX = Math.min(usedMinX, minArg);
                    }

                    if (isValid(maxArg)) {
                        usedMaxX = Math.max(usedMaxX, maxArg);
                    }

                    for (Double x : plotable.getSamples()) {
                        Double xx = Plotable.transform(plotable.convertToUnit(paramX, x, unitX), transformX);

                        if (isValid(xx)) {
                            usedMinX = Math.min(usedMinX, xx);
                            usedMaxX = Math.max(usedMaxX, xx);
                        }
                    }
                }
            }
        } catch (ConvertException e) {
        }
    }

    if (Double.isInfinite(usedMinX)) {
        usedMinX = 0.0;
    }

    if (Double.isInfinite(usedMaxX)) {
        usedMaxX = 100.0;
    }

    if (paramX.equals(AttributeUtilities.TIME) || paramX.equals(AttributeUtilities.CONCENTRATION)) {
        usedMinX = Math.min(usedMinX, 0.0);
        xAxis.setAutoRangeIncludesZero(true);
    } else {
        xAxis.setAutoRangeIncludesZero(false);
    }

    if (paramY.equals(AttributeUtilities.TIME) || paramY.equals(AttributeUtilities.CONCENTRATION)) {
        yAxis.setAutoRangeIncludesZero(true);
    } else {
        yAxis.setAutoRangeIncludesZero(false);
    }

    if (usedMinX == usedMaxX) {
        usedMinX -= 1.0;
        usedMaxX += 1.0;
    }

    if (useManualRange && minX < maxX && minY < maxY) {
        usedMinX = minX;
        usedMaxX = maxX;
        xAxis.setRange(new Range(minX, maxX));
        yAxis.setRange(new Range(minY, maxY));
    }

    Set<ConvertException> convertExceptions = new LinkedHashSet<>();

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable != null && plotable.getType() == Plotable.DATASET) {
            try {
                plotDataSet(plot, plotable, id, colorAndShapeCreator.getColorList().get(index),
                        colorAndShapeCreator.getShapeList().get(index));
                index++;
            } catch (ConvertException e) {
                convertExceptions.add(e);
            }
        }
    }

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable != null && plotable.getType() == Plotable.DATASET_STRICT) {
            try {
                plotDataSetStrict(plot, plotable, id);
                index++;
            } catch (ConvertException e) {
                convertExceptions.add(e);
            }
        }
    }

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable != null && plotable.getType() == Plotable.FUNCTION) {
            try {
                plotFunction(plot, plotable, id, colorAndShapeCreator.getColorList().get(index),
                        colorAndShapeCreator.getShapeList().get(index), usedMinX, usedMaxX);
                index++;
            } catch (ConvertException e) {
                convertExceptions.add(e);
            }
        }
    }

    warnings = new ArrayList<>();

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable != null && plotable.getType() == Plotable.FUNCTION_SAMPLE) {
            try {
                plotFunctionSample(plot, plotable, id, colorAndShapeCreator.getColorList().get(index),
                        colorAndShapeCreator.getShapeList().get(index), usedMinX, usedMaxX, warnings);
                index++;
            } catch (ConvertException e) {
                convertExceptions.add(e);
            }
        }
    }

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable != null && plotable.getType() == Plotable.BOTH) {
            try {
                plotBoth(plot, plotable, id, colorAndShapeCreator.getColorList().get(index),
                        colorAndShapeCreator.getShapeList().get(index), usedMinX, usedMaxX);
                index++;
            } catch (ConvertException e) {
                convertExceptions.add(e);
            }
        }
    }

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable != null && plotable.getType() == Plotable.BOTH_STRICT) {
            try {
                plotBothStrict(plot, plotable, id, usedMinX, usedMaxX);
                index++;
            } catch (ConvertException e) {
                convertExceptions.add(e);
            }
        }
    }

    if (!convertExceptions.isEmpty()) {
        String warning = "Some datasets/functions cannot be converted to the desired unit\n";

        warning += "Uncovertable units: ";

        for (ConvertException e : convertExceptions) {
            warning += e.getFromUnit() + "->" + e.getToUnit() + ", ";
        }

        warning = warning.substring(0, warning.length() - 2);

        JOptionPane.showMessageDialog(this, warning, "Warning", JOptionPane.WARNING_MESSAGE);
    }

    return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
}

From source file:net.rptools.maptool.client.MapTool.java

public static boolean confirmDrawDelete() {
    if (!AppPreferences.getDrawWarnWhenDeleted()) {
        return true;
    }/*  ww w  .jav  a2s  .  c  om*/

    String msg = I18N.getText("msg.confirm.deleteDraw");
    log.debug(msg);
    Object[] options = { I18N.getText("msg.title.messageDialog.yes"),
            I18N.getText("msg.title.messageDialog.no"), I18N.getText("msg.title.messageDialog.dontAskAgain") };
    String title = I18N.getText("msg.title.messageDialogConfirm");
    int val = JOptionPane.showOptionDialog(clientFrame, msg, title, JOptionPane.NO_OPTION,
            JOptionPane.WARNING_MESSAGE, null, options, options[0]);

    // "Yes, don't show again" Button
    if (val == 2) {
        showInformation("msg.confirm.deleteDraw.removed");
        AppPreferences.setDrawWarnWhenDeleted(false);
    }
    // Any version of 'Yes'...
    if (val == JOptionPane.YES_OPTION || val == 2) {
        return true;
    }
    // Assume 'No' response
    return false;
}

From source file:edu.ku.brc.specify.config.init.secwiz.UserPanel.java

/**
 * /* w w  w  .jav a 2 s.c  o  m*/
 */
private void sendKeys() {
    final Hashtable<String, String> emailPrefs = new Hashtable<String, String>();
    if (!EMailHelper.isEMailPrefsOK(emailPrefs)) {
        JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), getResourceString("NO_EMAIL_PREF_INFO"),
                getResourceString("NO_EMAIL_PREF_INFO_TITLE"), JOptionPane.WARNING_MESSAGE);
        return;
    }

    int[] selectedIds = getSelectedIds();

    Vector<UserData> items = userModel.getUserData();
    for (int inx : selectedIds) {
        //UserData ud  = items.get(inx);
        /*emailPrefs.put("to", toAgent.getEmail() != null ? toAgent.getEmail() : "");
        emailPrefs.put("from", emailPrefs.get("email"));
        emailPrefs.put("subject", String.format(getResourceString("SEC_WIZ"), new Object[] {infoRequest.getIdentityTitle()}));
        emailPrefs.put("bodytext", "");
        */
        StringBuilder sb = new StringBuilder();

        // EMailHelper.setDebugging(true);
        String text = emailPrefs.get("bodytext").replace("\n", "<br>") + "<BR><BR>" + sb.toString();
        UIRegistry.displayLocalizedStatusBarText("SENDING_EMAIL");

        String password = Encryption.decrypt(emailPrefs.get("password"));
        if (StringUtils.isEmpty(password)) {
            password = EMailHelper.askForPassword((Frame) UIRegistry.getTopWindow());
        }

        if (StringUtils.isNotEmpty(password)) {
            final EMailHelper.ErrorType status = EMailHelper.sendMsg(emailPrefs.get("smtp"),
                    emailPrefs.get("username"), password, emailPrefs.get("email"), emailPrefs.get("to"),
                    emailPrefs.get("subject"), text, EMailHelper.HTML_TEXT, emailPrefs.get("port"),
                    emailPrefs.get("security"), null);
            if (status != EMailHelper.ErrorType.Cancel) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        UIRegistry.displayLocalizedStatusBarText(
                                status == EMailHelper.ErrorType.Error ? "EMAIL_SENT_ERROR" : "EMAIL_SENT_OK");
                    }
                });
            }
        }
    }
}

From source file:com.jvms.i18neditor.editor.Editor.java

public void showDuplicateTranslationDialog(String key) {
    String newKey = "";
    while (newKey != null && newKey.isEmpty()) {
        newKey = Dialogs.showInputDialog(this, MessageBundle.get("dialogs.translation.duplicate.title"),
                MessageBundle.get("dialogs.translation.duplicate.text"), JOptionPane.QUESTION_MESSAGE, key,
                true);//from   www. ja va  2 s.c o  m
        if (newKey != null) {
            newKey = newKey.trim();
            if (!ResourceKeys.isValid(newKey)) {
                showError(MessageBundle.get("dialogs.translation.duplicate.error"));
            } else {
                TranslationTreeNode newNode = translationTree.getNodeByKey(newKey);
                TranslationTreeNode oldNode = translationTree.getNodeByKey(key);
                if (newNode != null) {
                    boolean isReplace = newNode.isLeaf() || oldNode.isLeaf();
                    boolean confirm = Dialogs.showConfirmDialog(this,
                            MessageBundle.get("dialogs.translation.conflict.title"),
                            MessageBundle.get(
                                    "dialogs.translation.conflict.text." + (isReplace ? "replace" : "merge")),
                            JOptionPane.WARNING_MESSAGE);
                    if (confirm) {
                        duplicateTranslationKey(key, newKey);
                    }
                } else {
                    duplicateTranslationKey(key, newKey);
                }
            }
        }
    }
}

From source file:de.cebitec.readXplorer.differentialExpression.plot.DeSeqGraphicsTopComponent.java

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
    ReadXplorerFileChooser fc = new ReadXplorerFileChooser(new String[] { "svg" }, "svg") {
        private static final long serialVersionUID = 1L;

        @Override/*from w w  w  . j  ava 2 s  . c o m*/
        public void save(String fileLocation) {
            ProgressHandle progressHandle = ProgressHandleFactory
                    .createHandle("Save plot to svg file: " + fileLocation);
            Path to = FileSystems.getDefault().getPath(fileLocation, "");
            DeSeqAnalysisHandler.Plot selectedPlot = (DeSeqAnalysisHandler.Plot) plotType.getSelectedItem();
            if (selectedPlot == DeSeqAnalysisHandler.Plot.MAplot) {
                saveToSVG(fileLocation);
            } else {
                Path from = currentlyDisplayed.toPath();
                try {
                    Path outputFile = Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
                    messages.setText("SVG image saved to " + outputFile.toString());
                } catch (IOException ex) {
                    Date currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
                    Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "{0}: " + ex.getMessage(),
                            currentTimestamp);
                    JOptionPane.showMessageDialog(null, ex.getMessage(), "Could not write to file.",
                            JOptionPane.WARNING_MESSAGE);
                } finally {
                    progressHandle.switchToDeterminate(100);
                    progressHandle.finish();
                }
            }
        }

        @Override
        public void open(String fileLocation) {
        }
    };
    fc.openFileChooser(ReadXplorerFileChooser.SAVE_DIALOG);
}

From source file:ru.develgame.jflickrorganizer.MainForm.java

private void jButtonBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBackupActionPerformed
    if (jTextFieldBackupFolder.getText().isEmpty()) {
        JOptionPane.showMessageDialog(this, LocaleMessages.getMessage("MainForm.Warning.BackupFolderEmpty"),
                LocaleMessages.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);

        return;/*from   w  w  w.  j a v  a2  s .c o m*/
    }

    File backupFolder = new File(jTextFieldBackupFolder.getText());
    if (!backupFolder.exists()) {
        JOptionPane.showMessageDialog(this, LocaleMessages.getMessage("MainForm.Warning.BackupFolderNotExists"),
                LocaleMessages.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);

        return;
    }

    if (!backupFolder.isDirectory()) {
        JOptionPane.showMessageDialog(this,
                LocaleMessages.getMessage("MainForm.Warning.BackupFolderNotDirectory"),
                LocaleMessages.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);

        return;
    }

    try {
        // === Get photo list ===
        GetPhotoListRunnable photoListRunnable = getGetPhotoListRunnable();

        ProgressForm indeterminateProgressForm = new ProgressForm(this, true,
                LocaleMessages.getMessage("ProgressForm.GetPhotosList"), photoListRunnable, true);
        indeterminateProgressForm.setVisible(true);
        indeterminateProgressForm.dispose();

        if (photoListRunnable.getStatus() != Status.STATUS_OK) {
            if (photoListRunnable.getStatus() == Status.STATUS_CANCELED)
                return;

            JOptionPane.showMessageDialog(this,
                    LocaleMessages.getMessage("MainForm.Error.GetPhotoList", photoListRunnable.getError()),
                    LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

            return;
        }

        // === Backup photos ===
        BackupRunnable backupRunnable = getBackupRunnable(photoListRunnable.getPhotos(), backupFolder);

        ProgressForm progressForm = new ProgressForm(this, true,
                LocaleMessages.getMessage("ProgressForm.BackupPhotos"), backupRunnable, false);
        progressForm.setVisible(true);
        progressForm.dispose();

        if (backupRunnable.getStatus() != Status.STATUS_OK) {
            if (backupRunnable.getStatus() == Status.STATUS_CANCELED) {
                tablePhotosDataModel.loadData();
                return;
            }

            JOptionPane.showMessageDialog(this,
                    LocaleMessages.getMessage("MainForm.Error.BackupPhotos", backupRunnable.getError()),
                    LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

            return;
        }

        // === Backup sets ===            
        BackupSetsRunnable backupSetsRunnable = getBackupSetsRunnable();

        ProgressForm indeterminateProgressFormBackupSets = new ProgressForm(this, true,
                LocaleMessages.getMessage("ProgressForm.BackupSets"), backupSetsRunnable, true);
        indeterminateProgressFormBackupSets.setVisible(true);
        indeterminateProgressFormBackupSets.dispose();

        if (backupSetsRunnable.getStatus() != Status.STATUS_OK) {
            if (backupSetsRunnable.getStatus() == Status.STATUS_CANCELED) {
                treeAlbumsDataModel.loadData();
                jTreeAlbums.setSelectionRow(0);
                tablePhotosDataModel.loadData();
                return;
            }

            JOptionPane.showMessageDialog(this,
                    LocaleMessages.getMessage("MainForm.Error.BackupPhotos", backupSetsRunnable.getError()),
                    LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

            return;
        }

        JOptionPane.showMessageDialog(this, LocaleMessages.getMessage("MainForm.Info.BackupPhotos"),
                LocaleMessages.getMessage("InformationTitle"), JOptionPane.INFORMATION_MESSAGE);

        authorizer.getUser().setSyncFolder(jTextFieldBackupFolder.getText());
        userRepository.save(authorizer.getUser());

        treeAlbumsDataModel.loadData();
        jTreeAlbums.setSelectionRow(0);
        tablePhotosDataModel.loadData();
    } catch (InvalidAttributesException ex) {
        JOptionPane.showMessageDialog(this,
                LocaleMessages.getMessage("MainForm.Error.BackupPhotos", ex.getMessage()),
                LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

        return;
    }
}

From source file:io.github.jeddict.jpa.modeler.properties.joincolumn.JoinColumnPanel.java

private boolean validateField() {
    if (this.name_TextField.getText().trim()
            .length() <= 0 /*|| Pattern.compile("[^\\w-]").matcher(this.id_TextField.getText().trim()).find()*/) {
        JOptionPane.showMessageDialog(this, "Parameter column name can't be empty", "Invalid Value",
                javax.swing.JOptionPane.WARNING_MESSAGE);
        return false;
    } //I18n//from w  w w . j  a v  a 2  s  . c  o m
    //        if (this.referencedColumnName_TextField.getText().trim().length() <= 0 /*|| Pattern.compile("[^\\w-]").matcher(this.id_TextField.getText().trim()).find()*/) {
    //            JOptionPane.showMessageDialog(this, "Parameter referenced column name can't be empty", "Invalid Value", javax.swing.JOptionPane.WARNING_MESSAGE);
    //            return false;
    //        }//I18n
    return true;
}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

/**
 * Build menu items for TA./*from  w w w  .jav a  2 s  .  c om*/
 */
private void buildTAMenuItems() {
    final int[] days = { 14, 28, 50, 100, 200 };
    final MACD.Period[] macd_periods = { MACD.Period.newInstance(12, 26, 9) };

    // day_keys, week_keys and month_keys should be having same length as
    // days.        
    final String[] day_keys = { "ChartJDialog_14Days", "ChartJDialog_28Days", "ChartJDialog_50Days",
            "ChartJDialog_100Days", "ChartJDialog_200Days" };
    final String[] week_keys = { "ChartJDialog_14Weeks", "ChartJDialog_28Weeks", "ChartJDialog_50Weeks",
            "ChartJDialog_100Weeks", "ChartJDialog_200Weeks" };
    final String[] month_keys = { "ChartJDialog_14Months", "ChartJDialog_28Months", "ChartJDialog_50Months",
            "ChartJDialog_100Months", "ChartJDialog_200Months" };
    assert (days.length == day_keys.length);
    assert (days.length == week_keys.length);
    assert (days.length == week_keys.length);
    // macd_day_keys, macd_week_keys and macd_month_keys should be having 
    // same length as macd_periods.
    final String[] macd_day_keys = { "ChartJDialog_12_26_9Days" };
    final String[] macd_week_keys = { "ChartJDialog_12_26_9Weeks" };
    final String[] macd_month_keys = { "ChartJDialog_12_26_9Months" };
    assert (macd_periods.length == macd_day_keys.length);
    assert (macd_periods.length == macd_week_keys.length);
    assert (macd_periods.length == macd_month_keys.length);

    String[] keys = null;
    String[] macd_keys = null;
    if (this.getCurrentInterval() == Interval.Daily) {
        keys = day_keys;
        macd_keys = macd_day_keys;
    } else if (this.getCurrentInterval() == Interval.Weekly) {
        keys = week_keys;
        macd_keys = macd_week_keys;
    } else if (this.getCurrentInterval() == Interval.Monthly) {
        keys = month_keys;
        macd_keys = macd_month_keys;
    } else {
        assert (false);
    }
    final TA[] tas = TA.values();
    final String[] ta_keys = { "ChartJDialog_SMA", "ChartJDialog_EMA", "ChartJDialog_MACD", "ChartJDialog_RSI",
            "ChartJDialog_MFI", "ChartJDialog_CCI" };
    final String[] ta_tip_keys = { "ChartJDialog_SimpleMovingAverage", "ChartJDialog_ExponentialMovingAverage",
            "ChartJDialog_MovingAverageConvergenceDivergence", "ChartJDialog_RelativeStrengthIndex",
            "ChartJDialog_MoneyFlowIndex", "ChartJDialog_CommodityChannelIndex" };
    final String[] custom_message_keys = { "info_message_please_enter_number_of_days_for_SMA",
            "info_message_please_enter_number_of_days_for_EMA", "dummy",
            "info_message_please_enter_number_of_days_for_RSI",
            "info_message_please_enter_number_of_days_for_MFI",
            "info_message_please_enter_number_of_days_for_CCI" };
    final Map<TA, Set<Object>> m = new EnumMap<TA, Set<Object>>(TA.class);
    final int taExSize = JStock.instance().getChartJDialogOptions().getTAExSize();
    for (int i = 0; i < taExSize; i++) {
        final TAEx taEx = JStock.instance().getChartJDialogOptions().getTAEx(i);
        if (m.containsKey(taEx.getTA()) == false) {
            m.put(taEx.getTA(), new HashSet<Object>());
        }
        m.get(taEx.getTA()).add(taEx.getParameter());
    }

    for (int i = 0, length = tas.length; i < length; i++) {
        final TA ta = tas[i];
        javax.swing.JMenu menu = new javax.swing.JMenu();
        menu.setText(GUIBundle.getString(ta_keys[i])); // NOI18N
        menu.setToolTipText(GUIBundle.getString(ta_tip_keys[i])); // NOI18N

        if (ta == TA.MACD) {
            for (int j = 0, length2 = macd_periods.length; j < length2; j++) {
                final int _j = j;
                final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem();
                item.setText(GUIBundle.getString(macd_keys[j]));
                if (m.containsKey(ta)) {
                    if (m.get(ta).contains(macd_periods[_j])) {
                        item.setSelected(true);
                    }
                }
                item.addActionListener(new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        if (ta == TA.MACD) {
                            updateMACD(macd_periods[_j], item.isSelected());
                        }
                    }
                });
                menu.add(item);
            }
        } else {
            for (int j = 0, length2 = days.length; j < length2; j++) {
                final int _j = j;
                final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem();
                item.setText(GUIBundle.getString(keys[j])); // NOI18N
                if (m.containsKey(ta)) {
                    if (m.get(ta).contains(days[_j])) {
                        item.setSelected(true);
                    }
                }
                item.addActionListener(new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        if (ta == TA.SMA) {
                            updateSMA(days[_j], item.isSelected());
                        } else if (ta == TA.EMA) {
                            updateEMA(days[_j], item.isSelected());
                        } else if (ta == TA.MFI) {
                            updateMFI(days[_j], item.isSelected());
                        } else if (ta == TA.RSI) {
                            updateRSI(days[_j], item.isSelected());
                        } else if (ta == TA.CCI) {
                            updateCCI(days[_j], item.isSelected());
                        }
                    }
                });
                menu.add(item);
            } // for
        } // if (ta == TA.MACD)

        menu.add(new javax.swing.JSeparator());
        javax.swing.JMenuItem item = new javax.swing.JMenuItem();
        item.setText(GUIBundle.getString("ChartJDialog_Custom...")); // NOI18N
        final int _i = i;
        item.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                if (ta == TA.MACD) {
                    showMACDCustomDialog();
                } else {
                    do {
                        final String days_string = JOptionPane.showInputDialog(ChartJDialog.this,
                                MessagesBundle.getString(custom_message_keys[_i]));
                        if (days_string == null) {
                            return;
                        }
                        try {
                            final int days = Integer.parseInt(days_string);
                            if (days <= 0) {
                                JOptionPane.showMessageDialog(ChartJDialog.this,
                                        MessagesBundle.getString("info_message_number_of_days_required"),
                                        MessagesBundle.getString("info_title_number_of_days_required"),
                                        JOptionPane.WARNING_MESSAGE);
                                continue;
                            }
                            ChartJDialog.this.updateTA(ta, days, true);
                            return;
                        } catch (java.lang.NumberFormatException exp) {
                            log.error(null, exp);
                            JOptionPane.showMessageDialog(ChartJDialog.this,
                                    MessagesBundle.getString("info_message_number_of_days_required"),
                                    MessagesBundle.getString("info_title_number_of_days_required"),
                                    JOptionPane.WARNING_MESSAGE);
                            continue;
                        }
                    } while (true);
                }
            }
        });
        menu.add(item);

        // TEMP DISABLE MACD
        // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        if (ta != TA.MACD) {
            this.jMenu2.add(menu);
        }
    } // for
    this.jMenu2.add(new javax.swing.JSeparator());
    javax.swing.JMenuItem item = new javax.swing.JMenuItem();
    item.setText(GUIBundle.getString("ChartJDialog_ClearAll")); // NOI18N
    item.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ChartJDialog.this.clearAll();
        }
    });
    this.jMenu2.add(item);
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.preenchedor_formulario.PanelPreenchedorFormulario.java

/**
 * Avalia o arquivo/*ww w .  ja  v a 2s. c  o  m*/
 * 
 * @param path
 *            caminho
 */
public void avaliaArq(String path) {
    G_File temp = new G_File(path);
    if (temp.exists()) {
        avaliaArq(temp);
    } else {
        JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_VERIFIQUE_URL, TradPainelAvaliacao.AVISO,
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellStatisticsController.java

/**
 * Get conditions according to selected rows and add them to the Analysis
 * Group/*from w  w w.  ja va 2  s. c o  m*/
 */
private void addGroupToAnalysis() {
    List<SingleCellConditionDataHolder> conditionDataHolders = new ArrayList<>();

    Boolean filteredData = singleCellAnalysisController.isFilteredData();
    AnalysisPanel analysisPanel = singleCellAnalysisController.getAnalysisPanel();
    int[] selectedIndices = analysisPanel.getConditionList().getSelectedIndices();

    // we check here that at least two conditions have been selected to be part of the analysis group
    // else, the analysis does not really make sense
    if (selectedIndices.length > 1) {

        if (filteredData) {
            conditionDataHolders.addAll(singleCellAnalysisController.getFilteringMap().keySet());
        } else {
            conditionDataHolders.addAll(singleCellAnalysisController.getPreProcessingMap().values());
        }

        // make a new analysis group, with those conditions and those results
        SingleCellAnalysisGroup singleCellAnalysisGroup = new SingleCellAnalysisGroup(conditionDataHolders);

        //set name for the group
        if (!analysisPanel.getGroupNameTextField().getText().isEmpty()) {
            singleCellAnalysisGroup.setGroupName(analysisPanel.getGroupNameTextField().getText());
            // set correction method to NONE by default
            singleCellAnalysisGroup.setCorrectionMethodName("none");
            analysisPanel.getGroupNameTextField().setText("");
            // actually add the group to the analysis list
            if (!groupsBindingList.contains(singleCellAnalysisGroup)) {
                groupsBindingList.add(singleCellAnalysisGroup);
            }
        } else {
            // ask the user to type a name for the group
            singleCellAnalysisController.showMessage("Please type a name for the analysis group.",
                    "no name typed for the analysis group", JOptionPane.INFORMATION_MESSAGE);
        }
    } else {
        // we tell the user that statistics cannot be performed on only one condition !!
        // the selection is basically ignored
        singleCellAnalysisController.showMessage(
                "Sorry! It is not possible to perform analysis on one condition only!\nPlease select at least two conditions.",
                "at least two conditions need to be chosen for analysis", JOptionPane.WARNING_MESSAGE);
    }
}