|
|
Line 1: |
Line 1: |
− | {{ScoutPage|cat=Component Model}}
| + | The Scout documentation has been moved to https://eclipsescout.github.io/. |
− | | + | |
− | Specific type of {{ScoutLink|Concepts|ValueField|value field}} to use a Smart association (with {{ScoutLink|Concepts|CodeType|CodeType}} or {{ScoutLink|Concepts|LookupCall|LookupCall}}).
| + | |
− | | + | |
− | * implements: {{ScoutJavadoc|ISmartField<T>|I}}
| + | |
− | * extends: {{ScoutJavadoc|AbstractSmartField<T>|C}}
| + | |
− | | + | |
− | == 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 <code><all></all></code>)
| + | |
− | | + | |
− | If the client write text into the field, it will show all values, which starts with this text. (Lookup-Service Statement <code><text></text></code>)<br>
| + | |
− | Wildcards like <code>*</code>, <code>%</code> or <code>_</code> 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 <code><key></key></code>)
| + | |
− | | + | |
− | == Screenshot ==
| + | |
− | {|{{BMTableStyle}}
| + | |
− | |-{{BMTHStyle}}
| + | |
− | ! Type
| + | |
− | ! RAP
| + | |
− | ! SWT
| + | |
− | ! Swing
| + | |
− | ! Swing Rayo
| + | |
− | |-
| + | |
− | | Without values || [[Image:Scout_3.8_SmartField_all_RAP.png]] || [[Image:Scout_3.8_SmartField_all_SWT.png]] || [[Image:Scout_3.8_SmartField_all_Swing.png]] || [[Image:Scout_3.8_SmartField_all_Swing_Rayo.png]]
| + | |
− | |-
| + | |
− | | With text || [[Image:Scout_3.8_SmartField_text_RAP.png]] || [[Image:Scout_3.8_SmartField_text_SWT.png]] || [[Image:Scout_3.8_SmartField_text_Swing.png]] || [[Image:Scout_3.8_SmartField_text_Swing_Rayo.png]]
| + | |
− | |-
| + | |
− | | With text and wildcard || [[Image:Scout_3.8_SmartField_wildcard_RAP.png]] || [[Image:Scout_3.8_SmartField_wildcard_SWT.png]] || [[Image:Scout_3.8_SmartField_wildcard_Swing.png]] || [[Image:Scout_3.8_SmartField_wildcard_Swing_Rayo.png]]
| + | |
− | |-
| + | |
− | |}
| + | |
− | | + | |
− | == Properties ==
| + | |
− | ''Defined with {{ScoutLink|Concepts|GetConfigured Methods|getConfiguredXxxxxx()}} methods''.
| + | |
− | | + | |
− | See also the {{ScoutLink|Concepts|Field|Field}} and the {{ScoutLink|Concepts|ValueField|Value field}} pages for the properties that all fields have in common.
| + | |
− | | + | |
− | {{ScoutProp|BrowseHierarchy}}: overwrites the property of {{ScoutProp|IsHierarchy}} of the CodeType. If true the CodeType will be displayed as a tree, if false it will be displayed as a list.
| + | |
− | | + | |
− | <gallery>
| + | |
− | Image:Scout SmartField BrowseHierarchy True.png|BrowseHierarchy is true
| + | |
− | Image:Scout SmartField BrowseHierarchy False.png|BrowseHierarchy is false
| + | |
− | </gallery>
| + | |
− | | + | |
− | == Events ==
| + | |
− | ''Defined with {{ScoutLink|Concepts|Exec_Methods|execXxxxxx()}} methods''.
| + | |
− | | + | |
− | See also the {{ScoutLink|Concepts|Field|Field}} and the {{ScoutLink|Concepts|ValueField|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.
| + | |
− | | + | |
− | [[File:Scout_MultiColumnSmartField.png]]
| + | |
− | | + | |
− | How to get there:
| + | |
− | <ol>
| + | |
− | <li>
| + | |
− | Write your own table <code>implements org.eclipse.scout.rt.client.ui.form.fields.smartfield.IContentAssistFieldTable<KEY_TYPE></code> or extend the default table <code>extends org.eclipse.scout.rt.client.ui.form.fields.smartfield.ContentAssistFieldTable<KEY></code> 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.
| + | |
− | </li>
| + | |
− | <li>
| + | |
− | In case the table is implemented in its own compilation unit the <code>org.eclipsescout.demo.widgets.client.ui.forms.SmartFieldForm.MainBox.GroupBox.LeftBox.ListWithTableProposalField.getConfiguredContentAssistTable()</code> must be implemented and return the table class.
| + | |
− | </li>
| + | |
− | <li>
| + | |
− | To provide additional data to the created table use the <code>org.eclipse.scout.rt.shared.services.lookup.ILookupRow.setAdditionalTableRowData(AbstractTableRowData)</code> 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.
| + | |
− | | + | |
− | </li>
| + | |
− | </ol>
| + | |
− | | + | |
− | ==== Example ====
| + | |
− | ===== Smart Field =====
| + | |
− | <source lang="java">
| + | |
− | @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;
| + | |
− | }
| + | |
− | }
| + | |
− | }
| + | |
− | }
| + | |
− | </source>
| + | |
− | | + | |
− | ===== Lookup call =====
| + | |
− | <source lang="java">
| + | |
− | 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;
| + | |
− | }
| + | |
− | }
| + | |
− | </source>
| + | |
− | | + | |
− | ===== Table row data =====
| + | |
− | <source lang="java">
| + | |
− | 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;
| + | |
− | }
| + | |
− | }
| + | |
− | </source>
| + | |
− | | + | |
− | == See Also ==
| + | |
− | * {{ScoutLink|Concepts|ValueField|Value field}}
| + | |
− | * {{ScoutLink|Concepts|Field|Field}}
| + | |
− | * {{ScoutLink|Concepts|Form|Form}}
| + | |
− | * The corresponding column: {{ScoutLink|Concepts|SmartColumn|SmartColumn}}
| + | |
− | * {{ScoutLink|Concepts|Type of Data|Type of data supported by Scout in the fields}}
| + | |