com.ibm.jdg2e.miniwp
Class MiniWPWorkbenchAdvisor

java.lang.Object
  extended byorg.eclipse.ui.application.WorkbenchAdvisor
      extended bycom.ibm.jdg2e.miniwp.MiniWPWorkbenchAdvisor

public class MiniWPWorkbenchAdvisor
extends org.eclipse.ui.application.WorkbenchAdvisor

The heart of the Mini-Workplace, MiniWPWorkbenchAdvisor, decides what elements make up the main window and the set of base actions.


Field Summary
 
Fields inherited from class org.eclipse.ui.application.WorkbenchAdvisor
FILL_COOL_BAR, FILL_MENU_BAR, FILL_PROXY, FILL_STATUS_LINE
 
Constructor Summary
MiniWPWorkbenchAdvisor()
           
 
Method Summary
protected  org.eclipse.jface.action.MenuManager createEditMenu(org.eclipse.ui.IWorkbenchWindow window, org.eclipse.ui.application.IActionBarConfigurer configurer)
          Fill the Edit pulldown menu with the standard separators, ready to accept contributions.
protected  org.eclipse.jface.action.MenuManager createFileMenu(org.eclipse.ui.IWorkbenchWindow window, org.eclipse.ui.application.IActionBarConfigurer configurer)
          Fill the File pulldown menu with the standard separators, ready to accept contributions.
protected  org.eclipse.jface.action.MenuManager createHelpMenu(org.eclipse.ui.IWorkbenchWindow window)
          Add the standard Help pulldown menu insertion points so the Mini-Workbench is help-enabled (Exercise 7, Developing Your First Rich Client Application covers these steps).
protected  org.eclipse.jface.action.MenuManager createWindowMenu(org.eclipse.ui.IWorkbenchWindow window)
          Fill the Window pulldown menu with the standard separators, ready to accept contributions.
 void fillActionBars(org.eclipse.ui.IWorkbenchWindow window, org.eclipse.ui.application.IActionBarConfigurer configurer, int flags)
          Fill the toolbar and menu bar with the base actions.
protected  void fillCoolBar(org.eclipse.ui.IWorkbenchWindow window, org.eclipse.ui.application.IActionBarConfigurer configurer)
          Fill the base coolbar items that are always accessible, like in our case, the Save toolbar button.
protected  void fillMenuBar(org.eclipse.ui.IWorkbenchWindow window, org.eclipse.ui.application.IActionBarConfigurer configurer)
          Fill the menu bar with the standard based choices for the Mini-Workplace.
 java.lang.String getInitialWindowPerspectiveId()
          Return the "main" perspective as defined in the org.eclipse.ui.perspectives extension.
 void postWindowOpen(org.eclipse.ui.application.IWorkbenchWindowConfigurer configurer)
          Handle window initialization now that the main window's shell is available.
 void preWindowOpen(org.eclipse.ui.application.IWorkbenchWindowConfigurer configurer)
          Decide what window elements the Mini-Workplace needs.
 
Methods inherited from class org.eclipse.ui.application.WorkbenchAdvisor
createWindowContents, eventLoopException, eventLoopIdle, getDefaultPageInput, getMainPreferencePageId, getWorkbenchConfigurer, initialize, internalBasicInitialize, isApplicationMenu, openIntro, openWindows, postShutdown, postStartup, postWindowClose, postWindowCreate, postWindowRestore, preShutdown, preStartup, preWindowShellClose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MiniWPWorkbenchAdvisor

public MiniWPWorkbenchAdvisor()
Method Detail

createEditMenu

protected org.eclipse.jface.action.MenuManager createEditMenu(org.eclipse.ui.IWorkbenchWindow window,
                                                              org.eclipse.ui.application.IActionBarConfigurer configurer)
Fill the Edit pulldown menu with the standard separators, ready to accept contributions. See org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor for more example code.

Note: This method registers global actions. Its tests for previously created menus is necessary because this method may be called multiple times (e.g., by the Window > Customize Perspective... dialog to create its menu proxies that show the structure of the menu).


