List of usage examples for javax.swing JOptionPane YES_OPTION
int YES_OPTION
To view the source code for javax.swing JOptionPane YES_OPTION.
Click Source Link
From source file:com.mirth.connect.client.ui.ChannelPanel.java
private boolean promptSave(boolean force) { int option;// w ww . j ava 2 s . co m if (force) { option = JOptionPane.showConfirmDialog(parent, "You must save the channel group changes before continuing. Would you like to save now?"); } else { option = JOptionPane.showConfirmDialog(parent, "Would you like to save the channel groups?"); } if (option == JOptionPane.YES_OPTION) { return doSaveGroups(false); } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION || (option == JOptionPane.NO_OPTION && force)) { return false; } return true; }
From source file:com.sec.ose.osi.thread.ui_related.UserCommandExecutionThread.java
private void syncToServer() { long start = System.currentTimeMillis(); boolean result = IdentifyQueue.getInstance().makeBackup(); if (result == false) { mObserver.setResult(UIResponseObserver.RESULT_FAIL); mObserver.setFailMessage("Can't make backup file"); return;/*w ww. j ava 2 s. com*/ } Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "false"); while (IdentifyQueue.getInstance().size() > 0) { if (IdentifyQueue.getInstance().size() <= 1) { Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "true"); } else { Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "false"); } try { Thread.sleep(50); } catch (Exception e) { } mObserver.setMessageHeader("Flushing items in identify queue to Protex Server - " + IdentifyQueue.getInstance().size() + " file(s) remains.\n"); IdentifyData iData = IdentifyQueue.getInstance().firstElement(); if (iData == null) break; String fullPathMessage = iData.getFilePath().toString(); String displayedFullPath = ""; while (fullPathMessage.length() > 75) { displayedFullPath += fullPathMessage.substring(0, 75) + "\n "; fullPathMessage = fullPathMessage.substring(75); } displayedFullPath += fullPathMessage; String out = " > Identifying \"" + iData.getProjectName() + "\"\n" + " " + displayedFullPath + "\n " + " (identified at " + iData.getTimeStamp() + ")"; mObserver.pushMessageWithHeader(out); } Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "true"); String title = "Sync to server - " + IdentifyMediator.getInstance().getSelectedProjectName(); String message = "\"Sync To Server\" finished.\n" + "Do you want to progress \"Sync From Server\" for UI updating?"; int yesNo = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION); if (yesNo == JOptionPane.YES_OPTION) { long end = System.currentTimeMillis(); log.debug("@@@ To Server TIME : " + (end - start) / 1000.0); syncFromServer(); } }
From source file:com.sciaps.view.SpectrumShotPanel.java
private void doDelete() { if (tblShots_.getSelectedRowCount() == 0) { showErrorDialog("Nothing is selected."); return;// www . j a v a2s.c o m } int retval = JOptionPane.showConfirmDialog(Constants.MAIN_FRAME, "Delete Selected Row(s)?"); if (retval != JOptionPane.YES_OPTION) { return; } shotListTableModel_.removeRows(getSelectedRows()); }
From source file:com.proyecto.vista.MantenimientoFactura.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;// w ww . j av a2s . com if (tblFactura.getSelectedRow() != -1) { Integer codigo = tblFactura.getSelectedRow(); Factura factura = facturaControlador.buscarPorId(lista.get(codigo).getId()); if (factura != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblFactura.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Factura factura2 = lista.get(filas[0]); lista.remove(factura2); facturaControlador.setSeleccionado(factura2); facturaControlador.accion(accion); } if (facturaControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Tipo eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Tipo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:serial.ChartFromSerial.java
private boolean attemptConnection(String desiredPort, int baudRate) { //Port Setup//from w w w . j ava 2 s .co m chosenPort = SerialPort.getCommPort(desiredPort); chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0); chosenPort.setBaudRate(baudRate); //Making sure all goes well chosenPort.openPort(); if (chosenPort.openPort()) { createSerialThread(chosenPort); buttonsConnected(); // buttonsConnected(); // if (createSerialThread(chosenPort)){ // buttonsConnected(); // } else { // JOptionPane.showMessageDialog(rootPane, "Failed to create a serial connection.", "Serial connection failed.", JOptionPane.ERROR_MESSAGE); // chosenPort.closePort(); // } } else { //Prompt user for response if (JOptionPane.showConfirmDialog(rootPane, "Error at " + portList_jCombo.getSelectedItem().toString() + "\nWould you like to refresh?", "Trouble connecting to " + portList_jCombo.getSelectedItem().toString(), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) { hardRefresh(); } else { buttonsOff(); } } return false; }
From source file:canreg.client.gui.management.CanReg4MigrationInternalFrame.java
@Action public void MigrationAction() { okButton.setEnabled(false);// w w w . j a va 2s. co m doneButton.setEnabled(false); cancelButton.setEnabled(true); jList1.setEnabled(false); EditDatabaseVariableTableAssociationInternalFrame edvif = new EditDatabaseVariableTableAssociationInternalFrame(); int addServer = JOptionPane.showInternalConfirmDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle .getBundle("canreg/client/gui/management/resources/CanReg4SystemConverterInternalFrame") .getString("SUCCESSFULLY_CREATED_XML: ") + "\'" + Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode + "\'.\n" + java.util.ResourceBundle.getBundle( "canreg/client/gui/management/resources/CanReg4SystemConverterInternalFrame") .getString("ADD_IT_TO_FAV_SERVERS?"), "Success", JOptionPane.YES_NO_OPTION); if (addServer == JOptionPane.YES_OPTION) { localSettings = CanRegClientApp.getApplication().getLocalSettings(); localSettings.addServerToServerList(dlm.get(list.getSelectedIndex()), "localhost", Globals.DEFAULT_PORT, regcode); localSettings.writeSettings(); } try { edvif.setTitle("Variables and Tables for " + WordUtils.capitalize(dlm.get(list.getSelectedIndex()).toLowerCase())); edvif.loadSystemDefinition( Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode + ".xml"); edvif.setDesktopPane(desktopPane); CanRegClientView.showAndPositionInternalFrame(desktopPane, edvif); } catch (IOException ex) { Logger.getLogger(CanReg4SystemConverterInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (ParserConfigurationException ex) { Logger.getLogger(CanReg4SystemConverterInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (SAXException ex) { Logger.getLogger(CanReg4SystemConverterInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } edvif.saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //logout from canreg system before conversion if (CanRegClientApp.getApplication().loggedIn) { try { CanRegClientApp.getApplication().logOut(); } catch (RemoteException ex) { Logger.getLogger(CanReg4MigrationInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } } //check to see if there is a database already - rename it File databaseFolder = new File( Globals.CANREG_SERVER_DATABASE_FOLDER + Globals.FILE_SEPARATOR + regcode); if (databaseFolder.exists()) { int i = 0; File folder2 = databaseFolder; while (folder2.exists()) { i++; folder2 = new File( Globals.CANREG_SERVER_DATABASE_FOLDER + Globals.FILE_SEPARATOR + regcode + i); } databaseFolder.renameTo(folder2); debugOut("database: " + databaseFolder); try { canreg.common.Tools.fileCopy( Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode + ".xml", Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode + i + ".xml"); } catch (IOException ex) { Logger.getLogger(CanReg4MigrationInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } } ProgressBar.setStringPainted(true); cTask = new ProgressTask( org.jdesktop.application.Application.getInstance(canreg.client.CanRegClientApp.class)); cTask.execute(); cTask.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { ProgressBar.setValue((Integer) evt.getNewValue()); ProgressBar.setString(evt.getNewValue().toString() + "%"); } } }); } }); }
From source file:fll.subjective.SubjectiveFrame.java
/** * Prompt the user with yes/no/cancel. Yes exits and saves, no exits * without//from w w w .j a v a 2 s . com * saving and cancel doesn't quit. */ /* package */void quit() { if (validateData()) { final int state = JOptionPane.showConfirmDialog(SubjectiveFrame.this, "Save data? Data will be saved in same file as it was read from.", "Exit", JOptionPane.YES_NO_CANCEL_OPTION); if (JOptionPane.YES_OPTION == state) { try { save(); setVisible(false); } catch (final IOException ioe) { JOptionPane.showMessageDialog(null, "Error writing to data file: " + ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (JOptionPane.NO_OPTION == state) { setVisible(false); } } }
From source file:edu.ku.brc.specify.dbsupport.SpecifySchemaUpdateService.java
@Override public SchemaUpdateType updateSchema(final String appVerNumber, final String username) { String dbVersion = getDBSchemaVersionFromXML(); String appVerNum = appVerNumber; boolean internalVerNum = isInternalVerNum(appVerNum); boolean useSilentSuccess = false; DBConnection dbConn = DBConnection.getInstance(); if (dbConn != null) { SpVersion.fixSchemaNumber(dbConn); DBMSUserMgr dbMgr = DBMSUserMgr.getInstance(); if (dbMgr.connect(dbConn.getUserName(), dbConn.getPassword(), dbConn.getServerName(), dbConn.getDatabaseName())) { // Here checks to see if this is the first ever boolean doUpdateAppVer = false; boolean doSchemaUpdate = false; boolean doInsert = false; String appVerFromDB = null; String schemaVerFromDB = null; Integer spverId = null; Integer recVerNum = 1; //log.debug("appVerNumArg: ["+appVerNumber+"] dbVersion from XML["+dbVersion+"] "+ dbVersion.compareTo("1.6")); if (dbMgr.doesDBHaveTable("spversion")) { Vector<Object[]> rows = query(dbConn.getConnection(), "SELECT AppVersion, SchemaVersion, SpVersionID, Version FROM spversion ORDER BY TimestampCreated DESC"); if (rows.size() > 0) { Object[] row = (Object[]) rows.get(rows.size() - 1); appVerFromDB = row[0].toString(); schemaVerFromDB = row[1].toString(); spverId = (Integer) row[2]; recVerNum = (Integer) row[3]; log.debug("appVerNumArg: [" + appVerNumber + "] dbVersion from XML[" + dbVersion + "] appVersion[" + appVerFromDB + "] schemaVersion[" + schemaVerFromDB + "] spverId[" + spverId + "] recVerNum[" + recVerNum + "] "); if (appVerNum == null /*happens for developers*/ || internalVerNum) { appVerNum = appVerFromDB; }//from w ww.j a v a2 s. c om if (appVerFromDB == null || schemaVerFromDB == null) { doUpdateAppVer = true; } else if (!appVerFromDB.equals(appVerNum)) { if (checkVersion(appVerFromDB, appVerNum, mkKey("APP_VER_ERR"), mkKey("APP_VER_NEQ_OLD"), mkKey("APP_VER_NEQ_NEW"), false)) { doUpdateAppVer = true; } else { CommandDispatcher.dispatch(new CommandAction(APP, APP_REQ_EXIT, null)); return SchemaUpdateType.Error; } } if (StringUtils.isNotEmpty(schemaVerFromDB)) { boolean doOverrideUpdateSchema = AppPreferences.getLocalPrefs() .getBoolean("UPDATE_SCHEMA", false); if (doOverrideUpdateSchema) { AppPreferences.getLocalPrefs().putBoolean("UPDATE_SCHEMA", false); double currVersion = Double.parseDouble(schemaVerFromDB.trim()); if (currVersion > 1.6) { dbVersion = String.format("%2.1f", currVersion); currVersion -= 0.1; schemaVerFromDB = String.format("%2.1f", currVersion); } } } if (dbVersion != null && schemaVerFromDB != null) { Boolean isDBClosed = false; String dbClosedBy = null; //log.debug("schemaVerFromDB["+schemaVerFromDB+"] compareTo["+schemaVerFromDB.compareTo("1.6")+"] "); if (schemaVerFromDB.compareTo("1.6") > -1) { rows = query(dbConn.getConnection(), "SELECT IsDBClosed, DbClosedBy FROM spversion ORDER BY TimestampCreated DESC"); if (rows.size() > 0) { row = (Object[]) rows.get(rows.size() - 1); isDBClosed = (Boolean) row[0]; dbClosedBy = (String) row[1]; //log.debug("isDBClosed["+isDBClosed+"] dbClosedBy["+dbClosedBy+"] "); } } if (isDBClosed != null && isDBClosed) { if (dbClosedBy != null && !dbClosedBy.equals(username)) { UIRegistry.showLocalizedError("SYSSTP_CLSD_MSG", dbClosedBy); return SchemaUpdateType.Error; } } if (!schemaVerFromDB.equals(dbVersion)) { String errKey = mkKey("DB_VER_NEQ"); if (checkVersion(schemaVerFromDB, dbVersion, mkKey("DB_VER_ERR"), errKey, errKey, false)) { doSchemaUpdate = true; } else { CommandDispatcher.dispatch(new CommandAction(APP, APP_REQ_EXIT, null)); return SchemaUpdateType.Error; } } } } else { //If somebody somehow got a hold of an 'internal' version (via a conversion, or possibly by manually checking for updates. doUpdateAppVer = true; if (appVerNumber != null && appVerNumber.length() > 2) { doSchemaUpdate = true; //Integer.parseInt(appVerNumArg.substring(2, 3)) == 0; useSilentSuccess = true; } } } else { doInsert = true; } try { if (doSchemaUpdate || doInsert || doUpdateAppVer) { if (!appCanUpdateSchema) { UIRegistry.showLocalizedError("SpecifySchemaUpdateService.AppLacksUpdatePermission"); return SchemaUpdateType.Error; } fixDuplicatedPaleoContexts(dbConn.getConnection()); fixLatLonMethodGEOLocate(dbConn.getConnection()); if (doSchemaUpdate || doInsert) { //SpecifySchemaUpdateService.attachUnhandledException(); //BasicSQLUtils.setSkipTrackExceptions(true); if (!askToUpdateSchema()) { CommandDispatcher.dispatch(new CommandAction(APP, APP_REQ_EXIT, null)); return SchemaUpdateType.Error; } /* Warning Dlg about GUID overwrite. See Bug #9356 if (Double.parseDouble(schemaVerFromDB) < 1.8) { String msg = UIRegistry.getResourceString("SpecifySchemaUpdateService.UPDATE_SCH_GUID_OVERWRITE"); boolean opt = UIRegistry.displayConfirm(UIRegistry.getResourceString("SpecifySchemaUpdateService.UPDATE_SCH_GUID_TITLE"), msg, UIRegistry.getResourceString("CONTINUE"), UIRegistry.getResourceString("CANCEL"), JOptionPane.WARNING_MESSAGE); if (!opt) { CommandDispatcher.dispatch(new CommandAction(APP, APP_REQ_EXIT, null)); return SchemaUpdateType.Error; } }*/ String msg = UIRegistry.getResourceString("UPDATE_SCH_BACKUP"); int opt = UIRegistry.askYesNoLocalized("EXIT", "CONTINUE", msg, "MySQLBackupService.BACKUP_NOW"); if (opt == JOptionPane.YES_OPTION) { CommandDispatcher.dispatch(new CommandAction(APP, APP_REQ_EXIT, null)); return SchemaUpdateType.Error; } itUserNamePassword = DatabaseLoginPanel.getITUsernamePwd(); if (itUserNamePassword != null) { DBConnection dbc = DBConnection.getInstance(); DBMSUserMgr dbmsMgr = DBMSUserMgr.getInstance(); if (dbmsMgr.connectToDBMS(itUserNamePassword.first, itUserNamePassword.second, dbc.getServerName())) { if (!dbmsMgr.checkPermissionsForUpdate(itUserNamePassword.first, dbConn.getDatabaseName())) { dbmsMgr.close(); //errMsgList.add("You must have permissions to alter database tables."); errMsgList.add(dbmsMgr.getErrorMsg()); //CommandDispatcher.dispatch(new CommandAction(APP, APP_REQ_EXIT, null)); return SchemaUpdateType.Error; } } dbmsMgr.close(); frame = new ProgressFrame(getResourceString("UPDATE_SCHEMA_TITLE")); frame.adjustProgressFrame(); frame.getCloseBtn().setVisible(false); frame.getProcessProgress().setIndeterminate(true); frame.setDesc(UIRegistry.getLocalizedMessage("UPDATE_SCHEMA", dbVersion)); //frame.setOverall(0, OVERALL_TOTAL); UIHelper.centerAndShow(frame); //BasicSQLUtils.setSkipTrackExceptions(true); // Needs to be reset boolean ok = manuallyFixDB(DatabaseDriverInfo.getDriver(dbc.getDriver()), dbc.getServerName(), dbc.getDatabaseName(), itUserNamePassword.first, itUserNamePassword.second); if (!ok) { frame.setVisible(false); return SchemaUpdateType.Error; } frame.setProcess(0, 100); frame.setDesc("Updating Schema..."); ok = SpecifySchemaGenerator.updateSchema( DatabaseDriverInfo.getDriver(dbc.getDriver()), dbc.getServerName(), dbc.getDatabaseName(), itUserNamePassword.first, itUserNamePassword.second); if (ok) { ok &= finishSchemaUpdate(DatabaseDriverInfo.getDriver(dbc.getDriver()), dbc.getServerName(), dbc.getDatabaseName(), itUserNamePassword.first, itUserNamePassword.second); } if (!ok) { errMsgList.add("There was an error updating the schema."); frame.setVisible(false); return SchemaUpdateType.Error; } frame.setVisible(false); fixSchemaMappingScope(dbConn.getConnection(), dbConn.getDatabaseName()); fixLocaleSchema(); // Unhide All GUID fields for Schema 1.8 String updateSQL = "UPDATE splocalecontaineritem SET IsHidden=FALSE WHERE LOWER(Name) = 'guid'"; BasicSQLUtils.update(dbConn.getConnection(), updateSQL); } else { CommandDispatcher.dispatch(new CommandAction(APP, APP_REQ_EXIT, null)); return SchemaUpdateType.Error; } //UIHelper.attachUnhandledException(); //BasicSQLUtils.setSkipTrackExceptions(false); } if (doInsert || (appVerFromDB == null && schemaVerFromDB == null)) { SpVersion.createInitialRecord(dbConn.getConnection(), appVerNum, dbVersion); } else if (doSchemaUpdate || doUpdateAppVer) { fixDuplicatedPaleoContexts(dbConn.getConnection()); recVerNum++; SpVersion.updateRecord(dbConn.getConnection(), appVerNum, dbVersion, recVerNum, spverId); } boolean onlyAppVersion = !doSchemaUpdate && doUpdateAppVer; return useSilentSuccess ? SchemaUpdateType.SuccessSilent : onlyAppVersion ? SchemaUpdateType.SuccessAppVer : SchemaUpdateType.Success; } else { return SchemaUpdateType.NotNeeded; } } catch (Exception e) { e.printStackTrace(); //processUnhandledException(e); } finally { dbMgr.close(); } } } return SchemaUpdateType.Error; }
From source file:com.proyecto.vista.MantenimientoClase.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;//from w w w .j a v a 2 s . co m if (tblclase.getSelectedRow() != -1) { Integer id = tblclase.getSelectedRow(); // Clase clase = claseControlador.buscarPorId(lista.get(id).getId()); if (tblclase.getSelectedRow() != -1) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Clase?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { // int[] filas = tblclase.getSelectedRows(); // for (int i = 0; i < filas.length; i++) { // Clase clase2 = lista.get(filas[0]); claseControlador.setSeleccionado(lista.get(id)); lista.remove(lista.get(id)); claseControlador.accion(accion); // } if (claseControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Clase eliminada correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Clase no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Clase no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar una clase", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:com.dragoniade.deviantart.favorites.FavoritesDownloader.java
private void deleteEmptyFolders(File file) { File current = file;//w ww .jav a2s.c o m do { if (current.exists()) { if (current.isFile()) { return; } if (current.listFiles().length == 0) { if (!current.delete()) { int result = JOptionPane.showConfirmDialog(owner, "Unable to delete '" + current.getAbsolutePath() + "'. Try again?", "Error", JOptionPane.ERROR_MESSAGE); if (result != JOptionPane.YES_OPTION) { return; } } } else { return; } } else { current = current.getParentFile(); } } while (current != null); }