List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION
int OK_CANCEL_OPTION
To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. From source file:org.pgptool.gui.ui.tools.UiUtils.java
public static boolean confirm(String userPromptMessageCode, Object[] messageArgs, Window parent) { int response = JOptionPane.OK_OPTION; String msg = Messages.get(userPromptMessageCode, messageArgs); if (msg.length() > 70) { response = JOptionPane.showConfirmDialog(parent, getMultilineMessage(msg), Messages.get("term.confirmation"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); } else {// w w w . j a v a2 s . co m response = JOptionPane.showConfirmDialog(parent, msg, Messages.get("term.confirmation"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); } return response == JOptionPane.OK_OPTION; }
From source file:org.richie.codeGen.ui.GenAndPreviewUI.java
private boolean initCustomerVelocityContext(CodeTemplateVo vo) throws Exception { Table selectedTable = parent.getTable(); if (selectedTable == null) { int status = JOptionPane.showConfirmDialog(this, "?", "??", JOptionPane.OK_CANCEL_OPTION); if (status != JOptionPane.OK_OPTION) { return false; }/*from w w w .j av a 2 s . co m*/ } setTableValue(); // ????? DataTypeUtils.setDataType(selectedTable); if (selectedTable != null && selectedTable.getChildTable() != null) { DataTypeUtils.setDataType(selectedTable.getChildTable()); } Map<String, Object> map = GlobalData.getConstentMap(); CodeGen.initCustomerVelocityContext(map); return true; }
From source file:org.signserver.admin.gui.MainView.java
private void authAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authAddButtonActionPerformed editSerialNumberTextfield.setText(""); editSerialNumberTextfield.setEditable(true); editIssuerDNTextfield.setText(""); editIssuerDNTextfield.setEditable(true); editUpdateAllCheckbox.setSelected(false); final int res = JOptionPane.showConfirmDialog(getFrame(), authEditPanel, "Add authorized client", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (res == JOptionPane.OK_OPTION) { List<Worker> workers; if (editUpdateAllCheckbox.isSelected()) { workers = selectedWorkers;//from www . j a v a 2s .c o m } else { workers = Collections.singletonList(selectedWorker); } if (LOG.isDebugEnabled()) { LOG.debug("Selected workers: " + workers); } for (Worker worker : workers) { try { final BigInteger sn = new BigInteger(editSerialNumberTextfield.getText(), 16); org.signserver.admin.gui.adminws.gen.AuthorizedClient client = new org.signserver.admin.gui.adminws.gen.AuthorizedClient(); client.setCertSN(sn.toString(16)); client.setIssuerDN( org.cesecore.util.CertTools.stringToBCDNString(editIssuerDNTextfield.getText())); SignServerAdminGUIApplication.getAdminWS().addAuthorizedClient(worker.getWorkerId(), client); SignServerAdminGUIApplication.getAdminWS().reloadConfiguration(worker.getWorkerId()); } catch (AdminNotAuthorizedException_Exception ex) { showAdminNotAuthorized(ex); } catch (NumberFormatException ex) { showMalformedSerialNumber(ex); } catch (SOAPFaultException ex) { showServerSideException(ex); } catch (EJBException ex) { showServerSideException(ex); } } refreshButton.doClick(); } }
From source file:org.signserver.admin.gui.MainView.java
private void authEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authEditButtonActionPerformed final int row = authTable.getSelectedRow(); if (row != -1) { final String serialNumberBefore = (String) authTable.getValueAt(row, 0); final String issuerDNBefore = (String) authTable.getValueAt(row, 1); editSerialNumberTextfield.setText(serialNumberBefore); editSerialNumberTextfield.setEditable(true); editIssuerDNTextfield.setText(issuerDNBefore); editIssuerDNTextfield.setEditable(true); editUpdateAllCheckbox.setSelected(false); final int res = JOptionPane.showConfirmDialog(getFrame(), authEditPanel, "Edit authorized client", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (res == JOptionPane.OK_OPTION) { try { List<Worker> workers; if (editUpdateAllCheckbox.isSelected()) { workers = selectedWorkers; } else { workers = Collections.singletonList(selectedWorker); }/*from w w w . j a va 2 s . c o m*/ if (LOG.isDebugEnabled()) { LOG.debug("Selected workers: " + workers); } final AuthorizedClient oldAuthorizedClient = new AuthorizedClient(); oldAuthorizedClient.setCertSN(serialNumberBefore); oldAuthorizedClient.setIssuerDN(issuerDNBefore); final AuthorizedClient client = new AuthorizedClient(); final BigInteger sn = new BigInteger(editSerialNumberTextfield.getText(), 16); client.setCertSN(sn.toString(16)); client.setIssuerDN( org.cesecore.util.CertTools.stringToBCDNString(editIssuerDNTextfield.getText())); for (Worker worker : workers) { try { boolean removed = SignServerAdminGUIApplication.getAdminWS() .removeAuthorizedClient(worker.getWorkerId(), oldAuthorizedClient); if (removed) { SignServerAdminGUIApplication.getAdminWS().addAuthorizedClient(worker.getWorkerId(), client); SignServerAdminGUIApplication.getAdminWS() .reloadConfiguration(worker.getWorkerId()); } } catch (AdminNotAuthorizedException_Exception ex) { showAdminNotAuthorized(ex); } catch (SOAPFaultException ex) { showServerSideException(ex); } catch (EJBException ex) { showServerSideException(ex); } } refreshButton.doClick(); } catch (NumberFormatException e) { showMalformedSerialNumber(e); } } } }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
/** * Handles clicking the "New Rule" button. * * @param evt The event which caused this call. */// ww w . j a v a 2 s .com private void bnNewRuleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnNewRuleActionPerformed if (hasRuleChanged()) { // if rule has changed without saving if (JOptionPane.showConfirmDialog(this, NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.UnsavedChangesLost"), NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ChangesWillBeLost"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.CANCEL_OPTION) { // they were not quite ready to navigate away yet, so clear the selection treeSelectionModel.clearSelection(); return; } } clearRuleEditor(); localRule = makeRuleFromUserInput(); }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
/** * Handles clicking the "Delete Rule" button. * * @param evt The event which caused this call. *//*from www .j av a 2 s . co m*/ private void bnDeleteRuleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnDeleteRuleActionPerformed Item item = (Item) ((DefaultMutableTreeNode) trRuleList.getLastSelectedPathComponent()).getUserObject(); if (item != null) { if (item.getItemType() == ItemType.RULE) { String ruleName = item.getName(); if (JOptionPane.showConfirmDialog(this, NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ReallyDeleteRule") + " " + ruleName + NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.QuestionMark"), NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ConfirmRuleDeletion"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION) { exportRuleSet.removeRule(ruleName); clearRuleEditor(); localRule = makeRuleFromUserInput(); populateRuleTree(ruleName); } } } else { logger.log(Level.WARNING, "Nothing selected to delete"); } }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
private void bnDeleteAttributeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnDeleteAttributeActionPerformed String selection = lsAttributeList.getSelectedValue(); if (selection != null && !selection.isEmpty()) { Item item = (Item) ((DefaultMutableTreeNode) trRuleList.getLastSelectedPathComponent()).getUserObject(); if (item != null) { if (JOptionPane.showConfirmDialog(this, NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ReallyDeleteCondition") + " " + selection + NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.QuestionMark"), NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ConfirmClauseDeletion"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION) { String ruleName = item.getRuleName(); // get the rule Rule rule = exportRuleSet.getRule(ruleName); // find the clause and remove it for (ArtifactCondition ac : rule.getArtifactConditions()) { if (selection.compareTo(ac.getTreeDisplayName()) == 0) { rule.removeArtifactCondition(ac); break; }// w w w. ja v a 2 s . co m } if (isRuleEmpty(rule)) { exportRuleSet.removeRule(rule); } populateRuleTree(ruleName); } } } }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
private void trRuleListValueChanged(javax.swing.event.TreeSelectionEvent evt) { int selectionCount = treeSelectionModel.getSelectionCount(); lsAttributeList.removeAll();/*from w w w .j a v a 2 s .c o m*/ attributeListModel.removeAllElements(); if (selectionCount > 0) { if (hasRuleChanged()) { // and the rule has changed without saving if (JOptionPane.showConfirmDialog(this, NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.UnsavedChangesLost"), NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ChangesWillBeLost"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.CANCEL_OPTION) { // they were not quite ready to navigate away yet, so clear the selection trRuleList.clearSelection(); return; } } DefaultMutableTreeNode node = (DefaultMutableTreeNode) trRuleList.getLastSelectedPathComponent(); if (node == null) { // Nothing is selected return; } Item nodeInfo = (Item) node.getUserObject(); bnDeleteRule.setEnabled(nodeInfo.getItemType() == ItemType.RULE); if (nodeInfo.getItemType() == ItemType.RULE_SET) { tbRuleName.setText(null); clearSizeCondition(); clearMIMECondition(); clearArtifactCondition(); localRule = makeRuleFromUserInput(); return; } String selectedRuleName = nodeInfo.getRuleName(); Rule rule = exportRuleSet.getRules().get(selectedRuleName); if (rule != null) { // Read values for this rule and display them in the UI tbRuleName.setText(rule.getName()); FileMIMETypeCondition fileMIMETypeCondition = rule.getFileMIMETypeCondition(); if (fileMIMETypeCondition != null) { // if there is a MIME type condition cbMimeType.setSelected(true); comboBoxMimeTypeComparison.setSelectedItem(fileMIMETypeCondition.getRelationalOp().getSymbol()); comboBoxMimeValue.setSelectedItem(fileMIMETypeCondition.getMIMEType()); } else { // Clear the selection clearMIMECondition(); } List<FileSizeCondition> fileSizeCondition = rule.getFileSizeConditions(); if (fileSizeCondition != null && !fileSizeCondition.isEmpty()) { // if there is a file size condition FileSizeCondition condition = fileSizeCondition.get(0); cbFileSize.setSelected(true); spFileSizeValue.setValue(condition.getSize()); comboBoxFileSizeUnits.setSelectedItem(condition.getUnit().toString()); comboBoxFileSizeComparison.setSelectedItem(condition.getRelationalOperator().getSymbol()); } else { // Clear the selection clearSizeCondition(); } ArtifactCondition artifactConditionToPopulateWith = null; List<ArtifactCondition> artifactConditions = rule.getArtifactConditions(); if (nodeInfo.getItemType() != ItemType.ARTIFACT_CLAUSE) { // if there are any attribute clauses, populate the first one, otherwise clear artifact editor if (artifactConditions.isEmpty()) { clearArtifactCondition(); } else { artifactConditionToPopulateWith = artifactConditions.get(0); } } else { // an artifact clause is selected. populate it. for (ArtifactCondition artifact : artifactConditions) { if (artifact.getTreeDisplayName().compareTo(nodeInfo.getName()) == 0) { artifactConditionToPopulateWith = artifact; break; } } } if (artifactConditionToPopulateWith != null) { for (ArtifactCondition artifact : artifactConditions) { attributeListModel.addElement(artifact.getTreeDisplayName()); } // Don't let listSelectionListener respond lsAttributeList.removeListSelectionListener(listSelectionListener); lsAttributeList.setSelectedValue(artifactConditionToPopulateWith.getTreeDisplayName(), true); populateArtifactEditor(artifactConditionToPopulateWith); setDeleteAttributeButton(); lsAttributeList.addListSelectionListener(listSelectionListener); } } localRule = makeRuleFromUserInput(); } else { bnDeleteRule.setEnabled(false); } }
From source file:org.sleuthkit.autopsy.modules.hashdatabase.HashDbCreateDatabaseDialog.java
private void initFileChooser() { fileChooser = new JFileChooser() { @Override/*from ww w. j a v a2s .c om*/ public void approveSelection() { File selectedFile = getSelectedFile(); if (!FilenameUtils.getExtension(selectedFile.getName()) .equalsIgnoreCase(HashDbManager.getHashDatabaseFileExtension())) { if (JOptionPane.showConfirmDialog(this, NbBundle.getMessage(this.getClass(), "HashDbCreateDatabaseDialog.hashDbMustHaveFileExtensionMsg", HashDbManager.getHashDatabaseFileExtension()), NbBundle.getMessage(this.getClass(), "HashDbCreateDatabaseDialog.fileNameErr"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { cancelSelection(); } return; } if (selectedFile.exists()) { if (JOptionPane.showConfirmDialog(this, NbBundle.getMessage(this.getClass(), "HashDbCreateDatabaseDialog.fileNameAlreadyExistsMsg"), NbBundle.getMessage(this.getClass(), "HashDbCreateDatabaseDialog.fileExistsErr"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { cancelSelection(); } return; } super.approveSelection(); } }; fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setDragEnabled(false); fileChooser.setMultiSelectionEnabled(false); }
From source file:org.smart.migrate.ui.MigrateMain.java
private void btnDeleteMappingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteMappingActionPerformed if (tblTableMapping.getSelectedRowCount() == 0) { JOptionPane.showMessageDialog(rootPane, bundle.getString("MigrateMain.alert.deleteMapping")); } else {/* ww w .ja v a 2 s . com*/ if (JOptionPane.showConfirmDialog(rootPane, bundle.getString("MigrateMain.alert.confirmDeleteMapping"), UIManager.getString("OptionPane.titleText"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { String sourceTable = (String) tblTableMapping.getValueAt(tblTableMapping.getSelectedRow(), 0); TableSetting tableSetting = migratePlan.getTableSettingBySourceTable(sourceTable); if (tableSetting != null) { migratePlan.getTableSettings().remove(tableSetting); tblTableMapping.remove(tblTableMapping.getSelectedRow()); } } } }