19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Color;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import javax.swing.JProgressBar;
25 import org.openide.WizardDescriptor;
26 import org.openide.util.NbBundle;
32 class AddImageWizardAddingProgressVisual
extends javax.swing.JPanel {
34 private static final String ADDING_DATA_SOURCE_COMPLETE = NbBundle
35 .getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.addingDsComplete.text");
36 private String errorLog =
"";
37 private boolean hasCriticalErrors =
false;
46 public String getName() {
47 return NbBundle.getMessage(this.getClass(),
"AddImageWizardAddingProgressVisual.getName.text");
53 protected void setStateFinished() {
54 inProgressPanel.setVisible(
false);
55 donePanel.setVisible(
true);
64 public AddImageWizardAddingProgressVisual() {
66 customizeComponents();
70 private void customizeComponents() {
72 donePanel.setVisible(
false);
73 viewLogButton.setVisible(
false);
75 this.progressTextArea.setBackground(this.getBackground());
79 public JProgressBar getProgressBar() {
80 return this.progressBar;
90 public void setProgressBarTextAndColor(String text,
int value, Color color) {
91 progressLabel.setText(text);
92 progressLabel.setForeground(color);
93 progressBar.setValue(value);
101 public void setProgressMsgText(String msg) {
102 this.progressTextArea.setText(msg);
113 public void showErrors(
final String errors,
boolean critical) {
114 hasCriticalErrors |= critical;
117 if (hasCriticalErrors) {
118 statusLabel.setForeground(Color.RED);
120 NbBundle.getMessage(
this.getClass(),
"AddImageWizardAddingProgressVisual.showErrors.critText"));
122 statusLabel.setForeground(Color.BLACK);
124 NbBundle.getMessage(
this.getClass(),
"AddImageWizardAddingProgressVisual.showErrors.nonCritText"));
127 errorLog += errors +
"\n";
128 viewLogButton.setVisible(
true);
136 @SuppressWarnings(
"unchecked")
138 private
void initComponents() {
140 loadingPanel =
new javax.swing.JPanel();
141 donePanel =
new javax.swing.JPanel();
142 statusLabel =
new javax.swing.JLabel();
143 viewLogButton =
new javax.swing.JButton();
144 inProgressPanel =
new javax.swing.JPanel();
145 progressBar =
new javax.swing.JProgressBar();
146 progressLabel =
new javax.swing.JLabel();
147 progressTextArea =
new javax.swing.JTextArea();
148 subTitle1Label =
new javax.swing.JLabel();
150 javax.swing.GroupLayout loadingPanelLayout =
new javax.swing.GroupLayout(loadingPanel);
151 loadingPanel.setLayout(loadingPanelLayout);
152 loadingPanelLayout.setHorizontalGroup(
153 loadingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
154 .addGap(0, 540, Short.MAX_VALUE)
156 loadingPanelLayout.setVerticalGroup(
157 loadingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
158 .addGap(0, 247, Short.MAX_VALUE)
161 org.openide.awt.Mnemonics.setLocalizedText(statusLabel,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.statusLabel.text"));
163 org.openide.awt.Mnemonics.setLocalizedText(viewLogButton,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.viewLogButton.text"));
164 viewLogButton.addActionListener(
new java.awt.event.ActionListener() {
165 public void actionPerformed(java.awt.event.ActionEvent evt) {
166 viewLogButtonActionPerformed(evt);
170 javax.swing.GroupLayout donePanelLayout =
new javax.swing.GroupLayout(donePanel);
171 donePanel.setLayout(donePanelLayout);
172 donePanelLayout.setHorizontalGroup(
173 donePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
174 .addGroup(donePanelLayout.createSequentialGroup()
176 .addGroup(donePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177 .addComponent(viewLogButton)
178 .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 463, javax.swing.GroupLayout.PREFERRED_SIZE))
179 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
181 donePanelLayout.setVerticalGroup(
182 donePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
183 .addGroup(donePanelLayout.createSequentialGroup()
185 .addComponent(statusLabel)
186 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
187 .addComponent(viewLogButton)
188 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
191 progressBar.setIndeterminate(
true);
193 org.openide.awt.Mnemonics.setLocalizedText(progressLabel,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.progressLabel.text"));
194 progressLabel.setPreferredSize(null);
196 progressTextArea.setEditable(
false);
197 progressTextArea.setBackground(
new java.awt.Color(240, 240, 240));
198 progressTextArea.setLineWrap(
true);
199 progressTextArea.setRows(5);
200 progressTextArea.setWrapStyleWord(
true);
201 progressTextArea.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(),
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.progressTextArea.border.title")));
202 progressTextArea.setCursor(
new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
203 progressTextArea.setFocusable(
false);
205 org.openide.awt.Mnemonics.setLocalizedText(subTitle1Label,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.subTitle1Label.text"));
207 javax.swing.GroupLayout inProgressPanelLayout =
new javax.swing.GroupLayout(inProgressPanel);
208 inProgressPanel.setLayout(inProgressPanelLayout);
209 inProgressPanelLayout.setHorizontalGroup(
210 inProgressPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
211 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, inProgressPanelLayout.createSequentialGroup()
212 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
213 .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 475, javax.swing.GroupLayout.PREFERRED_SIZE)
215 .addGroup(inProgressPanelLayout.createSequentialGroup()
217 .addGroup(inProgressPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
218 .addComponent(progressTextArea)
219 .addComponent(progressLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
220 .addComponent(subTitle1Label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
221 .addGap(0, 0, Short.MAX_VALUE))
223 inProgressPanelLayout.setVerticalGroup(
224 inProgressPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
225 .addGroup(inProgressPanelLayout.createSequentialGroup()
226 .addComponent(subTitle1Label)
228 .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
230 .addComponent(progressTextArea, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
231 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
232 .addComponent(progressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
236 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
237 this.setLayout(layout);
238 layout.setHorizontalGroup(
239 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
240 .addGroup(layout.createSequentialGroup()
242 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
243 .addComponent(inProgressPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
244 .addComponent(donePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
245 .addGap(0, 67, Short.MAX_VALUE))
247 layout.setVerticalGroup(
248 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
249 .addGroup(layout.createSequentialGroup()
251 .addComponent(inProgressPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
252 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
253 .addComponent(donePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
254 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
258 private void viewLogButtonActionPerformed(java.awt.event.ActionEvent evt) {
260 AddImageErrorsDialog dialog =
new AddImageErrorsDialog(null,
true);
261 dialog.appendErrors(errorLog);
262 dialog.setLocationRelativeTo(null);
263 dialog.setVisible(
true);
266 protected javax.swing.JPanel donePanel;
267 protected javax.swing.JPanel inProgressPanel;
268 private javax.swing.JPanel loadingPanel;
269 private javax.swing.JProgressBar progressBar;
270 protected javax.swing.JLabel progressLabel;
271 protected javax.swing.JTextArea progressTextArea;
272 protected javax.swing.JLabel statusLabel;
273 protected javax.swing.JLabel subTitle1Label;
274 protected javax.swing.JButton viewLogButton;