19 package org.sleuthkit.autopsy.modules.hashdatabase;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.regex.Pattern;
26 import javax.swing.JFrame;
27 import javax.swing.JMenuItem;
28 import javax.swing.JPopupMenu;
29 import javax.swing.SwingUtilities;
30 import org.openide.util.NbBundle;
31 import org.openide.windows.WindowManager;
38 @SuppressWarnings(
"PMD.SingularField")
42 Pattern md5Pattern = Pattern.compile(
"^[a-fA-F0-9]{32}$");
43 List<HashEntry> hashes =
new ArrayList<>();
44 List<String> invalidHashes =
new ArrayList<>();
51 super((JFrame) WindowManager.getDefault().getMainWindow(),
60 setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
70 void enableAddHashValuesToDatabaseDialog(
boolean enable) {
72 setDefaultCloseOperation(2);
74 setDefaultCloseOperation(0);
76 AddValuesToHashDatabaseButton.setEnabled(enable);
77 cancelButton.setEnabled(enable);
78 pasteFromClipboardButton.setEnabled(enable);
86 @SuppressWarnings(
"unchecked")
88 private
void initComponents() {
90 instructionLabel =
new javax.swing.JLabel();
91 jScrollPane1 =
new javax.swing.JScrollPane();
92 hashValuesTextArea =
new javax.swing.JTextArea();
93 pasteFromClipboardButton =
new javax.swing.JButton();
94 AddValuesToHashDatabaseButton =
new javax.swing.JButton();
95 cancelButton =
new javax.swing.JButton();
97 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
100 org.openide.awt.Mnemonics.setLocalizedText(instructionLabel,
org.openide.util.NbBundle.getMessage(
AddHashValuesToDatabaseDialog.class,
"AddHashValuesToDatabaseDialog.instructionLabel.text_1"));
102 hashValuesTextArea.setColumns(20);
103 hashValuesTextArea.setRows(5);
104 hashValuesTextArea.addMouseListener(
new java.awt.event.MouseAdapter() {
105 public void mouseClicked(java.awt.event.MouseEvent evt) {
106 hashValuesTextAreaMouseClicked(evt);
109 jScrollPane1.setViewportView(hashValuesTextArea);
111 org.openide.awt.Mnemonics.setLocalizedText(pasteFromClipboardButton,
org.openide.util.NbBundle.getMessage(
AddHashValuesToDatabaseDialog.class,
"AddHashValuesToDatabaseDialog.pasteFromClipboardButton.text_2"));
112 pasteFromClipboardButton.addActionListener(
new java.awt.event.ActionListener() {
113 public void actionPerformed(java.awt.event.ActionEvent evt) {
114 pasteFromClipboardButtonActionPerformed(evt);
118 org.openide.awt.Mnemonics.setLocalizedText(AddValuesToHashDatabaseButton,
org.openide.util.NbBundle.getMessage(
AddHashValuesToDatabaseDialog.class,
"AddHashValuesToDatabaseDialog.AddValuesToHashDatabaseButton.text_2"));
119 AddValuesToHashDatabaseButton.addActionListener(
new java.awt.event.ActionListener() {
120 public void actionPerformed(java.awt.event.ActionEvent evt) {
121 AddValuesToHashDatabaseButtonActionPerformed(evt);
125 org.openide.awt.Mnemonics.setLocalizedText(cancelButton,
org.openide.util.NbBundle.getMessage(
AddHashValuesToDatabaseDialog.class,
"AddHashValuesToDatabaseDialog.cancelButton.text_2"));
126 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
127 public void actionPerformed(java.awt.event.ActionEvent evt) {
128 cancelButtonActionPerformed(evt);
132 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
133 getContentPane().setLayout(layout);
134 layout.setHorizontalGroup(
135 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
136 .addGroup(layout.createSequentialGroup()
138 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
139 .addGroup(layout.createSequentialGroup()
140 .addComponent(instructionLabel)
141 .addGap(0, 0, Short.MAX_VALUE))
142 .addComponent(jScrollPane1))
144 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
145 .addComponent(AddValuesToHashDatabaseButton, javax.swing.GroupLayout.Alignment.TRAILING)
146 .addComponent(cancelButton, javax.swing.GroupLayout.Alignment.TRAILING)
147 .addComponent(pasteFromClipboardButton, javax.swing.GroupLayout.Alignment.TRAILING))
150 layout.setVerticalGroup(
151 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
152 .addGroup(layout.createSequentialGroup()
154 .addComponent(instructionLabel)
155 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
156 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
157 .addGroup(layout.createSequentialGroup()
158 .addComponent(AddValuesToHashDatabaseButton)
159 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
160 .addComponent(cancelButton)
161 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
162 .addComponent(pasteFromClipboardButton))
163 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE))
171 hashValuesTextArea.paste();
172 hashValuesTextArea.append(
"\n");
181 if (SwingUtilities.isRightMouseButton(evt)) {
182 JPopupMenu popup =
new JPopupMenu();
184 JMenuItem cutMenu =
new JMenuItem(
"Cut");
185 cutMenu.addActionListener(
new ActionListener() {
187 public void actionPerformed(ActionEvent e) {
188 hashValuesTextArea.cut();
192 JMenuItem copyMenu =
new JMenuItem(
"Copy");
193 copyMenu.addActionListener(
new ActionListener() {
195 public void actionPerformed(ActionEvent e) {
196 hashValuesTextArea.copy();
200 JMenuItem pasteMenu =
new JMenuItem(
"Paste");
201 pasteMenu.addActionListener(
new ActionListener() {
203 public void actionPerformed(ActionEvent e) {
204 hashValuesTextArea.paste();
205 hashValuesTextArea.append(
"\n");
211 popup.add(pasteMenu);
212 popup.show(hashValuesTextArea, evt.getX(), evt.getY());
218 progressDialog.addHashValuesToDatabase();
void cancelButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JButton pasteFromClipboardButton
void hashValuesTextAreaMouseClicked(java.awt.event.MouseEvent evt)
void pasteFromClipboardButtonActionPerformed(java.awt.event.ActionEvent evt)
void AddValuesToHashDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextArea hashValuesTextArea
javax.swing.JButton AddValuesToHashDatabaseButton
javax.swing.JLabel instructionLabel
javax.swing.JScrollPane jScrollPane1
javax.swing.JButton cancelButton