List of usage examples for javax.swing JOptionPane YES_NO_CANCEL_OPTION
int YES_NO_CANCEL_OPTION
To view the source code for javax.swing JOptionPane YES_NO_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. From source file:ca.uhn.hl7v2.testpanel.controller.Controller.java
private int showPromptToSaveMessageBeforeClosingIt(Hl7V2MessageCollection theMsg, boolean theShowCancelButton) { Component parentComponent = myView.getFrame(); Object message = "<html>The following file is unsaved, do you want to save before closing?<br>" + theMsg.getBestDescription() + "</html>"; String title = DIALOG_TITLE;/* w w w . j a va 2 s . com*/ int optionType = theShowCancelButton ? JOptionPane.YES_NO_CANCEL_OPTION : JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; return JOptionPane.showConfirmDialog(parentComponent, message, title, optionType, messageType); }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * @param objWrapper/*from www .j av a 2s .co m*/ * @param groupObjWrapper * @param selectedObjTitle */ /*private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper userObjWrapperArg, final DataModelObjBaseWrapper groupObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout)(infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = groupObjWrapperArg != null ? groupObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal)dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] {getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL")}; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, userObjWrapperArg, groupObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; groupObjWrapper = groupObjWrapperArg; collectionObjWrapper = collectionWrapperArg; }*/ private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper secondObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout) (infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = secondObjWrapperArg != null ? secondObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal) dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] { getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL") }; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, secondObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; secondObjWrapper = secondObjWrapperArg; collectionWrapper = collectionWrapperArg; }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * @return true if no unsaved changes are present * else return results of prompt to save *//*from w w w.ja v a2 s .c om*/ protected boolean checkForChanges() { // if (termList != null) // { // int s = termList.getSelectedIndex(); // if (s != -1) // { // L10NItem entry = srcFile.getKey(s); // entry.setDstStr(textField.getText()); // } // if (srcFile.isEdited()) // { // int response = JOptionPane.showOptionDialog((Frame )getTopWindow(), // String.format(getResourceString("StrLocalizerApp.SaveChangesMsg"), destFile.getPath()), // getResourceString("StrLocalizerApp.SaveChangesTitle"), // JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION); // if (response == JOptionPane.CANCEL_OPTION) // { // return false; // } // if (response == JOptionPane.YES_OPTION) // { // doSave(); // return true; //what if it fails? // } // } // return true; // } boolean hasChanges = false; for (L10NFile f : srcFiles) { if (f.isChanged()) { hasChanges = true; break; } } if (hasChanges) { int response = JOptionPane.showOptionDialog((Frame) getTopWindow(), "Changes have not been saved.\n\nDo you wish to save them?", getResourceString("StrLocalizerApp.SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION); if (response == JOptionPane.CANCEL_OPTION) { return false; } if (response == JOptionPane.YES_OPTION) { doSave(); return true; //what if it fails? } } return true; }
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 *//* w ww . ja v a 2 s .com*/ 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:canreg.client.gui.analysis.ExportReportInternalFrame.java
/** * * @return//from w ww . j av a2s. 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:com._17od.upm.gui.DatabaseActions.java
public void importAccounts() throws TransportException, ProblemReadingDatabaseFile, IOException, CryptoException, PasswordDatabaseException { if (getLatestVersionOfDatabase()) { // Prompt for the file to import JFileChooser fc = new JFileChooser(); fc.setDialogTitle(Translator.translate("import")); int returnVal = fc.showOpenDialog(mainWindow); if (returnVal == JFileChooser.APPROVE_OPTION) { File csvFile = fc.getSelectedFile(); // Unmarshall the accounts from the CSV file try { AccountsCSVMarshaller marshaller = new AccountsCSVMarshaller(); ArrayList accountsInCSVFile = marshaller.unmarshal(csvFile); ArrayList accountsToImport = new ArrayList(); boolean importCancelled = false; // Add each account to the open database. If the account // already exits the prompt to overwrite for (int i = 0; i < accountsInCSVFile.size(); i++) { AccountInformation importedAccount = (AccountInformation) accountsInCSVFile.get(i); if (database.getAccount(importedAccount.getAccountName()) != null) { Object[] options = { "Overwrite Existing", "Keep Existing", "Cancel" }; int answer = JOptionPane.showOptionDialog(mainWindow, Translator.translate("importExistingQuestion", importedAccount.getAccountName()), Translator.translate("importExistingTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (answer == 1) { continue; // If keep existing then continue to the next iteration } else if (answer == 2) { importCancelled = true; break; // Cancel the import }// w w w. j av a 2s . c o m } accountsToImport.add(importedAccount); } if (!importCancelled && accountsToImport.size() > 0) { for (int i = 0; i < accountsToImport.size(); i++) { AccountInformation accountToImport = (AccountInformation) accountsToImport.get(i); database.deleteAccount(accountToImport.getAccountName()); database.addAccount(accountToImport); } saveDatabase(); accountNames = getAccountNames(); filter(); } } catch (ImportException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } catch (IOException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } catch (CryptoException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } } } }
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//from w w w. j a va 2 s.c o 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; }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
protected boolean checkRomModified() { if (!checkLevelModified()) { return false; }/*from w ww . j av a2 s .c o m*/ if (romHasChanged) { int res = JOptionPane.showConfirmDialog(this, "The currently open ROM has modified levels but is not saved to disk.\n" + "Do you want to save it now?", "Confirm ROM Changes", JOptionPane.YES_NO_CANCEL_OPTION); if (res == JOptionPane.YES_OPTION) { actionSaveRom(); } else if (res == JOptionPane.NO_OPTION) { } else { return false; } } updateTitle(); return true; }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private boolean checkLevelModified() { if (!checkPropertiesModified()) { return false; }//from ww w. ja v a 2 s .co m if (levelHasChanged) { int res = JOptionPane.showConfirmDialog(this, "The currently selected level has changed but not saved to the ROM.\n" + "Do you want to save it now?", "Confirm Level Changes", JOptionPane.YES_NO_CANCEL_OPTION); if (res == JOptionPane.YES_OPTION) { loadedRom.setLevel(selectedLevelNum, selectedLevel); levelHasChanged = false; romHasChanged = true; } else if (res == JOptionPane.NO_OPTION) { } else { return false; } } updateTitle(); return true; }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private boolean checkPropertiesModified() { if (propertiesPanel.hasChanged()) { int res = JOptionPane.showConfirmDialog(this, "Properties for this level were changed but not applied.\n" + "Do you want to apply them now?", "Confirm Properties Changes", JOptionPane.YES_NO_CANCEL_OPTION); if (res == JOptionPane.YES_OPTION) { propertiesPanel.actionApply(); } else if (res == JOptionPane.NO_OPTION) { propertiesPanel.actionReset(); } else {//from www.ja va2 s .c o m return false; } } updateTitle(); return true; }