List of usage examples for javax.swing JOptionPane NO_OPTION
int NO_OPTION
To view the source code for javax.swing JOptionPane NO_OPTION.
Click Source Link
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private void saveParameters(File file) { if (file.exists()) { int option = promptParametersFileOverwrite(); if (option == JOptionPane.NO_OPTION || option == JOptionPane.CLOSED_OPTION || option == JOptionPane.CANCEL_OPTION) { return; }/* w ww . j a v a2 s .co m*/ } File enhancedFile = file; if (!file.getName().contains(SINGLE_DOT)) { enhancedFile = new File(file.getAbsolutePath() + SINGLE_DOT + PARAMETER_FILE_EXTENSION); } ObjectOutput output = null; try { output = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(enhancedFile))); output.writeObject(parametersTableModel.getAttributeParameters()); LOG.debug("Wrote parameters to file " + enhancedFile.getAbsolutePath()); } catch (IOException ex) { error("Error writing parameters to a file."); ex.printStackTrace(); } finally { try { output.close(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.sec.ose.osi.ui.frm.main.JMenuMain.java
private JMenuItem getJMenuItemSyncToServer() { if (jMenuItemSyncToServer == null) { jMenuItemSyncToServer = new JMenuItem(); jMenuItemSyncToServer.setText("Sync to Server (flush identify queue)"); jMenuItemSyncToServer.setEnabled(true); jMenuItemSyncToServer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("Sync to Server clicked"); String title = "Sync to server - " + IdentifyMediator.getInstance().getSelectedProjectName(); String message = "OSI will flush all items in identify queue without UI update.\n" + "You are strongly suggested to click \"Sync From Server\" after completing this task.\n" + "Do you want to progress it now?"; int yesNo = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION); if (yesNo == JOptionPane.NO_OPTION) return; mEventHandler.handle(EventHandler.MAN_TOOL_SYNC_TO_SERVER); }//from ww w .j a va 2 s . co m }); } return jMenuItemSyncToServer; }
From source file:condorclient.MainFXMLController.java
@FXML void pauseButtonFired(ActionEvent event) { int delNo = 0; int pauseId = 0; int n = JOptionPane.showConfirmDialog(null, "??", "", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { //checkboxclusterId System.out.print(Thread.currentThread().getName() + "\n"); URL url = null;//from w w w.j ava2s. c om XMLHandler handler = new XMLHandler(); String scheddStr = handler.getURL("schedd"); try { url = new URL(scheddStr); } catch (MalformedURLException e3) { // TODO Auto-generated catch block e3.printStackTrace(); } Schedd schedd = null; try { schedd = new Schedd(url); } catch (ServiceException ex) { Logger.getLogger(CondorClient.class.getName()).log(Level.SEVERE, null, ex); } //ClassAdStructAttr[] int boxToClusterId; ClassAd ad = null;//birdbath.ClassAd; ClassAdStructAttr[][] classAdArray = null; Transaction xact = schedd.createTransaction(); try { xact.begin(30); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } int job = 0; //s final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems()); for (Object o : selectedNodeList) { if (o instanceof ObservableDisplayedClassAd) { pauseId = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId()); } } //e String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + pauseId; try { classAdArray = schedd.getJobAds(findreq); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } String showJobStatus = null; for (ClassAdStructAttr[] x : classAdArray) { ad = new ClassAd(x); job = Integer.parseInt(ad.get("ProcId")); status = Integer.valueOf(ad.get("JobStatus")); showJobStatus = statusName[status]; try { if (showJobStatus.equals("") || showJobStatus.equals("?") || showJobStatus.equals("")) { xact.holdJob(pauseId, job, ""); } else {//?? if (showJobStatus.equals("?") || showJobStatus.equals("")) { JOptionPane.showMessageDialog(null, "?????"); return; } } // System.out.print("ts.getClusterId():" + showClusterId + "\n"); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } } try { xact.commit(); } catch (RemoteException e) { e.printStackTrace(); } } else if (n == JOptionPane.NO_OPTION) { System.out.println("qu xiao"); } }
From source file:de.tor.tribes.ui.wiz.ret.RetimerCalculationPanel.java
private void fireCalculateAttacksEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireCalculateAttacksEvent /*//from w w w . ja v a 2s . c om * if (calculator == null) {//not used yet initializeCalculation(); } * else {//in use or finished if (calculator.isRunning()) {//in * use...abort calculator.abort(); return; } else {//not in * use...recalculate if (calculator.hasResults() && * JOptionPaneHelper.showQuestionConfirmBox(this, "Vorherige Berechnung * verwerfen?", "Berechnung verwerfen", "Nein", "Ja") == * JOptionPane.NO_OPTION) { //not recalculate return; } else { * //recalculate initializeCalculation(); } } } * * jCalculateButton.setText("Abbrechen"); calculator.start(); * setBusy(true); //wait until calculation is running try { * Thread.sleep(20); } catch (Exception e) { } */ if (!retimes.isEmpty()) { if (JOptionPaneHelper.showQuestionConfirmBox(this, "Vorherige Berechnung verwerfen?", "Berechnung verwerfen", "Nein", "Ja") == JOptionPane.NO_OPTION) { return; } } doCalculation(); }
From source file:edu.ku.brc.af.ui.forms.SubViewBtn.java
/** * //from ww w.j a va 2s .c o m */ protected void showForm() { //boolean isParentNew = parentObj instanceof FormDataObjIFace ? ((FormDataObjIFace)parentObj).getId() == null : false; boolean isNewObject = MultiView.isOptionOn(options, MultiView.IS_NEW_OBJECT); boolean isEdit = MultiView.isOptionOn(options, MultiView.IS_EDITTING) || isNewObject; String closeBtnTitle = isEdit ? getResourceString("DONE") : getResourceString("CLOSE"); ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(), subviewDef.getViewSetName(), subviewDef.getViewName(), null, // What is this argument??? frameTitle, closeBtnTitle, view.getClassName(), cellName, // idFieldName isEdit | isNewObject, false, cellName, mvParent, options | MultiView.HIDE_SAVE_BTN | MultiView.DONT_ADD_ALL_ALTVIEWS | MultiView.USE_ONLY_CREATION_MODE, CustomDialog.CANCEL_BTN | (StringUtils.isNotEmpty(helpContext) ? CustomDialog.HELP_BTN : 0)) { /* (non-Javadoc) * @see edu.ku.brc.ui.db.ViewBasedDisplayDialog#cancelButtonPressed() */ @Override protected void cancelButtonPressed() { multiView.aboutToShutdown(); FormViewObj fvo = multiView.getCurrentViewAsFormViewObj(); if (fvo != null) { FormValidator validator = multiView.getCurrentValidator(); if (validator != null && validator.getState() != UIValidatable.ErrorType.Valid) { boolean isNew = fvo.isNewlyCreatedDataObj(); String msgKey = isNew ? "MV_INCOMPLETE_DATA_NEW" : "MV_INCOMPLETE_DATA"; String btnKey = isNew ? "MV_REMOVE_ITEM" : "MV_DISCARD_ITEM"; Object[] optionLabels = { getResourceString(btnKey), getResourceString("CANCEL") }; int rv = JOptionPane.showOptionDialog(UIRegistry.getMostRecentWindow(), getResourceString(msgKey), getResourceString("MV_INCOMPLETE_DATA_TITLE"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.NO_OPTION) { return; } } } super.cancelButtonPressed(); } }; dlg.setHelpContext("SUBVIEW_FORM_HELP"); dlg.setCancelLabel(closeBtnTitle); frame = dlg; multiView = frame.getMultiView(); // Only get the data from the parent the first time. if (parentObj != null && dataObj == null) { DataProviderSessionIFace sessionLocal = null; try { DataObjectGettable getter = DataObjectGettableFactory.get(parentObj.getClass().getName(), FormHelper.DATA_OBJ_GETTER); sessionLocal = parentObj.getId() != null ? DataProviderFactory.getInstance().createSession() : null; // rods - 07/22/08 - Apparently Merge just doesn't work the way it seems it should // so instead we will just go get the parent again. if (parentObj.getId() != null) { parentObj = (FormDataObjIFace) sessionLocal.get(parentObj.getDataClass(), parentObj.getId()); } Object[] objs = UIHelper.getFieldValues(subviewDef, parentObj, getter); if (objs == null) { try { Class<?> cls = Class.forName(view.getClassName()); if (FormDataObjIFace.class.isAssignableFrom(cls)) { dataObj = cls.newInstance(); ((FormDataObjIFace) dataObj).initialize(); parentObj.addReference((FormDataObjIFace) dataObj, subviewDef.getName()); } } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SubViewBtn.class, ex); } } else { dataObj = objs[0]; } multiView.setParentDataObj(parentObj); multiView.setData(dataObj); CommandDispatcher.dispatch(new CommandAction("Data_Entry", "SHOW_SUBVIEW", new Pair<Object, Object>(parentObj, dataObj))); } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SubViewBtn.class, ex); } finally { if (sessionLocal != null) { sessionLocal.close(); } } } else { multiView.setParentDataObj(parentObj); DataProviderSessionIFace sessionLocal = null; try { sessionLocal = DataProviderFactory.getInstance().createSession(); multiView.setSession(sessionLocal); if (dataObj instanceof Set<?>) { for (Object obj : ((Set<?>) dataObj)) { if (obj instanceof FormDataObjIFace && ((FormDataObjIFace) obj).getId() != null) { sessionLocal.attach(obj); } } } else if (dataObj instanceof FormDataObjIFace && ((FormDataObjIFace) dataObj).getId() != null) { sessionLocal.attach(dataObj); } multiView.setData(dataObj); multiView.setSession(null); } catch (Exception ex) { ex.printStackTrace(); } finally { sessionLocal.close(); } } multiView.setClassToCreate(classToCreate); FormValidator formVal = null; if (multiView.getCurrentViewAsFormViewObj() != null) { formVal = multiView.getCurrentViewAsFormViewObj().getValidator(); if (formVal != null) { formVal.setEnabled(true); multiView.addCurrentValidator(); if (multiView.getCurrentViewAsFormViewObj() != null) { final ResultSetController rsc = multiView.getCurrentViewAsFormViewObj().getRsController(); if (rsc != null && rsc.getNewRecBtn() != null) { rsc.getNewRecBtn().setEnabled(true); /*if (rsc.getLength() == 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { //rsc.getNewRecBtn().doClick(); } }); }*/ } } } } dlg.createUI(); frame.getCancelBtn().setEnabled(true); frame.showDisplay(true); if (formVal != null) { multiView.removeCurrentValidator(); } FormViewObj fvo = null; if (multiView != null) { if (frame.isEditMode()) { frame.getMultiView().getDataFromUI(); FormViewObj.traverseToGetDataFromForms(frame.getMultiView()); updateBtnText(); mvParent.getCurrentValidator().validateRoot(); } } else { } CommandDispatcher.dispatch(new CommandAction("Data_Entry", "CLOSE_SUBVIEW", new Triple<Object, Object, Object>(fvo, parentObj, dataObj))); frame.dispose(); frame = null; }
From source file:net.sf.jabref.util.Util.java
/** * Warns the user of undesired side effects of an explicit assignment/removal of entries to/from this group. * Currently there are four types of groups: AllEntriesGroup, SearchGroup - do not support explicit assignment. * ExplicitGroup - never modifies entries. KeywordGroup - only this modifies entries upon assignment/removal. * Modifications are acceptable unless they affect a standard field (such as "author") besides the "keywords" field. * * @param parent The Component used as a parent when displaying a confirmation dialog. * @return true if the assignment has no undesired side effects, or the user chose to perform it anyway. false * otherwise (this indicates that the user has aborted the assignment). *//*from w w w.j a v a2s . c om*/ public static boolean warnAssignmentSideEffects(List<AbstractGroup> groups, Component parent) { List<String> affectedFields = new ArrayList<>(); for (AbstractGroup group : groups) { if (group instanceof KeywordGroup) { KeywordGroup kg = (KeywordGroup) group; String field = kg.getSearchField().toLowerCase(); if ("keywords".equals(field)) { continue; // this is not undesired } int len = InternalBibtexFields.numberOfPublicFields(); for (int i = 0; i < len; ++i) { if (field.equals(InternalBibtexFields.getFieldName(i))) { affectedFields.add(field); break; } } } } if (affectedFields.isEmpty()) { return true; // no side effects } // show a warning, then return StringBuilder message = new StringBuilder( Localization.lang("This action will modify the following field(s) in at least one entry each:")) .append('\n'); for (String affectedField : affectedFields) { message.append(affectedField).append('\n'); } message.append(Localization.lang("This could cause undesired changes to your entries.")).append('\n') .append("It is recommended that you change the grouping field in your group definition to \"keywords\" or a non-standard name.") .append("\n\n").append(Localization.lang("Do you still want to continue?")); int choice = JOptionPane.showConfirmDialog(parent, message, Localization.lang("Warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); return choice != JOptionPane.NO_OPTION; // if (groups instanceof KeywordGroup) { // KeywordGroup kg = (KeywordGroup) groups; // String field = kg.getSearchField().toLowerCase(); // if (field.equals("keywords")) // return true; // this is not undesired // for (int i = 0; i < GUIGlobals.ALL_FIELDS.length; ++i) { // if (field.equals(GUIGlobals.ALL_FIELDS[i])) { // // show a warning, then return // String message = Globals ... // .lang( // "This action will modify the \"%0\" field " // + "of your entries.\nThis could cause undesired changes to " // + "your entries, so it is\nrecommended that you change the grouping // field " // + "in your group\ndefinition to \"keywords\" or a non-standard name." // + "\n\nDo you still want to continue?", // field); // int choice = JOptionPane.showConfirmDialog(parent, message, // Globals.lang("Warning"), JOptionPane.YES_NO_OPTION, // JOptionPane.WARNING_MESSAGE); // return choice != JOptionPane.NO_OPTION; // } // } // } // return true; // found no side effects }
From source file:com.dragoniade.deviantart.favorites.FavoritesDownloader.java
private boolean nextDeviation(int skipped) { progress.incremTotal();/*from w w w.j av a 2s. co m*/ progress.setUnitValue(1); progress.setUnitMax(Integer.MAX_VALUE); if (skipped == 480) { int res = showConfirmDialog(owner, "480 deviations have been skipped so far. Continue scanning?", "Continue?", JOptionPane.YES_NO_OPTION); if (res == JOptionPane.NO_OPTION) { return false; } } if (requestCount > 20) { throttle(); } return true; }
From source file:latexstudio.editor.EditorTopComponent.java
public UnsavedWorkState canOpen() { if (isModified() && !isPreviewDisplayed()) { int userChoice = JOptionPane.showConfirmDialog(this, "This document has been modified. Do you want to save it first?", "Save document", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (userChoice == JOptionPane.YES_OPTION) { return UnsavedWorkState.SAVE_AND_OPEN; } else if (userChoice == JOptionPane.NO_OPTION) { return UnsavedWorkState.OPEN; } else {// ww w. j a v a 2 s . c o m return UnsavedWorkState.CANCEL; } } else { return UnsavedWorkState.OPEN; } }
From source file:ca.uhn.hl7v2.testpanel.controller.Controller.java
public void closeMessage(Hl7V2MessageCollection theMsg) { if (theMsg.isSaved() == false) { int save = showPromptToSaveMessageBeforeClosingIt(theMsg, true); switch (save) { case JOptionPane.YES_OPTION: if (!saveMessages(theMsg)) { return; }//w ww. j a v a2s .c o m break; case JOptionPane.NO_OPTION: break; case JOptionPane.CANCEL_OPTION: return; default: // shouldn't happen throw new Error("invalid option:" + save); } } updateRecentMessageFiles(theMsg); myMessagesList.removeMessage(theMsg); if (myMessagesList.getMessages().size() > 0) { setLeftSelectedItem(myMessagesList.getMessages().get(0)); } else { tryToSelectSomething(); } }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * @param args//from w ww . j a v a 2s. c o m */ public static void main(String[] args) { log.debug("********* Current [" + (new File(".").getAbsolutePath()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // This is for Windows and Exe4J, turn the args into System Properties for (String s : args) { String[] pairs = s.split("="); //$NON-NLS-1$ if (pairs.length == 2) { log.debug("[" + pairs[0] + "][" + pairs[1] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (pairs[0].startsWith("-D")) //$NON-NLS-1$ { System.setProperty(pairs[0].substring(2, pairs[0].length()), pairs[1]); } } } // Now check the System Properties String appDir = System.getProperty("appdir"); //$NON-NLS-1$ if (StringUtils.isNotEmpty(appDir)) { UIRegistry.setDefaultWorkingPath(appDir); } String appdatadir = System.getProperty("appdatadir"); //$NON-NLS-1$ if (StringUtils.isNotEmpty(appdatadir)) { UIRegistry.setBaseAppDataDir(appdatadir); } SwingUtilities.invokeLater(new Runnable() { public void run() { // Set App Name, MUST be done very first thing! UIRegistry.setAppName("Specify"); //$NON-NLS-1$ // Then set this IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$ try { UIHelper.OSTYPE osType = UIHelper.getOSType(); if (osType == UIHelper.OSTYPE.Windows) { //UIManager.setLookAndFeel(new WindowsLookAndFeel()); UIManager.setLookAndFeel(new PlasticLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); } else if (osType == UIHelper.OSTYPE.Linux) { //UIManager.setLookAndFeel(new GTKLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new SkyKrupp()); //PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); //PlasticLookAndFeel.setPlasticTheme(new ExperienceRoyale()); UIManager.setLookAndFeel(new PlasticLookAndFeel()); } } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaLocalizerFrame.class, e); e.printStackTrace(); } AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); //Specify.adjustLocaleFromPrefs(); System.setProperty(AppContextMgr.factoryName, "edu.ku.brc.specify.config.SpecifyAppContextMgr"); // Needed by AppContextMgr //$NON-NLS-1$ System.setProperty(SchemaI18NService.factoryName, "edu.ku.brc.specify.config.SpecifySchemaI18NService"); // Needed for Localization and Schema //$NON-NLS-1$ System.setProperty(UIFieldFormatterMgr.factoryName, "edu.ku.brc.specify.ui.SpecifyUIFieldFormatterMgr"); // Needed for CatalogNumbering //$NON-NLS-1$ System.setProperty(WebLinkMgr.factoryName, "edu.ku.brc.specify.config.SpecifyWebLinkMgr"); // Needed for WebLnkButton //$NON-NLS-1$ System.setProperty(DataObjFieldFormatMgr.factoryName, "edu.ku.brc.specify.config.SpecifyDataObjFieldFormatMgr"); // Needed for WebLnkButton //$NON-NLS-1$ SpecifyDataObjFieldFormatMgr.setDoingLocal(true); SpecifyUIFieldFormatterMgr.setDoingLocal(true); SpecifyWebLinkMgr.setDoingLocal(true); Object[] options = { getResourceString("SchemaLocalizerFrame.FULL_SCHEMA"), //$NON-NLS-1$ getResourceString("SchemaLocalizerFrame.WB_SCHEMA") }; //$NON-NLS-1$ int retVal = JOptionPane.showOptionDialog(null, getResourceString("SchemaLocalizerFrame.WHICH_SCHEMA"), //$NON-NLS-1$ getResourceString("SchemaLocalizerFrame.CHOOSE_SCHEMA"), JOptionPane.YES_NO_CANCEL_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, options, options[0]); SchemaLocalizerFrame sla; if (retVal == JOptionPane.NO_OPTION) { DBTableIdMgr schema = new DBTableIdMgr(false); schema.initialize(new File(XMLHelper.getConfigDirPath("specify_workbench_datamodel.xml"))); //$NON-NLS-1$ sla = new SchemaLocalizerFrame(SpLocaleContainer.WORKBENCH_SCHEMA, schema); } else { sla = new SchemaLocalizerFrame(SpLocaleContainer.CORE_SCHEMA, DBTableIdMgr.getInstance()); } AppContextMgr.getInstance().setHasContext(true); sla.createDisplay(); sla.pack(); Dimension size = sla.getSize(); size.width += 250; sla.setSize(size); UIHelper.centerAndShow(sla); final SchemaLocalizerFrame slaf = sla; slaf.setDefaultCloseOperation(EXIT_ON_CLOSE); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { slaf.chooseCurrentLocale(); } }); } }); }