Skip to content

Eclipse Workbench Modification_85983330

nxi edited this page Apr 9, 2015 · 1 revision
Created by Tony Lam, last modified on Jun 01, 2008

Workbench UI Comoponent 

The Eclipse IDE workbench is basically a SWT shell with TrimLayout (internal API).  That is, the UI component in the benchwork can be customised using any SWT widget.  The class which controls the SWT control inside the workbench shell is org.eclipse.ui.internal.WorkbenchWindow.  Assume you want to add a button permanently in the workbench, modify WorkbenchWindow with the following code snippet:
private Composite composite;
protected void createDefaultContents(final Shell shell) {
    ...
    composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new FillLayout());
    Button button = new Button(composite, SWT.NONE);
    Composite workbenchArea = new Composite(composite, SWT.NONE);
        workbenchArea.setLayout(new FillLayout());
        createPageComposite(workbenchArea);
    ...
}
private void updateLayoutDataForContents() {
    ...
    defaultLayout.setCenterControl(composite);
    ...
}

Welcome View Restore

To restore welcome view on every launch,  there are two options available:
  • Set IWorkbenchPreferenceConstants.SHOW_INTRO to true before org.eclipse.ui.application.WorkbenchWindowAdvisor.openIntro() is called
  • Modify org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor.openIntro() so that the variable showIntro is always true (WorkbenchWindowAdvisor line 163 in Eclipse 3.3.2)

Plug-in Overriding 

There are two ways to override the class in plugin org.eclipse.ui.workbench:
  • Import plug-in org.eclipse.ui.workbench as source and modify the source code
   or
  • Import plug-in org.eclipse.ui.workbench as binary project.  Remove the original jar from the build path.  Create a fragment to org.eclipse.ui.workbench, and place the original workbench jar into the fragment.
The drawback for the first approach is obvious: the IDE needs to maintain and background compile lots of code from the org.eclipse.ui.workbench plug-in.  However, this approach will always work.  The second approach (class override) does not seems to have good support in IDE (at less in Eclipse 3.3).  In this approach, none of other plug-ins in your workspace that depends on org.eclipse.ui.workbench can detect classes from that plug-in.  So, you may need to export that emtpy plug-in and fragment into your target directory first before further development.

Document generated by Confluence on Apr 01, 2015 00:11
Clone this wiki locally