createFileMenu

protected org.eclipse.jface.action.MenuManager createFileMenu(org.eclipse.ui.IWorkbenchWindow window,
                                                              org.eclipse.ui.application.IActionBarConfigurer configurer)
Fill the File pulldown menu with the standard separators, ready to accept contributions. See org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor for more example code.

Note: This method registers global actions. Its tests for previously created menus is necessary because this method may be called multiple times (e.g., by the Window > Customize Perspective... dialog to create its menu proxies that show the structure of the menu).


createHelpMenu

protected org.eclipse.jface.action.MenuManager createHelpMenu(org.eclipse.ui.IWorkbenchWindow window)
Add the standard Help pulldown menu insertion points so the Mini-Workbench is help-enabled (Exercise 7, Developing Your First Rich Client Application covers these steps).

Note: The standard About dialog relies on the application being "productized" to retrieve its content. Otherwise it will be empty, as you'll see if you run the Mini-Workplace as an application (not product). Chapter 13, Defining Features and Products, explains the process. See the rcp_miniwp_product directory on the CD-ROM for a production version of this example.


createWindowMenu

protected org.eclipse.jface.action.MenuManager createWindowMenu(org.eclipse.ui.IWorkbenchWindow window)
Fill the Window pulldown menu with the standard separators, ready to accept contributions. See org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor for more example code.

Notice that not all menu choices that you might expect in the Eclipse IDE are included here. The Mini-Workplace could choose to use a completely different scheme for transitioning between perspectives (or even use multiple main windows instead and hide the fact that perspectives from the user).

To keep this implementation somewhat familiar, it includes some recognizable standard choices from the Generic Workbench. This example also shows how the advisor can "help" the standard actions by handling their enablement, as is the case for the Customize Perspective... choice (internally known as EDIT_ACTION_SETS). Finally, createWindowMenu leaves a place for extensions to the Preferences dialog, although the Mini-Workplace itself doesn't define any. This allows for the other chapter examples that do contribute preferences to optionally be included in this example (see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor for more example code).


fillActionBars

public void fillActionBars(org.eclipse.ui.IWorkbenchWindow window,
                           org.eclipse.ui.application.IActionBarConfigurer configurer,
                           int flags)
Fill the toolbar and menu bar with the base actions.


fillCoolBar

protected void fillCoolBar(org.eclipse.ui.IWorkbenchWindow window,
                           org.eclipse.ui.application.IActionBarConfigurer configurer)
Fill the base coolbar items that are always accessible, like in our case, the Save toolbar button. In the current implementation, the Workbench expects there will be at least one item in the coolbar. Otherwise the sizing of the toolbar is incorrect (see bug 70049 for details).


fillMenuBar

protected void fillMenuBar(org.eclipse.ui.IWorkbenchWindow window,
                           org.eclipse.ui.application.IActionBarConfigurer configurer)
Fill the menu bar with the standard based choices for the Mini-Workplace. Many of these are actions from the Generic Workbench that we're reusing. This saves us time and also enables other plug-ins that "expect" certain menus choices to function (e.g., Edit > Cut / Copy / Paste).

The actions below are created directly to make this code a bit more readable. In many case, however, other advisor methods will need a reference to these actions, so they would be stored in fields of this class. (see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor for more example code).


getInitialWindowPerspectiveId

public java.lang.String getInitialWindowPerspectiveId()
Return the "main" perspective as defined in the org.eclipse.ui.perspectives extension.

See Also:
MiniWPPerspectiveFactory

postWindowOpen

public void postWindowOpen(org.eclipse.ui.application.IWorkbenchWindowConfigurer configurer)
Handle window initialization now that the main window's shell is available.


preWindowOpen

public void preWindowOpen(org.eclipse.ui.application.IWorkbenchWindowConfigurer configurer)
Decide what window elements the Mini-Workplace needs. A more complete implementation should offer the user the ability to customize these choices. The Workbench preferences, without the "programmer-oriented" settings, is a good place to start.