Hash nodes added.

This commit is contained in:
devin148 2012-07-27 14:58:15 -04:00
parent 402c428d3e
commit d3e07d350d
6 changed files with 121 additions and 66 deletions

View File

@ -53,3 +53,4 @@ HashDbSearchPanel.searchButton.text=Search
HashDbSearchPanel.removeButton.text=Remove Selected
HashDbSearchPanel.titleLabel.text=Search for files with the following MD5 hash(es):
HashDbSearchPanel.errorField.text=Error: Not all files have been hashed.
HashDbSearchPanel.saveBox.text=Remember Hashes

View File

@ -20,6 +20,8 @@ package org.sleuthkit.autopsy.hashdatabase;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import org.openide.util.HelpCtx;
import org.openide.util.actions.CallableSystemAction;
import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationCleanDialog;
@ -38,6 +40,14 @@ class HashDbSearchAction extends CallableSystemAction {
panel.cancelButtonListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
panel.clear();
dialog.close();
}
});
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
panel.clear();
dialog.close();
}
});

View File

@ -50,9 +50,9 @@ public class HashDbSearchManager {
for(String s : map.keySet()) {
for(FsContent file : map.get(s)) {
Map<String, Object> keyMap = new LinkedHashMap<String, Object>();
keyMap.put("Hash", s);
keyMap.put("MD5 Hash", s);
AbstractFsContentNode.fillPropertyMap(keyMap, file);
KeyValue kv = new KeyValue("MD5 - Name", keyMap, ++id);
KeyValue kv = new KeyValue(file.getName(), keyMap, ++id);
keyValues.add(kv);
}
}

View File

@ -44,6 +44,8 @@
<Component id="addButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="removeButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="saveBox" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
@ -71,6 +73,7 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="addButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="removeButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="saveBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="27" max="32767" attributes="0"/>
<Component id="jSeparator1" min="-2" pref="10" max="-2" attributes="0"/>
@ -179,5 +182,15 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="saveBox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/hashdatabase/Bundle.properties" key="HashDbSearchPanel.saveBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBoxActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -128,6 +128,7 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
jSeparator1 = new javax.swing.JSeparator();
titleLabel = new javax.swing.JLabel();
errorField = new javax.swing.JLabel();
saveBox = new javax.swing.JCheckBox();
hashTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
@ -173,6 +174,13 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
errorField.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(errorField, org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.errorField.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(saveBox, org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.saveBox.text")); // NOI18N
saveBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveBoxActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@ -202,7 +210,9 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
.addGap(61, 61, 61)
.addComponent(addButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(removeButton)))
.addComponent(removeButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(saveBox)))
.addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap())
);
@ -220,7 +230,8 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addButton)
.addComponent(removeButton))
.addComponent(removeButton)
.addComponent(saveBox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
@ -231,6 +242,11 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void saveBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBoxActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_saveBoxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addButton;
private javax.swing.JButton cancelButton;
@ -241,6 +257,7 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JButton removeButton;
private javax.swing.JCheckBox saveBox;
private javax.swing.JButton searchButton;
private javax.swing.JLabel titleLabel;
// End of variables declaration//GEN-END:variables
@ -306,4 +323,17 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
model.removeRow(rows[i]);
}
}
/**
* Clears the table of hashes
*/
void clear() {
if(!saveBox.isSelected()) {
DefaultTableModel model = (DefaultTableModel) hashTable.getModel();
int numRows = hashTable.getRowCount();
for(int i=0; i<numRows; i++) {
model.removeRow(i);
}
}
}
}

View File

@ -8,6 +8,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.datamodel.KeyValue;
import org.sleuthkit.autopsy.datamodel.KeyValueNode;
@ -34,6 +35,6 @@ public class HashDbSearchResultFactory extends ChildFactory<KeyValue> {
@Override
protected Node createNodeForKey(KeyValue thing) {
return new KeyValueNode(thing, null);
return new KeyValueNode(thing, Children.LEAF);
}
}