Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Concepts/SmartField"

(Screenshot)
(Replace the SmartFields proposal table)
(8 intermediate revisions by 2 users not shown)
Line 7: Line 7:
  
 
== Description ==
 
== Description ==
{{note|TODO|Add a 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>&lt;all>&lt;/all></code>)
 +
 +
If the client write text into the field, it will show all values, which starts with this text. (Lookup-Service Statement <code>&lt;text>&lt;/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>&lt;key>&lt;/key></code>)
  
 
== Screenshot ==
 
== Screenshot ==
'''RAP:       '''[[Image:Scout_3.8_SmartField_RAP.png]]
+
{|{{BMTableStyle}}
'''SWT:       '''[[Image:Scout_3.8_SmartField_SWT.png]]
+
|-{{BMTHStyle}}
'''Swing:     '''[[Image:Scout_3.8_SmartField_Swing.png]]
+
! Type
'''Swing Rayo: '''[[Image:Scout_3.8_SmartField_Swing_Rayo.png]]
+
! 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 ==
 
== Properties ==
Line 33: Line 54:
 
See also the {{ScoutLink|Concepts|Field|Field}} and the {{ScoutLink|Concepts|ValueField|Value field}} pages for the events that all fields have in common.
 
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 ==
 
== See Also ==

Revision as of 13:43, 19 November 2014

The Scout documentation has been moved to https://eclipsescout.github.io/.

Specific type of The Scout documentation has been moved to https://eclipsescout.github.io/. to use a Smart association (with The Scout documentation has been moved to https://eclipsescout.github.io/. or The Scout documentation has been moved to https://eclipsescout.github.io/.).

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 The Scout documentation has been moved to https://eclipsescout.github.io/. methods.

See also the The Scout documentation has been moved to https://eclipsescout.github.io/. and the The Scout documentation has been moved to https://eclipsescout.github.io/. pages for the properties that all fields have in common.

The Scout documentation has been moved to https://eclipsescout.github.io/.: overwrites the property of The Scout documentation has been moved to https://eclipsescout.github.io/. 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 The Scout documentation has been moved to https://eclipsescout.github.io/. methods.

See also the The Scout documentation has been moved to https://eclipsescout.github.io/. and the The Scout documentation has been moved to https://eclipsescout.github.io/. 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.

Scout MultiColumnSmartField.png

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
@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

Back to the top