19 package org.sleuthkit.autopsy.modules.hashdatabase;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.List;
25 import javax.swing.JOptionPane;
27 import org.openide.util.NbBundle;
43 @SuppressWarnings(
"PMD.SingularField")
44 class ModalNoButtons extends javax.swing.JDialog implements PropertyChangeListener {
46 List<SleuthkitHashSet> unindexed;
47 SleuthkitHashSet toIndex;
48 HashLookupSettingsPanel hdbmp;
51 String currentDb =
"";
61 ModalNoButtons(HashLookupSettingsPanel hdbmp, java.awt.Frame parent, List<SleuthkitHashSet> unindexed) {
62 super(parent, NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.indexingDbsTitle"),
true);
63 this.unindexed = unindexed;
78 ModalNoButtons(HashLookupSettingsPanel hdbmp, java.awt.Frame parent, SleuthkitHashSet unindexed) {
79 super(parent, NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.indexingDbTitle"),
true);
80 this.unindexed = null;
81 this.toIndex = unindexed;
92 @SuppressWarnings(
"unchecked")
94 private
void initComponents() {
96 INDEXING_PROGBAR =
new javax.swing.JProgressBar();
97 GO_GET_COFFEE_LABEL =
new javax.swing.JLabel();
98 CURRENTLYON_LABEL =
new javax.swing.JLabel();
99 CURRENTDB_LABEL =
new javax.swing.JLabel();
100 CANCEL_BUTTON =
new javax.swing.JButton();
102 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
103 setMinimumSize(
new java.awt.Dimension(519, 130));
107 GO_GET_COFFEE_LABEL.setDisplayedMnemonic(
'H');
108 org.openide.awt.Mnemonics.setLocalizedText(GO_GET_COFFEE_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.GO_GET_COFFEE_LABEL.text"));
110 CURRENTLYON_LABEL.setFont(CURRENTLYON_LABEL.getFont().deriveFont(CURRENTLYON_LABEL.getFont().getSize()+3f));
111 org.openide.awt.Mnemonics.setLocalizedText(CURRENTLYON_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CURRENTLYON_LABEL.text"));
113 CURRENTDB_LABEL.setFont(CURRENTDB_LABEL.getFont().deriveFont(CURRENTDB_LABEL.getFont().getSize()+3f));
114 org.openide.awt.Mnemonics.setLocalizedText(CURRENTDB_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CURRENTDB_LABEL.text"));
116 org.openide.awt.Mnemonics.setLocalizedText(CANCEL_BUTTON,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CANCEL_BUTTON.text"));
117 CANCEL_BUTTON.addMouseListener(
new java.awt.event.MouseAdapter() {
118 public void mouseClicked(java.awt.event.MouseEvent evt) {
119 CANCEL_BUTTONMouseClicked(evt);
123 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
124 getContentPane().setLayout(layout);
125 layout.setHorizontalGroup(
126 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
127 .addGroup(layout.createSequentialGroup()
129 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
130 .addComponent(INDEXING_PROGBAR, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
131 .addGroup(layout.createSequentialGroup()
132 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
133 .addComponent(GO_GET_COFFEE_LABEL)
134 .addGroup(layout.createSequentialGroup()
135 .addComponent(CURRENTLYON_LABEL)
136 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
137 .addComponent(CURRENTDB_LABEL)))
138 .addGap(0, 0, Short.MAX_VALUE))
139 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
140 .addGap(0, 0, Short.MAX_VALUE)
141 .addComponent(CANCEL_BUTTON)))
144 layout.setVerticalGroup(
145 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
146 .addGroup(layout.createSequentialGroup()
148 .addComponent(GO_GET_COFFEE_LABEL)
149 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
150 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
151 .addComponent(CURRENTLYON_LABEL)
152 .addComponent(CURRENTDB_LABEL))
153 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
154 .addComponent(INDEXING_PROGBAR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
155 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
156 .addComponent(CANCEL_BUTTON)
173 private void CANCEL_BUTTONMouseClicked(java.awt.event.MouseEvent evt) {
174 String message = NbBundle.getMessage(this.getClass(),
"ModalNoButtons.exitHashDbIndexingMsg");
176 int res = JOptionPane.showConfirmDialog(
this,
178 NbBundle.getMessage(
this.getClass(),
179 "ModalNoButtons.dlgTitle.unfinishedIndexing"),
180 JOptionPane.YES_NO_OPTION);
181 if (res == JOptionPane.YES_OPTION) {
182 List<SleuthkitHashSet>
remove =
new ArrayList<>();
183 if (this.toIndex == null) {
184 remove = this.unindexed;
186 remove.add(this.toIndex);
188 this.hdbmp.removeThese(
remove);
189 this.setVisible(
false);
190 this.setModal(
false);
196 private void initCustom() {
197 this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
198 if (this.unindexed != null) {
209 private void indexThis() {
210 this.INDEXING_PROGBAR.setIndeterminate(
true);
211 currentDb = this.toIndex.getHashSetName();
212 this.CURRENTDB_LABEL.setText(
"(" + currentDb +
")");
214 this.CURRENTLYON_LABEL.setText(
215 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.indexThis.currentlyIndexing1Db"));
216 if (!this.toIndex.isIndexing()) {
217 this.toIndex.addPropertyChangeListener(
this);
218 HashDbManager.getInstance().indexHashDatabase(toIndex);
226 private void indexThese() {
227 length = this.unindexed.size();
228 this.INDEXING_PROGBAR.setIndeterminate(
true);
229 for (SleuthkitHashSet db : this.unindexed) {
230 currentDb = db.getHashSetName();
231 this.CURRENTDB_LABEL.setText(
"(" + currentDb +
")");
232 this.CURRENTLYON_LABEL.setText(
233 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.indexThese.currentlyIndexing1OfNDbs", length));
234 if (!db.isIndexing()) {
235 db.addPropertyChangeListener(
this);
236 HashDbManager.getInstance().indexHashDatabase(db);
241 private javax.swing.JButton CANCEL_BUTTON;
242 private javax.swing.JLabel CURRENTDB_LABEL;
243 private javax.swing.JLabel CURRENTLYON_LABEL;
244 private javax.swing.JLabel GO_GET_COFFEE_LABEL;
245 private javax.swing.JProgressBar INDEXING_PROGBAR;
253 public void propertyChange(PropertyChangeEvent evt) {
254 if (evt.getPropertyName().equals(SleuthkitHashSet.Event.INDEXING_DONE.name())) {
255 if (currentcount >= length) {
256 this.INDEXING_PROGBAR.setValue(100);
257 this.setModal(
false);
258 this.setVisible(
false);
262 this.CURRENTLYON_LABEL.setText(
263 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.propChg.currentlyIndexingXofN",
264 currentcount, length));