1
0
mirror of https://github.com/elisspace/autopsy.git synced 2026-09-06 02:24:30 +00:00

add standalone ingest floating window top component, custom modes, remove old Ingest explorer

This commit is contained in:
adam-m
2012-02-16 12:11:58 -05:00
parent a8f6fcdf71
commit 986ee23261
8 changed files with 350 additions and 84 deletions

View File

@@ -18,7 +18,6 @@
*/
package org.sleuthkit.autopsy.ingest;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.DateFormat;
@@ -46,7 +45,6 @@ import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.Cancellable;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.ingest.IngestMessage.MessageType;
import org.sleuthkit.datamodel.FsContent;
import org.sleuthkit.datamodel.Image;
@@ -88,7 +86,7 @@ public class IngestManager {
public final static String SERVICE_STOPPED_EVT = IngestManagerEvents.SERVICE_STOPPED.name();
public final static String SERVICE_HAS_DATA_EVT = IngestManagerEvents.SERVICE_HAS_DATA.name();
//ui
private IngestUI ui = IngestTopComponent.getDefault();
private IngestUI ui = IngestMessageTopComponent.findInstance();
//singleton
private static IngestManager instance;
@@ -97,8 +95,8 @@ public class IngestManager {
}
static synchronized IngestManager getDefault() {
logger.log(Level.INFO, "creating manager instance");
if (instance == null) {
logger.log(Level.INFO, "creating manager instance");
instance = new IngestManager();
}
return instance;

View File

@@ -0,0 +1,28 @@
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" 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">
<EmptySpace min="0" pref="385" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="362" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>

View File

@@ -0,0 +1,264 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.ingest;
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.Image;
/**
* Top component which displays something.
*/
//@ConvertAsProperties(dtd = "-//org.sleuthkit.autopsy.ingest//IngestMessage//EN",
//autostore = false)
//@TopComponent.Description(preferredID = "IngestMessageTopComponent",
//iconBase = "org/sleuthkit/autopsy/ingest/ingest-msg-icon.png",
//persistenceType = TopComponent.PERSISTENCE_NEVER)
//@TopComponent.Registration(mode = "floatingLeftBottom", openAtStartup = false)
//@ActionID(category = "Window", id = "org.sleuthkit.autopsy.ingest.IngestMessageTopComponent")
//@ActionReference(path = "Menu/Window" /*, position = 333 */)
//@TopComponent.OpenActionRegistration(displayName = "#CTL_IngestMessageAction",
//preferredID = "IngestMessageTopComponent")
public final class IngestMessageTopComponent extends TopComponent implements IngestUI {
private static IngestMessageTopComponent instance;
private static final Logger logger = Logger.getLogger(IngestMessageTopComponent.class.getName());
private IngestMessagePanel messagePanel;
private static String PREFERRED_ID = "IngestMessageTopComponent";
public IngestMessageTopComponent() {
initComponents();
customizeComponents();
registerListeners();
setName(NbBundle.getMessage(IngestMessageTopComponent.class, "CTL_IngestMessageTopComponent"));
setToolTipText(NbBundle.getMessage(IngestMessageTopComponent.class, "HINT_IngestMessageTopComponent"));
putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE);
//putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE);
}
private static synchronized IngestMessageTopComponent getDefault() {
if (instance == null) {
instance = new IngestMessageTopComponent();
}
return instance;
}
public static synchronized IngestMessageTopComponent findInstance() {
TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
if (win == null) {
return getDefault();
}
if (win instanceof IngestMessageTopComponent) {
return (IngestMessageTopComponent) win;
}
return getDefault();
}
/** 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() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 385, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 362, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
@Override
public void componentOpened() {
// TODO add custom code on component opening
// WindowManager.getDefault().findMode("floatingLeftBottom").dockInto(this);
IngestManager.getDefault(); //create initial instance
//TODO alternatively, reigster manager with lookup and instantiate when case is opened or image added
}
@Override
public void componentClosed() {
// TODO add custom code on component closing
// WindowManager.getDefault().findMode("bottomSlidingSide").dockInto(this);
}
@Override
protected void componentShowing() {
super.componentShowing();
//WindowManager.getDefault().findMode("floatingLeftBottom").dockInto(this);
}
@Override
protected void componentHidden() {
super.componentHidden();
//WindowManager.getDefault().findMode("bottomSlidingSide").dockInto(this);
//WindowManager.getDefault().findMode("floatingLeftBottom").dockInto(this);
}
@Override
protected void componentActivated() {
super.componentActivated();
}
@Override
protected void componentDeactivated() {
super.componentDeactivated();
}
@Override
public boolean canClose() {
return false;
}
@Override
public int getPersistenceType() {
return TopComponent.PERSISTENCE_NEVER;
}
@Override
public java.awt.Image getIcon() {
return ImageUtilities.loadImage(
"org/sleuthkit/autopsy/ingest/ingest-msg-icon.png");
}
void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
// TODO store your settings
}
void readProperties(java.util.Properties p) {
String version = p.getProperty("version");
// TODO read your settings according to their version
}
private void registerListeners() {
//handle case change
Case.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(Case.CASE_CURRENT_CASE)) {
Case oldCase = (Case) evt.getOldValue();
if (oldCase == null) //nothing to do, new case had been opened
{
return;
}
//stop workers if running
IngestManager.getDefault().stopAll();
//clear inbox
clearMessages();
} else if (evt.getPropertyName().equals(Case.CASE_ADD_IMAGE)) {
final Image image = (Image) evt.getNewValue();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
displayIngestDialog(image);
}
});
}
}
});
}
private void customizeComponents() {
//custom GUI setup not done by builder
messagePanel = new IngestMessagePanel();
messagePanel.setOpaque(false);
setLayout(new BorderLayout());
add(messagePanel, BorderLayout.CENTER);
//messagePanel.addMessage(IngestMessage.createManagerMessage("TEST1"));
//messagePanel.addMessage(IngestMessage.createManagerMessage("TEST2"));
//messagePanel.addMessage(IngestMessage.createManagerMessage("TEST3"));
}
/**
* Display ingest summary report in some dialog
*/
@Override
public void displayReport(String ingestReport) {
JOptionPane.showMessageDialog(
null,
ingestReport,
"File Ingest Summary",
JOptionPane.INFORMATION_MESSAGE);
}
/**
* Display IngestMessage from service (forwarded by IngestManager)
*/
@Override
public void displayMessage(IngestMessage ingestMessage) {
addMessage(ingestMessage);
}
@Override
public void initProgress(int maximum) {
}
@Override
public void updateProgress(int progress) {
}
@Override
public void clearMessages() {
clearMessages();
}
@Override
public void displayIngestDialog(final Image image) {
final IngestDialog ingestDialog = new IngestDialog();
ingestDialog.setImage(image);
ingestDialog.display();
}
public void addMessage(IngestMessage m) {
messagePanel.addMessage(m);
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
<tc-ref version="2.2">
<tc-id id="IngestMessageTopComponent" />
<state opened="true" />
<previousMode name="bottomSlidingSide" index="0" />
</tc-ref>

View File

@@ -35,7 +35,7 @@ import org.sleuthkit.datamodel.Image;
/**
* Top component explorer for the Ingest module.
*/
public final class IngestTopComponent extends TopComponent implements DataExplorer, IngestUI {
public final class IngestTopComponent extends TopComponent implements DataExplorer {
private static IngestTopComponent instance;
private static final Logger logger = Logger.getLogger(IngestTopComponent.class.getName());
@@ -43,8 +43,8 @@ public final class IngestTopComponent extends TopComponent implements DataExplor
private IngestTopComponent() {
initComponents();
customizeComponents();
registerListeners();
// customizeComponents();
//registerListeners();
setName(NbBundle.getMessage(IngestTopComponent.class, "CTL_IngestTopComponent"));
setToolTipText(NbBundle.getMessage(IngestTopComponent.class, "HINT_IngestTopComponent"));
//putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE);
@@ -74,36 +74,6 @@ public final class IngestTopComponent extends TopComponent implements DataExplor
return TopComponent.PERSISTENCE_NEVER;
}
private void registerListeners() {
//handle case change
Case.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(Case.CASE_CURRENT_CASE)) {
Case oldCase = (Case) evt.getOldValue();
if (oldCase == null) //nothing to do, new case had been opened
{
return;
}
//stop workers if running
IngestManager.getDefault().stopAll();
//clear inbox
clearMessages();
} else if (evt.getPropertyName().equals(Case.CASE_ADD_IMAGE)) {
final Image image = (Image) evt.getNewValue();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
displayIngestDialog(image);
}
});
}
}
});
}
private void customizeComponents() {
//custom GUI setup not done by builder
@@ -257,7 +227,7 @@ public final class IngestTopComponent extends TopComponent implements DataExplor
@Override
public void componentOpened() {
logger.log(Level.INFO, "IngestTopComponent opened()");
IngestManager.getDefault(); //create initial instance
// IngestManager.getDefault(); //create initial instance
}
@@ -279,46 +249,7 @@ public final class IngestTopComponent extends TopComponent implements DataExplor
}
/**
* Display ingest summary report in some dialog
*/
@Override
public void displayReport(String ingestReport) {
JOptionPane.showMessageDialog(
null,
ingestReport,
"File Ingest Summary",
JOptionPane.INFORMATION_MESSAGE);
}
/**
* Display IngestMessage from service (forwarded by IngestManager)
*/
@Override
public void displayMessage(IngestMessage ingestMessage) {
messagePanel.addMessage(ingestMessage);
}
@Override
public void initProgress(int maximum) {
this.mainProgressBar.setMaximum(maximum);
}
@Override
public void updateProgress(int progress) {
this.mainProgressBar.setValue(progress);
}
@Override
public void clearMessages() {
messagePanel.clearMessages();
}
@Override
public void displayIngestDialog(final Image image) {
final IngestDialog ingestDialog = new IngestDialog();
ingestDialog.setImage(image);
ingestDialog.display();
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mode PUBLIC
"-//NetBeans//DTD Mode Properties 2.0//EN"
"http://www.netbeans.org/dtds/mode-properties2_0.dtd">
<mode version="2.3">
<name unique="floatingLeftBottom" />
<kind type="view" />
<!-- <kind type="sliding"/>
<slidingSide side="bottom"/> -->
<state type="separated" />
<constraints>
<path orientation="horizontal" number="100" weight="0.5"/>
</constraints>
<bounds x="8" y="710" width="369" height="421" />
<frame state="0"/>
<active-tc id="IngestMessageTopComponent" />
<empty-behavior permanent="true"/>
</mode>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Actions">
<folder name="Window">
<file name="org-sleuthkit-autopsy-ingest-IngestMessageTopComponent.instance"/>
</folder>
</folder>
<folder name="Services">
<file name="org-sleuthkit-autopsy-ingest-IngestTopComponent.instance">
<attr name="instanceOf" stringvalue="org.sleuthkit.autopsy.corecomponentinterfaces.DataExplorer"/>
<attr name="instanceCreate" methodvalue="org.sleuthkit.autopsy.ingest.IngestTopComponent.getDefault"/>
<attr name="position" intvalue="300"/>
</file>
<!-- <file name="org-sleuthkit-autopsy-ingest-IngestMessageTopComponent.instance">
<attr name="instanceOf" stringvalue="org.sleuthkit.autopsy.corecomponentinterfaces.FloatingMessageViewer"/>
<attr name="instanceCreate" methodvalue="org.sleuthkit.autopsy.ingest.IngestMessageTopComponent.findInstance"/>
<attr name="position" intvalue="100"/>
</file> -->
<!-- example services -->
<!--
<file name="org-sleuthkit-autopsy-ingest-example-ExampleImageIngestService.instance">
@@ -22,4 +28,12 @@
</file>
-->
</folder>
<folder name="Windows2">
<folder name="Modes">
<folder name="floatingLeftBottom">
<file name="IngestMessageTopComponent.wstcref" url="IngestMessageTopComponentWstcref.xml"/>
</folder>
<file name="floatingLeftBottom.wsmode" url="floatingLeftBottomWsmode.xml"/>
</folder>
</folder>
</filesystem>