# Class WorkbenchConfigurer

java.lang.Object
org.eclipse.ui.internal.WorkbenchConfigurer

All Implemented Interfaces:
  `IWorkbenchConfigurer`

public final class WorkbenchConfigurer extends Object implements IWorkbenchConfigurer
Internal class providing special access for configuring the workbench.

Note that these objects are only available to the main application (the plug-in that creates and owns the workbench).

This class is not intended to be instantiated or subclassed by clients.

Since:
  3.0

## Field Summary

### Fields inherited from interface IWorkbenchConfigurer

`RESTORE_CODE_EXIT, RESTORE_CODE_RESET`

## Method Summary

Modifier and Type
Method
Description
`void`
`declareImage(String symbolicName, ImageDescriptor descriptor, boolean shared)`
Declares a workbench image.
`void`
`emergencyClose()`
Forces the workbench to close due to an emergency.
`boolean`
`emergencyClosing()`
Returns whether the workbench is being closed due to an emergency.
`Object`
`getData(String key)`
Returns the data associated with the workbench at the given key.
`boolean`
`getExitOnLastWindowClose()`
Returns `true` if the workbench should exit when the last window is closed, `false` if the window should just be closed, leaving the workbench (and its event loop) running.
`boolean`
`getSaveAndRestore()`
Returns whether the workbench state should be saved on close and restored on subsequent open.
`IWorkbenchWindowConfigurer`
`getWindowConfigurer(IWorkbenchWindow window)`
Returns an object that can be used to configure the given window.
`IWorkbench`
`getWorkbench()`
Returns the underlying workbench.
`WindowManager`
`getWorkbenchWindowManager()`
Returns the workbench window manager.
`void`
`openFirstTimeWindow()`
Opens the first time window, using the default perspective and default page input.
`IStatus`
`restoreState()`
Restores the workbench state saved from the previous session, if any.
`IWorkbenchWindowConfigurer`
`restoreWorkbenchWindow(IMemento memento)`
Restores a workbench window from the given memento.
`void`
`setData(String key, Object data)`
Sets the data associated with the workbench at the given key.
`void`
`setExitOnLastWindowClose(boolean enabled)`
Sets whether the workbench should exit when the last window is closed, or whether the window should just be closed, leaving the workbench (and its event loop) running.
`void`
`setSaveAndRestore(boolean enabled)`
Sets whether the workbench state should be saved on close and restored on subsequent open.

### Methods inherited from class Object

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

## Method Details

### getWorkbench

public IWorkbench getWorkbench()
Description copied from interface: `IWorkbenchConfigurer`
Returns the underlying workbench.

Specified by:
  `getWorkbench` in interface `IWorkbenchConfigurer`
Returns:
  the workbench

### getWorkbenchWindowManager

public WindowManager getWorkbenchWindowManager()
Description copied from interface: `IWorkbenchConfigurer`
Returns the workbench window manager.

Specified by:
  `getWorkbenchWindowManager` in interface `IWorkbenchConfigurer`
Returns:
  the workbench window manager Note:IWorkbenchWindow is implemented using JFace's Window (and therefore uses WindowManager), but this is an implementation detail

### declareImage

public void declareImage(String symbolicName, ImageDescriptor descriptor, boolean shared)
Description copied from interface: `IWorkbenchConfigurer`
Declares a workbench image.

The workbench remembers the given image descriptor under the given name, and makes the image available to plug-ins via `IWorkbench.getSharedImages()`. For "shared" images, the workbench remembers the image descriptor and will manages the image object create from it; clients retrieve "shared" images via `ISharedImages.getImage()`. For the other, "non-shared" images, the workbench remembers only the image descriptor; clients retrieve the image descriptor via `ISharedImages.getImageDescriptor()` and are entirely responsible for managing the image objects they create from it. (This is made confusing by the historical fact that the API interface is called "ISharedImages".)

Specified by:
  `declareImage` in interface `IWorkbenchConfigurer`
Parameters:
  `symbolicName` - the symbolic name of the image
  `descriptor` - the image descriptor
  `shared` - `true` if this is a shared image, and `false` if this is not a shared image
See Also:
  - `ISharedImages.getImage(String)`
  - `ISharedImages.getImageDescriptor(String)`

### getWindowConfigurer

public IWorkbenchWindowConfigurer getWindowConfigurer(IWorkbenchWindow window)
Description copied from interface: `IWorkbenchConfigurer`
Returns an object that can be used to configure the given window.

Specified by:
  `getWindowConfigurer` in interface `IWorkbenchConfigurer`
Parameters:
  `window` - a workbench window
Returns:
  a workbench window configurer

### getSaveAndRestore

public boolean getSaveAndRestore()
Description copied from interface: `IWorkbenchConfigurer`
Returns whether the workbench state should be saved on close and restored on subsequent open.

The initial value is `false`.

Specified by:
  `getSaveAndRestore` in interface `IWorkbenchConfigurer`
Returns:
  `true` to save and restore workbench state, or `false` to forget current workbench state on close.

### setSaveAndRestore

