Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddImageWizardAddingProgressPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 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 
22 import java.awt.Color;
23 import java.awt.EventQueue;
24 import java.util.HashSet;
25 import java.util.Iterator;
26 import java.util.Set;
27 import javax.swing.event.ChangeEvent;
28 import javax.swing.event.ChangeListener;
29 import org.openide.WizardDescriptor;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
34 
43 class AddImageWizardAddingProgressPanel implements WizardDescriptor.FinishablePanel<WizardDescriptor> {
44 
49  private boolean imgAdded = false;
54  private AddImageWizardAddingProgressVisual component;
55  private final Set<ChangeListener> listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
56 
57  private DSPProgressMonitorImpl dspProgressMonitorImpl = new DSPProgressMonitorImpl();
58 
59  public DSPProgressMonitorImpl getDSPProgressMonitorImpl() {
60  return dspProgressMonitorImpl;
61  }
62 
64  @Override
65  public void setIndeterminate(final boolean indeterminate) {
66  // update the progress bar asynchronously
67  EventQueue.invokeLater(new Runnable() {
68  @Override
69  public void run() {
70  getComponent().getProgressBar().setIndeterminate(indeterminate);
71  }
72  });
73  }
74 
75  @Override
76  public void setProgress(final int progress) {
77  // update the progress bar asynchronously
78  EventQueue.invokeLater(new Runnable() {
79  @Override
80  public void run() {
81  getComponent().getProgressBar().setValue(progress);
82  }
83  });
84  }
85 
86  @Override
87  public void setProgressText(final String text) {
88  // update the progress UI asynchronously
89  EventQueue.invokeLater(new Runnable() {
90  @Override
91  public void run() {
92  getComponent().setProgressMsgText(text);
93  }
94  });
95  }
96 
97 
98 
99  }
110  @Override
111  public AddImageWizardAddingProgressVisual getComponent() {
112  if (component == null) {
113  component = new AddImageWizardAddingProgressVisual();
114  }
115  return component;
116  }
117 
124  @Override
125  public HelpCtx getHelp() {
126  // Show no Help button for this panel:
127  return HelpCtx.DEFAULT_HELP;
128  }
129 
136  @Override
137  public boolean isValid() {
138  // set the focus to the next button of the wizard dialog if it's enabled
139  if (imgAdded) {
140  Lookup.getDefault().lookup(AddImageAction.class).requestFocusButton(
141  NbBundle.getMessage(this.getClass(), "AddImageWizardAddingProgressPanel.isValid.focusNext"));
142  }
143 
144  return imgAdded;
145  }
146 
150  void setStateStarted() {
151  component.getProgressBar().setIndeterminate(true);
152  component.setProgressBarTextAndColor(
153  NbBundle.getMessage(this.getClass(), "AddImageWizardAddingProgressPanel.stateStarted.progressBarText"), 0, Color.black);
154  }
155 
159  void setStateFinished() {
160  imgAdded = true;
161  getComponent().setStateFinished();
162  fireChangeEvent();
163  }
164 
170  @Override
171  public final void addChangeListener(ChangeListener l) {
172  synchronized (listeners) {
173  listeners.add(l);
174  }
175  }
176 
182  @Override
183  public final void removeChangeListener(ChangeListener l) {
184  synchronized (listeners) {
185  listeners.remove(l);
186  }
187  }
188 
193  protected final void fireChangeEvent() {
194  Iterator<ChangeListener> it;
195  synchronized (listeners) {
196  it = new HashSet<ChangeListener>(listeners).iterator();
197  }
198  ChangeEvent ev = new ChangeEvent(this);
199  while (it.hasNext()) {
200  it.next().stateChanged(ev);
201  }
202  }
203 
210  @Override
211  public void readSettings(WizardDescriptor settings) {
212  settings.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, WizardDescriptor.NEXT_OPTION, WizardDescriptor.FINISH_OPTION, WizardDescriptor.CANCEL_OPTION});
213  if (imgAdded) {
214  getComponent().setStateFinished();
215  }
216  }
217 
224  @Override
225  public void storeSettings(WizardDescriptor settings) {
226  //why did we do this? -jm
227  // getComponent().resetInfoPanel();
228  }
229 
239  void addErrors(String errorString, boolean critical) {
240  getComponent().showErrors(errorString, critical);
241  }
242 
243  @Override
244  public boolean isFinishPanel() {
245  return true;
246  }
247 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.