From f39c3d7bbd7d4cdac0548a7656e2eca36c4836f5 Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 11 Aug 2015 14:13:53 -0400 Subject: [PATCH 01/39] cleanup --- .../autopsy/timeline/TimeLineController.java | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java index deae355fc6..a8881fc7da 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java @@ -66,6 +66,7 @@ import static org.sleuthkit.autopsy.casemodule.Case.Events.DATA_SOURCE_ADDED; import org.sleuthkit.autopsy.coreutils.History; import org.sleuthkit.autopsy.coreutils.LoggedTask; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.ThreadConfined; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.timeline.events.FilteredEventsModel; import org.sleuthkit.autopsy.timeline.events.db.EventsRepository; @@ -99,9 +100,6 @@ public class TimeLineController { private static final Logger LOGGER = Logger.getLogger(TimeLineController.class.getName()); - private static final String DO_REPOPULATE_MESSAGE = NbBundle.getMessage(TimeLineController.class, - "Timeline.do_repopulate.msg"); - private static final ReadOnlyObjectWrapper timeZone = new ReadOnlyObjectWrapper<>(TimeZone.getDefault()); public static ZoneId getTimeZoneID() { @@ -683,16 +681,28 @@ public class TimeLineController { return mainFrame != null && mainFrame.isOpened() && mainFrame.isVisible(); } + @ThreadConfined(type = ThreadConfined.ThreadType.AWT) + private void confirmOutOfDateRebuildIfWindowOpen() throws HeadlessException, MissingResourceException { + if (isWindowOpen()) { + if (confirmOutOfDateRebuild()) { + rebuildRepo(); + } + } + } + /** * prompt the user to rebuild the db because that datasource_ids are missing * from the database and that the datasource filter will not work * * @return true if they agree to rebuild */ + @ThreadConfined(type = ThreadConfined.ThreadType.AWT) synchronized boolean confirmDataSourceIDsMissingRebuild() { return JOptionPane.showConfirmDialog(mainFrame, - NbBundle.getMessage(TimeLineController.class, "datasource.missing.confirmation"), - "Update Timeline database?", + NbBundle.getMessage(TimeLineController.class, + "datasource.missing.confirmation"), + NbBundle.getMessage(TimeLineController.class, + "datasource.missing.confirmation.update_timeline_database"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION; } @@ -703,9 +713,11 @@ public class TimeLineController { * * @return true if they agree to rebuild */ + @ThreadConfined(type = ThreadConfined.ThreadType.AWT) synchronized boolean confirmLastBuiltDuringIngestRebuild() { return JOptionPane.showConfirmDialog(mainFrame, - DO_REPOPULATE_MESSAGE, + NbBundle.getMessage(TimeLineController.class, + "Timeline.do_repopulate.msg"), NbBundle.getMessage(TimeLineTopComponent.class, "Timeline.showLastPopulatedWhileIngestingConf.confDlg.details"), JOptionPane.YES_NO_OPTION, @@ -718,6 +730,7 @@ public class TimeLineController { * * @return true if they agree to rebuild */ + @ThreadConfined(type = ThreadConfined.ThreadType.AWT) synchronized boolean confirmOutOfDateRebuild() throws MissingResourceException, HeadlessException { return JOptionPane.showConfirmDialog(mainFrame, NbBundle.getMessage(TimeLineController.class, @@ -733,6 +746,7 @@ public class TimeLineController { * * @return true if they want to continue anyways */ + @ThreadConfined(type = ThreadConfined.ThreadType.AWT) synchronized boolean confirmRebuildDuringIngest() throws MissingResourceException, HeadlessException { return JOptionPane.showConfirmDialog(mainFrame, NbBundle.getMessage(TimeLineController.class, @@ -748,16 +762,9 @@ public class TimeLineController { public void propertyChange(PropertyChangeEvent evt) { switch (IngestManager.IngestModuleEvent.valueOf(evt.getPropertyName())) { case CONTENT_CHANGED: -// ((ModuleContentEvent)evt.getOldValue())???? - //ModuleContentEvent doesn't seem to provide any usefull information... - break; case DATA_ADDED: -// Collection artifacts = ((ModuleDataEvent) evt.getOldValue()).getArtifacts(); - //new artifacts, insert them into db break; case FILE_DONE: -// Long fileID = (Long) evt.getOldValue(); - //update file (known status) for file with id Platform.runLater(() -> { newEventsFlag.set(true); }); @@ -774,14 +781,7 @@ public class TimeLineController { switch (IngestManager.IngestJobEvent.valueOf(evt.getPropertyName())) { case CANCELLED: case COMPLETED: - //if we are doing incremental updates, drop this - SwingUtilities.invokeLater(() -> { - if (isWindowOpen()) { - if (confirmOutOfDateRebuild()) { - rebuildRepo(); - } - } - }); + SwingUtilities.invokeLater(TimeLineController.this::confirmOutOfDateRebuildIfWindowOpen); } } } @@ -793,15 +793,7 @@ public class TimeLineController { public void propertyChange(PropertyChangeEvent evt) { switch (Case.Events.valueOf(evt.getPropertyName())) { case DATA_SOURCE_ADDED: -// Content content = (Content) evt.getNewValue(); - //if we are doing incremental updates, drop this - SwingUtilities.invokeLater(() -> { - if (isWindowOpen()) { - if (confirmOutOfDateRebuild()) { - rebuildRepo(); - } - } - }); + SwingUtilities.invokeLater(TimeLineController.this::confirmOutOfDateRebuildIfWindowOpen); break; case CURRENT_CASE: OpenTimelineAction.invalidateController(); From b7ca50385d6167dd94050d1a91980e1e397b3593 Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 11 Aug 2015 14:34:37 -0400 Subject: [PATCH 02/39] move properties to NbBundle.messages annotation and out of Bundle.properties --- .../autopsy/timeline/Bundle.properties | 15 ----- .../autopsy/timeline/ProgressWindow.form | 4 +- .../autopsy/timeline/ProgressWindow.java | 58 +++++++++---------- .../autopsy/timeline/TimeLineController.java | 46 ++++++++------- 4 files changed, 53 insertions(+), 70 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/timeline/Bundle.properties b/Core/src/org/sleuthkit/autopsy/timeline/Bundle.properties index 7e3fb1cb56..6ea7e7bdc7 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/timeline/Bundle.properties @@ -1,4 +1,3 @@ -OpenIDE-Module-Name=Timeline CTL_MakeTimeline="Timeline" CTL_TimeLineTopComponentAction=TimeLineTopComponent CTL_TimeLineTopComponent=Timeline Window @@ -11,10 +10,6 @@ Timeline.goToButton.text=Go To\: Timeline.yearBarChart.x.years=Years Timeline.resultPanel.loading=Loading... Timeline.node.root=Root -Timeline.propChg.confDlg.timelineOOD.msg=The event data is out of date. Would you like to regenerate it? -Timeline.propChg.confDlg.timelineOOD.details=Timeline -Timeline.initTimeline.confDlg.genBeforeIngest.msg=You are trying to generate a timeline before ingest has been completed. The timeline may be incomplete. Do you want to continue? -Timeline.initTimeline.confDlg.genBeforeIngest.details=Timeline TimelineFrame.title=Timeline TimelinePanel.jButton1.text=6m TimelinePanel.jButton13.text=all @@ -29,18 +24,8 @@ TimelinePanel.jButton7.text=3d TimelinePanel.jButton2.text=1m TimelinePanel.jButton3.text=3m TimelinePanel.jButton4.text=2w -ProgressWindow.progressHeader.text=\ TimeLineTopComponent.eventsTab.name=Events TimeLineTopComponent.filterTab.name=Filters -Timeline.showLastPopulatedWhileIngestingConf.confDlg.details=Timeline -Timeline.do_repopulate.msg=The Timeline events database was previously populated while ingest was running.\nSome events may not have been populated or may have been populated inaccurately.\nDo you want to repopulate the events database now? -Timeline.pushDescrLOD.confdlg.msg=You are about to show details for {0} events. This might be very slow or even crash Autopsy.\n\nDo you want to continue? -Timeline.pushDescrLOD.confdlg.details= OpenTimelineAction.title=Timeline -Timeline.ProgressWindow.cancel.confdlg.msg=Do you want to cancel timeline creation? -Timeline.ProgressWindow.cancel.confdlg.detail=Cancel timeline creation? -Timeline.progressWindow.name=Timeline -Timeline.progressWindow.title=Generating Timeline data OpenTimeLineAction.msgdlg.text=Could not create timeline, there are no data sources. TimeLineTopComponent.timeZonePanel.text=Display Times In\: -datasource.missing.confirmation=The Timeline events database was previously populated with an old version of Autopsy.\nThe data source filter will be unavailable unless you update the events database.\nDo you want to update the events database now? diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.form b/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.form index 6c99e006c8..8a56da573d 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.form +++ b/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.form @@ -53,8 +53,8 @@ - - + + diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.java b/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.java index 772d1503a2..51af12e9e5 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ProgressWindow.java @@ -21,25 +21,20 @@ package org.sleuthkit.autopsy.timeline; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import javax.annotation.concurrent.Immutable; import javax.swing.AbstractAction; import javax.swing.ActionMap; -import javax.swing.GroupLayout; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JFrame; -import javax.swing.JLabel; import javax.swing.JOptionPane; -import javax.swing.JProgressBar; import javax.swing.KeyStroke; -import javax.swing.LayoutStyle; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; -import org.openide.awt.Mnemonics; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; +import static org.sleuthkit.autopsy.timeline.Bundle.Timeline_progressWindow_name; +import static org.sleuthkit.autopsy.timeline.Bundle.Timeline_progressWindow_title; /** * Dialog with progress bar that pops up when timeline is being generated @@ -51,6 +46,8 @@ public class ProgressWindow extends JFrame { /** * Creates new form TimelineProgressDialog */ + @NbBundle.Messages({"Timeline.progressWindow.name=Timeline", + "Timeline.progressWindow.title=Generating Timeline data"}) public ProgressWindow(Component parent, boolean modal, SwingWorker worker) { super(); initComponents(); @@ -64,9 +61,8 @@ public class ProgressWindow extends JFrame { setIconImage(WindowManager.getDefault().getMainWindow().getIconImage()); }); - //progressBar.setIndeterminate(true); - setName(NbBundle.getMessage(TimeLineTopComponent.class, "Timeline.progressWindow.name")); - setTitle(NbBundle.getMessage(TimeLineTopComponent.class, "Timeline.progressWindow.title")); + setName(Timeline_progressWindow_name()); + setTitle(Timeline_progressWindow_title()); // Close the dialog when Esc is pressed String cancelName = "cancel"; // NON-NLS InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); @@ -132,38 +128,38 @@ public class ProgressWindow extends JFrame { // //GEN-BEGIN:initComponents private void initComponents() { - progressBar = new JProgressBar(); - progressHeader = new JLabel(); + progressBar = new javax.swing.JProgressBar(); + progressHeader = new javax.swing.JLabel(); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); - Mnemonics.setLocalizedText(progressHeader, NbBundle.getMessage(ProgressWindow.class, "ProgressWindow.progressHeader.text")); // NOI18N + progressHeader.setPreferredSize(new java.awt.Dimension(0, 14)); - GroupLayout layout = new GroupLayout(getContentPane()); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(progressBar, GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() - .addComponent(progressHeader) + .addComponent(progressHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addComponent(progressHeader) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(progressBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(progressHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); @@ -176,14 +172,14 @@ public class ProgressWindow extends JFrame { cancel(); }//GEN-LAST:event_closeDialog + @NbBundle.Messages({"Timeline.ProgressWindow.cancel.confdlg.msg=Do you want to cancel timeline creation?", + "Timeline.ProgressWindow.cancel.confdlg.detail=Cancel timeline creation?"}) public void cancel() { SwingUtilities.invokeLater(() -> { if (isVisible()) { int showConfirmDialog = JOptionPane.showConfirmDialog(ProgressWindow.this, - NbBundle.getMessage(TimeLineTopComponent.class, - "Timeline.ProgressWindow.cancel.confdlg.msg"), - NbBundle.getMessage(TimeLineTopComponent.class, - "Timeline.ProgressWindow.cancel.confdlg.detail"), + Bundle.Timeline_ProgressWindow_cancel_confdlg_msg(), + Bundle.Timeline_ProgressWindow_cancel_confdlg_detail(), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (showConfirmDialog == JOptionPane.YES_OPTION) { close(); @@ -200,8 +196,8 @@ public class ProgressWindow extends JFrame { dispose(); } // Variables declaration - do not modify//GEN-BEGIN:variables - private JProgressBar progressBar; - private JLabel progressHeader; + private javax.swing.JProgressBar progressBar; + private javax.swing.JLabel progressHeader; // End of variables declaration//GEN-END:variables public void update(ProgressUpdate chunk) { diff --git a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java index a8881fc7da..bda8389e1f 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java @@ -96,6 +96,7 @@ import org.sleuthkit.datamodel.TskCoreException; * *