Package org.esa.snap.rcp.util
Class ProgressHandleMonitor
- java.lang.Object
-
- org.esa.snap.rcp.util.ProgressHandleMonitor
-
- All Implemented Interfaces:
ProgressMonitor
,org.openide.util.Cancellable
public class ProgressHandleMonitor extends Object implements ProgressMonitor, org.openide.util.Cancellable
A progress monitor that notifies aProgressHandle
instance (of the NetBeans Progress API).Use case 1:
ProgressHandleMonitor pm = ProgressHandleMonitor.create("Training"); Runnable operation = () -> { pm.beginTask("Classifier training...", 100); try { session.startTraining(queryPatches, pm); } catch (Exception e) { SnapApp.getDefault().handleError("Failed to train classifier", e); } finally { pm.done(); } }; ProgressUtils.runOffEventThreadWithProgressDialog(operation, "Extracting Features", pm.getProgressHandle(), true, 50, 1000);
Use case 2:
RequestProcessor.getDefault().post(() -> { ProgressHandle handle = ProgressHandleFactory.createHandle("Performing time consuming task"); ProgressMonitor pm = new ProgressHandleMonitor(handle); performTimeConsumingTask(pm); });
- Since:
- SNAP 2
-
-
Field Summary
-
Fields inherited from interface com.bc.ceres.core.ProgressMonitor
NULL, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description ProgressHandleMonitor(org.netbeans.api.progress.ProgressHandle progressHandle)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginTask(String taskName, int totalWork)
boolean
cancel()
static ProgressHandleMonitor
create(String displayName)
static ProgressHandleMonitor
create(String displayName, org.openide.util.Cancellable cancellable)
void
done()
org.netbeans.api.progress.ProgressHandle
getProgressHandle()
void
internalWorked(double work)
boolean
isCanceled()
void
setCanceled(boolean canceled)
void
setProgressHandle(org.netbeans.api.progress.ProgressHandle progressHandle)
void
setSubTaskName(String subTaskName)
void
setTaskName(String taskName)
void
worked(int work)
-
-
-
Method Detail
-
create
public static ProgressHandleMonitor create(String displayName)
-
create
public static ProgressHandleMonitor create(String displayName, org.openide.util.Cancellable cancellable)
-
getProgressHandle
public org.netbeans.api.progress.ProgressHandle getProgressHandle()
- Returns:
- The progress handle.
-
setProgressHandle
public void setProgressHandle(org.netbeans.api.progress.ProgressHandle progressHandle)
- Parameters:
progressHandle
- The progress handle.
-
beginTask
public void beginTask(String taskName, int totalWork)
- Specified by:
beginTask
in interfaceProgressMonitor
-
done
public void done()
- Specified by:
done
in interfaceProgressMonitor
-
internalWorked
public void internalWorked(double work)
- Specified by:
internalWorked
in interfaceProgressMonitor
-
isCanceled
public boolean isCanceled()
- Specified by:
isCanceled
in interfaceProgressMonitor
-
setCanceled
public void setCanceled(boolean canceled)
- Specified by:
setCanceled
in interfaceProgressMonitor
-
setTaskName
public void setTaskName(String taskName)
- Specified by:
setTaskName
in interfaceProgressMonitor
-
setSubTaskName
public void setSubTaskName(String subTaskName)
- Specified by:
setSubTaskName
in interfaceProgressMonitor
-
worked
public void worked(int work)
- Specified by:
worked
in interfaceProgressMonitor
-
cancel
public boolean cancel()
- Specified by:
cancel
in interfaceorg.openide.util.Cancellable
-
-