Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "E4/EAS/Updating UI Elements"

< E4‎ | EAS
Line 13: Line 13:
 
</source>
 
</source>
  
===Updating a part's title===
+
===Updating a part's image===
 
In Eclipse 3.x, a workbench part can alter its tab's image with the setTitleImage(Image) method.
 
In Eclipse 3.x, a workbench part can alter its tab's image with the setTitleImage(Image) method.
  
Line 40: Line 40:
 
   private void render(Model model) {
 
   private void render(Model model) {
 
     uiItem.setName(model.getName());
 
     uiItem.setName(model.getName());
 +
  }
 +
}
 +
</source>
 +
 +
===Updating a part's image===
 +
Injection can be used for retrieving the "owning" UI item. The client can then set its image directly.
 +
 +
<source lang="java">
 +
public class MyPart {
 +
 +
  @Inject
 +
  private MUIItem uiItem;
 +
 +
  private void render(Model model) {
 +
    uiItem.setIconUri(getImageURI(model));
 +
  }
 +
 +
  private String getImageURI(Model model) {
 +
    /* implementation not shown */
 
   }
 
   }
 
}
 
}
 
</source>
 
</source>

Revision as of 09:10, 10 November 2009

Any application that's not for kiosks will generally have some menus and a couple of tool bar items for the user to interact with. There may also be arrays of tabs to provide a view of the information that the user may be interested in. As the information and context of the application alters, these user interface elements may need to be updated.

Eclipse 3.x API

Updating a part's name

In Eclipse 3.x, a workbench part can alter its tab's text with the setPartName(String) method.

public class MyPart extends ViewPart {
  private void render(Model model) {
    setPartName(model.getName());
  }
}

Updating a part's image

In Eclipse 3.x, a workbench part can alter its tab's image with the setTitleImage(Image) method.

public class MyPart extends ViewPart {
  private void render(Model model) {
    setTitleImage(getImage(model));
  }
 
  private Image getImage(Model model) {
    /* implementation not shown */
  }
}

e4 (Java)

Updating a part's name

Injection can be used for retrieving the "owning" UI item. The client can then set its name directly.

public class MyPart {
 
  @Inject
  private MUIItem uiItem;
 
  private void render(Model model) {
    uiItem.setName(model.getName());
  }
}

Updating a part's image

Injection can be used for retrieving the "owning" UI item. The client can then set its image directly.

public class MyPart {
 
  @Inject
  private MUIItem uiItem;
 
  private void render(Model model) {
    uiItem.setIconUri(getImageURI(model));
  }
 
  private String getImageURI(Model model) {
    /* implementation not shown */
  }
}

Back to the top