Example usage for javax.swing JOptionPane QUESTION_MESSAGE

List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE

Introduction

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

Prototype

int QUESTION_MESSAGE

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

Click Source Link

Document

Used for questions.

Usage

From source file:userinterface.properties.GUIGraphPicker.java

private void lineOkayButtonActionPerformed(java.awt.event.ActionEvent evt) {

    if (!this.plotType2d.isSelected() && !this.plotType3d.isSelected()) {
        this.plugin.error("Please select a plot type!");
        return;//from   w  ww . j  a  v  a 2 s . c om
    }

    // this is for the parametric case, getselecteditem will be null then
    if (selectAxisConstantCombo.getSelectedItem() == null) {

        if (newGraphRadio.isSelected()) {
            /* Make new graph. */
            graphModel2D = new ParametricGraph("");
            graphHandler.addGraph(graphModel2D);

        } else {
            /* Add to an existing graph. */

            if (!(graphHandler
                    .getModel(existingGraphCombo.getSelectedItem().toString()) instanceof ParametricGraph)) {
                graphModel2D = null;
                return;
            }

            graphModel2D = (Graph) graphHandler.getModel(existingGraphCombo.getSelectedItem().toString());
        }

        graphCancelled = false;
        setVisible(false);

        return;
    }

    int numSeries = 1;

    // see which constant is on x axis
    rangerX = selectAxisConstantCombo.getSelectedItem().toString();

    if (this.plotType3d.isSelected()) {

        rangerY = selectYaxisConstantCombo.getSelectedItem().toString();

    }

    // init arrays
    otherValues = new Values();
    multiSeries = new Vector<DefinedConstant>();

    // go through all constants in picker list
    for (int j = 0; j < pickerList.getNumConstants(); j++) {
        // get constant
        DefinedConstant tmpConstant = pickerList.getConstantLine(j).getDC();
        // if its the constant for the x-axis, store info about the constant
        if (tmpConstant.getName().equals(rangerX)) {
            rangingConstantX = tmpConstant;
        }
        // otherwise store info about the selected values
        else {

            if (this.plotType3d.isSelected()) {
                if (tmpConstant.getName().equals(rangerY))
                    continue;
            }

            // Is this constant just a value, or does it have a range?
            Object value = pickerList.getConstantLine(j).getSelectedValue();
            if (value instanceof String) {
                /* Yes, calculate the numSeries. */
                multiSeries.add(pickerList.getConstantLine(j).getDC());
                numSeries *= tmpConstant.getNumSteps();
            } else {
                /* No, just the one. */
                otherValues.addValue(tmpConstant.getName(), value);
            }
        }
    }

    if (this.plotType3d.isSelected()) {

        //go through all constants in the y axis picker list
        for (int j = 0; j < pickerList.getNumConstants(); j++) {

            // get constant
            DefinedConstant tmpConstant = pickerList.getConstantLine(j).getDC();

            if (tmpConstant.getName().equals(rangerY)) {
                rangingConstantY = tmpConstant;
            }
        }

    }

    //sort out which one to add it to
    if (rangingConstantX == null)
        return;

    //if 3d plot is selected and y axis is not selected, select it!
    if (this.plotType3d.isSelected() && rangingConstantY == null)
        return;

    // if there are a lot of series, check if this is what the user really wanted
    if (numSeries > MAX_NUM_SERIES_BEFORE_QUERY) {
        String[] choices = { "Yes", "No" };
        int choice = -1;
        choice = plugin.optionPane(
                "Warning: This will plot " + numSeries + " series.\nAre you sure you want to continue?",
                "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, choices, choices[0]);
        if (choice != 0)
            return;
    }

    if (this.plotType2d.isSelected()) {

        if (newGraphRadio.isSelected()) {
            /* Make new graph. */
            //graphModel = new Graph();
            graphModel2D = new ParametricGraph("");
            graphHandler.addGraph(graphModel2D);

            graphModel2D.getYAxisSettings().setHeading(resultsCollection.getResultName());
            graphModel2D.getXAxisSettings().setHeading(rangerX);
        } else {
            /* Add to an existing graph. */

            graphModel2D = (Graph) graphHandler.getModel(existingGraphCombo.getSelectedItem().toString());
            if (!rangerX.equals(graphModel2D.getXAxisSettings().getHeading())) //FIXME: must do this better in future
                if (!roughExists(rangerX, graphModel2D.getXAxisSettings().getHeading()))
                    graphModel2D.getXAxisSettings()
                            .setHeading(graphModel2D.getXAxisSettings().getHeading() + ", " + rangerX);
        }

    } else if (this.plotType3d.isSelected()) {

        // always the new graph radio button will be selected since we can't have another 3d plot on the same plot

        if (selectAxisConstantCombo.getSelectedItem().toString()
                .equals(selectYaxisConstantCombo.getSelectedItem().toString())) {

            plugin.error("Please select diffrent variables for x and y axis!");
            return;

        }

        graphModel3D = new Graph3D();
        graphHandler.addGraph(graphModel3D);

    }

    graphCancelled = false;
    setVisible(false);
}

From source file:edu.ku.brc.ui.UIRegistry.java

/**
 * Asks Yes or No question using a JOptionPane
 * @param yesKey the resource key for the Yes button
 * @param noKey the resource key for the No button
 * @param nonL10NMsg the message or question NOT Localized
 * @param titleKey the resource key for the Dialog Title
 * @return JOptionPane.NO_OPTION or JOptionPane.YES_OPTION
 *///from   w  ww. j  av  a  2  s .  c o m
public static int askYesNoLocalized(final String yesKey, final String noKey, final String nonL10NMsg,
        final String titleKey) {
    int userChoice = JOptionPane.NO_OPTION;
    Object[] options = { getResourceString(yesKey), getResourceString(noKey) };

    userChoice = JOptionPane.showOptionDialog(UIRegistry.getMostRecentWindow(), nonL10NMsg,
            getResourceString(titleKey), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
            options[0]);
    return userChoice;
}

From source file:edu.ku.brc.specify.tasks.ReportsBaseTask.java

/**
 * Processes all Commands of type LABELS.
 * @param cmdAction the command to be processed
 *///from  ww w  .  j  ava 2 s . co  m
protected void processReportCommands(final CommandAction cmdAction) {

    //---------------------------------------------------------------------------
    // This Code here needs to be refactored and moved to the NavBoxAction
    // so it can happen in a single generic place (Each task has this code)
    //---------------------------------------------------------------------------
    /*if (cmdAction.getData() instanceof RecordSetIFace)
    {
    if (((RecordSetIFace)cmdAction.getData()).getDbTableId() != cmdAction.getTableId())
    {
        JOptionPane.showMessageDialog(null, getResourceString("ERROR_RECORDSET_TABLEID"), getResourceString("Error"), JOptionPane.ERROR_MESSAGE);
        return;
    }
    }*/

    Object data = cmdAction.getData();
    UsageTracker.incrUsageCount(
            "RP." + cmdAction.getType() + (data != null ? ("." + data.getClass().getSimpleName()) : ""));

    if (cmdAction.isAction(NEWRECORDSET_ACTION)) {
        if (cmdAction.getData() instanceof GhostActionable) {
            GhostActionable ga = (GhostActionable) cmdAction.getData();
            GhostMouseInputAdapter gpa = ga.getMouseInputAdapter();

            for (NavBoxItemIFace nbi : reportsList) {
                if (nbi instanceof GhostActionable) {
                    gpa.addGhostDropListener(new GhostActionableDropManager(UIRegistry.getGlassPane(),
                            nbi.getUIComponent(), ga));
                }
            }
        }
    } else if (cmdAction.isAction(PRINT_REPORT)) {
        if (data instanceof CommandAction && ((CommandAction) data).isAction(RUN_REPORT)) {
            runReport(cmdAction);
        }
        //            if (cmdAction.getData() instanceof CommandAction && ((CommandAction)cmdAction.getData()).isAction(OPEN_EDITOR))
        //            {
        //                openIReportEditor(cmdAction);
        //            }
        if (cmdAction.getData() instanceof RecordSetIFace) {
            RecordSetIFace rs = (RecordSetIFace) cmdAction.getData();
            if (rs.getDbTableId() != null && rs.getDbTableId() == SpReport.getClassTableId()
                    || cmdAction.getProperty("spreport") != null) {
                runReport(cmdAction);
            } else {
                printReport(cmdAction);
            }
        } else {
            if (data instanceof CommandAction && ((CommandAction) data).isAction(PRINT_REPORT)) {
                printReport((CommandAction) data);
            } else {
                printReport(cmdAction);
            }
        }
    }
    //        else if (cmdAction.isAction(OPEN_EDITOR))
    //        {
    //            openIReportEditor(cmdAction);
    //        }
    else if (cmdAction.isAction(RUN_REPORT)) {
        boolean doRun = true;
        if (data instanceof CommandAction && ((CommandAction) data).isAction(PRINT_REPORT)) {
            doRun = ((CommandAction) data).getProperty("spreport") != null;
        }
        if (doRun) {
            runReport(cmdAction);
        } else {
            printReport((CommandAction) data);
        }
    } else if (cmdAction.isAction(REFRESH)) {
        refreshCommands();

    } else if (cmdAction.isAction(IMPORT)) {
        importReport();

    } else if (cmdAction.isAction(PRINT_GRID)) {
        printGrid(cmdAction);

    } else if (cmdAction.isAction(DELETE_CMD_ACT)) {
        RecordSetIFace recordSet = null;
        if (cmdAction.getData() instanceof RecordSetIFace) {
            recordSet = (RecordSetIFace) cmdAction.getData();

        } else if (cmdAction.getData() instanceof RolloverCommand) {
            RolloverCommand roc = (RolloverCommand) cmdAction.getData();
            if (roc.getData() instanceof RecordSetIFace) {
                recordSet = (RecordSetIFace) roc.getData();
            }
        }
        if (recordSet != null || cmdAction.getProperties().get("name") != null) {
            String theName;
            String theTitle;
            if (recordSet != null) {
                theName = recordSet.getName();
                theTitle = theName;
            } else {
                theName = cmdAction.getProperties().getProperty("name");
                //currently the description of the appResource is used as the 'title' for the command button.
                //theTitle = ((AppResourceIFace)cmdAction.getProperties().get("appresource")).getDescription();
                theTitle = cmdAction.getProperties().getProperty("title");
            }
            int option = JOptionPane.showOptionDialog(UIRegistry.getMostRecentWindow(),
                    String.format(UIRegistry.getResourceString("REP_CONFIRM_DELETE"), theName),
                    UIRegistry.getResourceString("REP_CONFIRM_DELETE_TITLE"), JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.NO_OPTION); // I18N

            if (option == JOptionPane.YES_OPTION) {
                Integer resId = Integer.class.cast(cmdAction.getProperty("spappresourceid"));
                Integer resOrRepId = null;
                Integer repId = null;
                if (resId != null) {
                    resOrRepId = resId;
                }
                RecordSetItemIFace item = recordSet == null ? null : recordSet.getOnlyItem();
                if (item != null) {
                    repId = item.getRecordId();
                    resOrRepId = repId;
                }
                deleteReportAndResource(repId, resId);
                deleteReportFromUI(theTitle);
                if (resOrRepId != null) {
                    CommandDispatcher.dispatch(new CommandAction(REPORTS, REPORT_DELETED, resOrRepId));
                } else {
                    //what can you do?
                }
            }
        }
    }
}

From source file:org.forester.archaeopteryx.TreePanel.java

final private void deleteNodeOrSubtree(final PhylogenyNode node) {
    if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) {
        errorMessageNoCutCopyPasteInUnrootedDisplay();
        return;/*from w w w.  j  av a  2 s  . c o m*/
    }
    if (node.isRoot()) {
        JOptionPane.showMessageDialog(this, "Cannot delete entire tree", "Attempt to delete entire tree",
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    final String label = getASimpleTextRepresentationOfANode(node);
    final Object[] options = { "Node only", "Entire subtree", "Cancel" };
    final int r = JOptionPane.showOptionDialog(this, "Delete" + label + "?", "Delete Node/Subtree",
            JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]);
    boolean node_only = true;
    if (r == 1) {
        node_only = false;
    } else if (r != 0) {
        return;
    }
    if (node_only) {
        PhylogenyMethods.removeNode(node, _phylogeny);
    } else {
        _phylogeny.deleteSubtree(node, true);
    }
    _phylogeny.externalNodesHaveChanged();
    _phylogeny.hashIDs();
    _phylogeny.recalculateNumberOfExternalDescendants(true);
    resetNodeIdToDistToLeafMap();
    setEdited(true);
    repaint();
}

From source file:com.ga.forms.DailyLogAddUI.java

private void checkInOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkInOutButtonActionPerformed
    DailyLogRecord log = new DailyLogRecord();
    if (DailyLogAddUI.checkIn && !DailyLogAddUI.breakDone) {
        args = new HashMap();
        DailyLogAddUI.breakDone = true;//from  w  w w.j ava2 s .  com
        args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn));
        args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone));
        args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut));
        if (yesRdButton.isSelected() == true) {
            this.timeOnBreak = "00:30";
        } else if (customRdButton.isSelected() == true) {
            this.timeOnBreak = customBreakTimeTextField.getText();
        } else {
            this.timeOnBreak = "00:00";
        }
        log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(),
                checkInTimeCombo.getSelectedItem().toString(), "", this.timeOnBreak, "", "", "", args);
        doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString());
        args.clear();
        args.put("date", dateDisplayLbl.getText());
        log.updateRecord(doc, args);
    } else if (DailyLogAddUI.checkIn && DailyLogAddUI.breakDone && !DailyLogAddUI.checkOut) {
        args = new HashMap();
        DailyLogAddUI.checkOut = true;
        args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn));
        args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone));
        args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut));
        DailyLogDuration durationAgent = new DailyLogDuration();
        durationAgent.calculateCurrentDuration(checkInTimeCombo.getSelectedItem().toString(), this.timeOnBreak,
                checkOutTimeCombo.getSelectedItem().toString());
        this.duration = durationAgent.getCurrentDuration();

        JFrame parent = new JFrame();
        JOptionPane optionPane = new JOptionPane("Duration: " + this.duration + "\n\nDo you want to Check Out?",
                JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
        JDialog msgDialog = optionPane.createDialog(parent, "DLM");
        msgDialog.setVisible(true);

        if (optionPane.getValue().equals(0)) {
            int hours = Integer.parseInt(this.duration.split(":")[0]);
            int minutes = Integer.parseInt(this.duration.split(":")[1]);
            if (hours < 9) {
                durationAgent.calculateUnderTime(this.duration);
                this.underTime = durationAgent.getUnderTime();
                this.overTime = "00:00";
            } else if (hours >= 9 && minutes > 0 && minutes < 60) {
                this.underTime = "00:00";
                durationAgent.calculateOverTime(this.duration);
                this.overTime = durationAgent.getOverTime();

            } else {
                this.underTime = "00:00";
                this.overTime = "00:00";
            }
            log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(),
                    checkInTimeCombo.getSelectedItem().toString(),
                    checkOutTimeCombo.getSelectedItem().toString(), this.timeOnBreak, this.duration,
                    this.underTime, this.overTime, args);
            doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString());
            args.clear();
            args.put("date", dateDisplayLbl.getText());
            log.updateRecord(doc, args);
        } else {
            msgDialog.dispose();
        }
    } else {
        args = new HashMap();
        DailyLogAddUI.checkIn = true;
        args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn));
        args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone));
        args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut));
        log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(),
                checkInTimeCombo.getSelectedItem().toString(), "", "", "", "", "", args);
        doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString());
        log.insertRecord(doc);

    }

}

