List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) throws HeadlessException
optionType
parameter. From source file:com.diversityarrays.kdxplore.trials.TrialViewPanel.java
private void doRemoveTraitInstancesWithoutSamples() { TableModel model = trialDataTable.getModel(); if (model instanceof TrialData) { TrialData trialData = (TrialData) model; TraitNameStyle tns = trialData.trial.getTraitNameStyle(); List<Integer> modelRows = GuiUtil.getSelectedModelRows(trialDataTable); List<TraitInstance> withData = new ArrayList<>(); List<TraitInstance> withoutData = new ArrayList<>(); for (Integer row : modelRows) { TraitInstance ti = trialData.getTraitInstanceAt(row); int traitId = ti.getTraitId(); int instanceNumber = ti.getInstanceNumber(); boolean[] anyScored = new boolean[1]; BiPredicate<SampleGroup, KdxSample> sampleVisitor = new BiPredicate<SampleGroup, KdxSample>() { @Override/*from w w w .jav a2 s .c om*/ public boolean test(SampleGroup sg, KdxSample s) { if (traitId != s.getTraitId()) { return true; // not the correct trait } if (instanceNumber != s.getTraitInstanceNumber()) { return true; // not the correct trait } // Ok - it is for this traitInstance if (s.hasBeenScored()) { anyScored[0] = true; return false; } return true; // keep looking for scored samples } }; trialData.visitSampleGroupSamples(sampleVisitor); if (anyScored[0]) { withData.add(ti); } else { withoutData.add(ti); } } if (withoutData.isEmpty()) { if (withData.isEmpty()) { MsgBox.warn(TrialViewPanel.this, "Nothing to do!", "Remove Trait/Instances"); } else { String s = withData.stream().map(ti -> tns.makeTraitInstanceName(ti)) .collect(Collectors.joining("</li><li>", "<html>With Data:<ul><li>", "</li></ul>")); MsgBox.warn(TrialViewPanel.this, s, "Cannot remove Traits with Data"); } } else { String s = withoutData.stream().map(ti -> tns.makeTraitInstanceName(ti)) .collect(Collectors.joining("</li><li>", "<html><ul><li>", "</li></ul>")); int answer = JOptionPane.showConfirmDialog(TrialViewPanel.this, s, "Confirm Trait Instance Removeal", JOptionPane.YES_NO_OPTION); if (JOptionPane.YES_OPTION == answer) { try { offlineData.getKdxploreDatabase().removeTraitInstancesFromTrial(trial, withoutData); } catch (IOException e) { MsgBox.warn(TrialViewPanel.this, e, "Remove Trait/Instances from Trial"); } finally { setCurrentTrialDetails(trial, false); onTraitInstancesRemoved.accept(trial); } } } } }
From source file:com.mirth.connect.client.ui.SettingsPanelServer.java
public void doRestore() { if (getFrame().isSaveEnabled()) { if (!getFrame().alertOkCancel(this, "Your new settings will first be saved. Continue?")) { return; }/* w w w .j a va2 s .c o m*/ if (!doSave()) { return; } } String content = getFrame().browseForFileString("XML"); if (content != null) { try { if (!getFrame().promptObjectMigration(content, "server configuration")) { return; } final ServerConfiguration configuration = ObjectXMLSerializer.getInstance().deserialize(content, ServerConfiguration.class); final JCheckBox deployChannelsCheckBox = new JCheckBox("Deploy all channels after import"); deployChannelsCheckBox.setSelected(true); String warningMessage = "Import configuration from " + configuration.getDate() + "?\nWARNING: This will overwrite all current channels,\nalerts, server properties, and plugin properties.\n"; Object[] params = { warningMessage, new JLabel(" "), deployChannelsCheckBox }; int option = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { final Set<String> alertIds = new HashSet<String>(); for (AlertStatus alertStatus : PlatformUI.MIRTH_FRAME.mirthClient.getAlertStatusList()) { alertIds.add(alertStatus.getId()); } final String workingId = getFrame().startWorking("Restoring server config..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { private boolean updateAlerts = false; public Void doInBackground() { try { getFrame().mirthClient.setServerConfiguration(configuration, deployChannelsCheckBox.isSelected()); getFrame().channelPanel.clearChannelCache(); doRefresh(); getFrame().alertInformation(SettingsPanelServer.this, "Your configuration was successfully restored."); updateAlerts = true; } catch (ClientException e) { getFrame().alertThrowable(SettingsPanelServer.this, e); } return null; } public void done() { if (getFrame().alertPanel == null) { getFrame().alertPanel = new DefaultAlertPanel(); } if (updateAlerts) { getFrame().alertPanel.updateAlertDetails(alertIds); } getFrame().stopWorking(workingId); } }; worker.execute(); } } catch (Exception e) { getFrame().alertError(this, "Invalid server configuration file."); } } }
From source file:Formulario.CapturaHuella.java
private void btnConfiguracionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfiguracionActionPerformed // TODO add your handling code here: stop();/*from www . ja v a2 s . c o m*/ int op = JOptionPane.showConfirmDialog(this, "No modifique estos parametros al menos que se requiera.\n" + "Desea configurar?", "Desea configurar?", JOptionPane.YES_NO_OPTION); if (op == JOptionPane.OK_OPTION) { // Ingreso in=new Ingreso(this, true); try { new Ingreso(this, true).setVisible(true); dispose(); } catch (Exception ex) { Logger.getLogger(CapturaHuella.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.firmansyah.imam.sewa.kendaraan.FormUser.java
private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHapusActionPerformed String id = inputIdUser.getText(); System.out.println("Memilih ID : " + id); int dialogButton = JOptionPane.YES_NO_OPTION; int dialogResult; dialogResult = JOptionPane.showConfirmDialog(this, "Anda yakin Menghapus Data ini? ", "Konfirmasi", dialogButton);//from w w w .j ava2 s .c o m if (dialogResult == 0) { String url = Path.serverURL + "/user/delete/" + id; getDataURL dataurl = new getDataURL(); try { String data = dataurl.getData(url); System.out.println(data); if (data.equals("1")) { JOptionPane.showMessageDialog(this, "Data Berhasil dihapus", "Informasi", JOptionPane.INFORMATION_MESSAGE); System.out.println("Menghapus Data ID : " + id); } else { JOptionPane.showMessageDialog(this, "Data Tidak Berhasil dihapus", "Informasi", JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { Logger.getLogger(FormUser.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(this, "Data Tidak Bisa dihapus\nKarena Memiliki Relasi dengan Data Lainnya", "Informasi", JOptionPane.ERROR_MESSAGE); } } else { System.out.println("Tidak Menghapus : " + id); } // refresh form refreshForm(); }
From source file:com._17od.upm.gui.DatabaseActions.java
public void deleteAccount() throws IOException, CryptoException, TransportException, ProblemReadingDatabaseFile, PasswordDatabaseException {/*from ww w.j a va 2 s. c o m*/ if (getLatestVersionOfDatabase()) { SortedListModel listview = (SortedListModel) mainWindow.getAccountsListview().getModel(); String selectedAccName = (String) mainWindow.getAccountsListview().getSelectedValue(); int buttonSelected = JOptionPane.showConfirmDialog(mainWindow, Translator.translate("askConfirmDeleteAccount", selectedAccName), Translator.translate("confirmDeleteAccount"), JOptionPane.YES_NO_OPTION); if (buttonSelected == JOptionPane.OK_OPTION) { //Remove the account from the listview, accountNames arraylist & the database listview.removeElement(selectedAccName); int i = accountNames.indexOf(selectedAccName); accountNames.remove(i); database.deleteAccount(selectedAccName); saveDatabase(); //[1375385] Call the filter method so that the listview is //reinitialised with the remaining matching items filter(); } } }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoFactura.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = AbstractControlador.ELIMINAR; 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); }/*from w w w. j a v a 2 s . c o m*/ 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:com.proyecto.vista.MantenimientoUnidadMedida.java
private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed // TODO add your handling code here: String palabra = ""; String palabra2 = ""; if (accion == 1) { palabra = "registrar"; palabra2 = "registrado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " la Unidad?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { unidadControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); unidadControlador.getSeleccionado().setAbreviatura(abreviaturaField.getText().toUpperCase()); unidadControlador.accion(accion); lista.add(unidadControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Unidad " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Unidad no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); }//from ww w . j ava 2s. c o m } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Unidad no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " la Unidad?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Unidad " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); unidadControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); unidadControlador.getSeleccionado().setAbreviatura(abreviaturaField.getText().toUpperCase()); unidadControlador.accion(accion); listar(); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Unidad no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Unidad no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); }
From source file:com.proyecto.vista.MantenimientoPeriodo.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;/*from www. java 2 s . c o m*/ if (tblperiodo.getSelectedRow() != -1) { Integer codigo = tblperiodo.getSelectedRow(); Periodo periodo = periodoControlador.buscarPorId(lista.get(codigo).getId()); if (periodo != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Periodo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblperiodo.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Periodo periodo2 = lista.get(filas[0]); lista.remove(periodo2); periodoControlador.setSeleccionado(periodo2); periodoControlador.accion(accion); } if (periodoControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Periodo eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Periodo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Periodo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Periodo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:strobe.spectroscopy.StrobeSpectroscopy.java
private void menuFileSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFileSaveActionPerformed int result = fileChooser.showSaveDialog(this); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); if (selectedFile.exists()) { int resultOverride = JOptionPane.showConfirmDialog(this, "File is already exists.", "Rewrite file?", JOptionPane.YES_NO_CANCEL_OPTION); switch (resultOverride) { case JOptionPane.NO_OPTION: menuFileSaveActionPerformed(evt); return; case JOptionPane.CANCEL_OPTION: fileChooser.cancelSelection(); return; }//from w w w .j a va 2 s . com fileChooser.approveSelection(); } String name = selectedFile.getName(); String fileNameForSave = (name.contains(".txt") ? selectedFile.getPath() : selectedFile.getPath() + ".txt"); if (!dataGraphList.isEmpty()) { DataUtils.writeData(dataGraphList, fileNameForSave); } else { JOptionPane.showMessageDialog(this, "No data to write!"); fileChooser.cancelSelection(); } } dataGraphList.clear(); }
From source file:canreg.client.gui.management.CanReg4MigrationInternalFrame.java
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked // TODO add your handling code here: list = (JList) evt.getSource(); if (list.getModel().getSize() > 0) { if (list.isSelectedIndex(list.getSelectedIndex())) { okButton.setEnabled(true);/*from w ww . j av a2 s . co m*/ } regcode = registryCodes.get(list.getSelectedIndex()); filepath = paths.get(list.getSelectedIndex()); DBSearch dbs = new DBSearch(); File[] dbList = dbs.getDBList(filepath); int dbSearch = (dbs.searchDB(dbList)) ? 1 : 0; switch (dbSearch) { case 0: okButton.setEnabled(false); JOptionPane.showConfirmDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), "'" + dlm.get(list.getSelectedIndex()) + "' DB Files are Missing.\nPlease Confirm Location '" + CR4Path + regcode + "'", "Missing DB Files.", JOptionPane.PLAIN_MESSAGE); break; case 1: String dicFile = dbs.getDicDB(dbList); String datFile = dbs.getDatDB(dbList); if (dicFile == null || datFile == null) { okButton.setEnabled(false); JOptionPane.showConfirmDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), "'" + dlm.get(list.getSelectedIndex()) + "' DB Files are Missing.\nPlease Confirm Location '" + CR4Path + regcode + "'", "Missing DB Files.", JOptionPane.PLAIN_MESSAGE); } if (dicFile != null && datFile != null) { String dicname = "CR4-" + regcode + "D.DB"; String dataname = "CR4-" + regcode + "M.DB"; int dicdb = dicFile.equalsIgnoreCase(dicname) ? 1 : 0; int datdb = datFile.equalsIgnoreCase(dataname) ? 1 : 0; switch (dicdb) { case 0: okButton.setEnabled(false); JOptionPane.showConfirmDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), "Incorrect Dictionary Name.\nExpected: " + dicname + ", Found " + dicFile, "Incorrect Dictionary File Name.", JOptionPane.PLAIN_MESSAGE); switch (datdb) { case 0: okButton.setEnabled(false); JOptionPane.showConfirmDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), "Incorrect Data Name.\nExpected: " + dataname + ", Found " + datFile, "Incorrect Data File Name.", JOptionPane.PLAIN_MESSAGE); break; case 1: okButton.setEnabled(false); break; } break; case 1: switch (datdb) { case 0: okButton.setEnabled(false); JOptionPane.showConfirmDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), "Incorrect Data Name.\nExpected: " + dataname + ", Found " + datFile, "Incorect Data File Name.", JOptionPane.PLAIN_MESSAGE); break; case 1: dictionary = dicFile; data = datFile; okButton.setEnabled(true); break; } break; } } break; } } }