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:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java

private boolean checkLoadProfilePropertiesDirty() {
    if (dirty) {//from  w w  w . j  a  v a 2  s .  c  o m
        switch (JOptionPane.showConfirmDialog(AppFrame.this, "Save load profile changes?")) {
        case JOptionPane.YES_OPTION:
            saveLoadProfileConfiguration(false);
            return true;
        case JOptionPane.NO_OPTION:
            return true;
        case JOptionPane.CANCEL_OPTION:
        default:
            return false;
        }
    }
    return true;
}

From source file:edu.harvard.i2b2.previousquery.ui.QueryPreviousRunsPanel.java

private void populateChildNodes(DefaultMutableTreeNode node) {
    if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) {
        QueryMasterData data = (QueryMasterData) node.getUserObject();
        try {//from w ww  .j a v a  2 s  . co m
            String xmlRequest = data.writeContentQueryXML();

            String xmlResponse = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest);
            } else {
                xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest);
            }
            if (xmlResponse.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                return;
            }

            try {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();
                JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse);
                ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();

                BodyType bt = messageType.getMessageBody();
                InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper()
                        .getObjectByClass(bt.getAny(), InstanceResponseType.class);

                for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) {
                    // change later for working with new xml schema
                    // RunQuery runQuery =
                    //queryInstanceType.getResult().get(i).getRunQuery().get
                    // (0);

                    QueryInstanceData runData = new QueryInstanceData();

                    runData.visualAttribute("FA");
                    runData.tooltip("The results of the query run");
                    runData.id(queryInstanceType.getQueryInstanceId());
                    // runData.patientRefId(new
                    // Integer(queryInstanceType.getRefId()).toString());
                    // runData.patientCount(new
                    // Long(queryInstanceType.getCount()).toString());
                    // XMLGregorianCalendar cldr =
                    // queryInstanceType.getStartDate();
                    /*
                     * runData.name("Results of "+
                     * "["+addZero(cldr.getMonth(
                     * ))+"-"+addZero(cldr.getDay())+"-"
                     * +addZero(cldr.getYear())+"
                     * "+addZero(cldr.getHour())+":"
                     * +addZero(cldr.getMinute())
                     * +":"+addZero(cldr.getSecond())+"]");
                     */
                    runData.name("Results of " + data.name().substring(0, data.name().indexOf("[")));
                    runData.queryName(data.name());
                    data.runs.add(runData);
                    addNode(runData, node);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            // jTree1.scrollPathToVisible(new TreePath(node.getPath()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) {
        QueryInstanceData data = (QueryInstanceData) node.getUserObject();

        try {
            String xmlRequest = data.writeContentQueryXML();

            String xmlResponse = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest);
            } else {
                xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest);
            }
            if (xmlResponse.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                return;
            }

            JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

            JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse);
            ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
            BodyType bt = messageType.getMessageBody();
            ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper()
                    .getObjectByClass(bt.getAny(), ResultResponseType.class);

            for (QueryResultInstanceType queryResultInstanceType : resultResponseType
                    .getQueryResultInstance()) {
                String status = queryResultInstanceType.getQueryStatusType().getName();

                QueryResultData resultData = new QueryResultData();
                if (queryResultInstanceType.getQueryResultType().getName().equalsIgnoreCase("PATIENTSET")) {
                    resultData.visualAttribute("FA");
                } else {
                    resultData.visualAttribute("LAO");
                }
                // resultData.queryId(data.queryId());
                resultData.patientRefId(queryResultInstanceType.getResultInstanceId());// data.patientRefId());
                resultData.patientCount(new Integer(queryResultInstanceType.getSetSize()).toString());// data.patientCount());
                String resultname = "";
                // if ((resultname = queryResultInstanceType
                // .getQueryResultType().getDescription()) == null) {
                resultname = queryResultInstanceType.getQueryResultType().getDescription();// getName();
                // }
                if (status.equalsIgnoreCase("FINISHED")) {
                    if (queryResultInstanceType.getQueryResultType().getName().equals("PATIENTSET"))
                        resultname += " - " + resultData.patientCount() + " Patients";
                    resultData.name(resultname);// + " - "
                    //   + resultData.patientCount() + " Patients");
                    resultData.tooltip(resultData.patientCount() + " Patients");

                } else {
                    resultData.name(resultname);// + " - " + status);
                    resultData.tooltip(status);

                }
                resultData.xmlContent(xmlResponse);
                resultData.queryName(data.queryName());
                resultData.type(queryResultInstanceType.getQueryResultType().getName());
                addNode(resultData, node);
            }

            // jTree1.scrollPathToVisible(new TreePath(node.getPath()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) {
        QueryResultData data = (QueryResultData) node.getUserObject();
        if (data.patientCount().equalsIgnoreCase("0")) {
            return;
        }
        int maxNumPatientsToDisplay = Integer.valueOf(System.getProperty("PQMaxPatientsNumber"));
        if (Integer.valueOf(data.patientCount()) > maxNumPatientsToDisplay) {
            final JPanel parent = this;
            result = JOptionPane.showConfirmDialog(parent,
                    "The patient count is greater than maximum configured to be displayed.\n"
                            + "Populating the patient list may affect performance. \n"
                            + "Do you want to continue?",
                    "Please Note ...", JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.NO_OPTION) {
                DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0);
                QueryData tmpdata = (QueryData) tmpnode.getUserObject();
                if (tmpdata.name().equalsIgnoreCase("working ......")) {
                    tmpdata.name("Over maximum number of patient nodes");
                    treeModel.reload(tmpnode);
                }
                return;
            }
        }
        try {
            String xmlRequest = data.writeContentQueryXML();

            String xmlResponse = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                xmlResponse = QueryListNamesClient.sendPDORequestSOAP(xmlRequest, showName());
            } else {
                xmlResponse = QueryListNamesClient.sendPdoRequestREST(xmlRequest);
            }
            if (xmlResponse.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                return;
            }

            // check response status here ......

            // System.out.println("Response: "+xmlResponse);
            PatientSet patientSet = new PDOResponseMessageFactory().getPatientSetFromResponseXML(xmlResponse);
            List<PatientType> patients = patientSet.getPatient();
            System.out.println("Patient set size: " + patients.size());

            for (int i = 0; i < patients.size(); i++) {
                PatientType patient = patients.get(i);

                PatientData pData = new PatientData();
                pData.patientID(patient.getPatientId().getValue());
                pData.setParamData(patient.getParam());
                pData.visualAttribute("LAO");
                pData.tooltip("Patient");
                pData.patientSetID(data.patientRefId());
                if (showName()) {
                    pData.name(pData.patientID() + " [" + pData.lastName().substring(0, 1).toUpperCase()
                            + pData.lastName().substring(1, pData.lastName().length()).toLowerCase() + ", "
                            + pData.firstName().substring(0, 1).toUpperCase()
                            + pData.firstName().substring(1, pData.firstName().length()).toLowerCase() + "]");//["+pData.age()+"
                    // y/o
                    // "+pData.gender()+"
                    // "+pData.race()+"]");
                } else {
                    pData.name(pData.patientID() + " [" + pData.age() + " y/o " + pData.gender() + " "
                            + pData.race() + "]");
                }
                pData.queryName(data.queryName());
                addNode(pData, node);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // implement for other type of nodes later!!!
}

