Jump to: navigation, search

Scout/Concepts/SmartField


Scout
Wiki Home
Website
DownloadGit
Community
ForumsBlogTwitter
Bugzilla
Bugzilla


Specific type of value field to use a Smart association (with CodeType or LookupCall).

  • implements: I obj.pngISmartField<T>
  • extends: C obj.pngAbstractSmartField<T>

Description

A SmartField gives a selection of available values to the client. The field gets his contents from a CodeType or a LookupCall.

If the client doesn't write something into the SmartField, it will show all available values. (Lookup-Service Statement <all></all>)

If the client write text into the field, it will show all values, which starts with this text. (Lookup-Service Statement <text></text>)
Wildcards like *, % or _ are also possible to write into the SmartField.

The functions:

  • setValue(value)
  • getValue()

use the key of the CodeType or the LookupCall. (Lookup-Service Statement <key></key>)

Screenshot

Type RAP SWT Swing Swing Rayo
Without values Scout 3.8 SmartField all RAP.png Scout 3.8 SmartField all SWT.png Scout 3.8 SmartField all Swing.png Scout 3.8 SmartField all Swing Rayo.png
With text Scout 3.8 SmartField text RAP.png Scout 3.8 SmartField text SWT.png Scout 3.8 SmartField text Swing.png Scout 3.8 SmartField text Swing Rayo.png
With text and wildcard Scout 3.8 SmartField wildcard RAP.png Scout 3.8 SmartField wildcard SWT.png Scout 3.8 SmartField wildcard Swing.png Scout 3.8 SmartField wildcard Swing Rayo.png

Properties

Defined with getConfiguredXxxxxx() methods.

See also the Field and the Value field pages for the properties that all fields have in common.

BrowseHierarchy: overwrites the property of IsHierarchy of the CodeType. If true the CodeType will be displayed as a tree, if false it will be displayed as a list.

Events

Defined with execXxxxxx() methods.

See also the Field and the Value field pages for the events that all fields have in common.

Concepts

Replace the SmartFields proposal table

The proposal table can be replaced or extended by an own implementation. This feature is primarily used for adding more columns to a smart field. How to get there:

  1. Write your own table implements org.eclipse.scout.rt.client.ui.form.fields.smartfield.IContentAssistFieldTable<KEY_TYPE> or extend the default table extends org.eclipse.scout.rt.client.ui.form.fields.smartfield.ContentAssistFieldTable<KEY> providing already a key and text column and several utility functions. This table can be written in its own class file or as an inner class of the smart field.
  2. In case the table is implemented in its own compilation unit the org.eclipsescout.demo.widgets.client.ui.forms.SmartFieldForm.MainBox.GroupBox.LeftBox.ListWithTableProposalField.getConfiguredContentAssistTable() must be implemented and return the table class.
  3. To provide additional data to the created table use the org.eclipse.scout.rt.shared.services.lookup.ILookupRow.setAdditionalTableRowData(AbstractTableRowData) method. Create your own table row data class (a simple property bean with access methods name-matching with the column names and add it to the lookup row in the lookup service.
Example
Smart Field
public class SmartField extends AbstractSmartField<Long> {
 
  @Override
  protected String getConfiguredLabel() {
    return "A smart field";
  }
 
  @Override
  protected Class<? extends ILookupCall<Long>> getConfiguredLookupCall() {
    return CompanyLookupCall.class;
  }
 
  public class Table extends ContentAssistFieldTable<Long> {
 
    @Override
    protected String getConfiguredDefaultIconId() {
      return Icons.WeatherSnow;
    }
 
    @Override
    protected boolean getConfiguredHeaderVisible() {
      return true;
    }
 
    @Order(40)
    public class AdditionalInfoColumn extends AbstractStringColumn {
      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("AdditionalInfo");
      }
 
      @Override
      protected int getConfiguredWidth() {
        return 200;
      }
    }
 
    @Order(50)
    public class CompanyTypeColumn extends AbstractSmartColumn<Long> {
      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("CompanyType");
      }
 
      @Override
      protected int getConfiguredWidth() {
        return 200;
      }
 
      @Override
      protected Class<? extends ILookupCall<Long>> getConfiguredLookupCall() {
        return CompanyTypeLookupCall.class;
      }
 
      @Override
      protected void execDecorateCell(Cell cell, ITableRow row) throws ProcessingException {
        decorateCellWithLookupRow(cell, row);
      }
    }
  }
}
Lookup call
public class CompanyLookupCall extends LocalLookupCall<Long> {
 
  private static final long serialVersionUID = 1L;
 
  @Override
  protected List<ILookupRow<Long>> execCreateLookupRows() throws ProcessingException {
    ArrayList<ILookupRow<Long>> rows = new ArrayList<ILookupRow<Long>>();
    rows.add(createLookupRow(1L, "Business Systems Integration AG", "World best company.", 3L, Icons.WeatherSun, true));
    rows.add(createLookupRow(2L, "Eclipse", "Open source stuff.", 1L, Icons.WeatherCloudy, false));
    rows.add(createLookupRow(3L, "Google", "Also a fancy company.", 1L, null, false));
    // create some more rows
    for (int i = 4; i < 120; i++) {
      rows.add(createLookupRow(4L, "company" + String.format("%03d", i), "A company with id " + String.format("%03d", i) + ".", 3L, null, false));
    }
    return rows;
  }
 
  private LookupRow<Long> createLookupRow(long id, String name, String detail, long companyType, String iconId, boolean bold) {
    CompanySmartTableData addTableData = new CompanySmartTableData(detail, companyType);
    LookupRow<Long> result = new LookupRow<Long>(id, name, iconId, null, null, null, bold ? FontSpec.parse("bold") : null);
    result.setAdditionalTableRowData(addTableData);
    return result;
  }
}
Table row data
public class CompanySmartTableData extends AbstractTableRowData {
 
  private static final long serialVersionUID = 1L;
 
  public static final String additionalInfo = "additionalInfo";
  public static final String companyType = "companyType";
  private String m_additionalInfo;
  private Long m_companyType;
 
  public CompanySmartTableData() {
  }
 
  public CompanySmartTableData(String additionalInfo, Long companyType) {
    m_additionalInfo = additionalInfo;
    m_companyType = companyType;
  }
 
  public String getAdditionalInfo() {
    return m_additionalInfo;
  }
 
  public void setAdditionalInfo(String additionalInfo) {
    m_additionalInfo = additionalInfo;
  }
 
  public Long getCompanyType() {
    return m_companyType;
  }
 
  public void setCompanyType(Long companyType) {
    m_companyType = companyType;
  }
 
}
Company type lookup call
public class CompanyTypeLookupCall extends LocalLookupCall<Long> {
 
  private static final long serialVersionUID = 1L;
 
  @Override
  protected List<ILookupRow<Long>> execCreateLookupRows() throws ProcessingException {
    List<ILookupRow<Long>> rows = new ArrayList<ILookupRow<Long>>();
    rows.add(new LookupRow<Long>(1L, "Customer"));
    rows.add(new LookupRow<Long>(2L, "Supplier"));
    rows.add(new LookupRow<Long>(3L, "Other"));
    return rows;
  }
}

See Also