public void setSaveAndRestore(boolean enabled)
Description copied from interface: `IWorkbenchConfigurer`
Sets whether the workbench state should be saved on close and restored on subsequent open.

Specified by:
  `setSaveAndRestore` in interface `IWorkbenchConfigurer`
Parameters:
  `enabled` - `true` to save and restore workbench state, or `false` to forget current workbench state on close.

### getData

public Object getData(String key)
Description copied from interface: `IWorkbenchConfigurer`
Returns the data associated with the workbench at the given key.

Specified by:
  `getData` in interface `IWorkbenchConfigurer`
Parameters:
  `key` - the key
Returns:
  the data, or `null` if there is no data at the given key

### setData

public void setData(String key, Object data)
Description copied from interface: `IWorkbenchConfigurer`
Sets the data associated with the workbench at the given key.

Specified by:
  `setData` in interface `IWorkbenchConfigurer`
Parameters:
  `key` - the key
  `data` - the data, or `null` to delete existing data

### emergencyClose

public void emergencyClose()
Description copied from interface: `IWorkbenchConfigurer`
Forces the workbench to close due to an emergency. This method should only be called when the workbench is in dire straights and cannot continue, and cannot even risk a normal workbench close (think "out of memory" or "unable to create shell"). When this method is called, an abbreviated workbench shutdown sequence is performed (less critical steps may be skipped). The workbench advisor is still called; however, it must not attempt to communicate with the user. While an emergency close is in progress, `emergencyClosing` returns `true`. Workbench advisor methods should always check this flag before communicating with the user.

Specified by:
  `emergencyClose` in interface `IWorkbenchConfigurer`
See Also:
  - `IWorkbenchConfigurer.emergencyClosing()`

### emergencyClosing

public boolean emergencyClosing()
Description copied from interface: `IWorkbenchConfigurer`
Returns whether the workbench is being closed due to an emergency. When this method returns `true`, the workbench is in dire straights and cannot continue. Indeed, things are so bad that we cannot even risk a normal workbench close. Workbench advisor methods should always check this flag before attempting to communicate with the user.

Specified by:
  `emergencyClosing` in interface `IWorkbenchConfigurer`
Returns:
  `true` if the workbench is in the process of being closed under emergency conditions, and `false` otherwise

### restoreState

public IStatus restoreState()
Description copied from interface: `IWorkbenchConfigurer`
Restores the workbench state saved from the previous session, if any. This includes any open windows and their open perspectives, open views and editors, layout information, and any customizations to the open perspectives.

This is typically called from the advisor's `openWindows()` method.

Specified by:
  `restoreState` in interface `IWorkbenchConfigurer`
Returns:
  a status object indicating whether the restore was successful
See Also:
  - `IWorkbenchConfigurer.RESTORE_CODE_RESET`
  - `IWorkbenchConfigurer.RESTORE_CODE_EXIT`
  - `WorkbenchAdvisor.openWindows()`

### openFirstTimeWindow

public void openFirstTimeWindow()
Description copied from interface: `IWorkbenchConfigurer`
Opens the first time window, using the default perspective and default page input.

This is typically called from the advisor's `openWindows()` method.

Specified by:
  `openFirstTimeWindow` in interface `IWorkbenchConfigurer`
See Also:
  - `WorkbenchAdvisor.openWindows()`

### restoreWorkbenchWindow

public IWorkbenchWindowConfigurer restoreWorkbenchWindow(IMemento memento)
Description copied from interface: `IWorkbenchConfigurer`
Restores a workbench window from the given memento.

Specified by:
  `restoreWorkbenchWindow` in interface `IWorkbenchConfigurer`
Parameters:
  `memento` - the memento from which to restore the window's state
Returns:
  the configurer for the restored window
See Also:
  - `IWorkbenchWindowConfigurer.saveState(IMemento)`

### getExitOnLastWindowClose

public boolean getExitOnLastWindowClose()
Description copied from interface: `IWorkbenchConfigurer`
Returns `true` if the workbench should exit when the last window is closed, `false` if the window should just be closed, leaving the workbench (and its event loop) running.

If `true`, the last window's state is saved before closing, so that it will be restored in the next session. This applies only if `getSaveAndRestore()`) returns `true`.

If `false`, the window is simply closed, losing its state.

If the workbench is left running, it can be closed using `IWorkbench.close()`, or a new window can be opened using `IWorkbench.openWorkbenchWindow(String, IAdaptable)`.

The initial value is `true`.

Specified by:
  `getExitOnLastWindowClose` in interface `IWorkbenchConfigurer`
Returns:
  `true` if the workbench will exit when the last window is closed, `false` if the window should just be closed

### setExitOnLastWindowClose

public void setExitOnLastWindowClose(boolean enabled)
Description copied from interface: `IWorkbenchConfigurer`
Sets whether the workbench should exit when the last window is closed, or whether the window should just be closed, leaving the workbench (and its event loop) running.

For more details, see `IWorkbenchConfigurer.getExitOnLastWindowClose()`.

Specified by:
  `setExitOnLastWindowClose` in interface `IWorkbenchConfigurer`
Parameters:
  `enabled` - `true` if the workbench should exit when the last window is closed, `false` if the window should just be closed