Example usage for javax.swing JOptionPane NO_OPTION

List of usage examples for javax.swing JOptionPane NO_OPTION

Introduction

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

Prototype

int NO_OPTION

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

Click Source Link

Document

Return value from class method if NO is chosen.

Usage

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

/**
 * Processes all Commands of type LABELS.
 * @param cmdAction the command to be processed
 *//*from   w  w w.ja  v  a  2s  .  c om*/
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:canreg.client.gui.analysis.ExportReportInternalFrame.java

/**
 *
 * @return/*www. j  a  v  a2  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  a2  s.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/*  w w w.  ja  v  a  2 s.  c o m*/
 *            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;
}

From source file:org.agmip.ui.afsirs.frames.SWFrame.java

private void showSoilDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSoilDataButtonActionPerformed
    // TODO add your handling code here:

    boolean isFileEnabled = jRadioFile.isSelected();
    boolean isFileLocationEnabled = jRadioButtonSavedLocation.isSelected();
    String str = "";

    if (isFileLocationEnabled) {
        SoilData soilData;/*from  www  .  ja  v  a 2s  .c o m*/
        File latestFile;
        try {
            latestFile = findLatestFile(soilFileListCombo.getSelectedIndex());
            str = readFromJsonFileForSoilDetailsButton(latestFile);

        } catch (FileNotFoundException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
            return;
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (isFileEnabled) {
        str += "Soil Name = " + SNAME + "\n";
        str += "Texture = " + TXT[0] + "\n";
        str += "Number of Layers = " + NL + "\n";
        str += "    DU        WCL        WCU        (WCU-WCL)\n";
        for (int i = 0; i < NL; i++) {
            str += (i + 1) + "  " + DU[i] + "       " + WCL[i] + "       " + WCU[i] + "       "
                    + (WCU[i] - WCL[i]) + "\n";
        }
    }

    JTextArea textArea = new JTextArea(str);
    JScrollPane scrollPane = new JScrollPane(textArea);
    textArea.setLineWrap(true);
    textArea.setEditable(false);
    textArea.setWrapStyleWord(true);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    JOptionPane.showMessageDialog(null, scrollPane, "Soil Info", JOptionPane.NO_OPTION);

    //JOptionPane.showMessageDialog(null, str);            

}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Invokes the Cluster Shutdown Operation
 *//*from  w  w  w. ja va 2  s  . c o m*/
protected void doShutdownCluster() {

    // Consider different messages when there are active jobs
    String message = "Are you sure to shutdown the cluster ?";

    int response = JOptionPane.showConfirmDialog(this, message, "Shutdown Cluster", JOptionPane.YES_NO_OPTION);

    // User chose 'No'
    if (response == JOptionPane.NO_OPTION)
        return;
    JButton shutdownButton = getUIElement("general.shutdown");
    shutdownButton.setEnabled(false);

    showBusyIcon();

    // Shutdown
    onShutdown();
}

From source file:musite.ui.MusiteResultPanel.java

public boolean saveResult(boolean showConfirm) {
    JFileChooser fc = new JFileChooser(MusiteInit.defaultPath);

    // TODO: windows reserverd
    String fileName = panelName.replaceAll("[" + StringUtil.toOct("|\\?*<\":>+[]/") + "]+", "_");
    fc.setSelectedFile(new File(MusiteInit.defaultPath + File.separator + fileName + ".pred.xml.gz"));

    ArrayList<String> exts = new ArrayList<String>(2);
    exts.add("xml");
    exts.add("xml.gz");
    fc.addChoosableFileFilter(new FileExtensionsFilter(exts, "Prediction XML file (.xml, .xml.gz)"));

    exts = new ArrayList<String>(2);
    exts.add("pred.xml");
    exts.add("pred.xml.gz");
    fc.addChoosableFileFilter(new FileExtensionsFilter(exts, "Prediction result file (pred.xml, pred.xml.gz)"));

    //fc.setAcceptAllFileFilterUsed(true);
    fc.setDialogTitle("Save the the result to...");
    int returnVal = fc.showSaveDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        MusiteInit.defaultPath = file.getParent();

        String filePath = MusiteInit.defaultPath + File.separator + file.getName();

        //            if (!filePath.toLowerCase().endsWith(".xml")&&!filePath.toLowerCase().endsWith(".xml.gz")) {
        //                filePath += ".pred.xml.gz";
        //            }

        if (IOUtil.fileExist(filePath)) {
            int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?",
                    "Relace the existing file?", JOptionPane.YES_NO_OPTION);
            if (ret == JOptionPane.NO_OPTION)
                return false;
        }//from w ww .ja v  a  2s.com

        PredictionResultXMLWriter writer = PredictionResultXMLWriter.createWriter();
        WriteTask task = new WriteTask(result, writer, filePath);

        TaskUtil.execute(task);
        if (task.success()) {
            if (showConfirm)
                JOptionPane.showMessageDialog(this, "Result saved!");
            saved = true;
            return true;
        } else {
            JOptionPane.showMessageDialog(this, "Failed to save the result.");
            return false;
        }
    } else {
        return false;
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java

private void copyBBToExternalClipboardEvent() {
    try {//from   w w  w.j  av  a  2s .co  m
        List<Attack> attacks = getSelectedAttacks();
        if (attacks.isEmpty()) {
            showInfo("Keine Angriffe ausgewhlt");
            return;
        }
        boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this,
                "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code",
                "Nein", "Ja") == JOptionPane.YES_OPTION);

        StringBuilder buffer = new StringBuilder();
        if (extended) {
            buffer.append("[u][size=12]Angriffsplan[/size][/u]\n\n");
        } else {
            buffer.append("[u]Angriffsplan[/u]\n\n");
        }

        buffer.append(new AttackListFormatter().formatElements(attacks, extended));

        if (extended) {
            buffer.append("\n[size=8]Erstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n");
        } else {
            buffer.append("\nErstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n");
        }

        String b = buffer.toString();
        StringTokenizer t = new StringTokenizer(b, "[");
        int cnt = t.countTokens();
        if (cnt > 1000) {
            if (JOptionPaneHelper.showQuestionConfirmBox(this,
                    "Die ausgewhlten Angriffe bentigen mehr als 1000 BB-Codes\n"
                            + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\nTrotzdem exportieren?",
                    "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) {
                return;
            }
        }

        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null);
        String result = "Daten in Zwischenablage kopiert.";
        showSuccess(result);
    } catch (Exception e) {
        logger.error("Failed to copy data to clipboard", e);
        String result = "Fehler beim Kopieren in die Zwischenablage.";
        showError(result);
    }
}

