Jump to: navigation, search

Scout/Concepts/CodeType/Example

< Scout‎ | Concepts‎ | CodeType
Revision as of 02:28, 15 April 2013 by Jbr.bsiag.com (Talk | contribs)


Scout
Wiki Home
Website
DownloadGit
Community
ForumsBlogTwitter
Bugzilla
Bugzilla


This page contains some example Java code for a simple CodeType having just two codes:

  • YesOrNoCodeType.YesCode
  • YesOrNoCodeType.NoCode


Notice that the CodeType Id is a String and that both code have an Boolean Id.

The definition of codes is reduced to an Id and a Text, but we could also imagine to configure the IconId or the Tooltip.

Code

public class YesOrNoCodeType extends AbstractCodeType<String> {
  private static final long serialVersionUID = 1L;
  public static final String ID = "YesOrNo";
 
  public YesOrNoCodeType() throws ProcessingException {
    super();
  }
 
  @Override
  protected String getConfiguredText() {
    return TEXTS.get("YesOrNo");
  }
 
  @Override
  public String getId() {
    return ID;
  }
 
  @Order(10.0)
  public class YesCode extends AbstractCode<Boolean> {
    private static final long serialVersionUID = 1L;
    public final Boolean ID = Boolean.TRUE;
 
    @Override
    protected String getConfiguredText() {
      return TEXTS.get("Yes");
    }
 
    @Override
    public Boolean getId() {
      return ID;
    }
  }
 
  @Order(20.0)
  public class NoCode extends AbstractCode<Boolean> {
    private static final long serialVersionUID = 1L;
    public final Boolean ID = Boolean.FALSE;
 
    @Override
    protected String getConfiguredText() {
      return TEXTS.get("No");
    }
 
    @Override
    public Boolean getId() {
      return ID;
    }
  }
}

Usage

This code Type can be used in a SmartField extending AbstractSmartField<Boolean>

public class YesOrNoSmartField extends AbstractSmartField<Boolean> {
  // other configuration of properties.
  @Override
  protected Class<? extends ICodeType<?>> getConfiguredCodeType(){
    return YesOrNoCodeType.class;
  }
}

In the SDK

Explorer View proposes a graphical representation of this CodeType. It is possible to modify the corresponding Java code directly in the SDK.

ScoutSDK CodeType.png