List of usage examples for javax.swing JOptionPane CLOSED_OPTION
int CLOSED_OPTION
To view the source code for javax.swing JOptionPane CLOSED_OPTION.
Click Source Link
CANCEL_OPTION
or NO_OPTION
. From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemExportJsonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExportJsonActionPerformed // Select a file to save fc.setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.JSON)); fc.setSelectedFile(new File("")); fc.setCurrentDirectory(DefaultDir);/*w ww. ja va 2 s .c o m*/ if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (!file.getName().endsWith(".json")) file = new File(file.getPath().concat(".json")); // write object if (!Project.saveAsJSON(file)) { // warning message JOptionPane.showMessageDialog(this, "The JEPlus Project cannot be saved for some reasons. :-(", "Error", JOptionPane.CLOSED_OPTION); } } else { } fc.resetChoosableFileFilters(); fc.setSelectedFile(new File("")); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
@Override public boolean aboutToShutdown() { super.aboutToShutdown(); for (WorkBenchPluginIFace wbp : workBenchPlugins.values()) { wbp.shutdown();/*w w w. j a v a2s.c om*/ } // Tell it is about to be hidden. // this way it can end any editing if (formPane != null) { if (!checkCurrentEditState()) { SubPaneMgr.getInstance().showPane(this); // Need to reverify to get the error to display again. if (spreadSheet.getCellEditor() != null) { spreadSheet.getCellEditor().stopCellEditing(); } return false; } } if (datasetUploader != null && !datasetUploader.aboutToShutdown(this)) { return false; } if (datasetUploader != null) { if (datasetUploader.closing(this)) { datasetUploader = null; Uploader.unlockApp(); Uploader.unlockUpload(); } } boolean retStatus = true; if (hasChanged) { // turn off alwaysOnTop for Swing repaint reasons (prevents a lock up) if (imageFrame != null) { imageFrame.setAlwaysOnTop(false); } String msg = String.format(getResourceString("SaveChanges"), getTitle()); JFrame topFrame = (JFrame) UIRegistry.getTopWindow(); final String wbName = workbench.getName(); int rv = JOptionPane.showConfirmDialog(topFrame, msg, getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION); if (rv == JOptionPane.YES_OPTION) { //GlassPane and Progress bar currently don't show up during shutdown SwingUtilities.invokeLater(new Runnable() { public void run() { UIRegistry.writeSimpleGlassPaneMsg( String.format(getResourceString("WB_SAVING"), new Object[] { workbench.getName() }), WorkbenchTask.GLASSPANE_FONT_SIZE); UIRegistry.getStatusBar().setIndeterminate(wbName, true); } }); SwingWorker saver = new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { Boolean result = null; try { saveObject(); result = new Boolean(true); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchPaneSS.class, ex); log.error(ex); } return result; } /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#finished() */ @Override public void finished() { UIRegistry.clearSimpleGlassPaneMsg(); UIRegistry.getStatusBar().setProgressDone(wbName); shutdownLock.decrementAndGet(); shutdown(); } }; shutdownLock.incrementAndGet(); saver.start(); //retStatus = saver.get() != null; } else if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { return false; } else if (rv == JOptionPane.NO_OPTION) { hasChanged = false; // we do this so we don't get asked a second time } } if (retStatus) { ((WorkbenchTask) ContextMgr.getTaskByClass(WorkbenchTask.class)).closing(this); ((SGRTask) ContextMgr.getTaskByClass(SGRTask.class)).closing(this); if (spreadSheet != null) { spreadSheet.getSelectionModel().removeListSelectionListener(workbenchRowChangeListener); } workbenchRowChangeListener = null; } return retStatus; }
From source file:jeplus.JEPlusFrameMain.java
public void openProject(Component parent, File file) { JEPlusProject proj = JEPlusProject.loadAsXML(file); if (proj == null) { // warning message JOptionPane.showMessageDialog(parent, "Failed to load project from file: " + file.getPath() + ". Please check if the file is accessible.", "Error", JOptionPane.CLOSED_OPTION); } else {/*from ww w. j a v a2 s . c o m*/ Project = proj; // GUI update // this.initProjectSection(); // Update project type (E+ or TRNSYS) and gui this.cboProjectType.setSelectedIndex(Project.getProjectType()); this.setProjectType(Project.getProjectType()); // update Exec Agent's reference to the Execution options for (EPlusAgent agent : ExecAgents) { agent.setSettings(Project.getExecSettings()); } // select again Exec agent and update gui this.setExecType(Project.getExecSettings().getExecutionType()); this.cboExecutionTypeActionPerformed(null); // Base directory update DefaultDir = new File(Project.getBaseDir()); // Batch options gui this.initBatchOptions(); this.setCurrentProjectFile(file.getPath()); } }
From source file:jeplus.JEPlusFrameMain.java
public void importProjectFromJson(Component parent, File file) { JEPlusProject proj = null;/*from w w w .ja v a2 s . c o m*/ try { proj = JEPlusProject.loadFromJSON(file); } catch (IOException ioe) { logger.error("Error opening JSON file " + file.getAbsolutePath(), ioe); } if (proj == null) { // warning message JOptionPane.showMessageDialog(parent, "Failed to import project from file: " + file.getPath() + ". Please check if the file is accessible.", "Error", JOptionPane.CLOSED_OPTION); } else { Project = proj; // GUI update // this.initProjectSection(); // Update project type (E+ or TRNSYS) and gui this.cboProjectType.setSelectedIndex(Project.getProjectType()); this.setProjectType(Project.getProjectType()); // update Exec Agent's reference to the Execution options for (EPlusAgent agent : ExecAgents) { agent.setSettings(Project.getExecSettings()); } // select again Exec agent and update gui this.setExecType(Project.getExecSettings().getExecutionType()); this.cboExecutionTypeActionPerformed(null); // Base directory update DefaultDir = new File(Project.getBaseDir()); // Batch options gui this.initBatchOptions(); } }
From source file:com.mirth.connect.client.ui.Frame.java
public void doRemoveAllEvents() { int option = JOptionPane.showConfirmDialog(this, "All events will be removed. Would you also like them to be\n" + "exported to a file on the server?"); if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { return;// w ww .j a v a2s . co m } final boolean export = (option == JOptionPane.YES_OPTION); final String workingId = startWorking("Clearing events..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { private String exportPath = null; public Void doInBackground() { try { if (export) { exportPath = mirthClient.exportAndRemoveAllEvents(); } else { mirthClient.removeAllEvents(); } } catch (ClientException e) { alertThrowable(PlatformUI.MIRTH_FRAME, e); } return null; } public void done() { eventBrowser.runSearch(); if (exportPath != null) { alertInformation(PlatformUI.MIRTH_FRAME, "Events have been exported to the following server path:\n" + exportPath); } stopWorking(workingId); } }; worker.execute(); }
From source file:it.isislab.dmason.util.SystemManagement.Master.thrower.DMasonMaster.java
private void loadUpdateFile() { String message = "There is no reference worker JAR. Do you want to specify a reference\n " + "JAR for the worker?\n" + "\n" + "If you choose Yes, D-Mason will ensure that every worker is running an\n" + "instance of the reference JAR and update them automatically.\n" + "If you choose No, D-Mason won't perform any check (this is highly\n" + "discouraged as it may lead to unreported errors during the simulation).\n" + "If you choose Cancel, D-Mason will exit.\n\n"; int res = JOptionPane.showConfirmDialog(this, message); if (res == JOptionPane.OK_OPTION) { updateFile = showFileChooser();/*w ww . j a v a 2 s. c o m*/ if (updateFile != null) { File dest = new File(FTP_HOME + dirSeparator + UPDATE_DIR + dirSeparator + updateFile.getName()); try { FileUtils.copyFile(updateFile, dest); Digester dg = new Digester(DigestAlgorithm.MD5); InputStream in = new FileInputStream(dest); curWorkerDigest = dg.getDigest(in); workerJarName = updateFile.getName(); String fileName = FilenameUtils.removeExtension(updateFile.getName()); dg.storeToPropFile(FTP_HOME + dirSeparator + UPDATE_DIR + dirSeparator + fileName + ".hash"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoDigestFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // else // { // JOptionPane.showMessageDialog(this, "User aborted, D-Mason will now exit."); // this.dispose(); // System.exit(EXIT_ON_CLOSE); // } } else if (res == JOptionPane.NO_OPTION) { enableWorkersUpdate = false; return; } if (updateFile == null || res == JOptionPane.CANCEL_OPTION || res == JOptionPane.CLOSED_OPTION) { JOptionPane.showMessageDialog(this, "User aborted, D-Mason will now exit."); this.dispose(); System.exit(EXIT_ON_CLOSE); } }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void pasteSubtree(final PhylogenyNode node) { if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) { errorMessageNoCutCopyPasteInUnrootedDisplay(); return;/*from w ww. j av a 2 s.c o m*/ } if ((getCutOrCopiedTree() == null) || getCutOrCopiedTree().isEmpty()) { JOptionPane.showMessageDialog(this, "No tree in buffer (need to copy or cut a subtree first)", "Attempt to paste with empty buffer", JOptionPane.ERROR_MESSAGE); return; } final String label = getASimpleTextRepresentationOfANode(getCutOrCopiedTree().getRoot()); final Object[] options = { "As sibling", "As descendant", "Cancel" }; final int r = JOptionPane.showOptionDialog(this, "How to paste subtree" + label + "?", "Paste Subtree", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); boolean paste_as_sibling = true; if (r == 1) { paste_as_sibling = false; } else if (r != 0) { return; } final Phylogeny buffer_phy = getCutOrCopiedTree().copy(); buffer_phy.setAllNodesToNotCollapse(); buffer_phy.preOrderReId(); if (paste_as_sibling) { if (node.isRoot()) { JOptionPane.showMessageDialog(this, "Cannot paste sibling to root", "Attempt to paste sibling to root", JOptionPane.ERROR_MESSAGE); return; } buffer_phy.addAsSibling(node); } else { buffer_phy.addAsChild(node); } if (getCopiedAndPastedNodes() == null) { setCopiedAndPastedNodes(new HashSet<PhylogenyNode>()); } getCopiedAndPastedNodes().addAll(PhylogenyMethods.obtainAllNodesAsSet(buffer_phy)); _phylogeny.externalNodesHaveChanged(); _phylogeny.hashIDs(); _phylogeny.recalculateNumberOfExternalDescendants(true); resetNodeIdToDistToLeafMap(); setEdited(true); repaint(); }
From source file:com.mirth.connect.client.ui.Frame.java
public boolean exportChannelOnError() { if (isSaveEnabled()) { int option = JOptionPane.showConfirmDialog(this, "Would you like to save the channel changes locally to your computer?"); if (option == JOptionPane.YES_OPTION) { if (!channelEditPanel.saveChanges()) { return false; }/*from w ww.j a va 2 s . com*/ boolean enabled = isSaveEnabled(); setSaveEnabled(false); if (!doExportChannel()) { setSaveEnabled(enabled); return false; } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { return false; } else { setSaveEnabled(false); } } return true; }
From source file:com.xilinx.ultrascale.gui.MainScreen_video.java
private void windowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_windowClosing // TODO add your handling code here: //powerTimer.cancel(); Object[] options1 = { "No", "Yes" }; int s = JOptionPane.showOptionDialog(null, "This will uninstall Device Drivers. Are you sure?", " ", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options1, null); if (s == 1) { loadDelay = 0;/*from ww w. j av a2 s . c o m*/ timer.cancel(); if (testStarted) { testStarted = false; jbuttonEngStart.setText("Start"); int size = Integer.parseInt(sizeTextField.getText()); di.stopTest(0, testMode, size); } if (ethTestStarted0) { ethTestStarted0 = false; jbuttonEngStart1.setText("Start"); int size = Integer.parseInt(sizeTextField1.getText()); di.stopTest(0, eth0TestMode, size); } if (ethTestStarted1) { ethTestStarted1 = false; jbuttonEngStart2.setText("Start"); int size = Integer.parseInt(sizeTextField2.getText()); di.stopTest(0, eth1TestMode, size); } System.gc(); di.flush(); lp.uninstallDrivers(this); showDialog("Removing Device Drivers...Please wait..."); } // lp.showLP(); if (txMediaPlayer != null) { // Cleanly dispose of the media player instance and any associated native resources txMediaPlayer.release(); // Cleanly dispose of the media player factory and any associated native resources //txMediaPlayerFactory.release(); rxMediaPlayer.release(); // Cleanly dispose of the media player factory and any associated native resources //rxMediaPlayerFactory.release(); videoFrame.dispose(); frame1.dispose(); frame2.dispose(); } }
From source file:com.xilinx.ultrascale.gui.MainScreen.java
private void windowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_windowClosing // TODO add your handling code here: //powerTimer.cancel(); Object[] options1 = { "No", "Yes" }; int s = JOptionPane.showOptionDialog(null, "This will uninstall Device Drivers. Are you sure?", " ", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options1, null); if (s == 1) { timer.cancel();/*ww w.j a v a 2 s. c o m*/ if (testStarted) { testStarted = false; jbuttonEngStart.setText("Start"); int size = Integer.parseInt(sizeTextField.getText()); di.stopTest(0, testMode, size); } if (ethTestStarted0) { ethTestStarted0 = false; jbuttonEngStart1.setText("Start"); int size = Integer.parseInt(sizeTextField1.getText()); di.stopTest(0, eth0TestMode, size); } if (ethTestStarted1) { ethTestStarted1 = false; jbuttonEngStart2.setText("Start"); int size = Integer.parseInt(sizeTextField2.getText()); int distatus = di.stopTest1(1, eth1TestMode, size); //System.out.println("distatus after stop " + distatus); } System.gc(); di.flush(); lp.uninstallDrivers(this); showDialog("Removing Device Drivers...Please wait..."); } // lp.showLP(); }