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:com.mirth.connect.client.ui.ChannelPanel.java
public Channel importChannel(Channel importChannel, boolean showAlerts, boolean refreshStatuses) { boolean overwrite = false; try {//from w w w . j a va 2 s . c om String channelName = importChannel.getName(); String tempId = parent.mirthClient.getGuid(); // Check to see that the channel name doesn't already exist. if (!parent.checkChannelName(channelName, tempId)) { if (!parent.alertOption(parent, "Would you like to overwrite the existing channel? Choose 'No' to create a new channel.")) { importChannel.setRevision(0); do { channelName = JOptionPane.showInputDialog(this, "Please enter a new name for the channel.", channelName); if (channelName == null) { return null; } } while (!parent.checkChannelName(channelName, tempId)); importChannel.setName(channelName); setIdAndUpdateLibraries(importChannel, tempId); } else { overwrite = true; for (ChannelStatus channelStatus : channelStatuses.values()) { Channel channel = channelStatus.getChannel(); if (channel.getName().equalsIgnoreCase(channelName)) { // If overwriting, use the old revision number and id importChannel.setRevision(channel.getRevision()); setIdAndUpdateLibraries(importChannel, channel.getId()); } } } } else { // Start the revision number over for a new channel importChannel.setRevision(0); // If the channel name didn't already exist, make sure // the id doesn't exist either. if (!checkChannelId(importChannel.getId())) { setIdAndUpdateLibraries(importChannel, tempId); } } channelStatuses.put(importChannel.getId(), new ChannelStatus(importChannel)); parent.updateChannelTags(false); } catch (ClientException e) { parent.alertThrowable(parent, e); } // Import code templates / libraries if applicable parent.removeInvalidItems(importChannel.getCodeTemplateLibraries(), CodeTemplateLibrary.class); if (!(importChannel instanceof InvalidChannel) && !importChannel.getCodeTemplateLibraries().isEmpty()) { 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[] { "Channel \"" + importChannel.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 null; } } else { importLibraries = Boolean.parseBoolean(importChannelCodeTemplateLibraries); } if (importLibraries) { CodeTemplateImportDialog dialog = new CodeTemplateImportDialog(parent, importChannel.getCodeTemplateLibraries(), 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 null; } else { for (CodeTemplateUpdateResult result : updateSummary.getCodeTemplateResults().values()) { if (!result.isSuccess()) { return null; } } } parent.codeTemplatePanel.doRefreshCodeTemplates(); } } importChannel.getCodeTemplateLibraries().clear(); } if (CollectionUtils.isNotEmpty(importChannel.getDependentIds()) || CollectionUtils.isNotEmpty(importChannel.getDependencyIds())) { Set<ChannelDependency> channelDependencies = new HashSet<ChannelDependency>( getCachedChannelDependencies()); if (CollectionUtils.isNotEmpty(importChannel.getDependentIds())) { for (String dependentId : importChannel.getDependentIds()) { if (StringUtils.isNotBlank(dependentId) && !StringUtils.equals(dependentId, importChannel.getId())) { channelDependencies.add(new ChannelDependency(dependentId, importChannel.getId())); } } } if (CollectionUtils.isNotEmpty(importChannel.getDependencyIds())) { for (String dependencyId : importChannel.getDependencyIds()) { if (StringUtils.isNotBlank(dependencyId) && !StringUtils.equals(dependencyId, importChannel.getId())) { channelDependencies.add(new ChannelDependency(importChannel.getId(), dependencyId)); } } } if (!channelDependencies.equals(getCachedChannelDependencies())) { try { parent.mirthClient.setChannelDependencies(channelDependencies); } catch (ClientException e) { parent.alertThrowable(parent, e, "Unable to save channel dependencies."); } } importChannel.clearDependencies(); } // Update resource names parent.updateResourceNames(importChannel); /* * Update the channel if we're overwriting an imported channel, if we're not showing alerts * (dragging/dropping multiple channels), or if we're working with an invalid channel. */ if (overwrite || !showAlerts || importChannel instanceof InvalidChannel) { try { parent.updateChannel(importChannel, overwrite); if (importChannel instanceof InvalidChannel && showAlerts) { InvalidChannel invalidChannel = (InvalidChannel) importChannel; Throwable cause = invalidChannel.getCause(); parent.alertThrowable(parent, cause, "Channel \"" + importChannel.getName() + "\" is invalid. " + getMissingExtensions(invalidChannel) + " Original cause:\n" + cause.getMessage()); } } catch (Exception e) { channelStatuses.remove(importChannel.getId()); parent.updateChannelTags(false); parent.alertThrowable(parent, e); return null; } finally { if (refreshStatuses) { doRefreshChannels(); } } } if (showAlerts) { final Channel importChannelFinal = importChannel; final boolean overwriteFinal = overwrite; /* * MIRTH-2048 - This is a hack to fix the memory access error that only occurs on OS X. * The block of code that edits the channel needs to be invoked later so that the screen * does not change before the drag/drop action of a channel finishes. */ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { parent.editChannel(importChannelFinal); parent.setSaveEnabled(!overwriteFinal); } catch (Exception e) { channelStatuses.remove(importChannelFinal.getId()); parent.updateChannelTags(false); parent.alertError(parent, "Channel had an unknown problem. Channel import aborted."); parent.channelEditPanel = new ChannelSetup(); parent.doShowChannel(); } } }); } return importChannel; }
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(); }// w ww . ja v a 2 s . co 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:edu.ku.brc.specify.Specify.java
/** * /*from w w w. j av a 2s.c o m*/ */ protected void checkForUpdates() { //UIRegistry.displayInfoMsgDlg("checkForUpdates(): checking for updates"); String errKey = null; //NOTE: it looks like the "UPDATE_PATH" resource and the update url setting in i4jparams.conf need to be kept in sync String updatePath = UIRegistry.getResourceString("UPDATE_PATH"); boolean doTheUpdate = false; try { // if automatic update checking is disabled, disable intentional // update checking also... // ...seems like a good idea. Boolean isReleaseManagedGlobally = AppContextMgr.getInstance().getClassObject(Institution.class) .getIsReleaseManagedGlobally(); // AppPreferences localPrefs = AppPreferences.getLocalPrefs(); // String VERSION_CHECK = "version_check.auto"; // boolean localChk4VersionUpdate = localPrefs.getBoolean(VERSION_CHECK, true); //UIRegistry.displayInfoMsgDlg("checkForUpdates(): isReleaseManagedGlobally=" + isReleaseManagedGlobally); doTheUpdate = (isReleaseManagedGlobally == null || !isReleaseManagedGlobally) /*&& localChk4VersionUpdate*/; //UIRegistry.displayInfoMsgDlg("checkForUpdates(): checking for updates at " + updatePath); UpdateDescriptor updateDesc = UpdateChecker.getUpdateDescriptor(updatePath, ApplicationDisplayMode.UNATTENDED); //UIRegistry.displayInfoMsgDlg("checkForUpdates(): UpdateDescriptor=" + updateDesc); if (updateDesc != null) { UpdateDescriptorEntry entry = updateDesc.getPossibleUpdateEntry(); //UIRegistry.displayInfoMsgDlg("checkForUpdates(): PossibleUpdate=" + (entry != null ? entry.getNewVersion() : entry)); if (entry != null) { Object[] options = { getResourceString("Specify.INSTALLUPDATE"), //$NON-NLS-1$ getResourceString("Specify.SKIP") //$NON-NLS-1$ }; if (doTheUpdate) { int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("Specify.UPDATE_AVAIL", entry.getNewVersion()), //$NON-NLS-1$ getResourceString("Specify.UPDATE_AVAIL_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == JOptionPane.YES_OPTION) { if (!doExit(false)) { return; } } else { return; } } else { JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), getLocalizedMessage("Specify.UPDATE_AVAIL_BUT_UPDATES_DISABLED", //$NON-NLS-1$ entry.getNewVersion()), getResourceString("Specify.UPDATE_AVAIL_TITLE"), //$NON-NLS-1$ JOptionPane.INFORMATION_MESSAGE); } } else { errKey = "Specify.NO_UPDATE_AVAIL"; } } else { errKey = UPDATE_CHK_ERROR; } } catch (Exception ex) { errKey = UPDATE_CHK_ERROR; ex.printStackTrace(); log.error(ex); } if (errKey != null) { log.error(String.format("Update Error: %s - %s", errKey, updatePath)); UIRegistry.showLocalizedError(errKey); return; } if (doTheUpdate) { try { ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback() { public void exited(int exitValue) { log.error("exitValue: " + exitValue); // startApp(doConfig); } public void prepareShutdown() { log.error("prepareShutdown"); } }; //UIRegistry.displayInfoMsgDlg("checkForUpdates(): launching update application"); ApplicationLauncher.launchApplication("100", getProxySettings(), true, callback); } catch (Exception ex) { log.error(ex); log.error("EXPCEPTION"); } } else { //UIRegistry.showLocalizedMsg(UIRegistry.getResourceString("UPDATES_DISABLED_FOR_INSTALLATION")); return; } }
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); }/* ww w .j ava 2 s . c o m*/ } 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:net.sf.jabref.gui.JabRefFrame.java
private int showSaveDialog(String filename) { Object[] options = { Localization.lang("Save changes"), Localization.lang("Discard changes"), Localization.lang("Return to JabRef") }; return JOptionPane.showOptionDialog(JabRefFrame.this, Localization.lang("Database '%0' has changed.", filename), Localization.lang("Save before closing"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[2]); }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
private boolean handleExportGroups(List<ChannelGroup> groups) { // Populate list of groups with full channels for (ChannelGroup group : groups) { List<Channel> channels = new ArrayList<Channel>(); for (Channel channel : group.getChannels()) { ChannelStatus channelStatus = this.channelStatuses.get(channel.getId()); if (channelStatus != null) { channels.add(channelStatus.getChannel()); }/*from w w w . java2 s . c om*/ } group.setChannels(channels); } try { // Add code template libraries to channels if necessary if (groupHasLinkedCodeTemplates(groups)) { 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); } } else { return false; } } else { addLibraries = Boolean.parseBoolean(exportChannelCodeTemplateLibraries); } if (addLibraries) { for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { addCodeTemplateLibrariesToChannel(channel); } } } } // Update resource names for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { addDependenciesToChannel(channel); parent.updateResourceNames(channel); } } if (groups.size() == 1) { return exportGroup(groups.iterator().next()); } else { return exportGroups(groups); } } finally { // Reset the libraries on the cached channels for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { channel.getCodeTemplateLibraries().clear(); channel.clearDependencies(); } } } }
From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExitActionPerformed // Save the project file before exit? String cfn = this.CurrentProjectFile; int n = JOptionPane.showConfirmDialog(this, "Do you want to save the current project to " + (cfn == null ? "file" : cfn) + " before exit?", "Save project", JOptionPane.YES_NO_CANCEL_OPTION); if (n == JOptionPane.CANCEL_OPTION) { return;/*from ww w . j av a2 s . co m*/ } else if (n == JOptionPane.YES_OPTION) { this.jMenuItemSaveActionPerformed(null); } // Check opened files for (int i = TpnEditors.getTabCount() - 1; i >= 0; i--) { try { ((IFJEPlusEditorPanel) TpnEditors.getComponentAt(i)).closeTextPanel(); } catch (ClassCastException | NullPointerException cce) { } } // Save EnergyPlus settings String currentdate = SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(new Date()); JEPlusConfig.getDefaultInstance().saveToFile("jEPlus configuration generated at " + currentdate); // Exit if (this.getFrameCloseOperation() == JEPlusFrameMain.EXIT_ON_CLOSE) { System.exit(-1); } else { this.dispose(); } }
From source file:JNLPAppletLauncher.java
private void updateDeploymentPropertiesImpl() { String userHome = System.getProperty("user.home"); File dontAskFile = new File(userHome + File.separator + ".jnlp-applet" + File.separator + DONT_ASK); if (dontAskFile.exists()) return; // User asked us not to prompt again int option = 0; if (!getBooleanParameter("noddraw.check.silent")) { option = JOptionPane.showOptionDialog(null, "For best robustness of OpenGL applets on Windows,\n" + "we recommend disabling Java2D's use of DirectDraw.\n" + "This setting will affect all applets, but is unlikely\n" + "to slow other applets down significantly. May we update\n" + "your deployment.properties to turn off DirectDraw for\n" + "applets? You can change this back later if necessary\n" + "using the Java Control Panel, Java tab, under Java\n" + "Applet Runtime Settings.", "Update deployment.properties?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Yes", "No", "No, Don't Ask Again" }, "Yes"); }/*w w w . j a va 2 s.co m*/ if (option < 0 || option == 1) return; // No if (option == 2) { try { dontAskFile.createNewFile(); } catch (IOException e) { } return; // No, Don't Ask Again } try { // Must update deployment.properties File propsDir = new File(getDeploymentPropsDir()); if (!propsDir.exists()) { // Don't know what's going on or how to set this permanently return; } File propsFile = new File(propsDir, "deployment.properties"); if (!propsFile.exists()) { // Don't know what's going on or how to set this permanently return; } Properties props = new Properties(); InputStream input = new BufferedInputStream(new FileInputStream(propsFile)); props.load(input); input.close(); // Search through the keys looking for JRE versions Set/*<String>*/ jreVersions = new HashSet/*<String>*/(); for (Iterator /*<String>*/ iter = props.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); if (key.startsWith(JRE_PREFIX)) { int idx = key.lastIndexOf("."); if (idx >= 0 && idx > JRE_PREFIX.length()) { String jreVersion = key.substring(JRE_PREFIX.length(), idx); jreVersions.add(jreVersion); } } } // Make sure the currently-running JRE shows up in this set to // avoid repeated displays of the dialog. It might not in some // upgrade scenarios where there was a pre-existing // deployment.properties and the new Java Control Panel hasn't // been run yet. jreVersions.add(System.getProperty("java.version")); // OK, now that we know all JRE versions covered by the // deployment.properties, check out the args for each and update // them for (Iterator /*<String>*/ iter = jreVersions.iterator(); iter.hasNext();) { String version = (String) iter.next(); String argKey = JRE_PREFIX + version + ".args"; String argVal = props.getProperty(argKey); if (argVal == null) { argVal = NODDRAW_PROP; } else if (argVal.indexOf(NODDRAW_PROP) < 0) { argVal = argVal + " " + NODDRAW_PROP; } props.setProperty(argKey, argVal); } OutputStream output = new BufferedOutputStream(new FileOutputStream(propsFile)); props.store(output, null); output.close(); if (!getBooleanParameter("noddraw.check.silent")) { // Tell user we're done JOptionPane.showMessageDialog(null, "For best robustness, we recommend you now exit and\n" + "restart your web browser. (Note: clicking \"OK\" will\n" + "not exit your browser.)", "Browser Restart Recommended", JOptionPane.INFORMATION_MESSAGE); } } catch (IOException e) { e.printStackTrace(); } }
From source file:fi.hoski.remote.ui.Admin.java
private void swapPatrolShift(AnyDataObject user) { Long memberNumber = (Long) user.get(Member.JASENNO); PatrolShift selectedShift = choosePatrolShift(user); if (selectedShift != null) { SwapRequest req = new SwapRequest(); req.set(Repository.JASENNO, user.createKey()); req.set(Repository.VUOROID, selectedShift.createKey()); req.set(Repository.PAIVA, selectedShift.get(Repository.PAIVA)); List<Long> excluded = new ArrayList<Long>(); Day day = (Day) selectedShift.get(Repository.PAIVA); excluded.add(day.getValue());/* w w w. j av a 2 s . c om*/ req.set(SwapRequest.EXCLUDE, excluded); req.set(Repository.CREATOR, creator); Object[] options = { TextUtil.getText("SWAP SHIFT"), TextUtil.getText("EXCLUDE DATE"), TextUtil.getText("DELETE PREVIOUS SWAP"), TextUtil.getText("CANCEL") }; String msg = TextUtil.getText("SWAP OPTIONS"); try { msg = dss.getShiftString(selectedShift.getEntity(), msg); } catch (EntityNotFoundException ex) { Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex); } while (true) { int choise = JOptionPane.showOptionDialog(frame, msg + dateList(excluded), "", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); switch (choise) { case 0: try { msg = TextUtil.getText("SWAP CONFIRMATION"); msg = dss.getShiftString(selectedShift.getEntity(), msg) + dateList(excluded); int confirm = JOptionPane.showConfirmDialog(frame, msg, TextUtil.getText("SWAP SHIFT"), JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.YES_OPTION == confirm) { boolean ok = dss.swapShift(req); if (ok) { JOptionPane.showMessageDialog(frame, TextUtil.getText("SwapOk")); } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("SwapPending")); } } } catch (EntityNotFoundException | IOException | SMSException | AddressException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ex.getMessage()); } return; case 1: Day d = DateChooser.chooseDate(TextUtil.getText("EXCLUDE DATE"), new Day(excluded.get(excluded.size() - 1))); excluded.add(d.getValue()); break; case 2: dss.deleteSwaps(memberNumber.intValue()); return; case 3: return; } } } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } }
From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemToRelativeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemToRelativeActionPerformed if (Project != null) { // Project base String base;//from w w w . j a v a 2 s. co m int resp = JOptionPane.showConfirmDialog(this, "<html><p>Relative path will be calculated against the location where the " + "project is saved. Do you want to save your project first?</p><p>Current location is: " + Project.getBaseDir() + " </p></html>", "Save project?", JOptionPane.YES_NO_CANCEL_OPTION); if (resp == JOptionPane.CANCEL_OPTION) { return; } else if (resp == JOptionPane.YES_OPTION) { this.jMenuItemSaveAsActionPerformed(null); } base = Project.getBaseDir(); // Weather file path String path = Project.resolveWeatherDir(); Project.setWeatherDir(RelativeDirUtil.getRelativePath(path, base, "/")); // idf file path path = Project.resolveIDFDir(); Project.setIDFDir(RelativeDirUtil.getRelativePath(path, base, "/")); // dck file path path = Project.resolveDCKDir(); Project.setDCKDir(RelativeDirUtil.getRelativePath(path, base, "/")); // rvi file path path = Project.resolveRVIDir(); Project.setRVIDir(RelativeDirUtil.getRelativePath(path, base, "/")); // output dir path = Project.resolveWorkDir(); Project.getExecSettings().setParentDir(RelativeDirUtil.getRelativePath(path, base, "/")); // update screen this.initProjectSection(); this.cboExecutionTypeActionPerformed(null); } }