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:generadorqr.jifrGestionArticulos.java
private void btnImprimirMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnImprimirMouseClicked /*if(jcbBuscarQrCategora.getSelectedIndex() != 0){ Object [] opciones={"ACEPTAR", "CANCELAR"}; int eleccion = JOptionPane.showOptionDialog(this, "Esta seguro de imprimir los QR por categoria", "Imprimir", JOptionPane.YES_NO_OPTION,/*from ww w. j a v a2 s .c om*/ JOptionPane.QUESTION_MESSAGE, null, opciones, "Aceptar"); if(eleccion==JOptionPane.YES_OPTION){ ItemSeleccionado.accionBoton = "ImprimirXCategoria"; ImprimirQRs iqr = new ImprimirQRs(); iqr.setVisible(true); } }*/ Object[] opciones = { "TODOS LOS QR", "QR UNICO", "POR CATEGOR?A" }; int eleccion = JOptionPane.showOptionDialog(this, "Escoja el modo de impresin", "Imprimir", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, opciones, "Aceptar"); if (eleccion == JOptionPane.YES_OPTION) { ItemSeleccionado.accionBoton = "ImprimirTotal"; ImprimirQRs iqr = new ImprimirQRs(); iqr.setVisible(true); } else if (eleccion == JOptionPane.NO_OPTION) { if (!idA.isEmpty()) { ItemSeleccionado.accionBoton = "ImprimirParcial"; isA.setIdArticulo(idA); ImprimirQRs iqr = new ImprimirQRs(); iqr.setVisible(true); } else JOptionPane.showMessageDialog(this, "Busque y Seleccione un registro para imprimir"); } else { if (jcbBuscarQrCategora.getSelectedIndex() != 0) { ItemSeleccionado.accionBoton = "ImprimirXCategoria"; ImprimirQRs iqr = new ImprimirQRs(); iqr.setVisible(true); } else JOptionPane.showMessageDialog(this, "Seleccione una categora"); } LimpiarTablaEImagenes(); }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
@Override public boolean aboutToShutdown() { boolean result = true; if (formHasChanged()) { String msg = String.format(getResourceString("SaveChanges"), getTitle()); JFrame topFrame = (JFrame) UIRegistry.getTopWindow(); int rv = JOptionPane.showConfirmDialog(topFrame, msg, getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION); if (rv == JOptionPane.YES_OPTION) { doSave(false);/* w w w. j av a 2 s.c om*/ } else if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { return false; } else if (rv == JOptionPane.NO_OPTION) { // nothing } } return result; }
From source file:edu.ku.brc.specify.tools.StrLocalizerApp.java
/** * @return true if no unsaved changes are present * else return results of prompt to save *//*from w ww.j av a 2 s .c om*/ protected boolean checkForChanges() { int s = termList.getSelectedIndex(); if (s != -1) { StrLocaleEntry 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; }
From source file:com.t3.client.ui.T3Frame.java
public void closingMaintenance() { if (AppPreferences.getSaveReminder()) { if (TabletopTool.getPlayer().isGM()) { int result = TabletopTool.confirmImpl(I18N.getText("msg.title.saveCampaign"), JOptionPane.YES_NO_CANCEL_OPTION, "msg.confirm.saveCampaign", (Object[]) null); // int result = JOptionPane.showConfirmDialog(TabletopTool.getFrame(), I18N.getText("msg.confirm.saveCampaign"), I18N.getText("msg.title.saveCampaign"), JOptionPane.YES_NO_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { return; }/* w w w . j a v a 2s.c o m*/ if (result == JOptionPane.YES_OPTION) { final Observer callback = new Observer() { @Override public void update(java.util.Observable o, Object arg) { if (arg instanceof String) { // There was an error during the save -- don't terminate TabletopTool! } else { TabletopTool.getFrame().close(); } } }; ActionEvent ae = new ActionEvent(callback, 0, "close"); AppActions.SAVE_CAMPAIGN.actionPerformed(ae); return; } } else { if (!TabletopTool.confirm("msg.confirm.disconnecting")) { return; } } } close(); }
From source file:edu.ku.brc.ui.UIRegistry.java
/** * Display an Confirmation Dialog where everything comes from the bundle. * @param titleKey the key to the dialog title * @param msgKey the key to the dialog message * @param keyBtn1 the key to the first button * @param keyBtn2 the key to the second button * @param keyBtn3 the key to the third button * @param iconOption the icon to show// ww w.jav a2 s . com * @return YES_OPTION, NO_OPTION, CANCEL_OPTION */ public static int displayConfirm(final String title, final String msg, final String keyBtn1, // Yes final String keyBtn2, // No final String keyBtn3, // Cancel final int iconOption) { // Custom button text Object[] options = { keyBtn1, keyBtn2, keyBtn3 }; return JOptionPane.showOptionDialog(getMostRecentWindow(), msg, title, JOptionPane.YES_NO_CANCEL_OPTION, iconOption, null, options, options[2]); }
From source file:net.sf.jabref.gui.BasePanel.java
private boolean saveDatabase(File file, boolean selectedOnly, Charset enc, SavePreferences.DatabaseSaveType saveType) throws SaveException { SaveSession session;/*from w w w . j a va2s .c o m*/ frame.block(); final String SAVE_DATABASE = Localization.lang("Save database"); try { SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs).withEncoding(enc) .withSaveType(saveType); BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(FileSaveSession::new); if (selectedOnly) { session = databaseWriter.savePartOfDatabase(bibDatabaseContext, mainTable.getSelectedEntries(), prefs); } else { session = databaseWriter.saveDatabase(bibDatabaseContext, prefs); } registerUndoableChanges(session); } catch (UnsupportedCharsetException ex2) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ' ' + Localization.lang("Character encoding '%0' is not supported.", enc.displayName()), SAVE_DATABASE, JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex.specificEntry()) { // Error occurred during processing of // be. Highlight it: final int row = mainTable.findEntry(ex.getEntry()); final int topShow = Math.max(0, row - 3); mainTable.setRowSelectionInterval(row, row); mainTable.scrollTo(topShow); showEntry(ex.getEntry()); } else { LOGGER.warn("Could not save", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + "\n" + ex.getMessage(), SAVE_DATABASE, JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { frame.unblock(); } boolean commit = true; if (!session.getWriter().couldEncodeAll()) { FormBuilder builder = FormBuilder.create() .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1); builder.add(ta).xy(3, 1); builder.add(Localization.lang("What do you want to do?")).xy(1, 3); String tryDiff = Localization.lang("Try different encoding"); int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), SAVE_DATABASE, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), SAVE_DATABASE, JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, enc); if (choice == null) { commit = false; } else { Charset newEncoding = Charset.forName((String) choice); return saveDatabase(file, selectedOnly, newEncoding, saveType); } } else if (answer == JOptionPane.CANCEL_OPTION) { commit = false; } } if (commit) { session.commit(file.toPath()); this.bibDatabaseContext.getMetaData().setEncoding(enc); // Make sure to remember which encoding we used. } else { session.cancel(); } return commit; }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
public void importGroup(ChannelGroup importGroup, boolean showAlerts, boolean synchronous) { // First consolidate and import code template libraries Map<String, CodeTemplateLibrary> codeTemplateLibraryMap = new LinkedHashMap<String, CodeTemplateLibrary>(); Set<String> codeTemplateIds = new HashSet<String>(); for (Channel channel : importGroup.getChannels()) { if (channel.getCodeTemplateLibraries() != null) { for (CodeTemplateLibrary library : channel.getCodeTemplateLibraries()) { CodeTemplateLibrary matchingLibrary = codeTemplateLibraryMap.get(library.getId()); if (matchingLibrary != null) { for (CodeTemplate codeTemplate : library.getCodeTemplates()) { if (codeTemplateIds.add(codeTemplate.getId())) { matchingLibrary.getCodeTemplates().add(codeTemplate); }/*w w w .j a va2 s . com*/ } } else { matchingLibrary = library; codeTemplateLibraryMap.put(matchingLibrary.getId(), matchingLibrary); List<CodeTemplate> codeTemplates = new ArrayList<CodeTemplate>(); for (CodeTemplate codeTemplate : matchingLibrary.getCodeTemplates()) { if (codeTemplateIds.add(codeTemplate.getId())) { codeTemplates.add(codeTemplate); } } matchingLibrary.setCodeTemplates(codeTemplates); } // Combine the library enabled / disabled channel IDs matchingLibrary.getEnabledChannelIds().addAll(library.getEnabledChannelIds()); matchingLibrary.getEnabledChannelIds().add(channel.getId()); matchingLibrary.getDisabledChannelIds().addAll(library.getDisabledChannelIds()); matchingLibrary.getDisabledChannelIds().removeAll(matchingLibrary.getEnabledChannelIds()); } channel.getCodeTemplateLibraries().clear(); } } List<CodeTemplateLibrary> codeTemplateLibraries = new ArrayList<CodeTemplateLibrary>( codeTemplateLibraryMap.values()); parent.removeInvalidItems(codeTemplateLibraries, CodeTemplateLibrary.class); if (CollectionUtils.isNotEmpty(codeTemplateLibraries)) { boolean importLibraries; String importChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class) .get("importChannelCodeTemplateLibraries", null); if (importChannelCodeTemplateLibraries == 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[] { "Group \"" + importGroup.getName() + "\" has code template libraries included with it. Would you like to import them?", 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) { importLibraries = result == JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("importChannelCodeTemplateLibraries", importLibraries); } } else { return; } } else { importLibraries = Boolean.parseBoolean(importChannelCodeTemplateLibraries); } if (importLibraries) { CodeTemplateImportDialog dialog = new CodeTemplateImportDialog(parent, codeTemplateLibraries, false, true); if (dialog.wasSaved()) { CodeTemplateLibrarySaveResult updateSummary = parent.codeTemplatePanel.attemptUpdate( dialog.getUpdatedLibraries(), new HashMap<String, CodeTemplateLibrary>(), dialog.getUpdatedCodeTemplates(), new HashMap<String, CodeTemplate>(), true, null, null); if (updateSummary == null || updateSummary.isOverrideNeeded() || !updateSummary.isLibrariesSuccess()) { return; } else { for (CodeTemplateUpdateResult result : updateSummary.getCodeTemplateResults().values()) { if (!result.isSuccess()) { return; } } } parent.codeTemplatePanel.doRefreshCodeTemplates(); } } } List<Channel> successfulChannels = new ArrayList<Channel>(); for (Channel channel : importGroup.getChannels()) { Channel importChannel = importChannel(channel, false, false); if (importChannel != null) { successfulChannels.add(importChannel); } } if (!StringUtils.equals(importGroup.getId(), ChannelGroup.DEFAULT_ID)) { ChannelTreeTableModel model = (ChannelTreeTableModel) channelTable.getTreeTableModel(); AbstractChannelTableNode importGroupNode = null; String groupName = importGroup.getName(); String tempId; try { tempId = parent.mirthClient.getGuid(); } catch (ClientException e) { tempId = UUID.randomUUID().toString(); } // Check to see that the channel name doesn't already exist. if (!checkGroupName(groupName)) { if (!parent.alertOption(parent, "Would you like to overwrite the existing group? Choose 'No' to create a new group.")) { importGroup.setRevision(0); do { groupName = JOptionPane.showInputDialog(this, "Please enter a new name for the group.", groupName); if (groupName == null) { return; } } while (!checkGroupName(groupName)); importGroup.setId(tempId); importGroup.setName(groupName); } else { MutableTreeTableNode root = (MutableTreeTableNode) model.getRoot(); for (Enumeration<? extends MutableTreeTableNode> groupNodes = root.children(); groupNodes .hasMoreElements();) { AbstractChannelTableNode groupNode = (AbstractChannelTableNode) groupNodes.nextElement(); if (StringUtils.equals(groupNode.getGroupStatus().getGroup().getName(), groupName)) { importGroupNode = groupNode; } } } } else { // Start the revision number over for a new channel group importGroup.setRevision(0); // If the channel name didn't already exist, make sure // the id doesn't exist either. if (!checkGroupId(importGroup.getId())) { importGroup.setId(tempId); } } Set<ChannelGroup> channelGroups = new HashSet<ChannelGroup>(); Set<String> removedChannelGroupIds = new HashSet<String>(groupStatuses.keySet()); removedChannelGroupIds.remove(ChannelGroup.DEFAULT_ID); MutableTreeTableNode root = (MutableTreeTableNode) channelTable.getTreeTableModel().getRoot(); if (root == null) { return; } for (Enumeration<? extends MutableTreeTableNode> groupNodes = root.children(); groupNodes .hasMoreElements();) { ChannelGroup group = ((AbstractChannelTableNode) groupNodes.nextElement()).getGroupStatus() .getGroup(); if (!StringUtils.equals(group.getId(), ChannelGroup.DEFAULT_ID)) { // If the current group is the one we're overwriting, merge the channels if (importGroupNode != null && StringUtils.equals(group.getId(), importGroupNode.getGroupStatus().getGroup().getId())) { group = importGroup; group.setRevision(importGroupNode.getGroupStatus().getGroup().getRevision()); Set<String> channelIds = new HashSet<String>(); for (Channel channel : group.getChannels()) { channelIds.add(channel.getId()); } // Add the imported channels for (Channel channel : successfulChannels) { channelIds.add(channel.getId()); } List<Channel> channels = new ArrayList<Channel>(); for (String channelId : channelIds) { channels.add(new Channel(channelId)); } group.setChannels(channels); } channelGroups.add(group); removedChannelGroupIds.remove(group.getId()); } } if (importGroupNode == null) { List<Channel> channels = new ArrayList<Channel>(); for (Channel channel : successfulChannels) { channels.add(new Channel(channel.getId())); } importGroup.setChannels(channels); channelGroups.add(importGroup); removedChannelGroupIds.remove(importGroup.getId()); } Set<String> channelIds = new HashSet<String>(); for (Channel channel : importGroup.getChannels()) { channelIds.add(channel.getId()); } for (ChannelGroup group : channelGroups) { if (group != importGroup) { for (Iterator<Channel> channels = group.getChannels().iterator(); channels.hasNext();) { if (!channelIds.add(channels.next().getId())) { channels.remove(); } } } } attemptUpdate(channelGroups, removedChannelGroupIds, false); } if (synchronous) { retrieveChannels(); updateModel(getCurrentTableState()); updateTasks(); parent.setSaveEnabled(false); } else { doRefreshChannels(); } }
From source file:net.rptools.maptool.client.ui.MapToolFrame.java
public void closingMaintenance() { if (AppPreferences.getSaveReminder()) { if (MapTool.getPlayer().isGM()) { int result = MapTool.confirmImpl(I18N.getText("msg.title.saveCampaign"), JOptionPane.YES_NO_CANCEL_OPTION, "msg.confirm.saveCampaign", (Object[]) null); // int result = JOptionPane.showConfirmDialog(MapTool.getFrame(), I18N.getText("msg.confirm.saveCampaign"), I18N.getText("msg.title.saveCampaign"), JOptionPane.YES_NO_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { return; }//from w w w . j a v a 2 s . c o m if (result == JOptionPane.YES_OPTION) { final Observer callback = new Observer() { public void update(java.util.Observable o, Object arg) { if (arg instanceof String) { // There was an error during the save -- don't terminate MapTool! } else { MapTool.getFrame().close(); } } }; ActionEvent ae = new ActionEvent(callback, 0, "close"); AppActions.SAVE_CAMPAIGN.actionPerformed(ae); return; } } else { if (!MapTool.confirm("msg.confirm.disconnecting")) { return; } } } close(); }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void menuItemTraceAllFragments_actionPerformed(ActionEvent event) { try {//from w w w . java 2s. co m int newTraceAllCode = JOptionPane.showConfirmDialog(this, "Trace over elution curves of ALL fragments?", "Trace All Fragments", JOptionPane.YES_NO_CANCEL_OPTION); if (newTraceAllCode != JOptionPane.YES_OPTION && newTraceAllCode != JOptionPane.NO_OPTION) return; boolean newTraceAll = (newTraceAllCode == JOptionPane.YES_OPTION); if (newTraceAll != _traceAllFragments) { _traceAllFragments = newTraceAll; updateChartsAndFields(false); } _traceAllFragments = newTraceAll; } catch (Exception e) { ApplicationContext.infoMessage("Cannot change 'Trace All' mode: " + e); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void menuItemSyncLH_actionPerformed(ActionEvent event) { try {/*www .j av a2 s . c om*/ int newsync = JOptionPane.showConfirmDialog(this, "Synchronize L/H Elution Regions", "Sync Label Elution Regions", JOptionPane.YES_NO_CANCEL_OPTION); if (newsync != JOptionPane.YES_OPTION && newsync != JOptionPane.NO_OPTION) return; boolean newsyncbool = (newsync == JOptionPane.YES_OPTION); _synclh = newsyncbool; } catch (Exception e) { ApplicationContext.infoMessage("Cannot change 'Synchronize L/H' mode: " + e); } }