Skip to main content

Notice: This Wiki is now read only and edits are no longer 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"

(Replace the SmartFields proposal table)
(Replaced content with "The Scout documentation has been moved to https://eclipsescout.github.io/.")
 
(2 intermediate revisions by the same user not shown)
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>&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 ==
+
{|{{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.
+
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 <codeorg.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">
+
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);
+
      }
+
    }
+
  }
+
}
+
</source>
+
 
+
====== Lookup call ======
+
<source lang="java">
+
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;
+
  }
+
}
+
</source>
+
 
+
====== Table row data ======
+
<source lang="java">
+
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;
+
  }
+
 
+
}
+
</source>
+
 
+
====== Company type lookup call ======
+
<source lang="java">
+
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;
+
  }
+
}
+
</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}}
+

Latest revision as of 04:50, 14 March 2024

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

Back to the top