From source file:com.mirth.connect.client.ui.Frame.java

public boolean alertRefresh() {
    boolean cancelRefresh = false;

    if (PlatformUI.MIRTH_FRAME.isSaveEnabled()) {
        int option = JOptionPane.showConfirmDialog(PlatformUI.MIRTH_FRAME,
                "<html>Any unsaved changes will be lost.<br>Would you like to continue?</html>", "Warning",
                JOptionPane.YES_NO_OPTION);

        if (option == JOptionPane.NO_OPTION || option == JOptionPane.CLOSED_OPTION) {
            cancelRefresh = true;
        } else {// w  w w . j a v  a 2 s  .  com
            setSaveEnabled(false);
        }
    }

    return cancelRefresh;
}

From source file:edu.ku.brc.af.ui.forms.FormViewObj.java

public boolean isDataCompleteAndValid(final boolean throwAwayOnDiscard) {
    //log.debug((formValidator != null) +" "+ formValidator.hasChanged() +"  "+mvParent.isTopLevel() +" "+ mvParent.hasChanged());

    // Figure out if it is New and whether it has changed or is incomplete
    boolean isNewAndComplete = true;
    if (mvParent != null) {
        Object topParentData = mvParent.getTopLevel().getData();
        if (topParentData != null && topParentData instanceof FormDataObjIFace) {
            if (((FormDataObjIFace) topParentData).getId() == null) {
                if (formValidator != null && dataObj != null) {
                    isNewAndComplete = formValidator.isFormValid();
                }//from   w w  w  .  ja  va 2  s.  c o m
            }
        }
    }

    //log.debug("Form     Val: "+(formValidator != null && formValidator.hasChanged()));
    //log.debug("mvParent Val: "+(mvParent != null && mvParent.isTopLevel() && mvParent.hasChanged()));

    //if ((formValidator != null && formValidator.hasChanged()) ||
    //    (mvParent != null && mvParent.isTopLevel() && mvParent.hasChanged()))
    if (!doingDiscard && mvParent != null && mvParent.isTopLevel() && mvParent.hasChanged()) {
        try {
            doingDiscard = true;
            String title = null;
            if (dataObj != null) {
                if (tableInfo == null) {
                    tableInfo = DBTableIdMgr.getInstance()
                            .getByShortClassName(dataObj.getClass().getSimpleName());
                }

                title = tableInfo != null ? tableInfo.getTitle() : null;

                if (StringUtils.isEmpty(title)) {
                    title = UIHelper.makeNamePretty(dataObj.getClass().getSimpleName());
                }
            }

            if (StringUtils.isEmpty(title)) {
                title = "data"; // I18N, not really sure what to put here.
            }

            // For the DISCARD
            // Since JOptionPane doesn't have a YES_CANCEL_OPTION 
            // I have to use YES_NO_OPTION and since this is a Discard question
            // the rv has completely different meanings:
            // YES -> Means don't save (Discard) and close dialog (return true)
            // NO  -> Means do nothing so return false

            String[] optionLabels;
            int dlgOptions;
            int defaultRV;
            if (!isNewAndComplete || (formValidator != null && !formValidator.isFormValid())) {
                dlgOptions = JOptionPane.YES_NO_OPTION;
                optionLabels = new String[] { getResourceString("DiscardChangesBtn"),
                        getResourceString("CANCEL") };
                defaultRV = JOptionPane.NO_OPTION;
            } else {
                dlgOptions = JOptionPane.YES_NO_CANCEL_OPTION;
                optionLabels = new String[] { getResourceString("SaveChangesBtn"),
                        getResourceString("DiscardChangesBtn"), getResourceString("CANCEL") };
                defaultRV = JOptionPane.CANCEL_OPTION;
            }

            int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(),
                    isNewAndComplete ? UIRegistry.getLocalizedMessage("DiscardChanges", title)
                            : UIRegistry.getLocalizedMessage("SaveChanges", title),
                    isNewAndComplete ? getResourceString("DiscardChangesTitle")
                            : getResourceString("SaveChangesTitle"),
                    dlgOptions, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]);

            if (rv == JOptionPane.CLOSED_OPTION) {
                rv = defaultRV;
            }

            if (dlgOptions == JOptionPane.YES_NO_OPTION) {
                if (rv == JOptionPane.YES_OPTION) {
                    discardCurrentObject(throwAwayOnDiscard);
                    return true;

                } else if (rv == JOptionPane.NO_OPTION) {
                    return false;
                }

            } else {
                if (rv == JOptionPane.YES_OPTION) {
                    return saveObject();

                } else if (rv == JOptionPane.CANCEL_OPTION) {
                    return false;

                } else if (rv == JOptionPane.NO_OPTION) {
                    // NO means Discard
                    discardCurrentObject(throwAwayOnDiscard);
                    return true;
                }
            }
        } finally {
            doingDiscard = false;
        }

    } else {
        return true;
    }
    return isNewAndComplete;
}

