Package org.eclipse.jface.wizard

# Class ProgressMonitorPart

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.jface.wizard.ProgressMonitorPart

All Implemented Interfaces:
  `IProgressMonitor`, `IProgressMonitorWithBlocking`, `Drawable`

public class ProgressMonitorPart extends Composite implements IProgressMonitorWithBlocking
A standard implementation of an IProgressMonitor. It consists of a label displaying the task and subtask name, and a progress indicator to show progress. In contrast to `ProgressMonitorDialog` this class only implements `IProgressMonitor`.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected IStatus`
`blockedStatus`
current blocked status
`protected Control`
`fCancelComponent`
the cancel component
`protected Listener`
`fCancelListener`
the cancel lister attached to the cancel component
`protected boolean`
`fIsCanceled`
true if canceled
`protected Label`
`fLabel`
the label
`protected ProgressIndicator`
`fProgressIndicator`
the progress indicator
`protected String`
`fSubTaskName`
the current sub task name
`protected String`
`fTaskName`
the current task name

### Fields inherited from class org.eclipse.swt.widgets.Control

`handle`

### Fields inherited from class org.eclipse.swt.widgets.Widget

`nativeZoom`

### Fields inherited from interface org.eclipse.core.runtime.IProgressMonitor

`UNKNOWN`

## Constructor Summary

Constructors
Constructor
Description
`ProgressMonitorPart(Composite parent, Layout layout)`
Creates a `ProgressMonitorPart` that does not provide a stop button.
`ProgressMonitorPart(Composite parent, Layout layout, boolean createStopButton)`
Creates a `ProgressMonitorPart`.
`ProgressMonitorPart(Composite parent, Layout layout, int progressIndicatorHeight)`
Creates a `ProgressMonitorPart` that does not provide a stop button.

## Method Summary

Modifier and Type
Method
Description
`void`
`attachToCancelComponent(Control cancelComponent)`
Attaches the progress monitor part to the given cancel component.
`void`
`beginTask(String name, int totalWork)`
Notifies that the main task is beginning.
`void`
`clearBlocked()`
Clears the blocked state of the running operation.
`void`
`done()`
Notifies that the work is done; that is, either the main task is completed or the user canceled it.
`protected static String`
`escapeMetaCharacters(String in)`
Escapes any occurrence of '&' in the given String so that it is not considered as a mnemonic character in SWT ToolItems, MenuItems, Button and Labels.
`protected void`
`initialize(Layout layout, int progressIndicatorHeight)`
Creates the progress monitor's UI parts and layouts them according to the given layout.
`void`
`internalWorked(double work)`
Internal method to handle scaling correctly.
`boolean`
`isCanceled()`
Returns whether cancelation of current operation has been requested.
`protected void`
`queueUpdateLabel()`
Enqueues a label update for asynchronous execution.
`void`
`removeFromCancelComponent(Control cancelComponent)`
Detach the progress monitor part from the given cancel component.
`void`
`setBlocked(IStatus reason)`
Indicates that this operation is blocked by some background activity.
`void`
`setCanceled(boolean b)`
Sets the cancel state to the given value.
`void`
`setFont(Font font)`
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
`void`
`setTaskName(String name)`
Sets the task name to the given value.
`void`
`subTask(String name)`
Notifies that a subtask of the main task is beginning.
`protected void`
`updateLabel()`
Updates the label with the current task and subtask names.
`void`
`worked(int work)`
Notifies that a given number of work unit of the main task has been completed.

### Methods inherited from class org.eclipse.swt.widgets.Composite

`changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString`

### Methods inherited from class org.eclipse.swt.widgets.Scrollable

`computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsMode`

### Methods inherited from class org.eclipse.swt.widgets.Control

`addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getData, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setAutoscalingMode, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setData, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update`

### Methods inherited from class org.eclipse.swt.widgets.Widget

`addDisposeListener, addListener, addTypedListener, checkWidget, dispose, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, reskin, setData`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.swt.graphics.Drawable

`isAutoScalable`

### Methods inherited from interface org.eclipse.core.runtime.IProgressMonitor

`slice`

## Field Details

### fLabel

protected Label fLabel
the label

### fTaskName

protected String fTaskName
the current task name

### fSubTaskName

protected String fSubTaskName
the current sub task name

### fProgressIndicator

protected ProgressIndicator fProgressIndicator
the progress indicator

### fCancelComponent

protected Control fCancelComponent
the cancel component

### fIsCanceled

protected volatile boolean fIsCanceled
true if canceled

### blockedStatus

protected IStatus blockedStatus
current blocked status

### fCancelListener

protected Listener fCancelListener
the cancel lister attached to the cancel component

## Constructor Details

### ProgressMonitorPart

public ProgressMonitorPart(Composite parent, Layout layout)
Creates a `ProgressMonitorPart` that does not provide a stop button.

Parameters:
  `parent` - The SWT parent of the part.
  `layout` - The SWT grid layout used by the part. A client can supply the layout to control how the progress monitor part is laid out. If `null` is passed the part uses its default layout.

### ProgressMonitorPart

public ProgressMonitorPart(Composite parent, Layout layout, int progressIndicatorHeight)
Creates a `ProgressMonitorPart` that does not provide a stop button.

Parameters:
  `parent` - The SWT parent of the part.
  `layout` - The SWT grid layout used by the part. A client can supply the layout to control how the progress monitor part is laid out. If `null` is passed the part uses its default layout.
  `progressIndicatorHeight` - The height of the progress indicator in pixels. This value may be SWT.DEFAULT in order to get the default height as calculated by the widget and its layout.

### ProgressMonitorPart

public ProgressMonitorPart(Composite parent, Layout layout, boolean createStopButton)
Creates a `ProgressMonitorPart`.

Parameters:
  `parent` - the SWT parent of the part
  `layout` - the SWT grid layout used by the part. A client can supply the layout to control how the progress monitor part is laid out. If `null` is passed the part uses its default layout.
  `createStopButton` - `true` if the progress indicator should include a stop button that can be used to cancel any currently running task, and `false` if no such stop button should be created.
Since:
  3.6

## Method Details

### attachToCancelComponent

public void attachToCancelComponent(Control cancelComponent)
Attaches the progress monitor part to the given cancel component.

Parameters:
  `cancelComponent` - the control whose selection will trigger a cancel. This parameter will be ignored and hence can be `null` if a stop button was requested upon construction and instead the stop button will enabled and serve as the cancel component.
See Also:
  - `ProgressMonitorPart(Composite, Layout, boolean)`

### beginTask

public void beginTask(String name, int totalWork)
Description copied from interface: `IProgressMonitor`
Notifies that the main task is beginning. This must only be called once on a given progress monitor instance.

Specified by:
  `beginTask` in interface `IProgressMonitor`
Parameters:
  `name` - the name (or description) of the main task
  `totalWork` - the total number of work units into which the main task is been subdivided. If the value is `UNKNOWN` the implementation is free to indicate progress in a way which doesn't require the total number of work units in advance.

### done

public void done()
Description copied from interface: `IProgressMonitor`
Notifies that the work is done; that is, either the main task is completed or the user canceled it. This method may be called more than once (implementations should be prepared to handle this case).

Specified by:
  `done` in interface `IProgressMonitor`

### escapeMetaCharacters

protected static String escapeMetaCharacters(String in)
Escapes any occurrence of '&' in the given String so that it is not considered as a mnemonic character in SWT ToolItems, MenuItems, Button and Labels.

Parameters:
  `in` - the original String
Returns:
  The converted String

### initialize

protected void initialize(Layout layout, int progressIndicatorHeight)
Creates the progress monitor's UI parts and layouts them according to the given layout. If the layout is `null` the part's default layout is used.

Parameters:
  `layout` - The layout for the receiver.
  `progressIndicatorHeight` - The suggested height of the indicator

### internalWorked

public void internalWorked(double work)
Description copied from interface: `IProgressMonitor`
Internal method to handle scaling correctly. This method must not be called by a client. Clients should always use the method `worked(int)`.

Specified by:
  `internalWorked` in interface `IProgressMonitor`
Parameters:
  `work` - the amount of work done

### isCanceled

public boolean isCanceled()
Description copied from interface: `IProgressMonitor`
Returns whether cancelation of current operation has been requested. Long-running operations should poll to see if cancelation has been requested.

Specified by:
  `isCanceled` in interface `IProgressMonitor`
Returns:
  `true` if cancellation has been requested, and `false` otherwise
See Also:
  - `IProgressMonitor.setCanceled(boolean)`

### removeFromCancelComponent

public void removeFromCancelComponent(Control cancelComponent)
Detach the progress monitor part from the given cancel component.

Parameters:
  `cancelComponent` - the control that was previously used as a cancel component. This parameter will be ignored and hence can be `null` if a stop button was requested upon construction and instead the stop button will be disabled.
See Also:
  - `ProgressMonitorPart(Composite, Layout, boolean)`

### setCanceled

public void setCanceled(boolean b)
Description copied from interface: `IProgressMonitor`
Sets the cancel state to the given value.

Specified by:
  `setCanceled` in interface `IProgressMonitor`
Parameters:
  `b` - `true` indicates that cancelation has been requested (but not necessarily acknowledged); `false` clears this flag
See Also:
  - `IProgressMonitor.isCanceled()`

### setFont

public void setFont(Font font)
Description copied from class: `Control`
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.

Overrides:
  `setFont` in class `Control`
Parameters:
  `font` - the new font (or null)

### setTaskName

public void setTaskName(String name)
Description copied from interface: `IProgressMonitor`
Sets the task name to the given value. This method is used to restore the task label after a nested operation was executed. Normally there is no need for clients to call this method.

Specified by:
  `setTaskName` in interface `IProgressMonitor`
Parameters:
  `name` - the name (or description) of the main task
See Also:
  - `IProgressMonitor.beginTask(java.lang.String, int)`

### subTask

public void subTask(String name)
Description copied from interface: `IProgressMonitor`
Notifies that a subtask of the main task is beginning. Subtasks are optional; the main task might not have subtasks.

Specified by:
  `subTask` in interface `IProgressMonitor`
Parameters:
  `name` - the name (or description) of the subtask

### queueUpdateLabel

protected void queueUpdateLabel()
Enqueues a label update for asynchronous execution. The update is performed throttled to 100ms, i.e. updates within the throttle range are not displayed.

Since:
  3.14

### updateLabel

protected void updateLabel()
Updates the label with the current task and subtask names.

### worked

public void worked(int work)
Description copied from interface: `IProgressMonitor`
Notifies that a given number of work unit of the main task has been completed. Note that this amount represents an installment, as opposed to a cumulative amount of work done to date.

Specified by:
  `worked` in interface `IProgressMonitor`
Parameters:
  `work` - a non-negative number of work units just completed

### clearBlocked

public void clearBlocked()
Description copied from interface: `IProgressMonitor`
Clears the blocked state of the running operation. If a running operation ever calls `setBlocked`, it must eventually call `clearBlocked` before the operation completes.

Specified by:
  `clearBlocked` in interface `IProgressMonitor`
See Also:
  - `IProgressMonitor.setBlocked(IStatus)`

### setBlocked

public void setBlocked(IStatus reason)
Description copied from interface: `IProgressMonitor`
Indicates that this operation is blocked by some background activity. If a running operation ever calls `setBlocked`, it must eventually call `clearBlocked` before the operation completes.

If the caller is blocked by a currently executing job, this method will return an `IJobStatus` indicating the job that is currently blocking the caller. If this blocking job is not known, this method will return a plain informational `IStatus` object.

Specified by:
  `setBlocked` in interface `IProgressMonitor`
Parameters:
  `reason` - an optional status object whose message describes the reason why this operation is blocked, or `null` if this information is not available.
See Also:
  - `IProgressMonitor.clearBlocked()`