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:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
/** * Handles clicking the "Browse Root Directory" button. * * @param evt The event which caused this call. *//*from w w w. java 2s .com*/ private void bnBrowseRootDirectoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnBrowseRootDirectoryActionPerformed int returnVal = rootDirectoryChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try { validateAndSanitizeBrowsedDirectory(rootDirectoryChooser, tbRootDirectory); } catch (FolderDidNotValidateException ex) { JOptionPane.showMessageDialog(this, NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.BadRootFolder") + " " + ex.getMessage(), NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.BadFolderForInterestingFileExport"), JOptionPane.OK_OPTION); } } }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
/** * Handles clicking the "Browse Report Directory" button. * * @param evt The event which caused this call. *//*from w w w. j av a2s.co m*/ private void bnBrowseReportDirectoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnBrowseReportDirectoryActionPerformed int returnVal = reportDirectoryChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try { validateAndSanitizeBrowsedDirectory(reportDirectoryChooser, tbReportDirectory); } catch (FolderDidNotValidateException ex) { JOptionPane.showMessageDialog(this, NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.BadReportFolder") + " " + ex.getMessage(), NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.BadFolderForInterestingFileExport"), JOptionPane.OK_OPTION); } } }
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 .c o m } if (isRuleEmpty(rule)) { exportRuleSet.removeRule(rule); } populateRuleTree(ruleName); } } } }
From source file:org.sleuthkit.autopsy.experimental.autoingest.SingleUserCaseImporter.java
/** * This causes iteration over all .aut files in the baseCaseInput path, * calling SingleUserCaseConverter.importCase() for each one. *///from w w w .ja v a2s. co m public void importCases() throws Exception { openLog(baseCaseOutput.toFile()); log(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.StartingBatch") + baseCaseInput.toString() + " " + NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.to") + " " + baseCaseOutput.toString()); //NON-NLS // iterate for .aut files FindDotAutFolders dotAutFolders = new FindDotAutFolders(); try { Path walked = Files.walkFileTree(baseCaseInput, dotAutFolders); } catch (IOException ex) { log(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.ErrorFindingAutFiles") + " " + ex.getMessage()); //NON-NLS } ArrayList<ImportCaseData> ableToProcess = new ArrayList<>(); ArrayList<ImportCaseData> unableToProcess = new ArrayList<>(); SingleUserCaseConverter scc = new SingleUserCaseConverter(); // validate we can convert the .aut file, one by one for (FoundAutFile f : dotAutFolders.getCandidateList()) { this.oldCaseName = f.getPath().getFileName().toString(); // Test image output folder for uniqueness, find a unique folder for it if we can File specificOutputFolder = baseImageOutput.resolve(oldCaseName).toFile(); String newImageName = oldCaseName; if (specificOutputFolder.exists()) { // Not unique. add numbers before timestamp to specific image output name String timeStamp = TimeStampUtils.getTimeStampOnly(oldCaseName); newImageName = TimeStampUtils.removeTimeStamp(oldCaseName); int number = 1; String temp = ""; //NON-NLS while (specificOutputFolder.exists()) { if (number == Integer.MAX_VALUE) { // It never became unique, so give up. throw new Exception(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.NonUniqueOutputFolder") + newImageName); //NON-NLS } temp = newImageName + "_" + Integer.toString(number) + timeStamp; //NON-NLS specificOutputFolder = baseImageOutput.resolve(temp).toFile(); ++number; } newImageName = temp; } Path imageOutput = baseImageOutput.resolve(newImageName); imageOutput.toFile().mkdirs(); // Create image output folder // Test case output folder for uniqueness, find a unique folder for it if we can specificOutputFolder = baseCaseOutput.resolve(oldCaseName).toFile(); newCaseName = oldCaseName; if (specificOutputFolder.exists()) { // not unique. add numbers before timestamp to specific case output name String timeStamp = TimeStampUtils.getTimeStampOnly(oldCaseName); //NON-NLS newCaseName = TimeStampUtils.removeTimeStamp(oldCaseName); int number = 1; String temp = ""; //NON-NLS while (specificOutputFolder.exists()) { if (number == Integer.MAX_VALUE) { // It never became unique, so give up. throw new Exception(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.NonUniqueOutputFolder") + newCaseName); //NON-NLS } temp = newCaseName + "_" + Integer.toString(number) + timeStamp; //NON-NLS specificOutputFolder = baseCaseOutput.resolve(temp).toFile(); ++number; } newCaseName = temp; } Path caseOutput = baseCaseOutput.resolve(newCaseName); caseOutput.toFile().mkdirs(); // Create case output folder /** * Test if the input path has a corresponding image input folder and * no repeated case names in the path. If both of these conditions * are true, we can process this case, otherwise not. */ // Check that there is an image folder if they are trying to copy it boolean canProcess = true; Path imageInput = null; String relativeCaseName = TimeStampUtils .removeTimeStamp(baseCaseInput.relativize(f.getPath()).toString()); Path testImageInputsFromOldCase = Paths.get(baseImageInput.toString(), relativeCaseName); if (copyImages) { if (!testImageInputsFromOldCase.toFile().isDirectory()) { // Mark that we are unable to process this item canProcess = false; } else { imageInput = testImageInputsFromOldCase; } if (imageInput == null) { throw new Exception(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.SourceImageMissing") + " " + f.getPath()); //NON-NLS } // If case name is in the image path, it causes bad things to happen with the parsing. Test for this. for (int x = 0; x < imageInput.getNameCount(); ++x) { if (oldCaseName.toLowerCase().equals(imageInput.getName(x).toString().toLowerCase())) { // Mark that we are unable to process this item canProcess = false; } } } else { imageInput = testImageInputsFromOldCase; } // Create an Import Case Data object for this case SingleUserCaseConverter.ImportCaseData icd = scc.new ImportCaseData(imageInput, f.getPath(), imageOutput, caseOutput, oldCaseName, newCaseName, f.getAutFile().toString(), f.getFolderName().toString(), copyImages, deleteCase); if (canProcess) { ableToProcess.add(icd); } else { unableToProcess.add(icd); } } // Create text to be populated in the confirmation dialog StringBuilder casesThatWillBeProcessed = new StringBuilder(); StringBuilder casesThatWillNotBeProcessed = new StringBuilder(); casesThatWillBeProcessed .append(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.WillImport")) .append(SEP); // NON-NLS if (ableToProcess.isEmpty()) { casesThatWillBeProcessed .append(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.None")) .append(SEP); // NON-NLS } else { for (ImportCaseData i : ableToProcess) { casesThatWillBeProcessed.append(i.getCaseInputFolder().toString()).append(SEP); } } if (!unableToProcess.isEmpty()) { casesThatWillNotBeProcessed.append( NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.WillNotImport")) .append(SEP); // NON-NLS for (ImportCaseData i : unableToProcess) { casesThatWillNotBeProcessed.append(i.getCaseInputFolder().toString()).append(SEP); } } JTextArea jta = new JTextArea( casesThatWillBeProcessed.toString() + SEP + casesThatWillNotBeProcessed.toString()); jta.setEditable(false); JScrollPane jsp = new JScrollPane(jta) { private static final long serialVersionUID = 1L; @Override public Dimension getPreferredSize() { return new Dimension(700, 480); } }; // Show confirmation dialog SwingUtilities.invokeLater(() -> { userAnswer = JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(), jsp, NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.ContinueWithImport"), // NON-NLS OK_CANCEL_OPTION); synchronized (threadWaitNotifyLock) { threadWaitNotifyLock.notify(); } }); // Wait while the user handles the confirmation dialog synchronized (threadWaitNotifyLock) { try { threadWaitNotifyLock.wait(); } catch (InterruptedException ex) { Logger.getLogger(SingleUserCaseImporter.class.getName()).log(Level.SEVERE, "Threading Issue", ex); //NON-NLS throw new Exception(ex); } } // If the user wants to proceed, do so. if (userAnswer == JOptionPane.OK_OPTION) { boolean result = true; // if anything went wrong, result becomes false. // Feed .aut files in one by one for processing for (ImportCaseData i : ableToProcess) { try { log(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.StartedProcessing") + i.getCaseInputFolder() + " " + NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.to") + " " + i.getCaseOutputFolder()); //NON-NLS SingleUserCaseConverter.importCase(i); handleAutoIngestLog(i); log(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.FinishedProcessing") + i.getCaseInputFolder() + " " + NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.to") + " " + i.getCaseOutputFolder()); //NON-NLS } catch (Exception ex) { log(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.FailedToComplete") + i.getCaseInputFolder() + " " + NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.to") + " " + i.getCaseOutputFolder() + " " + ex.getMessage()); //NON-NLS result = false; } } log(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.CompletedBatch") + baseCaseInput.toString() + " " + NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.to") + " " + baseCaseOutput.toString()); //NON-NLS closeLog(); if (notifyOnComplete != null) { notifyOnComplete.importDoneCallback(result, ""); // NON-NLS } } else { // The user clicked cancel. Abort. log(NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.AbortingBatch") + baseCaseInput.toString() + " " + NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.to") + " " + baseCaseOutput.toString()); //NON-NLS closeLog(); if (notifyOnComplete != null) { notifyOnComplete.importDoneCallback(false, NbBundle.getMessage(SingleUserCaseImporter.class, "SingleUserCaseImporter.Cancelled")); // NON-NLS } } }
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.j a va 2s . co m 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()); } } } }
From source file:org.smart.migrate.ui.MigrateMain.java
private void popDeletePlanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_popDeletePlanActionPerformed ///* w ww. j a v a2 s . c o m*/ if (listPlan.getSelectedIndex() >= 0) { if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(rootPane, bundle.getString("MigrateMain.alert.confirmDeletePlan"), "Confirm", JOptionPane.OK_CANCEL_OPTION)) { MigratePlanIO.deletePlan((String) listPlan.getSelectedValue()); initModel(); if (listPlan.getModel().getSize() > 0) { listPlan.setSelectedIndex(listPlan.getModel().getSize() - 1); setSelectedMigratePlan(); } } } }
From source file:org.smart.migrate.ui.MigrateMain.java
private void btnDeleteTargetDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteTargetDataActionPerformed if (tblTableMapping.getSelectedRowCount() == 0) { JOptionPane.showMessageDialog(rootPane, bundle.getString("MigrateMain.alert.deleteTargetData")); } else {// w w w .j a va2s .c o m if (JOptionPane.showConfirmDialog(rootPane, bundle.getString("MigrateMain.alert.confirmDeleteTargetData"), UIManager.getString("OptionPane.titleText"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { importManager.setMigratePlan(migratePlan); importManager.connectToDataBase(false, true); importManager.deleteTargetData( (String) tblTableMapping.getValueAt(tblTableMapping.getSelectedRow(), 1), edtDeleteWhere.getText()); importManager.closeConnection(); JOptionPane.showMessageDialog(rootPane, bundle.getString("MigrateMain.message.deleteTarget")); } } }
From source file:org.smart.migrate.ui.MigrateMain.java
private void btnRollBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRollBackActionPerformed if (JOptionPane.showConfirmDialog(rootPane, bundle.getString("MigrateMain.alert.confirmRollback"), UIManager.getString("OptionPane.titleText"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { currentThread.deleteImportedData(); }/*from w w w . j av a 2s. c o m*/ }
From source file:org.smart.migrate.ui.MigrateMain.java
private void btnDeleteRelationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteRelationActionPerformed ////w w w . j av a 2 s . c om if (tblTableRelations.getSelectedRowCount() == 0) { JOptionPane.showMessageDialog(rootPane, bundle.getString("MigrateMain.alert.deleteRelation")); } else { if (JOptionPane.showConfirmDialog(rootPane, bundle.getString("MigrateMain.alert.confirmDeleteRelation"), UIManager.getString("OptionPane.titleText"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { String fkTable = (String) tblTableRelations.getValueAt(tblTableRelations.getSelectedRow(), 0); String pkTable = (String) tblTableRelations.getValueAt(tblTableRelations.getSelectedRow(), 2); TableRelation relation = SettingUtils.getRelationByPKTableAndFKTable(migratePlan, pkTable, fkTable); if (relation != null) { migratePlan.getSourceRelations().remove(relation); tblTableRelations.remove(tblTableRelations.getSelectedRow()); } // // TableSetting tableSetting = migratePlan.getTableSettingBySourceTable(sourceTable); // if (tableSetting!=null){ // migratePlan.getTableSettings().remove(tableSetting); // tblTableMapping.remove(tblTableMapping.getSelectedRow()); // } } } }
From source file:org.squidy.designer.zoom.ContainerShape.java
@Override public void initializeLayout() { super.initializeLayout(); final ImageButton startProcessing = new ImageButton( ActionShape.class.getResource("/images/24x24/media_play_green.png"), "Start"); final ImageButton stopProcessing = new ImageButton( ActionShape.class.getResource("/images/24x24/media_stop_red.png"), "Stop"); stopProcessing.setEnabled(false);/*from w ww . j a v a 2s . c o m*/ startProcessing.addZoomActionListener(new ZoomActionListener() { /** * @param e */ public void actionPerformed(ZoomActionEvent e) { new Thread() { /* * (non-Javadoc) * * @see java.lang.Thread#run() */ @Override public void run() { if (!getProcessable().isProcessing()) { startProcessing.setEnabled(false); stopProcessing.setEnabled(true); invalidatePaint(); ContainerShape.this.start(); ContainerShape.this.doStart(); Manager.get().notify(getProcessable(), Action.START); } } }.start(); } }); stopProcessing.addZoomActionListener(new ZoomActionListener() { /** * @param e */ public void actionPerformed(ZoomActionEvent e) { new Thread() { /* * (non-Javadoc) * * @see java.lang.Thread#run() */ @Override public void run() { // if (getProcessable().isProcessing()) { startProcessing.setEnabled(true); stopProcessing.setEnabled(false); invalidatePaint(); ContainerShape.this.stop(); ContainerShape.this.doStop(); // } Manager.get().notify(getProcessable(), Action.STOP); } }.start(); } }); ImageButton delete = new ImageButton(ActionShape.class.getResource("/images/24x24/delete2.png"), "Delete"); delete.addZoomActionListener(new ZoomActionListener() { /* * (non-Javadoc) * * @see * org.squidy.designer.event.ZoomActionListener#actionPerformed * (org.squidy.designer.event.ZoomActionEvent) */ public void actionPerformed(ZoomActionEvent e) { if (LOG.isDebugEnabled()) { LOG.debug("Pressed delete on " + getBreadcrumb()); } int option = JOptionPane.showConfirmDialog(Designer.getInstance(), "Would you like to delete " + getTitle() + "?", "Delete?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, new ImageIcon(ActionShape.class.getResource("/images/delete.png"))); if (option == JOptionPane.OK_OPTION) { ZoomShape<?> zoomShape = null; if (currentZoomState == ZoomState.ZOOM_IN && getParent() instanceof ZoomShape<?>) { zoomShape = (ZoomShape<?>) getParent(); } delete(); if (zoomShape != null) { zoomShape.animateToCenterView(e.getCamera()); // Set pipe shapes visible and pickable. for (Object child : zoomShape.getChildrenReference()) { if (child instanceof PipeShape) { ShapeUtils.setApparent((PipeShape) child, true); } } } Manager.get().notify(getProcessable(), Action.DELETE); } } }); ImageButton duplicate = new ImageButton(ActionShape.class.getResource("/images/24x24/copy.png"), "Duplicate"); duplicate.addZoomActionListener(new ZoomActionListener() { /* * (non-Javadoc) * * @see * org.squidy.designer.event.ZoomActionListener#actionPerformed * (org.squidy.designer.event.ZoomActionEvent) */ public void actionPerformed(ZoomActionEvent e) { if (LOG.isDebugEnabled()) { LOG.debug("Duplicate has been pressed for " + getBreadcrumb()); } Manager.get().notify(getProcessable(), Action.DUPLICATE); } }); duplicate.setEnabled(false); ImageButton publish = new ImageButton(ActionShape.class.getResource("/images/24x24/export2.png"), "Publish"); publish.addZoomActionListener(new ZoomActionListener() { /* * (non-Javadoc) * * @see * org.squidy.designer.event.ZoomActionListener#actionPerformed * (org.squidy.designer.event.ZoomActionEvent) */ public void actionPerformed(ZoomActionEvent e) { if (LOG.isDebugEnabled()) { LOG.debug("Publish has been pressed for " + getBreadcrumb()); } Storable storable = ShapeUtils.getObjectInHierarchy(Storable.class, ContainerShape.this); if (storable != null) { storable.store(); } } }); publish.setEnabled(false); ImageButton update = new ImageButton(ActionShape.class.getResource("/images/24x24/import1.png"), "Update"); update.addZoomActionListener(new ZoomActionListener() { /* * (non-Javadoc) * * @see * org.squidy.designer.event.ZoomActionListener#actionPerformed * (org.squidy.designer.event.ZoomActionEvent) */ public void actionPerformed(ZoomActionEvent e) { if (LOG.isDebugEnabled()) { LOG.debug("Update has been pressed for " + getBreadcrumb()); } } }); update.setEnabled(false); addPropertyChangeListener(Processable.PROPERTY_PROCESSING, new PropertyChangeListener() { /* * (non-Javadoc) * * * * @seejava.beans.PropertyChangeListener#propertyChange(java. * beans. PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { startProcessing.setEnabled(!(Boolean) evt.getNewValue()); stopProcessing.setEnabled((Boolean) evt.getNewValue()); if ((Boolean) evt.getNewValue()) doStart(); else doStop(); } }); // addPropertyChangeListener(Processable.PROPERTY_PROCESSING_STOP, // new PropertyChangeListener() { // // /* // * (non-Javadoc) // * // * // * // * @seejava.beans.PropertyChangeListener#propertyChange(java. // * beans. PropertyChangeEvent) // */ // public void propertyChange(PropertyChangeEvent evt) { // // startProcessing.setToggleState(ZoomToggle.RELEASED); // // stopProcessing.setToggleState(ZoomToggle.PRESSED); // startProcessing.setEnabled(true); // stopProcessing.setEnabled(false); // doStop(); // } // }); ShapeUtils.setApparent(startProcessing, false); ShapeUtils.setApparent(stopProcessing, false); if (!(this instanceof WorkspaceShape)) { ShapeUtils.setApparent(delete, false); ShapeUtils.setApparent(duplicate, false); ShapeUtils.setApparent(publish, false); ShapeUtils.setApparent(update, false); } addAction(startProcessing); addAction(stopProcessing); if (!(this instanceof WorkspaceShape)) { addAction(delete); addAction(duplicate); addAction(publish); addAction(update); } }