From 360d12c68c0d0419ecb3eac011731f5eaab40db5 Mon Sep 17 00:00:00 2001 From: millmanorama Date: Fri, 2 Sep 2016 15:52:44 +0200 Subject: [PATCH] finish showing rejected results Action --- .../sleuthkit/autopsy/datamodel/Accounts.java | 42 ++++++-------- .../autopsy/datamodel/SetShowRejected.java | 25 +++++++++ .../autopsy/directorytree/Bundle.properties | 1 + .../DirectoryTreeTopComponent.form | 33 +++++++---- .../DirectoryTreeTopComponent.java | 56 ++++++++++++------- 5 files changed, 100 insertions(+), 57 deletions(-) create mode 100644 Core/src/org/sleuthkit/autopsy/datamodel/SetShowRejected.java diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Accounts.java b/Core/src/org/sleuthkit/autopsy/datamodel/Accounts.java index 5b89e26b21..5105d13790 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/Accounts.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/Accounts.java @@ -86,11 +86,24 @@ public class Accounts extends Observable implements AutopsyVisitableItem { @GuardedBy("Accounts.class") private static boolean iinsLoaded = false; - private SleuthkitCase skCase; private boolean showRejected = false; + void showRejected(boolean showRejected) { + + boolean needsUpdate = showRejected != this.showRejected; + this.showRejected = showRejected; + + if (needsUpdate) { + update(); + } + } + + boolean isShowRejected() { + return showRejected; + } + /** * Load the IIN range information from disk. If the map has already been * initialized, don't load again. @@ -214,7 +227,7 @@ public class Accounts extends Observable implements AutopsyVisitableItem { public class AccountsRootNode extends DisplayableItemNode { AccountsRootNode() { - super(Children.create(new AccountTypeFactory(), true)); + super(Children.create(new AccountTypeFactory(), true), Lookups.singleton(Accounts.this)); super.setName("Accounts"); //NON-NLS super.setDisplayName(Bundle.Accounts_RootNode_displayName()); this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/account_menu.png"); //NON-NLS @@ -230,14 +243,6 @@ public class Accounts extends Observable implements AutopsyVisitableItem { return v.visit(this); } - @Override - public Action[] getActions(boolean context) { - Action[] actions = super.getActions(context); - ArrayList actionsList = new ArrayList<>(); - actionsList.addAll(Arrays.asList(actions)); - actionsList.add(new SetShowRejected(!showRejected)); - return actionsList.toArray(new Action[actionsList.size()]); - } } /** @@ -971,22 +976,6 @@ public class Accounts extends Observable implements AutopsyVisitableItem { } } - private class SetShowRejected extends AbstractAction { - - private final boolean show; - - public SetShowRejected(boolean show) { - super(show ? "Show Rejected Results" : "Hide Rejected Results"); - this.show = show; - } - - @Override - public void actionPerformed(ActionEvent e) { - showRejected = show; - update(); - } - } - private class RejectAccounts extends AbstractAction { private final Collection artifacts; @@ -1171,4 +1160,5 @@ public class Accounts extends Observable implements AutopsyVisitableItem { return bankCity; } } + } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/SetShowRejected.java b/Core/src/org/sleuthkit/autopsy/datamodel/SetShowRejected.java new file mode 100644 index 0000000000..5ae053b460 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/datamodel/SetShowRejected.java @@ -0,0 +1,25 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.datamodel; + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; + +public final class SetShowRejected extends AbstractAction { + + private final Accounts accounts; + + public SetShowRejected(Accounts accounts) { + super("Show Rejected Results"); + this.accounts = accounts; + + } + + @Override + public void actionPerformed(ActionEvent e) { + accounts.showRejected(accounts.isShowRejected() == false); + } +} diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/Bundle.properties b/Core/src/org/sleuthkit/autopsy/directorytree/Bundle.properties index aae7628173..31dbbd1b49 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/directorytree/Bundle.properties @@ -93,3 +93,4 @@ ExtractUnallocAction.done.notifyMsg.completedExtract.msg=Files were extracted to ExtractUnallocAction.done.errMsg.title=Error Extracting ExtractUnallocAction.done.errMsg.msg=Error extracting unallocated space\: {0} ExtractAction.done.notifyMsg.extractErr=Error extracting files\: {0} +DirectoryTreeTopComponent.showRejectedCheckBox.text=Show Rejected Results diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.form b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.form index e4821adcb3..672552b6df 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.form +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.form @@ -16,28 +16,29 @@ - - + + + - + + + - - - - + + + + - - - - + + @@ -122,7 +123,15 @@ - + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java index 9d7f7c5df8..c52085a5c9 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java @@ -57,10 +57,10 @@ import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent; import org.sleuthkit.autopsy.corecomponents.TableFilterNode; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; +import org.sleuthkit.autopsy.datamodel.Accounts; import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode; import org.sleuthkit.autopsy.datamodel.DataSources; import org.sleuthkit.autopsy.datamodel.DataSourcesNode; -import org.sleuthkit.autopsy.datamodel.DisplayableItemNode; import org.sleuthkit.autopsy.datamodel.ExtractedContent; import org.sleuthkit.autopsy.datamodel.KeywordHits; import org.sleuthkit.autopsy.datamodel.KnownFileFilterNode; @@ -68,6 +68,7 @@ import org.sleuthkit.autopsy.datamodel.Reports; import org.sleuthkit.autopsy.datamodel.Results; import org.sleuthkit.autopsy.datamodel.ResultsNode; import org.sleuthkit.autopsy.datamodel.RootContentChildren; +import org.sleuthkit.autopsy.datamodel.SetShowRejected; import org.sleuthkit.autopsy.datamodel.Tags; import org.sleuthkit.autopsy.datamodel.Views; import org.sleuthkit.autopsy.datamodel.ViewsNode; @@ -164,65 +165,73 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat jScrollPane1 = new BeanTreeView(); backButton = new javax.swing.JButton(); forwardButton = new javax.swing.JButton(); - jSeparator1 = new javax.swing.JSeparator(); + showRejectedCheckBox = new javax.swing.JCheckBox(); jScrollPane1.setBorder(null); - backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_back.png"))); // NOI18N NON-NLS + backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_back.png"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(backButton, org.openide.util.NbBundle.getMessage(DirectoryTreeTopComponent.class, "DirectoryTreeTopComponent.backButton.text")); // NOI18N backButton.setBorderPainted(false); backButton.setContentAreaFilled(false); - backButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_back_disabled.png"))); // NOI18N NON-NLS + backButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_back_disabled.png"))); // NOI18N backButton.setMargin(new java.awt.Insets(2, 0, 2, 0)); backButton.setMaximumSize(new java.awt.Dimension(55, 100)); backButton.setMinimumSize(new java.awt.Dimension(5, 5)); backButton.setPreferredSize(new java.awt.Dimension(23, 23)); - backButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_back_hover.png"))); // NOI18N NON-NLS + backButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_back_hover.png"))); // NOI18N backButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backButtonActionPerformed(evt); } }); - forwardButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_forward.png"))); // NOI18N NON-NLS + forwardButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_forward.png"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(forwardButton, org.openide.util.NbBundle.getMessage(DirectoryTreeTopComponent.class, "DirectoryTreeTopComponent.forwardButton.text")); // NOI18N forwardButton.setBorderPainted(false); forwardButton.setContentAreaFilled(false); - forwardButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_forward_disabled.png"))); // NOI18N NON-NLS + forwardButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_forward_disabled.png"))); // NOI18N forwardButton.setMargin(new java.awt.Insets(2, 0, 2, 0)); forwardButton.setMaximumSize(new java.awt.Dimension(55, 100)); forwardButton.setMinimumSize(new java.awt.Dimension(5, 5)); forwardButton.setPreferredSize(new java.awt.Dimension(23, 23)); - forwardButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_forward_hover.png"))); // NOI18N NON-NLS + forwardButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/directorytree/btn_step_forward_hover.png"))); // NOI18N forwardButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { forwardButtonActionPerformed(evt); } }); + org.openide.awt.Mnemonics.setLocalizedText(showRejectedCheckBox, org.openide.util.NbBundle.getMessage(DirectoryTreeTopComponent.class, "DirectoryTreeTopComponent.showRejectedCheckBox.text")); // NOI18N + showRejectedCheckBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + showRejectedCheckBoxActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() - .addContainerGap() + .addGap(5, 5, 5) .addComponent(backButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(forwardButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(206, Short.MAX_VALUE)) - .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE) + .addComponent(showRejectedCheckBox) + .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(5, 5, 5) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(forwardButton, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(backButton, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(forwardButton, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(0, 0, 0) - .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 860, Short.MAX_VALUE) + .addComponent(showRejectedCheckBox)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 838, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); }// //GEN-END:initComponents @@ -275,11 +284,16 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat this.setCursor(null); }//GEN-LAST:event_forwardButtonActionPerformed + + private void showRejectedCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showRejectedCheckBoxActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_showRejectedCheckBoxActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton backButton; private javax.swing.JButton forwardButton; private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JSeparator jSeparator1; + private javax.swing.JCheckBox showRejectedCheckBox; // End of variables declaration//GEN-END:variables /** @@ -356,6 +370,7 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat items.add(new Tags()); items.add(new Reports()); contentChildren = new RootContentChildren(items); + Node root = new AbstractNode(contentChildren) { /** * to override the right click action in the white blank @@ -398,6 +413,9 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat Children resultsChilds = results.getChildren(); tree.expandNode(resultsChilds.findChild(KeywordHits.NAME)); tree.expandNode(resultsChilds.findChild(ExtractedContent.NAME)); + Accounts accounts = resultsChilds.findChild("Accounts").getLookup().lookup(Accounts.class); + showRejectedCheckBox.setAction(new SetShowRejected(accounts)); + showRejectedCheckBox.setSelected(false); Node views = childNodes.findChild(ViewsNode.NAME); Children viewsChilds = views.getChildren();