Scout/Concepts/SmartField
Scout |
Wiki Home |
Website |
Download • Git |
Community |
Forums • Blog • Twitter • G+ |
Bugzilla |
Bugzilla |
Specific type of value field to use a Smart association (with CodeType or LookupCall).
Contents
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 | ![]() |
![]() |
![]() |
![]() |
With text | ![]() |
![]() |
![]() |
![]() |
With text and wildcard | ![]() |
![]() |
![]() |
![]() |
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:
-
Write your own table
implements org.eclipse.scout.rt.client.ui.form.fields.smartfield.IContentAssistFieldTable<KEY_TYPE>
or extend the default tableextends 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. -
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. -
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
@Order(10.0) public class PersonField extends AbstractSmartField<Long> { @Override protected String getConfiguredLabel() { return TEXTS.get("Person"); } @Override protected Class<? extends ILookupCall<Long>> getConfiguredLookupCall() { return PersonLookupCall.class; } @Order(10.0) public class Table extends ContentAssistFieldTable<Long> { /** * @return the CityColumn */ public CityColumn getCityColumn() { return getColumnSet().getColumnByClass(CityColumn.class); } /** * @return the BirthdateColumn */ public BirthdateColumn getBirthdateColumn() { return getColumnSet().getColumnByClass(BirthdateColumn.class); } @Order(100.0) public class BirthdateColumn extends AbstractDateColumn { @Override protected String getConfiguredHeaderText() { return TEXTS.get("Birthdate"); } @Override protected int getConfiguredWidth() { return 100; } } @Order(110.0) public class CityColumn extends AbstractStringColumn { @Override protected String getConfiguredHeaderText() { return TEXTS.get("City"); } @Override protected int getConfiguredWidth() { return 100; } } } }
Lookup call
public class PersonLookupCall extends LocalLookupCall<Long> { private static final long serialVersionUID = 1L; @Override protected List<? extends ILookupRow<Long>> execCreateLookupRows() throws ProcessingException { List<LookupRow<Long>> rows = new ArrayList<LookupRow<Long>>(); rows.add(createLookupRow(23L, true, "Robert", "Smith", "1983-03-23", "Chicago")); rows.add(createLookupRow(34L, false, "Mary", "Johnson", "1962-10-19", "New-York")); rows.add(createLookupRow(45L, true, "David", "Jones", "1984-12-07", "New-York")); rows.add(createLookupRow(56L, true, "James", "Wilson", "1979-05-29", "Chicago")); rows.add(createLookupRow(67L, true, "Donald", "Johnson", "1972-08-13", "Boston")); rows.add(createLookupRow(78L, false, "Susan", "Jackson", "1989-02-17", "Boston")); rows.add(createLookupRow(89L, false, "Betty", "Taylor", "1964-04-24", "New-York")); rows.add(createLookupRow(90L, true, "James", "Jones", "1957-06-30", "Chicago")); return rows; } private LookupRow<Long> createLookupRow(Long id, boolean male, String firstName, String lastName, String date, String city) { String text = firstName + " " + lastName; String iconId = (male) ? Icons.MALE : Icons.FEMALE; LookupRow<Long> row = new LookupRow<Long>(id, text, iconId); PersonTableRowData data = new PersonTableRowData(); data.setBirthdate(DateUtility.parse(date, "yyyy-MM-dd")); data.setCity(city); row.setAdditionalTableRowData(data); return row; } }
Table row data
public class PersonTableRowData extends AbstractTableRowData { private static final long serialVersionUID = 1L; public static final String birthdate = "birthdate"; public static final String city = "city"; private Date m_birthdate; private String m_city; public PersonTableRowData() { } /** * @return the Birthdate */ public Date getBirthdate() { return m_birthdate; } /** * @param birthdate * the Birthdate to set */ public void setBirthdate(Date birthdate) { m_birthdate = birthdate; } /** * @return the City */ public String getCity() { return m_city; } /** * @param city * the City to set */ public void setCity(String city) { m_city = city; } }
See Also
- Value field
- Field
- Form
- The corresponding column: SmartColumn
- Type of data supported by Scout in the fields