Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AppFrameProgressBar.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2019-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 * 9
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 */
19package org.sleuthkit.autopsy.progress;
20
21import org.netbeans.api.progress.ProgressHandle;
22import org.openide.util.Cancellable;
23
29public final class AppFrameProgressBar implements ProgressIndicator {
30
31 private final String displayName;
32 private Cancellable cancellationBehavior;
33 private ProgressHandle progressHandle;
34 private volatile boolean cancelling;
35
45 this.displayName = displayName;
46 }
47
56 this.cancellationBehavior = cancellationBehavior;
57 }
58
59 @Override
60 public void start(String message, int totalWorkUnits) {
61 cancelling = false;
62 this.progressHandle = ProgressHandle.createHandle(displayName, cancellationBehavior);
63 progressHandle.start(totalWorkUnits);
64 progressHandle.progress(message);
65 }
66
67 @Override
68 public void start(String message) {
69 cancelling = false;
70 this.progressHandle = ProgressHandle.createHandle(displayName, cancellationBehavior);
71 progressHandle.start();
72 progressHandle.progress(message);
73 }
74
75 @Override
76 public void switchToIndeterminate(String message) {
77 if (!cancelling) {
78 progressHandle.switchToIndeterminate();
79 progressHandle.progress(message);
80 }
81 }
82
83 @Override
84 public void switchToDeterminate(String message, int workUnitsCompleted, int totalWorkUnits) {
85 if (!cancelling) {
86 progressHandle.switchToDeterminate(totalWorkUnits);
87 progressHandle.progress(message, workUnitsCompleted);
88 }
89 }
90
91 @Override
92 public void progress(String message) {
93 if (!cancelling) {
94 progressHandle.progress(message);
95 }
96 }
97
98 @Override
99 public void progress(int workUnitsCompleted) {
100 if (!cancelling) {
101 progressHandle.progress(workUnitsCompleted);
102 }
103 }
104
105 @Override
106 public void progress(String message, int workUnitsCompleted) {
107 if (!cancelling) {
108 progressHandle.progress(message, workUnitsCompleted);
109 }
110 }
111
112 @Override
113 public void setCancelling(String cancellingMessage) {
114 cancelling = true;
115 progressHandle.switchToIndeterminate();
116 progressHandle.progress(cancellingMessage);
117 }
118
119 @Override
120 public void finish() {
121 progressHandle.finish();
122 }
123
124}
void start(String message, int totalWorkUnits)
void progress(String message, int workUnitsCompleted)
void switchToDeterminate(String message, int workUnitsCompleted, int totalWorkUnits)
void setCancellationBehavior(Cancellable cancellationBehavior)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.