Jump to: navigation, search

E4/EAS/Part Input

< E4‎ | EAS
Revision as of 10:59, 4 November 2009 by Remysuen.ca.ibm.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In any application, a user is presented with some information which they may or may not take any action on. A data object may have a very limited amount of properties but there may be multiple ways of presenting this information. Consider four non-negative integers. Individually, they could be something random like four candidate numbers for the lottery, but together, they may represent a quadrilateral on a Cartesian coordinate system based on its X and Y coordinate and values for its height and width. These four values may be displayed to the user as four discrete number on one part but as a rectangle on the user's screen on another part.

Eclipse 3.x API

In 3.x, there are two types of workbench parts, editors and views.

Consuming input

Editors interact with its input through the IEditorInput.

public void init(IEditorSite site, IEditorInput input) throws PartInitException {
  if (!(input instanceof ModelEditorInput)) {
    throw new PartInitException("Unknown editor input");
public void createPartControl(Composite parent) {
  ModelEditorInput input = (ModelEditorInput) getEditorInput();
  Model model = input.getModel();
  /* render the model */

Views do not have an input so they are usually forced to expose a public method for setting the input.

public void setModel(Model model) {
  /* populate the view with the model's information */

Providing input

Editors can be opened with a specific type of editor.

IEditorInput input = new ModelEditorInput(model);
workbenchPage.openEditor(input, "org.eclipse.e4.examples.modelEditorId");

Views have their input set after the view has been shown.

ModelView modelView = (ModelView) workbenchPage.showView("org.eclipse.e4.examples.modelView");