Example usage for javax.swing JOptionPane YES_OPTION

List of usage examples for javax.swing JOptionPane YES_OPTION

Introduction

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

Prototype

int YES_OPTION

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

Click Source Link

Document

Return value from class method if YES is chosen.

Usage

From source file:com.brainflow.application.toplevel.Brainflow.java

private void register(IImageDataSource limg) {
    DataSourceManager manager = DataSourceManager.getInstance();
    boolean alreadyRegistered = manager.isRegistered(limg);

    if (alreadyRegistered) {
        StringBuffer sb = new StringBuffer();
        sb.append("Image " + limg.getDataFile().getName().getBaseName());
        sb.append(" has already been loaded, would you like to reload from disk?");
        Integer ret = JOptionPane.showConfirmDialog(brainFrame, sb.toString(), "Image Already Loaded",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        log.info("return value is: " + ret);

        if (ret == JOptionPane.YES_OPTION) {
            limg.releaseData();/*from w  w  w . j  a  v  a2  s  .  c  om*/
        }
    } else {
        manager.register(limg);
    }

}

From source file:org.fhaes.jsea.JSEAFrame.java

private void launchLagMap() {

    Object[] options = { "Yes", "No", "Cancel" };
    int n = JOptionPane.showOptionDialog(this,
            "LagMap is an interactive web application written by Wendy Gross and run within your web browser.\nWould you like to continue?",
            "Lauch LagMap", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
            options[2]);/*  w ww  .j a va2s.co m*/

    if (n == JOptionPane.YES_OPTION)
        Platform.browseWebpage(RemoteHelp.LAUNCH_LAG_MAP, this);

}

From source file:cl.almejo.vsim.gui.SimWindow.java

public int saveAs() {
    SAVE_AS_FILE_CHOOSER.setSelectedFile(new File(_circuit.getName()));
    if (SAVE_AS_FILE_CHOOSER.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
        LOGGER.info("save cancelled by user.");
        return 0;
    }/*  w w  w .j  av  a2s.  co m*/

    File file = SAVE_AS_FILE_CHOOSER.getSelectedFile();
    if (file.exists()) {
        if (askOverwrite() != JOptionPane.YES_OPTION) {
            return JOptionPane.CANCEL_OPTION;
        }
    }

    _circuit.setName(file.getPath());
    updateTitle();
    save(file.getPath());
    LOGGER.info("saved: " + file.getPath());
    return JOptionPane.OK_OPTION;
}

From source file:jeplus.gui.JPanel_TrnsysProjectFiles.java

private void cmdEditTemplateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEditTemplateActionPerformed

    // Test if the template file is present
    String fn = (String) cboTemplateFile.getSelectedItem();
    String templfn = RelativeDirUtil.checkAbsolutePath(txtDCKDir.getText() + fn, Project.getBaseDir());
    File ftmpl = new File(templfn);
    if (!ftmpl.exists()) {
        int n = JOptionPane.showConfirmDialog(this,
                "<html><p><center>The template file " + templfn + " does not exist."
                        + "Do you want to select one?</center></p><p> Select 'NO' to create this file. </p>",
                "Template file not available", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.YES_OPTION) {
            this.cmdSelectTemplateFileActionPerformed(null);
            templfn = txtDCKDir.getText() + (String) cboTemplateFile.getSelectedItem();
        }/*from w ww  .j  a  v  a 2s  .c  om*/
    }
    int idx = MainGUI.getTpnEditors().indexOfTab(fn);
    if (idx >= 0) {
        MainGUI.getTpnEditors().setSelectedIndex(idx);
    } else {
        EPlusTextPanel TemplFilePanel = new EPlusTextPanel(MainGUI.getTpnEditors(), fn,
                EPlusTextPanel.EDITOR_MODE, TRNSYSConfig.getFileFilter(TRNSYSConfig.TRNINPUT), templfn,
                Project);
        int ti = MainGUI.getTpnEditors().getTabCount();
        TemplFilePanel.setTabId(ti);
        MainGUI.getTpnEditors().addTab(fn, TemplFilePanel);
        MainGUI.getTpnEditors().setSelectedIndex(ti);
        MainGUI.getTpnEditors().setTabComponentAt(ti,
                new ButtonTabComponent(MainGUI.getTpnEditors(), TemplFilePanel));
        MainGUI.getTpnEditors().setToolTipTextAt(ti, templfn);
    }
}

From source file:de.cismet.cids.custom.objecteditors.wunda_blau.WebDavPicturePanel.java

/**
 * DOCUMENT ME!/*from   w ww  .jav a 2 s  .  c o m*/
 *
 * @param  evt  DOCUMENT ME!
 */
