Scout/Concepts/Code

From Eclipsepedia

Jump to: navigation, search


Scout
Wiki Home
Website
DownloadGit
Community
ForumsBlogTwitter
Bugzilla
Bugzilla


A code is an element of a CodeType. It group together some properties.

  • implements: I obj.pngICode<T>
  • extends: C obj.pngAbstractCode<T>

Description

Needs to override the getId()

For each code following properties can be set:


Texts:


State of the code:

  • Active
  • Enabled
Note.png
TODO
Difference Active/Enabled


Styling:

  • IconId using Icons
  • Font
  • Foreground Color
  • Background Color


Other properties:

  • ExtKey
  • Value

Example - Good Practice

A good practice is to define an ID as static member like in this example:

 
  @Order(10.0)
  public class RedCode extends AbstractCode<String>{
    private static final long serialVersionUID=1L;
    private final String ID = "FF0000";
 
    @Override
    public String getId() {
      return ID;
    }
 
    @Override
    public String getConfiguredText() {
      return Texts.get("Red");
    }
 
    @Override
    protected String getConfiguredIconId(){
      return Icons.RedIcon;
    }
 
  }

It is recommanded to use this member if you want to compare the ID of an ICode.

 
  private void displayValue(ICode c) {
    if(CompareUtility.equals(c.getId(), ColorCodeType.RedCode.ID)) {
      // the code c is RedCode 
      // add some business logic here ...
    }
  }

See Also