List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:net.sf.jabref.gui.openoffice.OOBibBase.java
public static XTextDocument selectComponent(List<XTextDocument> list) throws UnknownPropertyException, WrappedTargetException, IndexOutOfBoundsException { String[] values = new String[list.size()]; int ii = 0;/*from w ww . j a v a 2 s.co m*/ for (XTextDocument doc : list) { values[ii] = String.valueOf(OOUtil.getProperty(doc.getCurrentController().getFrame(), "Title")); ii++; } JList<String> sel = new JList<>(values); sel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); sel.setSelectedIndex(0); int ans = JOptionPane.showConfirmDialog(null, new JScrollPane(sel), Localization.lang("Select document"), JOptionPane.OK_CANCEL_OPTION); if (ans == JOptionPane.OK_OPTION) { return list.get(sel.getSelectedIndex()); } else { return null; } }
From source file:edu.ku.brc.specify.tools.ireportspecify.MainFrameSpecify.java
/** * @param report/*from ww w. j a v a2s . c o m*/ * @return true if properties were gotten and set. */ protected boolean getReportProperties(final Report report) { ReportPropertiesFrame rpf = new ReportPropertiesFrame(this, true); rpf.setModal(true); // find the first name free... String name = getFirstNameFree(); rpf.setReportName(name); rpf.setVisible(true); if (rpf.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) { // The user has clicked on OK... // Storing in a new report the report characteristics. report.setUsingMultiLineExpressions(false); //this.isUsingMultiLineExpressions()); report.setWidth(rpf.getReportWidth()); report.setHeight(rpf.getReportHeight()); report.setOrientation(rpf.getOrientation()); report.setName(rpf.getReportName()); report.setTopMargin(rpf.getTopMargin()); report.setLeftMargin(rpf.getLeftMargin()); report.setRightMargin(rpf.getRightMargin()); report.setBottomMargin(rpf.getBottomMargin()); report.setColumnCount(rpf.getColumns()); report.setColumnWidth(rpf.getColumnsWidth()); report.setColumnSpacing(rpf.getColumnsSpacing()); report.setIsSummaryNewPage(rpf.isSummaryOnNewPage()); report.setIsTitleNewPage(rpf.isTitleOnNewPage()); report.setWhenNoDataType(rpf.getWhenNoDataType()); report.setScriptletClass(rpf.getScriptletClass()); report.setEncoding(rpf.getXmlEncoding()); report.setPrintOrder(rpf.getPrintOrder()); report.setReportFormat(rpf.getReportFormat()); report.setFloatColumnFooter(rpf.isFloatColumnFooter()); report.setResourceBundleBaseName(rpf.getResourceBundleBaseName()); report.setWhenResourceMissingType(rpf.getWhenResourceMissingType()); report.setIgnorePagination(rpf.isIgnorePagination()); report.setFormatFactoryClass(rpf.getFormatFactoryClass()); report.setLanguage(rpf.getLanguage()); return true; } return false; }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private void actionExit() { logger.trace("Program exit requested..."); boolean close = true; if (!checkRomModified()) { close = false;/*from w ww . j a va 2s . c o m*/ } if (close && config.getBoolean("Hazelnutt.gui.confirmExit", true)) { int res = JOptionPane.showConfirmDialog(this, "Do you really want to close Hazelnutt?", "Confirm", JOptionPane.YES_NO_OPTION); close = (res == JOptionPane.OK_OPTION); } if (close) { logger.info("Saving configuration values..."); boolean maximum = (getExtendedState() & JFrame.MAXIMIZED_BOTH) != 0; config.setProperty("Hazelnutt.gui.maximum", maximum); Point loc = getLocation(); Dimension size = getSize(); config.setProperty("Hazelnutt.gui.location.x", (int) loc.getX()); config.setProperty("Hazelnutt.gui.location.y", (int) loc.getY()); config.setProperty("Hazelnutt.gui.size.width", (int) size.getWidth()); config.setProperty("Hazelnutt.gui.size.height", (int) size.getHeight()); logger.debug("Saving the last opened directory: '" + fileChooser.getCurrentDirectory() + "'"); config.setProperty("Hazelnutt.gui.lastDirectory", fileChooser.getCurrentDirectory()); logger.debug("Saving the recently opened files"); config.clearProperty("Hazelnutt.gui.recentFiles"); for (String str : recentFiles) { config.addProperty("Hazelnutt.gui.recentFiles", str); } logger.trace("Closing program..."); dispose(); //memoryMonitor.cancel( true ); } }
From source file:com.josescalia.tumblr.form.PreferenceForm.java
private void btnCleanLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCleanLogActionPerformed frame = (MainFrame) this.getTopLevelAncestor(); if (UIAlert.showConfirm(this, "Are you sure ?") == JOptionPane.OK_OPTION) { logger.info("deleting log file"); //busy cursor and progress bar frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.startProgressBar("Deleting"); //background process new SwingWorker<String, String>() { @Override/*w w w . j a va2 s .com*/ protected String doInBackground() throws Exception { int successDeleteCount = 0; int failedDeleteCount = 0; for (File file : logFile.getFileList()) { logger.info(file.getName()); if (!file.getName().equalsIgnoreCase(Bootstrap.applicationLog) && !file.getName().equalsIgnoreCase(Bootstrap.applicationErrorLog)) { if (file.delete()) { successDeleteCount++; } else { failedDeleteCount++; } } } return "Done\n " + successDeleteCount + " log file(s) deleted\n" + failedDeleteCount + " log file(s) not deleted"; } @Override protected void done() { try { UIAlert.showInformation(null, get()); } catch (InterruptedException e) { logger.error(e); } catch (ExecutionException e) { logger.error(e); } setupLogFileInfo(); frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.stopProgressBar(""); } }.execute(); } }
From source file:com.freedomotic.jfrontend.MainWindow.java
/** * //from www.ja v a 2s. co m * @param evt */ private void mnuLanguageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuLanguageActionPerformed //JDK 1,7 version: JComboBox<i18n.ComboLanguage> combo = new JComboBox<i18n.ComboLanguage>(I18n.getAvailableLocales()); //JDK 1.6 version: next line Vector<ComboLanguage> languages = new Vector<ComboLanguage>(); for (Locale loc : i18n.getAvailableLocales()) { languages.add(new ComboLanguage( loc.getDisplayCountry(i18n.getDefaultLocale()) + " - " + loc.getDisplayLanguage(loc), loc.toString(), loc)); } Collections.sort(languages); languages.add(new ComboLanguage("Automatic", "auto", Locale.ENGLISH)); JComboBox combo = new JComboBox(languages); for (ComboLanguage cmb : languages) { if (cmb.getValue().equals(i18n.getDefaultLocale())) { combo.setSelectedItem(cmb); break; } } JLabel lbl = new JLabel(i18n.msg("language")); int result = JOptionPane.showConfirmDialog(this, new Object[] { lbl, combo }, i18n.msg("language"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { ComboLanguage selected = (ComboLanguage) combo.getSelectedItem(); i18n.setDefaultLocale(selected.getValue()); updateStrings(); } }
From source file:com.adito.server.DefaultAditoServerFactory.java
private boolean fullReset() { if (gui) {/*from w w w .j a v a 2 s.c o m*/ if (JOptionPane.showConfirmDialog(null, "The embedded configuration database will be\n" + "completely deleted and re-created the next\ntime you run the server. Are you absolutely\n" + "sure you wish to do this?", "Full Reset", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION) != JOptionPane.OK_OPTION) { return false; } } else { System.out.println("The embedded configuration database will be"); System.out.println("completely deleted and re-created the next"); System.out.println("time you run the server. Are you absolutely"); System.out.println("sure you wish to do this?"); System.out.println(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.print("(Y)es or (N)o: "); String s; try { s = br.readLine(); if (s == null) { return false; } if (s.toLowerCase().equals("y") || s.toLowerCase().equals("yes")) { break; } if (s.toLowerCase().equals("n") || s.toLowerCase().equals("no")) { return false; } System.out.println( "\nPlease answer 'y' or 'yes' to perform the reset, or 'n' or 'no' to abort the reset."); } catch (IOException e) { return false; } } } // Start the reset System.out.println("Resetting all configuration"); File[] f = getDBDirectory().listFiles(); if (f != null) { for (File f1 : f) { System.out.println(" Deleting " + f1.getPath()); if (!f1.delete()) { System.out.println(" Failed to remove"); } } } return true; }
From source file:GUI.MainWindow.java
public void addAffectedHost() { System.out.println("==addAffectedHost"); DefaultMutableTreeNode node = (DefaultMutableTreeNode) this.VulnTree.getLastSelectedPathComponent(); if (node == null) { return;//from ww w . j av a 2s .co m } Vulnerability vuln = (Vulnerability) node.getUserObject(); //ManageAffectedHosts.setVisible(true) ; // Old way of doing it JTextField ip_address = new JTextField(); JTextField hostname = new JTextField(); JTextField port_number = new JTextField(); port_number.setText("0"); JTextField protocol = new JTextField(); protocol.setText("tcp"); Object[] message = { "IP Address:", ip_address, "Hostname:", hostname, "Port Number:", port_number, "Protocol:", protocol }; String new_ip = null; String new_hostname = null; String new_port_number = null; String new_protocol = null; while (new_ip == null || new_hostname == null || new_port_number == null || new_protocol == null) { int option = JOptionPane.showConfirmDialog(null, message, "Add affected host", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { new_ip = ip_address.getText(); new_hostname = hostname.getText(); new_port_number = port_number.getText(); new_protocol = protocol.getText(); Host host = new Host(); host.setIp_address(new_ip); host.setHostname(new_hostname); host.setPortnumber(new_port_number); host.setProtocol(new_protocol); vuln.addAffectedHost(host); DefaultTableModel dtm = (DefaultTableModel) this.VulnAffectedHostsTable.getModel(); dtm.addRow(host.getAsVector()); dtm.fireTableDataChanged(); } else { return; // End the infinite loop } } }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java
public UECodeMatch exportUIEntity(String projectName) { String tmpComponentName = ""; String tmpVersionName = ""; String tmpLicenseName = ""; String originComponentName = ""; String originVersionName = ""; String originLicenseName = ""; String currentComponentName = ""; String currentVersionName = ""; String currentLicenseName = ""; String newComponentName = ""; String newVersionName = ""; String newLicenseName = ""; String matchedFile = ""; String comment = IdentifyMediator.getInstance().getComment(); int compositeType = IdentificationConstantValue.CODE_MATCH_TYPE; int row = 0;/*www .j av a2 s.c o m*/ JTableMatchedInfo jTableMatchedInfo = jPanelTableCardLayout.getSelectedTable(); String status = ""; switch (pathType) { case SelectedFilePathInfo.SINGLE_FILE_TYPE: { row = jTableMatchedInfo.getSelectedRow(); tmpComponentName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_COMPONENT_NAME)); tmpVersionName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_VERSION_NAME)); tmpLicenseName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_LICENSE_NAME)); matchedFile = String.valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_MATCHED_FILE)); status = String.valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_STATUS)); } break; case SelectedFilePathInfo.MULTIPLE_FILE_TYPE: { row = jTableMatchedInfo.getSelectedRow(); tmpComponentName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMMultipleFile.COL_COMPONENT_NAME)); tmpVersionName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMMultipleFile.COL_VERSION_NAME)); tmpLicenseName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMMultipleFile.COL_LICENSE_NAME)); status = String.valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMMultipleFile.COL_STATUS)); compositeType |= IdentificationConstantValue.FOLDER_TYPE; } break; case SelectedFilePathInfo.FOLDER_TYPE: case SelectedFilePathInfo.PROJECT_TYPE: { row = jTableMatchedInfo.getSelectedRow(); tmpComponentName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFolder.COL_COMPONENT_NAME)); tmpVersionName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFolder.COL_VERSION_NAME)); tmpLicenseName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFolder.COL_LICENSE_NAME)); status = String.valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFolder.COL_STATUS)); compositeType |= IdentificationConstantValue.FOLDER_TYPE; } break; } currentComponentName = DCCodeMatch.getCurrentValue(tmpComponentName); currentVersionName = DCCodeMatch.getCurrentValue(tmpVersionName); currentLicenseName = DCCodeMatch.getCurrentValue(tmpLicenseName); originComponentName = DCCodeMatch.getOriginValue(tmpComponentName); originVersionName = DCCodeMatch.getOriginValue(tmpVersionName); originLicenseName = DCCodeMatch.getOriginValue(tmpLicenseName); if (rdbtnOpt1IConform.isSelected()) { compositeType |= IdentificationConstantValue.STANDARD_COMPONENT_TYPE; newComponentName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_COMPONENT_NAME)); newLicenseName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_LICENSE_NAME)); newVersionName = String .valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_VERSION_NAME)); if (newVersionName.equals("Unspecified")) newVersionName = ""; } else if (rdbtnOpt2ICannotFind.isSelected()) { status = String.valueOf(jTableMatchedInfo.getValueAt(row, TableModelForCMFile.COL_STATUS)); if (("Pending".equals(status)) && (IdentifyMediator.getInstance().getSelectedLicenseName().length() == 0)) { JOptionPane.showOptionDialog(null, "Select License.", "Pending identification", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK"); return null; } if (("Pending".equals(status)) && (cbComponent.getSelectedItem() == null)) { JOptionPane.showOptionDialog(null, "Component must be completed.", "Pending identification", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK"); return null; } else { newComponentName = String.valueOf(cbComponent.getSelectedItem()); newLicenseName = String.valueOf(cbCmLicense.getSelectedItem()); } compositeType |= IdentificationConstantValue.STANDARD_COMPONENT_TYPE; } else if (rdbtnOpt3Internal.isSelected()) { newComponentName = OPTION3_DECLARED_NOT_OPEN_SOURCE; } else if (rdbtnOpt4NotAlarm.isSelected()) { newComponentName = OPTION4_DECLARED_DO_NOT_ALARM_AGAIN; } log.debug("[JPanCodeMatchMain.exportUIEntity()] newComponentName : " + newComponentName); log.debug("[JPanCodeMatchMain.exportUIEntity()] newVersionName : " + newVersionName); log.debug("[JPanCodeMatchMain.exportUIEntity()] newLicenseName : " + newLicenseName); UECodeMatch xUECodeMatch = new UECodeMatch(originComponentName, originVersionName, originLicenseName, currentComponentName, currentVersionName, currentLicenseName, newComponentName, newVersionName, newLicenseName, matchedFile, compositeType, comment, status); return xUECodeMatch; }
From source file:de.huxhorn.lilith.swing.MainFrame.java
public void importFile(File importFile) { if (logger.isInfoEnabled()) logger.info("Import file: {}", importFile.getAbsolutePath()); File parentFile = importFile.getParentFile(); String inputName = importFile.getName(); if (!importFile.isFile()) { String message = "'" + importFile.getAbsolutePath() + "' is not a file!"; JOptionPane.showMessageDialog(this, message, "Can't import file...", JOptionPane.ERROR_MESSAGE); return;/*from w ww. j ava 2 s. com*/ } if (!importFile.canRead()) { String message = "Can't read from '" + importFile.getAbsolutePath() + "'!"; JOptionPane.showMessageDialog(this, message, "Can't import file...", JOptionPane.ERROR_MESSAGE); return; } File dataFile = new File(parentFile, inputName + FileConstants.FILE_EXTENSION); File indexFile = new File(parentFile, inputName + FileConstants.INDEX_FILE_EXTENSION); // check if file exists and warn in that case if (dataFile.isFile()) { // check if file is already open ViewContainer<?> viewContainer = resolveViewContainer(dataFile); if (viewContainer != null) { showView(viewContainer); String message = "File '" + dataFile.getAbsolutePath() + "' is already open."; JOptionPane.showMessageDialog(this, message, "File is already open...", JOptionPane.INFORMATION_MESSAGE); return; } String dialogTitle = "Reimport file?"; String message = "Data file does already exist!\nReimport data file right now?"; int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (JOptionPane.OK_OPTION != result) { return; } if (dataFile.delete()) { if (logger.isInfoEnabled()) logger.info("Deleted file '{}'.", dataFile.getAbsolutePath()); } } if (indexFile.isFile()) { if (indexFile.delete()) { if (logger.isInfoEnabled()) logger.info("Deleted file '{}'.", indexFile.getAbsolutePath()); } } Map<String, String> metaData = new HashMap<String, String>(); metaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF); metaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_LOGGING); metaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP); FileBuffer<EventWrapper<LoggingEvent>> buffer = loggingFileBufferFactory.createBuffer(dataFile, indexFile, metaData); ImportType type = resolveType(importFile); if (type == ImportType.LOG4J) { String name = "Importing Log4J XML file"; String description = "Importing Log4J XML file '" + importFile.getAbsolutePath() + "'..."; Task<Long> task = longTaskManager.startTask(new Log4jImportCallable(importFile, buffer), name, description); if (logger.isInfoEnabled()) logger.info("Task-Name: {}", task.getName()); return; } if (type == ImportType.JUL) { String name = "Importing java.util.logging XML file"; String description = "Importing java.util.logging XML file '" + importFile.getAbsolutePath() + "'..."; Task<Long> task = longTaskManager.startTask(new JulImportCallable(importFile, buffer), name, description); if (logger.isInfoEnabled()) logger.info("Task-Name: {}", task.getName()); return; } // show warning "Unknown type" String message = "Couldn't detect type of file '" + importFile.getAbsolutePath() + "'.\nFile is unsupported."; JOptionPane.showMessageDialog(this, message, "Unknown file type...", JOptionPane.WARNING_MESSAGE); }
From source file:com.josescalia.tumblr.form.PreferenceForm.java
private void btnDeleteCacheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteCacheActionPerformed frame = (MainFrame) this.getTopLevelAncestor(); if (UIAlert.showConfirm(this, "Are you sure ?") == JOptionPane.OK_OPTION) { logger.info("deleting cache"); //busy cursor and frame progress bar frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.startProgressBar("Deleting"); new SwingWorker<String, String>() { @Override//from w w w . jav a 2 s.c o m protected String doInBackground() throws Exception { int successDeleteCount = 0; int failedDeleteCount = 0; for (File file : cacheFile.getFileList()) { if (!file.getName().contains("ImageNotFound")) { logger.info("deleting file " + file.getName()); if (file.delete()) { successDeleteCount++; } else { failedDeleteCount++; } } } return "Done\n " + successDeleteCount + " cache file(s) deleted\n" + failedDeleteCount + " cache file(s) not deleted"; } @Override protected void done() { try { UIAlert.showInformation(null, get()); getCacheFileInfo(); } catch (InterruptedException e) { logger.error(e); } catch (ExecutionException e) { logger.error(e); } frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.stopProgressBar(""); } }.execute(); } }