From source file:edu.ku.brc.ui.UIRegistry.java

/**
 * Asks Yes, No, Cancel question using a JOptionPane
 * @param yesKey the resource key for the Yes button
 * @param noKey the resource key for the No button
 * @param cancelKey the resource key for the Cancel button
 * @param nonL10NMsg the message or question NOT Localized
 * @param titleKey the resource key for the Dialog Title
 * @return JOptionPane.NO_OPTION or JOptionPane.YES_OPTION
 *//*from w  ww  .  ja v a  2 s.  co  m*/
public static int askYesNoLocalized(final String yesKey, final String noKey, final String cancelKey,
        final String nonL10NMsg, final String titleKey) {
    int userChoice = JOptionPane.CANCEL_OPTION;
    Object[] options = { getResourceString(yesKey), getResourceString(noKey), getResourceString(cancelKey) };

    userChoice = JOptionPane.showOptionDialog(UIRegistry.getMostRecentWindow(), nonL10NMsg,
            getResourceString(titleKey), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
            options, options[0]);
    return userChoice;
}

From source file:au.com.jwatmuff.eventmanager.gui.main.LoadCompetitionWindow.java

private void manualScoreboardButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manualScoreboardButtonActionPerformed
    List<String> errors = new ArrayList<String>();

    if (!PermissionChecker.isAllowed(Action.MANUAL_SCOREBOARD, null))
        return;/*from  w  w  w .java2s .  com*/

    String scoreboardName = JOptionPane.showInputDialog(this, "Enter a name for this scoreboard",
            "Manual Scoreboard", JOptionPane.QUESTION_MESSAGE);

    if (scoreboardName == null)
        return;
    else if (scoreboardName.isEmpty())
        errors.add("Scoreboard name must not be empty");
    else if (!scoreboardName.matches("[a-zA-Z0-9]*"))
        errors.add("Scoreboard name must only consist of letters and numbers, with no spaces");

    if (errors.size() > 0) {
        GUIUtils.displayErrors(this, errors);
        return;
    }

    scoreboardName = "Scoreboard/" + scoreboardName;
    //        new ScoreboardWindow("Manual Scoreboard - " + scoreboardName, ScoringSystem.OLD, peerManager, scoreboardName).setVisible(true);
    new ScoreboardWindow("Manual Scoreboard - " + scoreboardName, peerManager, scoreboardName).setVisible(true);
}