private void btnRemoveImgActionPerformed(final ActionEvent evt) { //GEN-FIRST:event_btnRemoveImgActionPerformed
    final Object[] selection = lstFotos.getSelectedValues();
    if ((selection != null) && (selection.length > 0)) {
        final int answer = JOptionPane.showConfirmDialog(StaticSwingTools.getParentFrame(this),
                "Sollen die Fotos wirklich gelscht werden?", "Fotos entfernen", JOptionPane.YES_NO_OPTION);
        if (answer == JOptionPane.YES_OPTION) {
            try {
                listListenerEnabled = false;
                final List<Object> removeList = Arrays.asList(selection);
                final List<CidsBean> fotos = cidsBean.getBeanCollectionProperty(beanCollProp);
                if (fotos != null) {
                    fotos.removeAll(removeList);
                }
                // TODO set the laufende_nr
                for (int i = 0; i < lstFotos.getModel().getSize(); i++) {
                    final CidsBean foto = (CidsBean) lstFotos.getModel().getElementAt(i);
                    foto.setProperty("laufende_nummer", i + 1);
                }

                for (final Object toDeleteObj : removeList) {
                    if (toDeleteObj instanceof CidsBean) {
                        final CidsBean fotoToDelete = (CidsBean) toDeleteObj;
                        final String file = String.valueOf(fotoToDelete.getProperty("url.object_name"));
                        IMAGE_CACHE.remove(file);
                        removedFotoBeans.add(fotoToDelete);
                    }
                }
            } catch (final Exception ex) {
                LOG.error(ex, ex);
                showExceptionToUser(ex, this);
            } finally {
                // TODO check the laufende_nummer attribute
                listListenerEnabled = true;
                final int modelSize = lstFotos.getModel().getSize();
                if (modelSize > 0) {
                    lstFotos.setSelectedIndex(0);
                } else {
                    image = null;
                    lblPicture.setIcon(FOLDER_ICON);
                }
            }
        }
    }
}

From source file:ca.uhn.hl7v2.testpanel.controller.Controller.java

public boolean saveAllMessagesAndReturnFalseIfCancelIsPressed() {

    for (Hl7V2MessageCollection next : myMessagesList.getMessages()) {
        if (next.isSaved() == false) {
            int save = showPromptToSaveMessageBeforeClosingIt(next, true);
            switch (save) {
            case JOptionPane.YES_OPTION:
                if (!saveMessages(next)) {
                    return false;
                }/*from   ww  w .  j a va2s.  c om*/
                break;
            case JOptionPane.NO_OPTION:
                break;
            case JOptionPane.CANCEL_OPTION:
                return false;
            default:
                // shouldn't happen
                throw new Error("invalid option:" + save);
            }
        }
    }

    return true;
}

From source file:edu.ku.brc.specify.tools.ireportspecify.MainFrameSpecify.java

/**
 * @param appResName/*  www . ja v  a 2 s.co m*/
 * @param tableid
 * @return AppResource with the provided name.
 * 
 * If a resource named appResName exists it will be returned, else a new resource is created.
 */
private static AppResAndProps getAppRes(final String appResName, final Integer tableid,
        final boolean confirmOverwrite) {
    AppResourceIFace resApp = AppContextMgr.getInstance().getResource(appResName);
    if (resApp != null) {
        if (!confirmOverwrite) {
            return new AppResAndProps(resApp, null);
        }
        //else
        int option = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(),
                String.format(UIRegistry.getResourceString("REP_CONFIRM_IMP_OVERWRITE"), resApp.getName()),
                UIRegistry.getResourceString("REP_CONFIRM_IMP_OVERWRITE_TITLE"), JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.NO_OPTION);

        if (option == JOptionPane.YES_OPTION) {
            return new AppResAndProps(resApp, null);
        }
        //else
        return null;
    }
    //else
    return createAppResAndProps(appResName, tableid, null);
}

From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java

private boolean confirmDelete(String text) {
    int choice;/* ww w.ja v a 2  s . c om*/

    choice = JOptionPane.showConfirmDialog(this, "Do you wisth to delete '" + text + "'?",
            "Delete Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    return (choice == JOptionPane.YES_OPTION);
}

From source file:dataviewer.DataViewer.java

private void btn_removeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_removeActionPerformed
    String name = "./db/" + cb_table.getSelectedItem().toString() + ".db";
    if (new File(name).exists()) {
        int dialogResult = JOptionPane
                .showConfirmDialog(null,
                        "Selected file [" + cb_table.getSelectedItem().toString()
                                + "] will be removed and not recoverable.",
                        "Are you sure?", JOptionPane.YES_NO_OPTION);
        if (dialogResult == JOptionPane.YES_OPTION) {
            (new File(name)).delete();
            cb_table.removeItem(cb_table.getSelectedItem());
            cb_table.setSelectedItem(null);
            tp_sql.setText("");
            tb_columns.setModel(new DefaultTableModel());
        }//from w  ww.j a  va 2  s  .com
    }

}

From source file:com.vgi.mafscaling.OpenLoop.java

