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:condorclient.MainFXMLController.java
@FXML void deleteButtonFired(ActionEvent event) { int delNo = 0; int n = JOptionPane.showConfirmDialog(null, "??", "", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { URL url = null;//from w w w. ja v a 2 s .c om XMLHandler handler = new XMLHandler(); String scheddStr = handler.getURL("schedd"); try { url = new URL(scheddStr); // url = new URL("http://localhost:9628"); } 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[] ClassAd ad = null;//birdbath.ClassAd; ClassAdStructAttr[][] classAdArray = null; int cluster = 0; int job = 0; Transaction xact = schedd.createTransaction(); try { xact.begin(30); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems()); String taskStatus = ""; for (Object o : selectedNodeList) { if (o instanceof ObservableDisplayedClassAd) { delNo = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId()); taskStatus = ((ObservableDisplayedClassAd) o).getJobStatus(); if (taskStatus.equals("")) { JOptionPane.showMessageDialog(null, "?"); return; } String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + delNo; try { classAdArray = schedd.getJobAds(findreq); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } for (ClassAdStructAttr[] x : classAdArray) { ad = new ClassAd(x); job = Integer.parseInt(ad.get("ProcId")); try { xact.closeSpool(delNo, job); // System.out.print("ts.getClusterId():" + showClusterId + "\n"); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } } try { xact.removeCluster(delNo, ""); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } } } //end try { xact.commit(); } catch (RemoteException e) { e.printStackTrace(); } //?? // XMLHandler handler = new XMLHandler(); int delNo1[] = new int[1];// delNo1[0] = delNo; handler.removeJobs(delNo1, 1); } else if (n == JOptionPane.NO_OPTION) { System.out.println("qu xiao"); } }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java
private JButton getJButtonOK() { if (jButtonOK == null) { jButtonOK = new JButton(); jButtonOK.setText(" OK "); jButtonOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { String dirPath = jTextFieldReportLocation.getText(); File dir = new File(dirPath); if (dir.exists() == false) { int choice = JOptionPane.showOptionDialog(null, "\"" + dir + "\" is not existed folder. Do you want to create it now?", "Alarm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (choice == JOptionPane.NO_OPTION) { return; }/*from w ww .ja v a2 s. co m*/ dir.mkdirs(); } if (getJRadioButtonIdentify().isSelected()) { mEventHandler.handle(EventHandler.BTN_OK_IDENTIFY); } else if (getJRadioButtonSPDX().isSelected()) { mEventHandler.handle(EventHandler.BTN_OK_SPDX); } else if (getJRadioButtonBoth().isSelected()) { mEventHandler.handle(EventHandler.BTN_OK_BOTH); } } }); } return jButtonOK; }
From source file:de.tor.tribes.ui.views.DSWorkbenchChurchFrame.java
private void bbCopySelection() { try {/*from w w w . j a v a2 s .c o m*/ int[] rows = jChurchTable.getSelectedRows(); if (rows.length == 0) { return; } boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this, "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code", "Nein", "Ja") == JOptionPane.YES_OPTION); StringBuilder buffer = new StringBuilder(); if (extended) { buffer.append("[u][size=12]Kirchendrfer[/size][/u]\n\n"); } else { buffer.append("[u]Kirchendrfer[/u]\n\n"); } buffer.append("[table]\n"); buffer.append("[**]Spieler[||]Dorf[||]Radius[/**]\n"); for (int row1 : rows) { int row = jChurchTable.convertRowIndexToModel(row1); int tribeCol = jChurchTable.convertColumnIndexToModel(0); int villageCol = jChurchTable.convertColumnIndexToModel(1); int rangeCol = jChurchTable.convertColumnIndexToModel(2); buffer.append("[*]").append(((Tribe) jChurchTable.getModel().getValueAt(row, tribeCol)).toBBCode()) .append("[|]") .append(((Village) jChurchTable.getModel().getValueAt(row, villageCol)).toBBCode()) .append("[|]").append(jChurchTable.getModel().getValueAt(row, rangeCol)); } buffer.append("[/table]"); if (extended) { buffer.append("\n[size=8]Erstellt am "); buffer.append( new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime())); buffer.append(" mit DS Workbench "); buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n"); } else { buffer.append("\nErstellt am "); buffer.append( new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime())); buffer.append(" mit DS Workbench "); buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n"); } String b = buffer.toString(); StringTokenizer t = new StringTokenizer(b, "["); int cnt = t.countTokens(); if (cnt > 1000) { if (JOptionPaneHelper.showQuestionConfirmBox(this, "Die ausgewhlten Kirchen bentigen mehr als 1000 BB-Codes\n" + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\n" + "Trotzdem exportieren?", "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) { return; } } Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null); String result = "Daten in Zwischenablage kopiert."; showSuccess(result); } catch (Exception e) { logger.error("Failed to copy data to clipboard", e); String result = "Fehler beim Kopieren in die Zwischenablage."; showError(result); } }
From source file:edu.ku.brc.specify.dbsupport.TaskSemaphoreMgr.java
/** * Locks the semaphore./*w w w . j a v a 2 s . c o m*/ * @param title The human (localized) title of the task * @param name the unique name * @param context * @param scope the scope of the lock * @param allViewMode allows it to ask the user about 'View Only' * @return */ public static USER_ACTION lock(final String title, final String name, final String context, final SCOPE scope, final boolean allViewMode, final TaskSemaphoreMgrCallerIFace caller, final boolean checkUsage) { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); int count = 0; do { SpTaskSemaphore semaphore = null; try { semaphore = setLock(session, name, context, scope, true, false, checkUsage); } catch (StaleObjectException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); semaphore = null; } if (semaphore == null || previouslyLocked) { if (caller != null) { return caller.resolveConflict(semaphore, previouslyLocked, prevLockedBy); } if (semaphore == null) { String msg = UIRegistry.getLocalizedMessage("SpTaskSemaphore.IN_USE", title);//$NON-NLS-1$ Object[] options = { getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL") //$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), msg, getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == JOptionPane.NO_OPTION) { return USER_ACTION.Cancel; } } else { // Check to see if we have the same user on the same machine. SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); String currMachineName = InetAddress.getLocalHost().toString(); String dbMachineName = semaphore.getMachineName(); //System.err.println("["+dbMachineName+"]["+currMachineName+"]["+user.getId()+"]["+semaphore.getOwner().getId()+"]"); if (StringUtils.isNotEmpty(dbMachineName) && StringUtils.isNotEmpty(currMachineName) && currMachineName.equals(dbMachineName) && semaphore.getOwner() != null && user != null && user.getId().equals(semaphore.getOwner().getId())) { if (allViewMode) { int options = JOptionPane.YES_NO_OPTION; Object[] optionLabels = new String[] { getResourceString("SpTaskSemaphore.VIEWMODE"), //$NON-NLS-1$ getResourceString("CANCEL")//$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpTaskSemaphore.IN_USE_BY_YOU", title), getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, 0); return userChoice == JOptionPane.NO_OPTION ? USER_ACTION.Cancel : USER_ACTION.ViewMode; // CHECKED } int options = JOptionPane.OK_OPTION; Object[] optionLabels = new String[] { getResourceString("OK")//$NON-NLS-1$ }; JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpTaskSemaphore.IN_USE_BY_YOU", title), getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, 0); return USER_ACTION.Cancel; } String userStr = prevLockedBy != null ? prevLockedBy : semaphore.getOwner().getIdentityTitle(); String msgKey = allViewMode ? "SpTaskSemaphore.IN_USE_OV" : "SpTaskSemaphore.IN_USE"; String msg = UIRegistry.getLocalizedMessage(msgKey, title, userStr, semaphore.getLockedTime() != null ? semaphore.getLockedTime().toString() : ""); int options; int defBtn; Object[] optionLabels; if (allViewMode) { defBtn = 2; options = JOptionPane.YES_NO_CANCEL_OPTION; optionLabels = new String[] { getResourceString("SpTaskSemaphore.VIEWMODE"), //$NON-NLS-1$ getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL")//$NON-NLS-1$ }; } else { defBtn = 0; options = JOptionPane.YES_NO_OPTION; optionLabels = new String[] { getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL"), //$NON-NLS-1$ }; } int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), msg, getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, defBtn); if (userChoice == JOptionPane.YES_OPTION) { if (options == JOptionPane.YES_NO_CANCEL_OPTION) { return USER_ACTION.ViewMode; // CHECKED } // this means try again } else if (userChoice == JOptionPane.NO_OPTION) { if (options == JOptionPane.YES_NO_OPTION) { return USER_ACTION.Cancel; } // CHECKED } else if (userChoice == JOptionPane.CANCEL_OPTION) { return USER_ACTION.Cancel; // CHECKED } } } else { return USER_ACTION.OK; } count++; } while (true); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); ex.printStackTrace(); //log.error(ex); } finally { if (session != null) { session.close(); } } return USER_ACTION.Error; }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplatePanel.java
public boolean promptSave(boolean force) { stopTableEditing();//from w w w.j a v a2s .c o m int option; if (force) { option = JOptionPane.showConfirmDialog(parent, "You must save the code template changes before continuing. Would you like to save now?"); } else { option = JOptionPane.showConfirmDialog(parent, "Would you like to save the code templates?"); } if (option == JOptionPane.YES_OPTION) { CodeTemplateLibrarySaveResult updateSummary = doSaveCodeTemplates(false); if (updateSummary == null || updateSummary.isOverrideNeeded() || !updateSummary.isLibrariesSuccess()) { return false; } else { for (CodeTemplateUpdateResult result : updateSummary.getCodeTemplateResults().values()) { if (!result.isSuccess()) { return false; } } } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION || (option == JOptionPane.NO_OPTION && force)) { return false; } return true; }
From source file:ca.sqlpower.architect.swingui.enterprise.SecurityPanel.java
private boolean promptForUnsavedChanges() { if (currentGroupOrUserEditPanel != null && (currentGroupOrUserEditPanel.hasUnsavedChanges())) { int option = JOptionPane.showConfirmDialog(getPanel(), "You have not saved all of your changes,\n" + "do you want to save them now?", "", JOptionPane.INFORMATION_MESSAGE); if (option == JOptionPane.YES_OPTION) { currentGroupOrUserEditPanel.applyChanges(); return true; }//ww w . ja va2s. c om if (option == JOptionPane.NO_OPTION) { return true; } if (option == JOptionPane.CANCEL_OPTION) { return false; } } return true; }
From source file:de.tor.tribes.ui.wiz.ref.SupportRefillCalculationPanel.java
private void fireCalculateAttacksEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireCalculateAttacksEvent if (calculator == null) {//not used yet initializeCalculation();/*w w w .j a v a 2 s .com*/ } else 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(); } } if (calculator != null && !calculator.hasResults()) { //do only if there were no problems during initiation of calculation jCalculateButton.setText("Abbrechen"); calculator.start(); setBusy(true); //wait until calculation is running try { Thread.sleep(20); } catch (Exception ignored) { } } }
From source file:de.tor.tribes.ui.views.DSWorkbenchWatchtowerFrame.java
private void bbCopySelection() { try {//from ww w.j av a 2 s .co m int[] rows = jWatchtowerTable.getSelectedRows(); if (rows.length == 0) { return; } boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this, "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code", "Nein", "Ja") == JOptionPane.YES_OPTION); StringBuilder buffer = new StringBuilder(); if (extended) { buffer.append("[u][size=12]Watchturmdrfer[/size][/u]\n\n"); } else { buffer.append("[u]Watchturmdrfer[/u]\n\n"); } buffer.append("[table]\n"); buffer.append("[**]Spieler[||]Dorf[||]Radius[/**]\n"); for (int row1 : rows) { int row = jWatchtowerTable.convertRowIndexToModel(row1); int tribeCol = jWatchtowerTable.convertColumnIndexToModel(0); int villageCol = jWatchtowerTable.convertColumnIndexToModel(1); int rangeCol = jWatchtowerTable.convertColumnIndexToModel(2); buffer.append("[*]") .append(((Tribe) jWatchtowerTable.getModel().getValueAt(row, tribeCol)).toBBCode()) .append("[|]") .append(((Village) jWatchtowerTable.getModel().getValueAt(row, villageCol)).toBBCode()) .append("[|]").append(jWatchtowerTable.getModel().getValueAt(row, rangeCol)); } buffer.append("[/table]"); if (extended) { buffer.append("\n[size=8]Erstellt am "); buffer.append( new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime())); buffer.append(" mit DS Workbench "); buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n"); } else { buffer.append("\nErstellt am "); buffer.append( new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime())); buffer.append(" mit DS Workbench "); buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n"); } String b = buffer.toString(); StringTokenizer t = new StringTokenizer(b, "["); int cnt = t.countTokens(); if (cnt > 1000) { if (JOptionPaneHelper.showQuestionConfirmBox(this, "Die ausgewhlten Wachtrme bentigen mehr als 1000 BB-Codes\n" + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\n" + "Trotzdem exportieren?", "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) { return; } } Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null); String result = "Daten in Zwischenablage kopiert."; showSuccess(result); } catch (Exception e) { logger.error("Failed to copy data to clipboard", e); String result = "Fehler beim Kopieren in die Zwischenablage."; showError(result); } }
From source file:net.sf.nmedit.nomad.core.Nomad.java
public void fileSave(boolean saveAs) { Document d = pageContainer.getSelection(); if (d == null) return;// ww w. j a v a 2 s .c o m if (!saveAs) { Iterator<FileService> iter = ServiceRegistry.getServices(FileService.class); FileService useService = null; while (iter.hasNext()) { FileService fs = iter.next(); if (fs.isDirectSaveOperationSupported(d)) { useService = fs; break; } } if (useService != null) { useService.save(d, useService.getAssociatedFile(d)); return; } } JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(lastSaveInFolderLocation); chooser.setMultiSelectionEnabled(false); Iterator<FileService> iter = ServiceRegistry.getServices(FileService.class); while (iter.hasNext()) { FileService fs = iter.next(); boolean add = (saveAs && fs.isSaveOperationSupported(d)) || ((!saveAs) && fs.isDirectSaveOperationSupported(d)); if (add) chooser.addChoosableFileFilter(fs.getFileFilter()); } File sfile = d.getFile(); if (sfile == null && d.getTitle() != null) sfile = new File(d.getTitle()); if (sfile != null) chooser.setSelectedFile(sfile); if (!(chooser.showSaveDialog(mainWindow) == JFileChooser.APPROVE_OPTION)) return; FileService service = FileServiceTool.lookupFileService(chooser); if (service != null) { File newFile = chooser.getSelectedFile(); if (newFile == null) return; if (newFile.exists() && JOptionPane.showConfirmDialog(mainWindow, "Overwrite existing file '" + newFile.getAbsolutePath() + "' ?", "File already exists.", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) return; service.save(d, newFile); lastSaveInFolderLocation = newFile.getParentFile(); } else { JOptionPane.showMessageDialog(mainWindow, "Could not find service to save file."); } }
From source file:com.sshtools.shift.FileTransferDialog.java
/** * * * @param sftp//w ww. j av a2s .c om * @param files * @param totalBytes */ public void getRemoteFiles(SftpClient sftp, java.util.List files, long totalBytes) { this.files = files; this.totalBytes = totalBytes; this.sftp = sftp; lblTargetAction.setText("Downloading to:"); progressbar.setMaximum(100); if ((totalBytes / 1073741824) > 0) { // Were in the gigabytes formattedTotal = formatMb.format((double) totalBytes / 1073741824) + " GB"; } else if ((totalBytes / 1048576) > 0) { // Were in the megabytes formattedTotal = formatMb.format((double) totalBytes / 1048576) + " MB"; } else { // Were still in Kilobytes formattedTotal = formatKb.format((double) totalBytes / 1024) + " KB"; } Thread thread = new Thread(new Runnable() { int i; public void run() { String pwd = FileTransferDialog.this.sftp.pwd(); String lpwd = FileTransferDialog.this.sftp.lpwd(); try { for (i = 0; i < FileTransferDialog.this.files.size(); i++) { // Test whether the file exists before the download commences File file = new File(lpwd + File.separator + FileTransferDialog.this.files.get(i)); if (file.exists()) { int result = JOptionPane.showConfirmDialog(FileTransferDialog.this, "This file already exists are you sure you wish to overwrite?\n\n" + file.getName(), "Confirm File Overwrite", JOptionPane.YES_NO_CANCEL_OPTION); if (result == JOptionPane.NO_OPTION) { if (i == FileTransferDialog.this.files.size() - 1) { // This was the last file for transfer cancelOperation(); return; } else { String ff = pwd + "/" + FileTransferDialog.this.files.get(i); FileAttributes attrs = FileTransferDialog.this.sftp.stat(ff); started(attrs.getSize().longValue(), ff); progressed(attrs.getSize().longValue()); completed(); // Was not the last file so goto next continue; } } if (result == JOptionPane.CANCEL_OPTION) { // Cancel the upload operation cancelOperation(); return; } } setSource(pwd + "/" + FileTransferDialog.this.files.get(i)); setTarget(lpwd + File.separator + FileTransferDialog.this.files.get(i)); if (!cancelled) { FileTransferDialog.this.sftp.get((String) FileTransferDialog.this.files.get(i), FileTransferDialog.this); } } // Notify any waiting threads that we've completed our operation completed = true; notifyWaiting(); } catch (IOException ex) { if (!cancelled) { SshToolsApplicationPanel.showErrorMessage(FileTransferDialog.this, "The file operation failed!\n" + ex.getMessage(), "File Transfer", ex); // Delete the partially completed file File file = new File(lpwd + File.separator + FileTransferDialog.this.files.get(i)); if (file.exists()) { file.delete(); } setVisible(false); } } } }); thread.start(); try { setVisible(true); } catch (NullPointerException e) { setVisible(true); } }