From source file:edmondskarp.Gui.EdmondsKarpGui.java

public void saveGraph() {

    int option2 = JOptionPane.NO_OPTION;
    File f = null;/*from   www. ja va 2s.c om*/
    String str = null;
    while (option2 == JOptionPane.NO_OPTION) //Finche' non decido di salvare
    {
        //Visualizzo la finestra di dialogo
        int option = chooser.showSaveDialog(this);
        if (option == JFileChooser.APPROVE_OPTION) //Se ho premuto il tasto salva
        {
            try {
                //Recupero il file selezionato
                f = chooser.getSelectedFile();
                //Recupero il path del file
                str = f.getCanonicalPath();
                //Se il nome del file non contiene l'estensione, la aggiungo io a mano
                //Se il file esiste chiedo se lo voglio sovrascrivere
                if (f.exists()) {
                    option2 = JOptionPane.showConfirmDialog(this,
                            "Il file esiste gia'.\nLo vuoi sovrascrivere?", "Sovrascrittura",
                            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                } else {
                    option2 = JOptionPane.YES_OPTION;
                }
            } catch (IOException | HeadlessException ex) {
            }
        } else {
            option2 = JOptionPane.CANCEL_OPTION;
        }
    }
    if (option2 == JOptionPane.YES_OPTION) {
        try {
            controller.save(str);
        } catch (JSONException ex) {
            Logger.getLogger(EdmondsKarpGui.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}

From source file:com.mirth.connect.client.ui.ChannelPanel.java

public boolean doExportChannel() {
    if (isSaveEnabled() && !promptSave(true)) {
        return false;
    }/*from  w  ww.  j  a v  a 2  s  .c o  m*/

    if (isGroupSelected()) {
        JOptionPane.showMessageDialog(parent, "This operation can only be performed on channels.");
        return false;
    }

    if (parent.changesHaveBeenMade()) {
        if (parent.alertOption(this,
                "This channel has been modified. You must save the channel changes before you can export. Would you like to save them now?")) {
            if (!parent.channelEditPanel.saveChanges()) {
                return false;
            }
        } else {
            return false;
        }

        parent.setSaveEnabled(false);
    }

    Channel channel;
    if (parent.currentContentPage == parent.channelEditPanel
            || parent.currentContentPage == parent.channelEditPanel.filterPane
            || parent.currentContentPage == parent.channelEditPanel.transformerPane) {
        channel = parent.channelEditPanel.currentChannel;
    } else {
        List<Channel> selectedChannels = getSelectedChannels();
        if (selectedChannels.size() > 1) {
            exportChannels(selectedChannels);
            return true;
        }
        channel = selectedChannels.get(0);
    }

    // Add code template libraries if necessary
    if (channelHasLinkedCodeTemplates(channel)) {
        boolean addLibraries = true;
        String exportChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class)
                .get("exportChannelCodeTemplateLibraries", null);

        if (exportChannelCodeTemplateLibraries == null) {
            ExportChannelLibrariesDialog dialog = new ExportChannelLibrariesDialog(channel);
            if (dialog.getResult() == JOptionPane.NO_OPTION) {
                addLibraries = false;
            } else if (dialog.getResult() != JOptionPane.YES_OPTION) {
                return false;
            }
        } else {
            addLibraries = Boolean.parseBoolean(exportChannelCodeTemplateLibraries);
        }

        if (addLibraries) {
            addCodeTemplateLibrariesToChannel(channel);
        }
    }

    addDependenciesToChannel(channel);

    // Update resource names
    parent.updateResourceNames(channel);

    ObjectXMLSerializer serializer = ObjectXMLSerializer.getInstance();
    String channelXML = serializer.serialize(channel);
    // Reset the libraries on the cached channel
    channel.getCodeTemplateLibraries().clear();
    channel.clearDependencies();

    return parent.exportFile(channelXML, channel.getName(), "XML", "Channel");
}

From source file:com.mirth.connect.client.ui.ChannelPanel.java

private void exportChannels(List<Channel> channelList) {
    if (channelHasLinkedCodeTemplates(channelList)) {
        boolean addLibraries;
        String exportChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class)
                .get("exportChannelCodeTemplateLibraries", null);

        if (exportChannelCodeTemplateLibraries == null) {
            JCheckBox alwaysChooseCheckBox = new JCheckBox(
                    "Always choose this option by default in the future (may be changed in the Administrator settings)");
            Object[] params = new Object[] {
                    "<html>One or more channels has code template libraries linked to them.<br/>Do you wish to include these libraries in each respective channel export?</html>",
                    alwaysChooseCheckBox };
            int result = JOptionPane.showConfirmDialog(this, params, "Select an Option",
                    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);

            if (result == JOptionPane.YES_OPTION || result == JOptionPane.NO_OPTION) {
                addLibraries = result == JOptionPane.YES_OPTION;
                if (alwaysChooseCheckBox.isSelected()) {
                    Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries",
                            addLibraries);
                }//from   w  ww  . j  a  v  a  2  s  .  com
            } else {
                return;
            }
        } else {
            addLibraries = Boolean.parseBoolean(exportChannelCodeTemplateLibraries);
        }

        if (addLibraries) {
            for (Channel channel : channelList) {
                addCodeTemplateLibrariesToChannel(channel);
            }
        }
    }

    for (Channel channel : channelList) {
        addDependenciesToChannel(channel);
    }

    JFileChooser exportFileChooser = new JFileChooser();
    exportFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    File currentDir = new File(Frame.userPreferences.get("currentDirectory", ""));
    if (currentDir.exists()) {
        exportFileChooser.setCurrentDirectory(currentDir);
    }

    int returnVal = exportFileChooser.showSaveDialog(this);
    File exportFile = null;
    File exportDirectory = null;
    String exportPath = "/";

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        Frame.userPreferences.put("currentDirectory", exportFileChooser.getCurrentDirectory().getPath());

        int exportCollisionCount = 0;
        exportDirectory = exportFileChooser.getSelectedFile();
        exportPath = exportDirectory.getAbsolutePath();

        for (Channel channel : channelList) {
            exportFile = new File(exportPath + "/" + channel.getName() + ".xml");

            if (exportFile.exists()) {
                exportCollisionCount++;
            }

            // Update resource names
            parent.updateResourceNames(channel);
        }

        try {
            int exportCount = 0;

            boolean overwriteAll = false;
            boolean skipAll = false;
            for (int i = 0, size = channelList.size(); i < size; i++) {
                Channel channel = channelList.get(i);
                exportFile = new File(exportPath + "/" + channel.getName() + ".xml");

                boolean fileExists = exportFile.exists();
                if (fileExists) {
                    if (!overwriteAll && !skipAll) {
                        if (exportCollisionCount == 1) {
                            if (!parent.alertOption(parent, "The file " + channel.getName()
                                    + ".xml already exists.  Would you like to overwrite it?")) {
                                continue;
                            }
                        } else {
                            ConflictOption conflictStatus = parent.alertConflict(parent,
                                    "<html>The file " + channel.getName()
                                            + ".xml already exists.<br>Would you like to overwrite it?</html>",
                                    exportCollisionCount);

                            if (conflictStatus == ConflictOption.YES_APPLY_ALL) {
                                overwriteAll = true;
                            } else if (conflictStatus == ConflictOption.NO) {
                                exportCollisionCount--;
                                continue;
                            } else if (conflictStatus == ConflictOption.NO_APPLY_ALL) {
                                skipAll = true;
                                continue;
                            }
                        }
                    }
                    exportCollisionCount--;
                }

                if (!fileExists || !skipAll) {
                    String channelXML = ObjectXMLSerializer.getInstance().serialize(channel);
                    FileUtils.writeStringToFile(exportFile, channelXML, UIConstants.CHARSET);
                    exportCount++;
                }
            }

            if (exportCount > 0) {
                parent.alertInformation(parent,
                        exportCount + " files were written successfully to " + exportPath + ".");
            }
        } catch (IOException ex) {
            parent.alertError(parent, "File could not be written.");
        }
    }

    // Reset the libraries on the cached channels
    for (Channel channel : channelList) {
        channel.getCodeTemplateLibraries().clear();
        channel.clearDependencies();
    }
}

