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:io.github.jeddict.jpa.modeler.properties.PropertiesHandler.java
public static ComboBoxPropertySupport getCollectionTypeProperty( AttributeWidget<? extends Attribute> attributeWidget, final CollectionTypeHandler colSpec) { JPAModelerScene modelerScene = attributeWidget.getModelerScene(); EntityMappings em = modelerScene.getBaseElementSpec(); ModelerFile modelerFile = modelerScene.getModelerFile(); ComboBoxListener<String> comboBoxListener = new ComboBoxListener<String>() { private final Set<String> value = new HashSet<>(); @Override/*from w w w . j a va2s . c o m*/ public void setItem(ComboBoxValue<String> value) { String prevType = colSpec.getCollectionType(); String newType = value.getValue(); setCollectionType(value); manageMapType(prevType, newType); attributeWidget.setAttributeTooltip(); attributeWidget.visualizeDataType(); } void setCollectionType(ComboBoxValue<String> value) { String collectionType = value.getValue(); boolean valid = validateCollectionType(collectionType, colSpec.getCollectionImplType(), true); boolean nextValidation = valid; if (!nextValidation) { try { if (StringUtils.isNotBlank(collectionType)) { if (java.util.Collection.class.isAssignableFrom(Class.forName(collectionType.trim())) || java.util.Map.class.isAssignableFrom(Class.forName(collectionType.trim()))) { nextValidation = true; } } } catch (ClassNotFoundException ex) { //skip allow = false; } } if (!nextValidation) { collectionType = java.util.Collection.class.getName(); } colSpec.setCollectionType(collectionType); em.getCache().addCollectionClass(collectionType); if (!valid) { attributeWidget.refreshProperties(); } } void manageMapType(String prevType, String newType) { Class prevClass = null; try { prevClass = Class.forName(prevType); } catch (ClassNotFoundException ex) { } Class newClass = null; try { newClass = Class.forName(newType); } catch (ClassNotFoundException ex) { } if ((prevClass != null && newClass != null && prevClass != newClass && (Map.class.isAssignableFrom(prevClass) || Map.class.isAssignableFrom(newClass))) || (prevClass == null && newClass != null && Map.class.isAssignableFrom(newClass)) || (prevClass != null && newClass == null && Map.class.isAssignableFrom(prevClass))) { if (newClass == null || !Map.class.isAssignableFrom(newClass)) { ((MapKeyHandler) attributeWidget.getBaseElementSpec()).resetMapAttribute(); } attributeWidget.refreshProperties(); } } @Override public ComboBoxValue<String> getItem() { if (!value.contains(colSpec.getCollectionType())) { value.add(colSpec.getCollectionType()); em.getCache().addCollectionClass(colSpec.getCollectionType()); } return new ComboBoxValue(colSpec.getCollectionType(), colSpec.getCollectionType().substring(colSpec.getCollectionType().lastIndexOf('.') + 1)); } @Override public List<ComboBoxValue<String>> getItemList() { List<ComboBoxValue<String>> comboBoxValues = new ArrayList<>(); value.addAll(em.getCache().getCollectionClasses()); em.getCache().getCollectionClasses().stream().filter(StringUtils::isNotEmpty) .forEach((collection) -> { Class _class; try { _class = Class.forName(collection); comboBoxValues.add(new ComboBoxValue(_class.getName(), _class.getSimpleName())); } catch (ClassNotFoundException ex) { comboBoxValues.add(new ComboBoxValue(collection, collection + "(Not Exist)")); } }); return comboBoxValues; } @Override public String getDefaultText() { return EMPTY; } @Override public ActionHandler getActionHandler() { return ActionHandler.getInstance(() -> { String collectionType = NBModelerUtil.browseClass(modelerFile); try { if (Collection.class.isAssignableFrom(Class.forName(collectionType)) || Map.class.isAssignableFrom(Class.forName(collectionType))) { return new ComboBoxValue<>(collectionType, collectionType.substring(collectionType.lastIndexOf('.') + 1)); } } catch (ClassNotFoundException ex) { } throw new IllegalStateException("Invalid Collection/Map type"); }).afterCreation(e -> em.getCache().addCollectionClass(e.getValue())) .afterDeletion(e -> em.getCache().getCollectionClasses().remove(e.getValue())) .beforeDeletion( () -> JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(), "Are you sue you want to delete this collection class ?", "Delete Collection Class", JOptionPane.OK_CANCEL_OPTION)); } }; return new ComboBoxPropertySupport(modelerScene.getModelerFile(), "collectionType", "Collection Type", "", comboBoxListener); }
From source file:com.tiempometa.muestradatos.JMuestraDatos.java
private void loadReadingsButtonActionPerformed(ActionEvent e) { if (ReaderContext.isFoxberryConnected() || (ReaderContext.isUsbConnected())) { JLoadTimeReadings loadReadings = new JLoadTimeReadings(); loadReadings.setVisible(true);// w ww. j a v a 2s . c om } else { JOptionPane.showConfirmDialog(this, "Se debe conectar a un lector primero", "Sin conexin a lectores", JOptionPane.WARNING_MESSAGE); } }
From source file:com.nwn.NwnUpdaterHomeView.java
/** * Delete server from gui and config/*from w ww .j a va 2 s. c o m*/ * Currently this cannot be undone * @param evt */ private void btnRemoveServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveServerActionPerformed ServerInfo selectedServer = (ServerInfo) cmbServerList.getSelectedItem(); int confirm = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + selectedServer.getServerName() + "?", "Warning", JOptionPane.YES_NO_OPTION); if (confirm == JOptionPane.YES_OPTION) { config.getServerList().remove(cmbServerList.getSelectedItem()); cmbServerList.removeItemAt(cmbServerList.getSelectedIndex()); config.save(); } }
From source file:MstrPetugas.FormPetugas.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed String kode = tabel_petugas.getValueAt(tabel_petugas.getSelectedRow(), 0).toString(); int jawab = JOptionPane.showConfirmDialog(this, "Hapus ? Data Petugas : " + kode, "Konfirmasi", JOptionPane.YES_NO_OPTION); if (jawab == JOptionPane.YES_OPTION) { MstrPetugas x = new MstrPetugas(); x.Delete(kode);//w ww . j av a 2s. c om LoadData(); } }
From source file:net.sf.profiler4j.console.Console.java
/** * // w w w . j a v a 2 s .c o m * @return <code>true</code> if the user has cancelled */ private boolean checkUnsavedChanges() { if (project.isChanged()) { int ret = JOptionPane.showConfirmDialog(mainFrame, "Project has unsaved changes? Save before exit?", "Unsaved Changes", JOptionPane.YES_NO_CANCEL_OPTION); if (ret == JOptionPane.CANCEL_OPTION) { return true; } else if (ret == JOptionPane.YES_OPTION) { return saveProject(false); } } return false; }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
public void fileSaveBankAs(SpinCADBank b) { // Create a file chooser String savedPath = prefs.get("MRUBankFolder", ""); final JFileChooser fc = new JFileChooser(savedPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("SpinCAD Bank Files", "spbk"); fc.setFileFilter(filter);/* w w w .java2 s. c o m*/ fc.setSelectedFile(new File(b.bankFileName)); int returnVal = fc.showSaveDialog(new JFrame()); // need to process user canceling box right here if (returnVal == JFileChooser.APPROVE_OPTION) { // In response to a button click: File fileToBeSaved = fc.getSelectedFile(); if (!fc.getSelectedFile().getAbsolutePath().endsWith(".spbk")) { fileToBeSaved = new File(fc.getSelectedFile() + ".spbk"); } b.bankFileName = fileToBeSaved.getName(); int n = JOptionPane.YES_OPTION; if (fileToBeSaved.exists()) { JFrame frame = new JFrame(); n = JOptionPane.showConfirmDialog(frame, "Would you like to overwrite it?", "File already exists!", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { try { fileSaveBank(b); } finally { } } } else { fileSaveBank(b); } b.changed = false; recentBankFileList.add(fileToBeSaved); saveMRUBankFolder(fileToBeSaved.getPath()); b.bankFileName = fileToBeSaved.getName(); } }
From source file:com.tiempometa.muestradatos.JMuestraDatos.java
private void countTagsButtonActionPerformed(ActionEvent e) { if (ReaderContext.isFoxberryConnected()) { JCountTags countTags = new JCountTags(this); countTags.setVisible(true);//from w ww .j a v a 2 s . c o m } else { JOptionPane.showConfirmDialog(this, "Se debe conectar a un lector primero", "Sin conexin a lectores", JOptionPane.WARNING_MESSAGE); } }
From source file:dylemator.UserResultList.java
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed int row = this.codeTable.getSelectedRow(); if (row == -1) return;// ww w . java 2 s . c om String[] values = exportData.get(row + 1); int dialogResult = JOptionPane.showConfirmDialog(null, "Usun wyniki uytkownika " + values[0] + "?", "Warning", JOptionPane.YES_NO_OPTION); if (dialogResult == JOptionPane.YES_OPTION) { exportData.remove(row + 1); DefaultTableModel m = (DefaultTableModel) codeTable.getModel(); m.setRowCount(0); for (int i = 1; i < exportData.size(); i++) { m.addRow(new String[] { exportData.get(i)[0] }); } DefaultTableModel n = (DefaultTableModel) infoTable.getModel(); DefaultTableModel o = (DefaultTableModel) resultsTable.getModel(); n.setRowCount(0); o.setRowCount(0); try { OutputStreamWriter output = new FileWriter(this.selectedFilename); BufferedWriter bufferWriter = new BufferedWriter(output); for (String[] v : exportData) { String s = StringUtils.join(v, ";"); bufferWriter.write(s + "\n"); } bufferWriter.flush(); bufferWriter.close(); } catch (IOException ex) { Logger.getLogger(UserResultList.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoTipo.java
private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed // TODO add your handling code here: List<Integer> array = new ArrayList(); array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.nombreField, "Nombre")); FormularioUtil.validar2(array);/*w w w. jav a 2 s. com*/ if (FormularioUtil.error) { JOptionPane.showMessageDialog(null, FormularioUtil.mensaje, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); FormularioUtil.mensaje = ""; FormularioUtil.error = false; } else { String palabra = ""; String palabra2 = ""; if (accion == 1) { palabra = "registrar"; palabra2 = "registrado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { tipoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); tipoControlador.accion(accion); lista.add(tipoControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Tipo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Tipo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); tipoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); tipoControlador.accion(accion); listar(); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } FormularioUtil.limpiarComponente(panelDatos); FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); } }
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Prompts the user if they want to save. * * @return false if they want to cancel//from ww w.jav a2 s . c o m */ private boolean askToSave() { int i = JOptionPane.showConfirmDialog(this, "Would you like to save your work first?", "Unsaved Work", JOptionPane.YES_NO_CANCEL_OPTION); if (i == 2) return false; if (i == 0) { try { Main.savePages().join(); } catch (InterruptedException e) { e.printStackTrace(); } } return true; }