Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ModalNoButtons.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2011-2018 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package org.sleuthkit.autopsy.modules.hashdatabase;
20
21import java.beans.PropertyChangeEvent;
22import java.beans.PropertyChangeListener;
23import java.util.ArrayList;
24import java.util.List;
25import javax.swing.JOptionPane;
26
27import org.openide.util.NbBundle;
28import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.SleuthkitHashSet;
29
43@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
44class ModalNoButtons extends javax.swing.JDialog implements PropertyChangeListener {
45
46 List<SleuthkitHashSet> unindexed;
47 SleuthkitHashSet toIndex;
49 int length = 0;
50 int currentcount = 1;
51 String currentDb = "";
52
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;
64 this.toIndex = null;
65 this.hdbmp = hdbmp;
66 initComponents();
67 initCustom();
68 }
69
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;
82 this.hdbmp = hdbmp;
83 initComponents();
84 initCustom();
85 }
86
92 @SuppressWarnings("unchecked")
93 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
94 private void initComponents() {
95
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();
101
102 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
103 setMinimumSize(new java.awt.Dimension(519, 130));
104 setModal(true);
105 setResizable(false);
106
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")); // NOI18N
109
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")); // NOI18N
112
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")); // NOI18N
115
116 org.openide.awt.Mnemonics.setLocalizedText(CANCEL_BUTTON, org.openide.util.NbBundle.getMessage(ModalNoButtons.class, "ModalNoButtons.CANCEL_BUTTON.text")); // NOI18N
117 CANCEL_BUTTON.addMouseListener(new java.awt.event.MouseAdapter() {
118 public void mouseClicked(java.awt.event.MouseEvent evt) {
119 CANCEL_BUTTONMouseClicked(evt);
120 }
121 });
122
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()
128 .addContainerGap()
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)))
142 .addContainerGap())
143 );
144 layout.setVerticalGroup(
145 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
146 .addGroup(layout.createSequentialGroup()
147 .addContainerGap()
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)
157 .addGap(36, 36, 36))
158 );
159
160 pack();
161 }// </editor-fold>//GEN-END:initComponents
162
173 private void CANCEL_BUTTONMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CANCEL_BUTTONMouseClicked
174 String message = NbBundle.getMessage(this.getClass(), "ModalNoButtons.exitHashDbIndexingMsg");
175
176 int res = JOptionPane.showConfirmDialog(this,
177 message,
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;
185 } else {
186 remove.add(this.toIndex);
187 }
188 this.hdbmp.removeThese(remove);
189 this.setVisible(false);
190 this.setModal(false);
191 this.dispose();
192 }
193
194 }//GEN-LAST:event_CANCEL_BUTTONMouseClicked
195
196 private void initCustom() {
197 this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
198 if (this.unindexed != null) {
199 indexThese();
200 } else {
201 indexThis();
202 }
203 }
204
209 private void indexThis() {
210 this.INDEXING_PROGBAR.setIndeterminate(true);
211 currentDb = this.toIndex.getHashSetName();
212 this.CURRENTDB_LABEL.setText("(" + currentDb + ")");
213 this.length = 1;
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);
219 }
220 }
221
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);
237 }
238 }
239 }
240 // Variables declaration - do not modify//GEN-BEGIN:variables
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;
246 // End of variables declaration//GEN-END:variables
247
248 @Override
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);
259 this.dispose();
260 } else {
261 currentcount++;
262 this.CURRENTLYON_LABEL.setText(
263 NbBundle.getMessage(this.getClass(), "ModalNoButtons.propChg.currentlyIndexingXofN",
264 currentcount, length));
265 }
266 }
267 }
268}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.