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
(New page: 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...)
 
(Updated with MUILabel API instead of MUIItem (as of RC0))
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
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.
 
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.
 +
 +
Commands often have two different representations on the user interface. Consider the save command for example, it has an entry in the 'File' menu and it is also displayed the tool bar as a clickable tool item. If this command's displayed text needs to be altered, say, if its keybinding has changed, then both its UI representation as a menu item and a tool item needs to be updated.
  
 
==Eclipse 3.x API==
 
==Eclipse 3.x API==
 
===Updating a part's name===
 
===Updating a part's name===
In Eclipse 3.x, a workbench part could alter its tab's text with the setPartName(String) method.
+
In Eclipse 3.x, a workbench part can alter its tab's text with the protected setPartName(String) method.
  
 
<source lang="java">
 
<source lang="java">
Line 9: Line 11:
 
   private void render(Model model) {
 
   private void render(Model model) {
 
     setPartName(model.getName());
 
     setPartName(model.getName());
 +
  }
 +
}
 +
</source>
 +
 +
===Updating a part's image===
 +
In Eclipse 3.x, a workbench part can alter its tab's image with the protected setTitleImage(Image) method.
 +
 +
<source lang="java">
 +
public class MyPart extends ViewPart {
 +
  private void render(Model model) {
 +
    setTitleImage(getImage(model));
 +
  }
 +
 +
  private Image getImage(Model model) {
 +
    /* implementation not shown */
 +
  }
 +
}
 +
</source>
 +
 +
===Updating a part's tooltip===
 +
In Eclipse 3.x, a workbench part can alter its tab's tooltip with the protected setTitleToolTip(String) method.
 +
 +
<source lang="java">
 +
public class MyPart extends ViewPart {
 +
  private void render(Model model) {
 +
    setTitleToolTip(model.getDescription());
 
   }
 
   }
 
}
 
}
Line 21: Line 49:
  
 
   @Inject
 
   @Inject
   private MUIItem uiItem;
+
   private MUILabel uiLabel;
 +
 
 +
  private void render(Model model) {
 +
    uiLabel.setLabel(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 MUILabel uiLabel;
 +
 
 +
  private void render(Model model) {
 +
    uiLabel.setIconUri(getImageURI(model));
 +
  }
 +
 
 +
  private String getImageURI(Model model) {
 +
    /* implementation not shown */
 +
  }
 +
}
 +
</source>
 +
 
 +
===Updating a part's tooltip===
 +
Injection can be used for retrieving the "owning" UI item. The client can then set its tooltip directly.
 +
 
 +
<source lang="java">
 +
public class MyPart {
 +
 
 +
  @Inject
 +
  private MUILabel uiLabel;
  
 
   private void render(Model model) {
 
   private void render(Model model) {
     uiItem.setName(model.getName());
+
     uiLabel.setTooltip(model.getDescription());
 
   }
 
   }
 
}
 
}
 
</source>
 
</source>

Latest revision as of 08:13, 23 June 2010

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.

Commands often have two different representations on the user interface. Consider the save command for example, it has an entry in the 'File' menu and it is also displayed the tool bar as a clickable tool item. If this command's displayed text needs to be altered, say, if its keybinding has changed, then both its UI representation as a menu item and a tool item needs 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 protected 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 protected setTitleImage(Image) method.

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

Updating a part's tooltip

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

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

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 MUILabel uiLabel;
 
  private void render(Model model) {
    uiLabel.setLabel(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 MUILabel uiLabel;
 
  private void render(Model model) {
    uiLabel.setIconUri(getImageURI(model));
  }
 
  private String getImageURI(Model model) {
    /* implementation not shown */
  }
}

Updating a part's tooltip

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

public class MyPart {
 
  @Inject
  private MUILabel uiLabel;
 
  private void render(Model model) {
    uiLabel.setTooltip(model.getDescription());
  }
}

Back to the top