Autopsy  4.6.0
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 - 2013 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  */
19 package org.sleuthkit.autopsy.modules.hashdatabase;
20 
21 import java.awt.*;
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;
27 
28 import org.openide.util.NbBundle;
30 
44 class ModalNoButtons extends javax.swing.JDialog implements PropertyChangeListener {
45 
46  List<SleuthkitHashSet> unindexed;
47  SleuthkitHashSet toIndex;
48  HashLookupSettingsPanel hdbmp;
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  INDEXING_PROGBAR.setFont(INDEXING_PROGBAR.getFont().deriveFont(INDEXING_PROGBAR.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
108 
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")); // NOI18N
112 
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")); // NOI18N
115 
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")); // NOI18N
118 
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")); // NOI18N
121  CANCEL_BUTTON.addMouseListener(new java.awt.event.MouseAdapter() {
122  public void mouseClicked(java.awt.event.MouseEvent evt) {
123  CANCEL_BUTTONMouseClicked(evt);
124  }
125  });
126 
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()
132  .addContainerGap()
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)))
146  .addContainerGap())
147  );
148  layout.setVerticalGroup(
149  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
150  .addGroup(layout.createSequentialGroup()
151  .addContainerGap()
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)
161  .addGap(36, 36, 36))
162  );
163 
164  pack();
165  }// </editor-fold>//GEN-END:initComponents
166 
177  private void CANCEL_BUTTONMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CANCEL_BUTTONMouseClicked
178  String message = NbBundle.getMessage(this.getClass(), "ModalNoButtons.exitHashDbIndexingMsg");
179 
180  int res = JOptionPane.showConfirmDialog(this,
181  message,
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;
189  } else {
190  remove.add(this.toIndex);
191  }
192  this.hdbmp.removeThese(remove);
193  this.setVisible(false);
194  this.setModal(false);
195  this.dispose();
196  }
197 
198  }//GEN-LAST:event_CANCEL_BUTTONMouseClicked
199 
200  private void initCustom() {
201  this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
202  if (this.unindexed != null) {
203  indexThese();
204  } else {
205  indexThis();
206  }
207  }
208 
213  private void indexThis() {
214  this.INDEXING_PROGBAR.setIndeterminate(true);
215  currentDb = this.toIndex.getHashSetName();
216  this.CURRENTDB_LABEL.setText("(" + currentDb + ")");
217  this.length = 1;
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);
223  }
224  }
225 
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);
241  }
242  }
243  }
244  // Variables declaration - do not modify//GEN-BEGIN:variables
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;
250  // End of variables declaration//GEN-END:variables
251 
252  @Override
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);
263  this.dispose();
264  } else {
265  currentcount++;
266  this.CURRENTLYON_LABEL.setText(
267  NbBundle.getMessage(this.getClass(), "ModalNoButtons.propChg.currentlyIndexingXofN",
268  currentcount, length));
269  }
270  }
271  }
272 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.