public class WorkbenchWindowAdvisor extends Object
The workbench window advisor object is created in response to a workbench window being created (one per window), and is used to configure the window.
An application should declare a subclass of WorkbenchWindowAdvisor
and override methods to configure workbench windows to suit the needs of the
particular application.
The following advisor methods are called at strategic points in the
workbench window's lifecycle (as with the workbench advisor, all occur
within the dynamic scope of the call to
PlatformUI.createAndRunWorkbench
):
preWindowOpen
- called as the window is being opened;
use to configure aspects of the window other than actions barspostWindowRestore
- called after the window has been
recreated from a previously saved state; use to adjust the restored
windowpostWindowCreate
- called after the window has been created,
either from an initial state or from a restored state; used to adjust the
windowopenIntro
- called immediately before the window is opened in
order to create the introduction component, if any.postWindowOpen
- called after the window has been
opened; use to hook window listeners, etc.preWindowShellClose
- called when the window's shell
is closed by the user; use to pre-screen window closingsConstructor and Description |
---|
WorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
Creates a new workbench window advisor for configuring a workbench
window via the given workbench window configurer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanUpEditorArea()
Close any empty editor stacks that may have been left open when the
Workbench Window shut down.
|
ActionBarAdvisor |
createActionBarAdvisor(IActionBarConfigurer configurer)
Creates a new action bar advisor to configure the action bars of the window
via the given action bar configurer.
|
Control |
createEmptyWindowContents(Composite parent)
Deprecated.
This method is no longer used. Applications now define
workbench window contents in their application model.
|
void |
createWindowContents(Shell shell)
Deprecated.
This method is no longer used. Applications now define
workbench window contents in their application model.
|
void |
dispose()
Disposes any resources allocated by this window advisor.
|
protected IWorkbenchWindowConfigurer |
getWindowConfigurer()
Returns the workbench window configurer.
|
boolean |
isDurableFolder(String perspectiveId,
String folderId)
Returns
true if the given folder in the given perspective
should remain visible even after all parts in it have been closed by the
user. |
void |
openIntro()
Opens the introduction componenet.
|
void |
postWindowClose()
Performs arbitrary actions after the window is closed.
|
void |
postWindowCreate()
Performs arbitrary actions after the window has been created (possibly
after being restored), but has not yet been opened.
|
void |
postWindowOpen()
Performs arbitrary actions after the window has been opened (possibly
after being restored).
|
void |
postWindowRestore()
Performs arbitrary actions after the window has been restored,
but before it is opened.
|
void |
preWindowOpen()
Performs arbitrary actions before the window is opened.
|
boolean |
preWindowShellClose()
Performs arbitrary actions as the window's shell is being closed
directly, and possibly veto the close.
|
IStatus |
restoreState(IMemento memento)
Restores arbitrary application specific state information.
|
IStatus |
saveState(IMemento memento)
Saves arbitrary application specific state information.
|
public WorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
configurer
- an object for configuring the workbench windowprotected IWorkbenchWindowConfigurer getWindowConfigurer()
public void preWindowOpen()
This method is called before the window's controls have been created.
Clients must not call this method directly (although super calls are okay).
The default implementation does nothing. Subclasses may override.
Typical clients will use the window configurer to tweak the
workbench window in an application-specific way; however, filling the
window's menu bar, tool bar, and status line must be done in
ActionBarAdvisor.fillActionBars(int)
, which is called immediately
after this method is called.
public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer)
ActionBarAdvisor
.configurer
- the action bar configurer for the windowpublic void postWindowRestore() throws WorkbenchException
This method is called after a previously-saved window has been
recreated. This method is not called when a new window is created from
scratch. This method is never called when a workbench is started for the
very first time, or when workbench state is not saved or restored.
Clients must not call this method directly (although super calls are okay).
The default implementation does nothing. Subclasses may override.
It is okay to call IWorkbench.close()
from this method.
WorkbenchException
- thrown if there are any errors to report
from post-restoration of the windowprotected void cleanUpEditorArea()
postWindowRestore()
in the subclass but is not called by
default.public void openIntro()
Clients must not call this method directly (although super calls are okay).
The default implementation opens the intro in the first window provided
if the preference IWorkbenchPreferences.SHOW_INTRO is true
. If
an intro is shown then this preference will be set to false
.
Subsequently, and intro will be shown only if
WorkbenchConfigurer.getSaveAndRestore()
returns
true
and the introduction was visible on last shutdown.
Subclasses may override.
public void postWindowCreate()
This method is called after the window has been created from scratch,
or when it has been restored from a previously-saved window. In the latter case,
this method is called after postWindowRestore
.
Clients must not call this method directly (although super calls are okay).
The default implementation does nothing. Subclasses may override.
public void postWindowOpen()
This method is called after the window has been opened. This method is called after the window has been created from scratch, or when it has been restored from a previously-saved window. Clients must not call this method directly (although super calls are okay). The default implementation does nothing. Subclasses may override.
public boolean preWindowShellClose()
This method is called from a ShellListener associated with the window,
for example when the user clicks the window's close button. It is not
called when the window is being closed for other reasons, such as if the
user exits the workbench via the ActionFactory.QUIT
action.
Clients must not call this method directly (although super calls are
okay). If this method returns false
, then the user's
request to close the shell is ignored. This gives the workbench advisor
an opportunity to query the user and/or veto the closing of a window
under some circumstances.
true
to allow the window to close, and
false
to prevent the window from closingIWorkbenchWindow.close()
,
WorkbenchAdvisor.preShutdown()
public void postWindowClose()
This method is called after the window's controls have been disposed. Clients must not call this method directly (although super calls are okay). The default implementation does nothing. Subclasses may override.
@Deprecated public void createWindowContents(Shell shell)
The default implementation adds a menu bar, a cool bar, a status line, a
perspective bar, and a fast view bar. The visibility of these controls
can be configured using the setShow*
methods on
IWorkbenchWindowConfigurer
.
Subclasses may override to define custom window contents and layout, but
must call IWorkbenchWindowConfigurer.createPageComposite
.
shell
- the window's shellIWorkbenchWindowConfigurer.createMenuBar()
,
IWorkbenchWindowConfigurer.createCoolBarControl(org.eclipse.swt.widgets.Composite)
,
IWorkbenchWindowConfigurer.createStatusLineControl(org.eclipse.swt.widgets.Composite)
,
IWorkbenchWindowConfigurer.createPageComposite(org.eclipse.swt.widgets.Composite)
@Deprecated public Control createEmptyWindowContents(Composite parent)
null
is returned, the default window background is
shown.
The default implementation returns null
. Subclasses may
override.
parent
- the parent compositenull
public boolean isDurableFolder(String perspectiveId, String folderId)
true
if the given folder in the given perspective
should remain visible even after all parts in it have been closed by the
user. The default is false
. The return value for a certain
combination of perspective id and folder id must not change over time.perspectiveId
- the perspective idfolderId
- the folder idtrue
if the given folder should be durablepublic void dispose()
public IStatus saveState(IMemento memento)
memento
- the storage area for object's state
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.