Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddImageWizardAddingProgressVisual.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012-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  */
19 package org.sleuthkit.autopsy.casemodule;
20 
21 import java.awt.Color;
22 import javax.swing.JProgressBar;
23 import org.openide.util.NbBundle;
24 
29 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
30 class AddImageWizardAddingProgressVisual extends javax.swing.JPanel {
31 
32  private static final String ADDING_DATA_SOURCE_COMPLETE = NbBundle
33  .getMessage(AddImageWizardAddingProgressVisual.class, "AddImageWizardAddingProgressVisual.addingDsComplete.text");
34  private String errorLog = "";
35  private boolean hasCriticalErrors = false;
36 
43  @Override
44  public String getName() {
45  return NbBundle.getMessage(this.getClass(), "AddImageWizardAddingProgressVisual.getName.text");
46  }
47 
51  protected void setStateFinished() {
52  inProgressPanel.setVisible(false);
53  donePanel.setVisible(true);
54  //force repaint just in case
55  validate();
56  repaint();
57  }
58 
62  public AddImageWizardAddingProgressVisual() {
63  initComponents();
64  customizeComponents();
65 
66  }
67 
68  private void customizeComponents() {
69  //done and log button are both hidden to start
70  donePanel.setVisible(false);
71  viewLogButton.setVisible(false);
72  //match visual background of panel
73  this.progressTextArea.setBackground(this.getBackground());
74 
75  }
76 
77  public JProgressBar getProgressBar() {
78  return this.progressBar;
79  }
80 
88  public void setProgressBarTextAndColor(String text, int value, Color color) {
89  progressLabel.setText(text);
90  progressLabel.setForeground(color);
91  progressBar.setValue(value);
92  }
93 
99  public void setProgressMsgText(String msg) {
100  this.progressTextArea.setText(msg);
101  }
102 
111  public void showErrors(final String errors, boolean critical) {
112  hasCriticalErrors |= critical;
113 
114  //progressBar.setValue(100); //always invoked when process completed
115  if (hasCriticalErrors) {
116  statusLabel.setForeground(Color.RED);
117  statusLabel.setText(
118  NbBundle.getMessage(this.getClass(), "AddImageWizardAddingProgressVisual.showErrors.critText"));
119  } else {
120  statusLabel.setForeground(Color.BLACK);
121  statusLabel.setText(
122  NbBundle.getMessage(this.getClass(), "AddImageWizardAddingProgressVisual.showErrors.nonCritText"));
123  }
124 
125  errorLog += errors + "\n";
126  viewLogButton.setVisible(true);
127  }
128 
134  @SuppressWarnings("unchecked")
135  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
136  private void initComponents() {
137 
138  loadingPanel = new javax.swing.JPanel();
139  donePanel = new javax.swing.JPanel();
140  statusLabel = new javax.swing.JLabel();
141  viewLogButton = new javax.swing.JButton();
142  inProgressPanel = new javax.swing.JPanel();
143  progressBar = new javax.swing.JProgressBar();
144  progressLabel = new javax.swing.JLabel();
145  progressTextArea = new javax.swing.JTextArea();
146  subTitle1Label = new javax.swing.JLabel();
147 
148  javax.swing.GroupLayout loadingPanelLayout = new javax.swing.GroupLayout(loadingPanel);
149  loadingPanel.setLayout(loadingPanelLayout);
150  loadingPanelLayout.setHorizontalGroup(
151  loadingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
152  .addGap(0, 540, Short.MAX_VALUE)
153  );
154  loadingPanelLayout.setVerticalGroup(
155  loadingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
156  .addGap(0, 247, Short.MAX_VALUE)
157  );
158 
159  org.openide.awt.Mnemonics.setLocalizedText(statusLabel, org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class, "AddImageWizardAddingProgressVisual.statusLabel.text")); // NOI18N
160 
161  org.openide.awt.Mnemonics.setLocalizedText(viewLogButton, org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class, "AddImageWizardAddingProgressVisual.viewLogButton.text")); // NOI18N
162  viewLogButton.addActionListener(new java.awt.event.ActionListener() {
163  public void actionPerformed(java.awt.event.ActionEvent evt) {
164  viewLogButtonActionPerformed(evt);
165  }
166  });
167 
168  javax.swing.GroupLayout donePanelLayout = new javax.swing.GroupLayout(donePanel);
169  donePanel.setLayout(donePanelLayout);
170  donePanelLayout.setHorizontalGroup(
171  donePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
172  .addGroup(donePanelLayout.createSequentialGroup()
173  .addContainerGap()
174  .addGroup(donePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
175  .addComponent(viewLogButton)
176  .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 463, javax.swing.GroupLayout.PREFERRED_SIZE))
177  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
178  );
179  donePanelLayout.setVerticalGroup(
180  donePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181  .addGroup(donePanelLayout.createSequentialGroup()
182  .addContainerGap()
183  .addComponent(statusLabel)
184  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
185  .addComponent(viewLogButton)
186  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
187  );
188 
189  progressBar.setIndeterminate(true);
190 
191  org.openide.awt.Mnemonics.setLocalizedText(progressLabel, org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class, "AddImageWizardAddingProgressVisual.progressLabel.text")); // NOI18N
192  progressLabel.setPreferredSize(null);
193 
194  progressTextArea.setEditable(false);
195  progressTextArea.setBackground(new java.awt.Color(240, 240, 240));
196  progressTextArea.setLineWrap(true);
197  progressTextArea.setRows(5);
198  progressTextArea.setWrapStyleWord(true);
199  progressTextArea.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class, "AddImageWizardAddingProgressVisual.progressTextArea.border.title"))); // NOI18N
200  progressTextArea.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
201  progressTextArea.setFocusable(false);
202 
203  org.openide.awt.Mnemonics.setLocalizedText(subTitle1Label, org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class, "AddImageWizardAddingProgressVisual.subTitle1Label.text")); // NOI18N
204 
205  javax.swing.GroupLayout inProgressPanelLayout = new javax.swing.GroupLayout(inProgressPanel);
206  inProgressPanel.setLayout(inProgressPanelLayout);
207  inProgressPanelLayout.setHorizontalGroup(
208  inProgressPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
209  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, inProgressPanelLayout.createSequentialGroup()
210  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
211  .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 475, javax.swing.GroupLayout.PREFERRED_SIZE)
212  .addContainerGap())
213  .addGroup(inProgressPanelLayout.createSequentialGroup()
214  .addContainerGap()
215  .addGroup(inProgressPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
216  .addComponent(progressTextArea)
217  .addComponent(progressLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
218  .addComponent(subTitle1Label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
219  .addGap(0, 0, Short.MAX_VALUE))
220  );
221  inProgressPanelLayout.setVerticalGroup(
222  inProgressPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223  .addGroup(inProgressPanelLayout.createSequentialGroup()
224  .addComponent(subTitle1Label)
225  .addGap(19, 19, 19)
226  .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
227  .addGap(18, 18, 18)
228  .addComponent(progressTextArea, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
229  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
230  .addComponent(progressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
231  .addContainerGap())
232  );
233 
234  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
235  this.setLayout(layout);
236  layout.setHorizontalGroup(
237  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
238  .addGroup(layout.createSequentialGroup()
239  .addContainerGap()
240  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
241  .addComponent(inProgressPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
242  .addComponent(donePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
243  .addGap(0, 67, Short.MAX_VALUE))
244  );
245  layout.setVerticalGroup(
246  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247  .addGroup(layout.createSequentialGroup()
248  .addGap(34, 34, 34)
249  .addComponent(inProgressPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
250  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251  .addComponent(donePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
252  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
253  );
254  }// </editor-fold>//GEN-END:initComponents
255 
256  private void viewLogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewLogButtonActionPerformed
257  //show error dialog
258  AddImageErrorsDialog dialog = new AddImageErrorsDialog(null, true);
259  dialog.appendErrors(errorLog);
260  dialog.setLocationRelativeTo(null);
261  dialog.setVisible(true);
262  }//GEN-LAST:event_viewLogButtonActionPerformed
263  // Variables declaration - do not modify//GEN-BEGIN:variables
264  protected javax.swing.JPanel donePanel;
265  protected javax.swing.JPanel inProgressPanel;
266  private javax.swing.JPanel loadingPanel;
267  private javax.swing.JProgressBar progressBar;
268  protected javax.swing.JLabel progressLabel;
269  protected javax.swing.JTextArea progressTextArea;
270  protected javax.swing.JLabel statusLabel;
271  protected javax.swing.JLabel subTitle1Label;
272  protected javax.swing.JButton viewLogButton;
273  // End of variables declaration//GEN-END:variables
274 }

Copyright © 2012-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.