diff --git a/Core/nbproject/project.xml b/Core/nbproject/project.xml index ff33bd0a36..9b49c8e266 100644 --- a/Core/nbproject/project.xml +++ b/Core/nbproject/project.xml @@ -42,6 +42,15 @@ 2.27.1 + + org.netbeans.modules.options.api + + + + 1 + 1.26.1 + + org.netbeans.modules.settings diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties index cf03389e6a..21f6aba4e4 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties @@ -98,3 +98,4 @@ DataResultViewerThumbnail.pageNumLabel.text=- DataResultViewerThumbnail.filePathLabel.text=\ \ \ DataResultViewerThumbnail.goToPageLabel.text=Go to Page: DataResultViewerThumbnail.goToPageField.text= +GeneralPanel.preferredViewerCheckBox.text=Remember preferred content viewer diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java index 49f9bc86f2..9bf28e0d81 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java @@ -22,6 +22,7 @@ import java.awt.Cursor; import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.List; +import java.util.prefs.Preferences; import org.sleuthkit.autopsy.coreutils.Logger; import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; @@ -31,6 +32,7 @@ import org.openide.util.NbBundle; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; import org.openide.util.Lookup; +import org.openide.util.NbPreferences; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; @@ -291,9 +293,15 @@ public final class DataContentTopComponent extends TopComponent implements DataC * @param selectedNode the selected content Node */ public void setupTabs(Node selectedNode) { + + // get the preference for the preferred viewer + Preferences pref = NbPreferences.forModule(GeneralPanel.class); + boolean keepCurrentViewer = pref.getBoolean("keepPreferredViewer", false); int currTabIndex = dataContentTabbedPane.getSelectedIndex(); int totalTabs = dataContentTabbedPane.getTabCount(); + int maxPreferred = 0; + int preferredViewerIndex = 0; for (int i = 0; i < totalTabs; ++i) { UpdateWrapper dcv = viewers.get(i); dcv.resetComponent(); @@ -304,10 +312,22 @@ public final class DataContentTopComponent extends TopComponent implements DataC dataContentTabbedPane.setEnabledAt(i, false); } else { dataContentTabbedPane.setEnabledAt(i, true); + + // remember the viewer with the highest preference value + int currentPreferred = dcv.isPreferred(selectedNode, dcvSupported); + if (currentPreferred > maxPreferred) { + preferredViewerIndex = i; + maxPreferred = currentPreferred; + } } } + + // let the user decide if we should stay with the current viewer + int tabIndex = keepCurrentViewer ? currTabIndex : preferredViewerIndex; - viewers.get(currTabIndex).setNode(selectedNode); + // set the tab to the one the user wants, then set that viewer's node. + dataContentTabbedPane.setSelectedIndex(tabIndex); + viewers.get(tabIndex).setNode(selectedNode); } /** diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralOptionsPanelController.java b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralOptionsPanelController.java new file mode 100644 index 0000000000..ec255fe021 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralOptionsPanelController.java @@ -0,0 +1,79 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.corecomponents; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import javax.swing.JComponent; +import org.netbeans.spi.options.OptionsPanelController; +import org.openide.util.HelpCtx; +import org.openide.util.Lookup; + +@OptionsPanelController.TopLevelRegistration( + categoryName = "#OptionsCategory_Name_General", +iconBase = "org/sleuthkit/autopsy/corecomponents/general-options.png", +position = 1, +keywords = "#OptionsCategory_Keywords_General", +keywordsCategory = "General") +@org.openide.util.NbBundle.Messages({"OptionsCategory_Name_General=General", "OptionsCategory_Keywords_General=general"}) +public final class GeneralOptionsPanelController extends OptionsPanelController { + + private GeneralPanel panel; + private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + private boolean changed; + + public void update() { + getPanel().load(); + changed = false; + } + + public void applyChanges() { + getPanel().store(); + changed = false; + } + + public void cancel() { + // need not do anything special, if no changes have been persisted yet + } + + public boolean isValid() { + return getPanel().valid(); + } + + public boolean isChanged() { + return changed; + } + + public HelpCtx getHelpCtx() { + return null; // new HelpCtx("...ID") if you have a help set + } + + public JComponent getComponent(Lookup masterLookup) { + return getPanel(); + } + + public void addPropertyChangeListener(PropertyChangeListener l) { + pcs.addPropertyChangeListener(l); + } + + public void removePropertyChangeListener(PropertyChangeListener l) { + pcs.removePropertyChangeListener(l); + } + + private GeneralPanel getPanel() { + if (panel == null) { + panel = new GeneralPanel(this); + } + return panel; + } + + void changed() { + if (!changed) { + changed = true; + pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); + } + pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); + } +} diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form new file mode 100644 index 0000000000..c1c9b63f55 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form @@ -0,0 +1,44 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java new file mode 100644 index 0000000000..b243ab9dd9 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java @@ -0,0 +1,63 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.corecomponents; + +import org.openide.util.NbPreferences; + +final class GeneralPanel extends javax.swing.JPanel { + + private final GeneralOptionsPanelController controller; + + GeneralPanel(GeneralOptionsPanelController controller) { + this.controller = controller; + initComponents(); + // TODO listen to changes in form fields and call controller.changed() + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + preferredViewerCheckBox = new javax.swing.JCheckBox(); + + org.openide.awt.Mnemonics.setLocalizedText(preferredViewerCheckBox, org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.preferredViewerCheckBox.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(preferredViewerCheckBox) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(preferredViewerCheckBox) + .addGap(0, 45, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + void load() { + preferredViewerCheckBox.setSelected(NbPreferences.forModule(GeneralPanel.class).getBoolean("keepPreferredViewer", false)); + } + + void store() { + NbPreferences.forModule(GeneralPanel.class).putBoolean("keepPreferredViewer", preferredViewerCheckBox.isSelected()); + } + + boolean valid() { + // TODO check whether form is consistent and complete + return true; + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox preferredViewerCheckBox; + // End of variables declaration//GEN-END:variables +} diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/general-options.png b/Core/src/org/sleuthkit/autopsy/corecomponents/general-options.png new file mode 100644 index 0000000000..272cce9d98 Binary files /dev/null and b/Core/src/org/sleuthkit/autopsy/corecomponents/general-options.png differ diff --git a/HashDatabase/nbproject/genfiles.properties b/HashDatabase/nbproject/genfiles.properties index faa3e5de44..afa0565e7e 100644 --- a/HashDatabase/nbproject/genfiles.properties +++ b/HashDatabase/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=b063abc7 +build.xml.data.CRC32=dee5be43 build.xml.script.CRC32=1308cb72 build.xml.stylesheet.CRC32=a56c6a5b@2.50.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=b063abc7 +nbproject/build-impl.xml.data.CRC32=dee5be43 nbproject/build-impl.xml.script.CRC32=a7a0d07a nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1 diff --git a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDatabaseOptionsPanelController.java b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDatabaseOptionsPanelController.java index 922fc02d44..2492db7d5f 100644 --- a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDatabaseOptionsPanelController.java +++ b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDatabaseOptionsPanelController.java @@ -29,6 +29,7 @@ import org.openide.util.Lookup; @OptionsPanelController.TopLevelRegistration( categoryName = "#OptionsCategory_Name_HashDatabase", iconBase = "org/sleuthkit/autopsy/hashdatabase/options_icon.png", +position = 3, keywords = "#OptionsCategory_Keywords_HashDatabase", keywordsCategory = "HashDatabase", id = "HashDatabase") diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchOptionsPanelController.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchOptionsPanelController.java index b8c3d95e39..4755b913f7 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchOptionsPanelController.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchOptionsPanelController.java @@ -14,6 +14,7 @@ import org.openide.util.Lookup; @OptionsPanelController.TopLevelRegistration( categoryName = "#OptionsCategory_Name_KeywordSearchOptions", iconBase = "org/sleuthkit/autopsy/keywordsearch/options-icon.png", +position = 2, keywords = "#OptionsCategory_Keywords_KeywordSearchOptions", keywordsCategory = "KeywordSearchOptions") @org.openide.util.NbBundle.Messages({"OptionsCategory_Name_KeywordSearchOptions=Keyword Search", "OptionsCategory_Keywords_KeywordSearchOptions=Keyword Search"})