Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ReportProgressIndicator.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 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.report.infrastructure;
20 
21 import org.openide.util.NbBundle;
24 
31 
32  private static final long serialVersionUID = 1L;
34  private int workUnitsCompleted;
35 
43  public ReportProgressIndicator(ProgressIndicator progressIndicator) {
44  this.progressIndicator = progressIndicator;
45  }
46 
47  @Override
48  @NbBundle.Messages({
49  "ReportProgressIndicator.startMessage=Report generation started"
50  })
51  public void start() {
52  workUnitsCompleted = 0;
54  progressIndicator.start(Bundle.ReportProgressIndicator_startMessage());
55  }
56 
57  @Override
58  @NbBundle.Messages({
59  "ReportProgressIndicator.switchToDeterminateMessage=Report generation progress switched to determinate"
60  })
61  public void setMaximumProgress(int max) {
62  progressIndicator.switchToDeterminate(Bundle.ReportProgressIndicator_switchToDeterminateMessage(), 0, max);
63  }
64 
65  @Override
66  public void increment() {
68  progressIndicator.progress(workUnitsCompleted);
69  }
70 
71  @Override
72  public void setProgress(int value) {
73  workUnitsCompleted = value;
74  progressIndicator.progress(workUnitsCompleted);
75  }
76 
77  @Override
78  @NbBundle.Messages({
79  "ReportProgressIndicator.switchToIndeterminateMessage=Report generation progress switched to indeterminate"
80  })
81  public void setIndeterminate(boolean indeterminate) {
82  progressIndicator.switchToIndeterminate(Bundle.ReportProgressIndicator_switchToIndeterminateMessage());
83  }
84 
85  @Override
86  public void updateStatusLabel(String statusMessage) {
87  if (getStatus() != ReportStatus.CANCELED) {
88  progressIndicator.progress(statusMessage);
89  }
90  }
91 
92  @Override
93  @NbBundle.Messages({
94  "ReportProgressIndicator.completedMessage=Report generation completed",
95  "ReportProgressIndicator.completedWithErrorsMessage=Report generation completed with errors",})
96  public void complete(ReportStatus reportStatus) {
97  if (getStatus() != ReportStatus.CANCELED) {
98  switch (reportStatus) {
99  case COMPLETE: {
100  progressIndicator.progress(Bundle.ReportProgressIndicator_completedMessage());
101  break;
102  }
103  case ERROR: {
104  progressIndicator.progress(Bundle.ReportProgressIndicator_completedWithErrorsMessage());
105  break;
106  }
107  default: {
108  break;
109  }
110  }
111  }
112  progressIndicator.finish();
113  }
114 
115  @Override
116  public void complete(ReportStatus reportStatus, String statusMessage) {
117  if (getStatus() != ReportStatus.CANCELED) {
118  progressIndicator.progress(statusMessage);
119  }
120  complete(reportStatus);
121  }
122 
123  @Override
124  @NbBundle.Messages({
125  "ReportProgressIndicator.cancelledMessage=Report generation cancelled",})
126  public void cancel() {
127  switch (getStatus()) {
128  case COMPLETE:
129  break;
130  case CANCELED:
131  break;
132  case ERROR:
133  break;
134  default:
136  progressIndicator.progress(Bundle.ReportProgressIndicator_cancelledMessage());
137  break;
138  }
139  }
140 
141 }
void start(String message, int totalWorkUnits)
void complete(ReportStatus reportStatus, String statusMessage)
void switchToDeterminate(String message, int workUnitsCompleted, int totalWorkUnits)

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.