From source file:canreg.client.gui.analysis.ExportReportInternalFrame.java

/**
 *
 * @return// w  w  w .j  av a  2  s .c  o  m
 */
@Action
public Task writeFileAction() {
    if (chooser == null) {
        path = localSettings.getProperty("export_data_path");
        if (path == null) {
            chooser = new JFileChooser();
        } else {
            chooser = new JFileChooser(path);
        }
    }
    // Get filename
    int returnVal = chooser.showSaveDialog(this);
    fileName = "";
    String separatingString = "\t";
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
            //set the file name
            fileName = chooser.getSelectedFile().getCanonicalPath();

            // TODO: Make this dynamic
            if (fileFormatComboBox.getSelectedIndex() == 0) {
                separatingString = ",";
                // append standard file extension
                if (!(fileName.endsWith(".csv") || fileName.endsWith(".CSV"))) {
                    fileName += ".csv";
                }
            } else {
                if (fileFormatComboBox.getSelectedIndex() == 1) {
                    separatingString = "\t";
                } else {
                    separatingString = fileFormatComboBox.getSelectedItem().toString();
                }
                // append standard file extension
                if (!(fileName.endsWith(".tsv") || fileName.endsWith(".TSV"))
                        && !(fileName.endsWith(".csv") || fileName.endsWith(".CSV"))
                        && !(fileName.endsWith(".txt") || fileName.endsWith(".TXT"))) {
                    fileName += ".txt";
                }
            }

            File file = new File(fileName);
            if (file.exists()) {
                int choice = JOptionPane.showInternalConfirmDialog(
                        CanRegClientApp.getApplication().getMainFrame().getContentPane(),
                        java.util.ResourceBundle
                                .getBundle("canreg/client/gui/analysis/resources/ExportReportInternalFrame")
                                .getString("FILE_EXISTS")
                                + ": " + fileName + ".\n"
                                + java.util.ResourceBundle.getBundle(
                                        "canreg/client/gui/analysis/resources/ExportReportInternalFrame")
                                        .getString("OVERWRITE?"),
                        java.util.ResourceBundle
                                .getBundle("canreg/client/gui/analysis/resources/ExportReportInternalFrame")
                                .getString("FILE_EXISTS") + ".",
                        JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (choice == JOptionPane.CANCEL_OPTION) {
                    return null;
                } else if (choice == JOptionPane.NO_OPTION) {
                    // choose a new file
                    writeFileAction();
                    return null;
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(ExportReportInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        return null;
    }
    return new WriteFileActionTask(fileName,
            org.jdesktop.application.Application.getInstance(canreg.client.CanRegClientApp.class),
            separatingString);
}

From source file:ca.osmcanada.osvuploadr.JPMain.java

private void jbAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAddActionPerformed
    try {/*from   w  w w. j av a 2s.  c o m*/
        JFileChooser fc = new JFileChooser();
        if (!last_dir.isEmpty()) {
            fc.setCurrentDirectory(new java.io.File(last_dir)); // start at application current directory
        }
        fc.setMultiSelectionEnabled(true);
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = fc.showSaveDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFiles().length == 1) {
                int response = JOptionPane.showConfirmDialog(null,
                        new String(r.getString("immediate_sub_folders").getBytes(), "UTF-8"),
                        new String(r.getString("add_subfolders").getBytes(), "UTF-8"),
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (response == JOptionPane.NO_OPTION) {
                    File folder = fc.getSelectedFile();
                    listDir.add(folder.getPath());
                    last_dir = folder.getPath();
                } else if (response == JOptionPane.YES_OPTION) {
                    //Get a list of subdirectories
                    String[] subDirs = fc.getSelectedFile().list(new FilenameFilter() {
                        @Override
                        public boolean accept(File current, String name) {
                            return new File(current, name).isDirectory();
                        }
                    });

                    for (String subDir : subDirs) {
                        listDir.add(new File(fc.getSelectedFile() + "/" + subDir).getPath());
                    }
                }
            } else if (fc.getSelectedFiles().length > 1) {
                File[] folders = fc.getSelectedFiles();
                for (File folder : folders) {
                    listDir.add(folder.getPath());
                    last_dir = folder.getPath();
                }
            }

        }
    } catch (UnsupportedEncodingException ex) {
    }
}

From source file:com.jug.MoMA.java

/**
 *
 * @param guiFrame/*from   w  ww.jav  a2  s.c om*/
 *            parent frame
 * @param datapath
 *            path to be suggested to open
 * @return
 */
private File showStartupDialog(final JFrame guiFrame, final String datapath) {

    File file = null;
    final String parentFolder = datapath.substring(0, datapath.lastIndexOf(File.separatorChar));

    // DATA TO BE LOADED --- DATA TO BE LOADED --- DATA TO BE LOADED --- DATA TO BE LOADED

    int decision = 0;
    if (datapath.equals(System.getProperty("user.home"))) {
        decision = JOptionPane.NO_OPTION;
    } else {
        final String message = "Should the MotherMachine be opened with the data found in:\n" + datapath
                + "\n\nIn case you want to choose a folder please select 'No'...";
        final String title = "MotherMachine Data Folder Selection";
        decision = JOptionPane.showConfirmDialog(guiFrame, message, title, JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
    }
    if (decision == JOptionPane.YES_OPTION) {
        file = new File(datapath);
    } else {
        file = showFolderChooser(guiFrame, parentFolder);
    }

    // CLASSIFIER TO BE LOADED --- CLASSIFIER TO BE LOADED --- CLASSIFIER TO BE LOADED

    //      final String message = "Should this classifier be used:\n" + SEGMENTATION_CLASSIFIER_MODEL_FILE + "\n\nIn case you want to choose a different one, please select 'No'...";
    //      final String title = "MotherMachine Classifier Selection";
    //      decision = JOptionPane.showConfirmDialog( guiFrame, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
    //      if ( decision == JOptionPane.YES_OPTION ) {
    //         GrowthLineSegmentationMagic.setClassifier( SEGMENTATION_CLASSIFIER_MODEL_FILE, "" );
    //      } else {
    //         final FileDialog fd = new FileDialog( guiFrame, "Select classifier model file...", FileDialog.LOAD );
    //         fd.setDirectory( SEGMENTATION_CLASSIFIER_MODEL_FILE );
    //         fd.setFilenameFilter( new FilenameFilter() {
    //
    //            @Override
    //            public boolean accept( final File dir, final String name ) {
    //               final String lowercaseName = name.toLowerCase();
    //               if ( lowercaseName.endsWith( ".model" ) ) {
    //                  return true;
    //               } else {
    //                  return false;
    //               }
    //            }
    //         } );
    //         fd.setVisible( true );
    //         final String filename = fd.getDirectory() + "/" + fd.getFile();
    //         if ( filename != null ) {
    //            SEGMENTATION_CLASSIFIER_MODEL_FILE = filename;
    //         }
    //      }

    return file;
}