19 package org.sleuthkit.autopsy.modules.hashdatabase;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.ArrayList;
25 import java.util.List;
26 import javax.swing.JOptionPane;
28 import org.openide.util.NbBundle;
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 INDEXING_PROGBAR.setFont(INDEXING_PROGBAR.getFont().deriveFont(INDEXING_PROGBAR.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
109 GO_GET_COFFEE_LABEL.setDisplayedMnemonic(
'H');
110 GO_GET_COFFEE_LABEL.setFont(GO_GET_COFFEE_LABEL.getFont().deriveFont(GO_GET_COFFEE_LABEL.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
111 org.openide.awt.Mnemonics.setLocalizedText(GO_GET_COFFEE_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.GO_GET_COFFEE_LABEL.text"));
113 CURRENTLYON_LABEL.setFont(CURRENTLYON_LABEL.getFont().deriveFont(CURRENTLYON_LABEL.getFont().getStyle() & ~java.awt.Font.BOLD, 14));
114 org.openide.awt.Mnemonics.setLocalizedText(CURRENTLYON_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CURRENTLYON_LABEL.text"));
116 CURRENTDB_LABEL.setFont(CURRENTDB_LABEL.getFont().deriveFont(CURRENTDB_LABEL.getFont().getStyle() & ~java.awt.Font.BOLD, 14));
117 org.openide.awt.Mnemonics.setLocalizedText(CURRENTDB_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CURRENTDB_LABEL.text"));
119 CANCEL_BUTTON.setFont(CANCEL_BUTTON.getFont().deriveFont(CANCEL_BUTTON.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
120 org.openide.awt.Mnemonics.setLocalizedText(CANCEL_BUTTON,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CANCEL_BUTTON.text"));
121 CANCEL_BUTTON.addMouseListener(
new java.awt.event.MouseAdapter() {
122 public void mouseClicked(java.awt.event.MouseEvent evt) {
123 CANCEL_BUTTONMouseClicked(evt);
127 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
128 getContentPane().setLayout(layout);
129 layout.setHorizontalGroup(
130 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
131 .addGroup(layout.createSequentialGroup()
133 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
134 .addComponent(INDEXING_PROGBAR, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
135 .addGroup(layout.createSequentialGroup()
136 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
137 .addComponent(GO_GET_COFFEE_LABEL)
138 .addGroup(layout.createSequentialGroup()
139 .addComponent(CURRENTLYON_LABEL)
140 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
141 .addComponent(CURRENTDB_LABEL)))
142 .addGap(0, 0, Short.MAX_VALUE))
143 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
144 .addGap(0, 0, Short.MAX_VALUE)
145 .addComponent(CANCEL_BUTTON)))
148 layout.setVerticalGroup(
149 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
150 .addGroup(layout.createSequentialGroup()
152 .addComponent(GO_GET_COFFEE_LABEL)
153 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
154 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
155 .addComponent(CURRENTLYON_LABEL)
156 .addComponent(CURRENTDB_LABEL))
157 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
158 .addComponent(INDEXING_PROGBAR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
159 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
160 .addComponent(CANCEL_BUTTON)
177 private void CANCEL_BUTTONMouseClicked(java.awt.event.MouseEvent evt) {
178 String message = NbBundle.getMessage(this.getClass(),
"ModalNoButtons.exitHashDbIndexingMsg");
180 int res = JOptionPane.showConfirmDialog(
this,
182 NbBundle.getMessage(
this.getClass(),
183 "ModalNoButtons.dlgTitle.unfinishedIndexing"),
184 JOptionPane.YES_NO_OPTION);
185 if (res == JOptionPane.YES_OPTION) {
186 List<SleuthkitHashSet>
remove =
new ArrayList<>();
187 if (this.toIndex == null) {
188 remove = this.unindexed;
190 remove.add(this.toIndex);
192 this.hdbmp.removeThese(
remove);
193 this.setVisible(
false);
194 this.setModal(
false);
200 private void initCustom() {
201 this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
202 if (this.unindexed != null) {
213 private void indexThis() {
214 this.INDEXING_PROGBAR.setIndeterminate(
true);
215 currentDb = this.toIndex.getHashSetName();
216 this.CURRENTDB_LABEL.setText(
"(" + currentDb +
")");
218 this.CURRENTLYON_LABEL.setText(
219 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.indexThis.currentlyIndexing1Db"));
220 if (!this.toIndex.isIndexing()) {
221 this.toIndex.addPropertyChangeListener(
this);
222 HashDbManager.getInstance().indexHashDatabase(toIndex);
230 private void indexThese() {
231 length = this.unindexed.size();
232 this.INDEXING_PROGBAR.setIndeterminate(
true);
233 for (SleuthkitHashSet db : this.unindexed) {
234 currentDb = db.getHashSetName();
235 this.CURRENTDB_LABEL.setText(
"(" + currentDb +
")");
236 this.CURRENTLYON_LABEL.setText(
237 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.indexThese.currentlyIndexing1OfNDbs", length));
238 if (!db.isIndexing()) {
239 db.addPropertyChangeListener(
this);
240 HashDbManager.getInstance().indexHashDatabase(db);
245 private javax.swing.JButton CANCEL_BUTTON;
246 private javax.swing.JLabel CURRENTDB_LABEL;
247 private javax.swing.JLabel CURRENTLYON_LABEL;
248 private javax.swing.JLabel GO_GET_COFFEE_LABEL;
249 private javax.swing.JProgressBar INDEXING_PROGBAR;
257 public void propertyChange(PropertyChangeEvent evt) {
258 if (evt.getPropertyName().equals(SleuthkitHashSet.Event.INDEXING_DONE.name())) {
259 if (currentcount >= length) {
260 this.INDEXING_PROGBAR.setValue(100);
261 this.setModal(
false);
262 this.setVisible(
false);
266 this.CURRENTLYON_LABEL.setText(
267 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.propChg.currentlyIndexingXofN",
268 currentcount, length));