mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
Merge pull request #125 from tmciver-basis/master
Preferred content viewer option
This commit is contained in:
commit
e56a75df04
@ -42,6 +42,15 @@
|
||||
<specification-version>2.27.1</specification-version>
|
||||
</run-dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<code-name-base>org.netbeans.modules.options.api</code-name-base>
|
||||
<build-prerequisite/>
|
||||
<compile-dependency/>
|
||||
<run-dependency>
|
||||
<release-version>1</release-version>
|
||||
<specification-version>1.26.1</specification-version>
|
||||
</run-dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<code-name-base>org.netbeans.modules.settings</code-name-base>
|
||||
<build-prerequisite/>
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="preferredViewerCheckBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="preferredViewerCheckBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="45" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JCheckBox" name="preferredViewerCheckBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="GeneralPanel.preferredViewerCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
|
||||
);
|
||||
}// </editor-fold>//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
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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"})
|
||||
|
Loading…
x
Reference in New Issue
Block a user