From source file:com.sshtools.sshterm.SshTerminalPanel.java

public boolean canClose() {
    if (session != null) {
        setFullScreenMode(false);/*  w w  w .j a v a2 s.c om*/

        if (JOptionPane.showConfirmDialog(this, "Close the current session and exit?", "Exit Application",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
            return false;
        }

        /*if (browserFrame != null) {
          if (! ( (SessionProviderFrame) browserFrame).canExit()) {
            return false;
          }
               }*/
    }

    return true;
}

From source file:edu.ku.brc.af.tasks.BaseTask.java

/**
 * Asks where the source of the COs should come from.
 * (This needs to be moved to the BaseTask in specify package)
 * @return the source enum//  w ww  . j  a va2s . co  m
 */
public ASK_TYPE askSourceOfObjects(final Class<? extends FormDataObjIFace> classForSrc) {
    Object[] options = { getResourceString("NEW_BT_USE_RS"),
            getResourceString("NEW_BT_ENTER_" + classForSrc.getSimpleName()) };
    int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(),
            getResourceString("NEW_BT_CHOOSE_RS_" + classForSrc.getSimpleName()),
            getResourceString("NEW_BT_CHOOSE_RSOPT_TITLE"), JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
    if (userChoice == JOptionPane.NO_OPTION) {
        return ASK_TYPE.EnterDataObjs;

    } else if (userChoice == JOptionPane.YES_OPTION) {
        return ASK_TYPE.ChooseRS;
    }
    return ASK_TYPE.Cancel;
}