From source file:GUI.MainWindow.java

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

    File save_file = null;/*  w  w  w. j  a v  a  2 s . co  m*/
    // Ask user where they want to save file
    boolean proceed = true;
    int returnVal = this.fileChooser.showSaveDialog(this);

    if (returnVal == JFileChooser.APPROVE_OPTION) {

        save_file = fileChooser.getSelectedFile();
        System.out.println("==LookupCVEActionPerformed(): " + save_file);

        if (save_file.exists() == true) {

            int response = JOptionPane.showConfirmDialog(null,
                    "Are you sure you want to replace existing file?", "Confirm", JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.NO_OPTION) {
                proceed = false;
            }
        }

        if (proceed == true) {

            save_file.delete(); // wipe original
            handleCVELookup(save_file);

        }

    }
}

From source file:org.jets3t.apps.cockpit.Cockpit.java

/**
 * Deletes the bucket currently selected in the gui.
 *
 *///from   www  . j  av a2 s .  c o  m
private void deleteSelectedBucket() {
    if (currentSelectedBucket == null) {
        log.warn("Ignoring delete bucket command, no currently selected bucket");
        return;
    }

    int response = JOptionPane.showConfirmDialog(ownerFrame,
            "Are you sure you want to delete '" + currentSelectedBucket.getName() + "'?", "Delete Bucket?",
            JOptionPane.YES_NO_OPTION);

    if (response == JOptionPane.NO_OPTION) {
        return;
    }

    try {
        s3ServiceMulti.getS3Service().deleteBucket(currentSelectedBucket.getName());
        bucketTableModel.removeBucket(currentSelectedBucket);
        currentSelectedBucket = null;
    } catch (Exception e) {
        String message = "Unable to delete bucket";
        log.error(message, e);
        ErrorDialog.showDialog(ownerFrame, this, message, e);
    }
}

From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java

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

    int answer = NarrowOptionPane.showConfirmDialog(this,
            "Are you sure you want to delete " + selectedStack.getName() + "?", "Delete Stack",
            JOptionPane.YES_NO_OPTION);
    if (answer == JOptionPane.NO_OPTION)
        return;// w w  w . ja v  a2s .  c  om

    try {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                SedStack stack = selectedStack;
                updateStackList(stack, false);
            }
        });
        sedsTable.setModel(new StackTableModel(selectedStack));
    } catch (ArrayIndexOutOfBoundsException ex) {
        sedsTable.setModel(new StackTableModel());
    }
}