20 package org.sleuthkit.autopsy.modules.hashdatabase;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import java.util.ArrayList;
26 import java.util.List;
27 import javax.swing.JOptionPane;
29 import org.openide.util.NbBundle;
42 class ModalNoButtons
extends javax.swing.JDialog implements PropertyChangeListener {
44 List<HashDb> unindexed;
46 HashLookupSettingsPanel hdbmp;
49 String currentDb =
"";
57 ModalNoButtons(HashLookupSettingsPanel hdbmp, java.awt.Frame parent, List<HashDb> unindexed) {
58 super(parent, NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.indexingDbsTitle"),
true);
59 this.unindexed = unindexed;
72 ModalNoButtons(HashLookupSettingsPanel hdbmp, java.awt.Frame parent, HashDb unindexed){
73 super(parent, NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.indexingDbTitle"),
true);
74 this.unindexed = null;
75 this.toIndex = unindexed;
86 @SuppressWarnings(
"unchecked")
88 private
void initComponents() {
90 INDEXING_PROGBAR =
new javax.swing.JProgressBar();
91 GO_GET_COFFEE_LABEL =
new javax.swing.JLabel();
92 CURRENTLYON_LABEL =
new javax.swing.JLabel();
93 CURRENTDB_LABEL =
new javax.swing.JLabel();
94 CANCEL_BUTTON =
new javax.swing.JButton();
96 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
97 setMinimumSize(
new java.awt.Dimension(519, 130));
101 GO_GET_COFFEE_LABEL.setDisplayedMnemonic(
'H');
102 org.openide.awt.Mnemonics.setLocalizedText(GO_GET_COFFEE_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.GO_GET_COFFEE_LABEL.text"));
104 CURRENTLYON_LABEL.setFont(CURRENTLYON_LABEL.getFont().deriveFont(Font.PLAIN, 14));
105 org.openide.awt.Mnemonics.setLocalizedText(CURRENTLYON_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CURRENTLYON_LABEL.text"));
107 CURRENTDB_LABEL.setFont(CURRENTDB_LABEL.getFont().deriveFont(Font.PLAIN, 14));
108 org.openide.awt.Mnemonics.setLocalizedText(CURRENTDB_LABEL,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CURRENTDB_LABEL.text"));
110 org.openide.awt.Mnemonics.setLocalizedText(CANCEL_BUTTON,
org.openide.util.NbBundle.getMessage(ModalNoButtons.class,
"ModalNoButtons.CANCEL_BUTTON.text"));
111 CANCEL_BUTTON.addMouseListener(
new java.awt.event.MouseAdapter() {
112 public void mouseClicked(java.awt.event.MouseEvent evt) {
113 CANCEL_BUTTONMouseClicked(evt);
117 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
118 getContentPane().setLayout(layout);
119 layout.setHorizontalGroup(
120 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121 .addGroup(layout.createSequentialGroup()
123 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124 .addComponent(INDEXING_PROGBAR, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
125 .addGroup(layout.createSequentialGroup()
126 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
127 .addComponent(GO_GET_COFFEE_LABEL)
128 .addGroup(layout.createSequentialGroup()
129 .addComponent(CURRENTLYON_LABEL)
130 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
131 .addComponent(CURRENTDB_LABEL)))
132 .addGap(0, 161, Short.MAX_VALUE))
133 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
134 .addGap(0, 0, Short.MAX_VALUE)
135 .addComponent(CANCEL_BUTTON, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
138 layout.setVerticalGroup(
139 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
140 .addGroup(layout.createSequentialGroup()
142 .addComponent(GO_GET_COFFEE_LABEL)
143 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
145 .addComponent(CURRENTLYON_LABEL)
146 .addComponent(CURRENTDB_LABEL))
147 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
148 .addComponent(INDEXING_PROGBAR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
149 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
150 .addComponent(CANCEL_BUTTON)
166 private void CANCEL_BUTTONMouseClicked(java.awt.event.MouseEvent evt) {
167 String message = NbBundle.getMessage(this.getClass(),
"ModalNoButtons.exitHashDbIndexingMsg");
169 int res = JOptionPane.showConfirmDialog(
this,
171 NbBundle.getMessage(
this.getClass(),
172 "ModalNoButtons.dlgTitle.unfinishedIndexing"),
173 JOptionPane.YES_NO_OPTION);
174 if(res == JOptionPane.YES_OPTION){
175 List<HashDb>
remove =
new ArrayList<>();
176 if(this.toIndex == null){
177 remove = this.unindexed;
180 remove.add(this.toIndex);
182 this.hdbmp.removeThese(
remove);
183 this.setVisible(
false);
184 this.setModal(
false);
190 private void initCustom() {
191 this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
192 if(this.unindexed != null){
203 private void indexThis() {
204 this.INDEXING_PROGBAR.setIndeterminate(
true);
205 currentDb = this.toIndex.getHashSetName();
206 this.CURRENTDB_LABEL.setText(
"(" + currentDb +
")");
208 this.CURRENTLYON_LABEL.setText(
209 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.indexThis.currentlyIndexing1Db"));
210 if (!this.toIndex.isIndexing()) {
211 this.toIndex.addPropertyChangeListener(
this);
212 HashDbManager.getInstance().indexHashDatabase(toIndex);
219 private void indexThese() {
220 length = this.unindexed.size();
221 this.INDEXING_PROGBAR.setIndeterminate(
true);
222 for (HashDb db : this.unindexed) {
223 currentDb = db.getHashSetName();
224 this.CURRENTDB_LABEL.setText(
"(" + currentDb +
")");
225 this.CURRENTLYON_LABEL.setText(
226 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.indexThese.currentlyIndexing1OfNDbs", length));
227 if (!db.isIndexing()) {
228 db.addPropertyChangeListener(
this);
229 HashDbManager.getInstance().indexHashDatabase(db);
234 private javax.swing.JButton CANCEL_BUTTON;
235 private javax.swing.JLabel CURRENTDB_LABEL;
236 private javax.swing.JLabel CURRENTLYON_LABEL;
237 private javax.swing.JLabel GO_GET_COFFEE_LABEL;
238 private javax.swing.JProgressBar INDEXING_PROGBAR;
245 public void propertyChange(PropertyChangeEvent evt) {
246 if (evt.getPropertyName().equals(HashDb.Event.INDEXING_DONE.name())) {
247 if (currentcount >= length) {
248 this.INDEXING_PROGBAR.setValue(100);
249 this.setModal(
false);
250 this.setVisible(
false);
254 this.CURRENTLYON_LABEL.setText(
255 NbBundle.getMessage(
this.getClass(),
"ModalNoButtons.propChg.currentlyIndexingXofN",
256 currentcount, length));