protected void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(true);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//from   w  w w . ja  v a 2  s.  c om
    boolean isPolSet = polfTable.isSet();
    File[] files = fileChooser.getSelectedFiles();
    for (File file : files) {
        BufferedReader br = null;
        ArrayDeque<String[]> buffer = new ArrayDeque<String[]>();
        try {
            br = new BufferedReader(new FileReader(file.getAbsoluteFile()));
            String line = br.readLine();
            if (line != null) {
                String[] elements = line.split("(\\s*)?,(\\s*)?", -1);
                getColumnsFilters(elements, false);

                boolean resetColumns = false;
                if (logThtlAngleColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0
                        || logMafvColIdx >= 0 || logAfrColIdx >= 0 || logRpmColIdx >= 0 || logLoadColIdx >= 0
                        || logCommandedAfrCol >= 0) {
                    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                            "Would you like to reset column names or filter values?", "Columns/Filters Reset",
                            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE))
                        resetColumns = true;
                }

                if (resetColumns || logThtlAngleColIdx < 0 || logAfLearningColIdx < 0
                        || logAfCorrectionColIdx < 0 || logMafvColIdx < 0 || logAfrColIdx < 0
                        || logRpmColIdx < 0 || logLoadColIdx < 0 || (logCommandedAfrCol < 0 && !isPolSet)) {
                    ColumnsFiltersSelection selectionWindow = new OLColumnsFiltersSelection(isPolSet);
                    if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements, isPolSet))
                        return;
                }

                String[] flds;
                String[] afrflds;
                boolean wotFlag = true;
                boolean foundWot = false;
                double throttle;
                double stft;
                double ltft;
                double afr;
                double rpm;
                double load;
                double mafv;
                double cmdafr = 0;
                double afrErr = 0;
                int skipRowCount = 0;
                int row = 0;
                int i = 0;
                int j = 0;
                for (; i < runTables.length; ++i) {
                    if (runTables[i].getValueAt(0, 0).toString().isEmpty())
                        break;
                }
                if (i == runTables.length)
                    return;
                setCursor(new Cursor(Cursor.WAIT_CURSOR));
                for (int k = 0; k <= afrRowOffset && line != null; ++k) {
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));
                }
                while (line != null && buffer.size() > afrRowOffset) {
                    afrflds = buffer.getFirst();
                    flds = buffer.removeLast();
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));

                    try {
                        throttle = Double.valueOf(flds[logThtlAngleColIdx]);
                        if (row == 0 && throttle < 99)
                            wotFlag = false;
                        if (throttle < wotPoint) {
                            if (wotFlag == true) {
                                wotFlag = false;
                                skipRowCount = 0;
                                j -= 1;
                                while (j > 0 && skipRowCount < skipRowsOnTransition) {
                                    runTables[i].setValueAt("", j, 0);
                                    runTables[i].setValueAt("", j, 1);
                                    runTables[i].setValueAt("", j, 2);
                                    skipRowCount += 1;
                                    j -= 1;
                                }
                                skipRowCount = 0;
                            }
                        } else {
                            if (wotFlag == false) {
                                wotFlag = true;
                                skipRowCount = 0;
                                if (foundWot) {
                                    i += 1;
                                    if (i == runTables.length)
                                        return;
                                }
                                if (row > 0)
                                    j = 0;
                            }
                            if (skipRowCount >= skipRowsOnTransition) {
                                mafv = Double.valueOf(flds[logMafvColIdx]);
                                if (minMafV <= mafv) {
                                    foundWot = true;
                                    stft = Double.valueOf(flds[logAfCorrectionColIdx]);
                                    ltft = Double.valueOf(flds[logAfLearningColIdx]);
                                    afr = Double.valueOf(afrflds[logAfrColIdx]);
                                    rpm = Double.valueOf(flds[logRpmColIdx]);
                                    load = Double.valueOf(flds[logLoadColIdx]);

                                    afr = afr / ((100.0 - (ltft + stft)) / 100.0);

                                    if (logCommandedAfrCol >= 0)
                                        cmdafr = Double.valueOf(flds[logCommandedAfrCol]);
                                    else if (isPolSet)
                                        cmdafr = Utils.calculateCommandedAfr(rpm, load, minWotEnrichment,
                                                polfTable);
                                    else {
                                        JOptionPane.showMessageDialog(null,
                                                "Please set either \"Commanded AFR\" column or \"Primary Open Loop Fueling\" table",
                                                "Error", JOptionPane.ERROR_MESSAGE);
                                        return;
                                    }

                                    afrErr = (afr - cmdafr) / cmdafr * 100.0;
                                    if (Math.abs(afrErr) <= afrErrPrct) {
                                        Utils.ensureRowCount(j + 1, runTables[i]);
                                        runTables[i].setValueAt(rpm, j, 0);
                                        runTables[i].setValueAt(mafv, j, 1);
                                        runTables[i].setValueAt(afrErr, j, 2);
                                        j += 1;
                                    }
                                }
                            }
                            skipRowCount += 1;
                        }
                    } catch (NumberFormatException e) {
                        logger.error(e);
                        JOptionPane.showMessageDialog(null,
                                "Error parsing number at " + file.getName() + " line " + (row + 1) + ": " + e,
                                "Error processing file", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    row += 1;
                }

                if (!foundWot) {
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    JOptionPane.showMessageDialog(null, "Sorry, no WOT pulls were found in the log file",
                            "No WOT data", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        } catch (Exception e) {
            logger.error(e);
            JOptionPane.showMessageDialog(null, e, "Error opening file", JOptionPane.ERROR_MESSAGE);
        } finally {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
        }
    }
}