19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Color;
22 import javax.swing.JProgressBar;
23 import org.openide.util.NbBundle;
29 @SuppressWarnings(
"PMD.SingularField")
30 class AddImageWizardAddingProgressVisual extends javax.swing.JPanel {
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;
44 public String getName() {
45 return NbBundle.getMessage(this.getClass(),
"AddImageWizardAddingProgressVisual.getName.text");
51 protected void setStateFinished() {
52 inProgressPanel.setVisible(
false);
53 donePanel.setVisible(
true);
62 public AddImageWizardAddingProgressVisual() {
64 customizeComponents();
68 private void customizeComponents() {
70 donePanel.setVisible(
false);
71 viewLogButton.setVisible(
false);
73 this.progressTextArea.setBackground(this.getBackground());
77 public JProgressBar getProgressBar() {
78 return this.progressBar;
88 public void setProgressBarTextAndColor(String text,
int value, Color color) {
89 progressLabel.setText(text);
90 progressLabel.setForeground(color);
91 progressBar.setValue(value);
99 public void setProgressMsgText(String msg) {
100 this.progressTextArea.setText(msg);
111 public void showErrors(
final String errors,
boolean critical) {
112 hasCriticalErrors |= critical;
115 if (hasCriticalErrors) {
116 statusLabel.setForeground(Color.RED);
118 NbBundle.getMessage(
this.getClass(),
"AddImageWizardAddingProgressVisual.showErrors.critText"));
120 statusLabel.setForeground(Color.BLACK);
122 NbBundle.getMessage(
this.getClass(),
"AddImageWizardAddingProgressVisual.showErrors.nonCritText"));
125 errorLog += errors +
"\n";
126 viewLogButton.setVisible(
true);
134 @SuppressWarnings(
"unchecked")
136 private
void initComponents() {
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();
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)
154 loadingPanelLayout.setVerticalGroup(
155 loadingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
156 .addGap(0, 247, Short.MAX_VALUE)
159 org.openide.awt.Mnemonics.setLocalizedText(statusLabel,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.statusLabel.text"));
161 org.openide.awt.Mnemonics.setLocalizedText(viewLogButton,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.viewLogButton.text"));
162 viewLogButton.addActionListener(
new java.awt.event.ActionListener() {
163 public void actionPerformed(java.awt.event.ActionEvent evt) {
164 viewLogButtonActionPerformed(evt);
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()
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))
179 donePanelLayout.setVerticalGroup(
180 donePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181 .addGroup(donePanelLayout.createSequentialGroup()
183 .addComponent(statusLabel)
184 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
185 .addComponent(viewLogButton)
186 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
189 progressBar.setIndeterminate(
true);
191 org.openide.awt.Mnemonics.setLocalizedText(progressLabel,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.progressLabel.text"));
192 progressLabel.setPreferredSize(null);
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")));
200 progressTextArea.setCursor(
new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
201 progressTextArea.setFocusable(
false);
203 org.openide.awt.Mnemonics.setLocalizedText(subTitle1Label,
org.openide.util.NbBundle.getMessage(AddImageWizardAddingProgressVisual.class,
"AddImageWizardAddingProgressVisual.subTitle1Label.text"));
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)
213 .addGroup(inProgressPanelLayout.createSequentialGroup()
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))
221 inProgressPanelLayout.setVerticalGroup(
222 inProgressPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223 .addGroup(inProgressPanelLayout.createSequentialGroup()
224 .addComponent(subTitle1Label)
226 .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
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)
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()
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))
245 layout.setVerticalGroup(
246 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247 .addGroup(layout.createSequentialGroup()
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))
256 private void viewLogButtonActionPerformed(java.awt.event.ActionEvent evt) {
258 AddImageErrorsDialog dialog =
new AddImageErrorsDialog(null,
true);
259 dialog.appendErrors(errorLog);
260 dialog.setLocationRelativeTo(null);
261 dialog.setVisible(
true);
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;