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/TreeBox"

(LookupService: Add a review mention)
Line 37: Line 37:
 
See also the {{ScoutLink|Concepts|Field|Field}} and the {{ScoutLink|Concepts|ValueField|Value field}} pages for the properties that all fields have in common.  
 
See also the {{ScoutLink|Concepts|Field|Field}} and the {{ScoutLink|Concepts|ValueField|Value field}} pages for the properties that all fields have in common.  
  
<br>
 
  
'''getConfiguredLookupCall()'''<br>
+
'''getConfiguredLookupCall()'''
  
 
The fields of a TreeBox are populated through the use of a <code>LookupCall</code>:  
 
The fields of a TreeBox are populated through the use of a <code>LookupCall</code>:  
  
@Override
+
<source lang="java">
protected Class&lt;? extends LookupCall&gt; getConfiguredLookupCall() {
+
@Override
return MyLookupCall.class;
+
protected Class<? extends LookupCall> getConfiguredLookupCall() {
}
+
  return MyLookupCall.class;
 +
}
 +
</source>
  
 
That lookup call in turn uses a lookup service:  
 
That lookup call in turn uses a lookup service:  
<pre>public class MyLookupCall extends LookupCall{
+
<source lang="java">
 +
public class MyLookupCall extends LookupCall{
 
   private static final long serialVersionUID = 1L;
 
   private static final long serialVersionUID = 1L;
 
   @Override
 
   @Override
   protected Class&lt;? extends ILookupService&gt; getConfiguredService() {
+
   protected Class<? extends ILookupService> getConfiguredService() {
 
     return IMyLookupService.class;
 
     return IMyLookupService.class;
 
   }
 
   }
 
}
 
}
</pre>  
+
</source>  
 
The lookup service on the server uses an SQL query to return the content for those fields (see below).  
 
The lookup service on the server uses an SQL query to return the content for those fields (see below).  
  
<br>
 
  
'''getConfiguredAutoExpandAll()''' <br>
+
'''getConfiguredAutoExpandAll()'''
  
 
By default the TreeBoxField shows a collapsed tree if not all elements of the tree can be shown in the field at the current size. This can be changed to always expand the tree by setting the <code>AutoExpandAll</code> property to true  
 
By default the TreeBoxField shows a collapsed tree if not all elements of the tree can be shown in the field at the current size. This can be changed to always expand the tree by setting the <code>AutoExpandAll</code> property to true  
  
@Override
+
<source lang="java">
protected boolean getConfiguredAutoExpandAll() {
+
@Override
return true;
+
protected boolean getConfiguredAutoExpandAll() {
}
+
  return true;
 
+
}
<br>  
+
</source>
  
 
== Events  ==
 
== Events  ==
Line 78: Line 79:
 
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.  
  
<br>
 
  
'''execFilterLookupResult()'''<br>
+
'''execFilterLookupResult()'''
  
 
By default the entries in the list and tree are sorted by the <code>text</code> attribute (i.e. the visible text), not the <code>key</code>. This can be changed by defining a filtering function:  
 
By default the entries in the list and tree are sorted by the <code>text</code> attribute (i.e. the visible text), not the <code>key</code>. This can be changed by defining a filtering function:  
  
@Override
+
<source lang="java">
protected void execFilterLookupResult(LookupCall call, List&lt;LookupRow&gt; result) throws ProcessingException {
+
@Override
java.util.Collections.sort(result, new MyLookupRowComparator());
+
protected void execFilterLookupResult(LookupCall call, List&lt;LookupRow&gt; result) throws ProcessingException {
}
+
  java.util.Collections.sort(result, new MyLookupRowComparator());
 
+
}
 +
</source>
 
This filter function requires a comparator class which implements <code>Comparator&lt;LookupRow&gt;</code>:  
 
This filter function requires a comparator class which implements <code>Comparator&lt;LookupRow&gt;</code>:  
<pre>public class MyRowComparator implements Comparator&lt;LookupRow&gt; {
+
<source lang="java">
 +
public class MyRowComparator implements Comparator&lt;LookupRow&gt; {
 
   @Override
 
   @Override
 
   public int compare(LookupRow object1, LookupRow object2) {
 
   public int compare(LookupRow object1, LookupRow object2) {
Line 102: Line 104:
 
   }
 
   }
 
}
 
}
</pre>  
+
</source>  
<br>
+
 
  
 
== LookupService ==
 
== LookupService ==
Line 112: Line 114:
 
}}
 
}}
  
The [[Scout/Tutorial/3.8/Minicrm/Lookup Calls and Lookup Services|MiniCRM tutorial]] describes how to use a lookup service to populate SmartFields (e.g. dropdown boxes).<br>
+
The [[Scout/Tutorial/3.8/Minicrm/Lookup Calls and Lookup Services|MiniCRM tutorial]] describes how to use a lookup service to populate SmartFields (e.g. dropdown boxes).
  
 
Populating TreeBoxFields and ListBoxFields require more fields to be returned.<br>  
 
Populating TreeBoxFields and ListBoxFields require more fields to be returned.<br>  
  
 
The LookupService has a '''getConfiguredSqlSelect()''' method which returns a number of fields. The first two attributes (<code>key</code> and <code>text</code>) are compulsory, any of the other attributes are optional (and can be skipped by returning null or an empty string; if all remaining fields would be skipped, the query can just end early). The attributes are returned in the following order:  
 
The LookupService has a '''getConfiguredSqlSelect()''' method which returns a number of fields. The first two attributes (<code>key</code> and <code>text</code>) are compulsory, any of the other attributes are optional (and can be skipped by returning null or an empty string; if all remaining fields would be skipped, the query can just end early). The attributes are returned in the following order:  
<pre> @Override
+
<source lang="java">
  protected String getConfiguredSqlSelect() {
+
@Override
    return "" +
+
protected String getConfiguredSqlSelect() {
        "SELECT " +
+
  return "" +
        "  C.COMPANY_NR, " +                    // key
+
      "SELECT " +
        "  C.SHORT_NAME || ': ' || C.NAME, " +  // text
+
      "  C.COMPANY_NR, " +                    // key
        "  C.LOGO, " +                          // iconId
+
      "  C.SHORT_NAME || ': ' || C.NAME, " +  // text
        "  C.TOOLTIP, " +                        // tooltip
+
      "  C.LOGO, " +                          // iconId
        "  'F0F0F0', " +                        // background
+
      "  C.TOOLTIP, " +                        // tooltip
        "  '404040', " +                        // foreground
+
      "  'F0F0F0', " +                        // background
        "  '" + Font.SERIF + "', " +            // font: not yet clear how this works
+
      "  '404040', " +                        // foreground
        "  1, "+                                // enabled
+
      "  '" + Font.SERIF + "', " +            // font: not yet clear how this works
        "  null, "+                              // parent
+
      "  1, "+                                // enabled
        "  1 "+                                  // active  
+
      "  null, "+                              // parent
        "FROM COMPANY C " +
+
      "  1 "+                                  // active  
        "WHERE 1=1 " +
+
      "FROM COMPANY C " +
        "AND (C.TYPE_UID =&nbsp;:master OR&nbsp;:master IS NULL) " +
+
      "WHERE 1=1 " +
        "    AND C.COMPANY_NR =&nbsp;:key  " +
+
      "AND (C.TYPE_UID =&nbsp;:master OR&nbsp;:master IS NULL) " +
        "    AND ((UPPER(C.NAME) LIKE '%'|| UPPER(:text)||'%') OR (UPPER(C.SHORT_NAME) LIKE '%'||UPPER(:text)||'%')) " +
+
      "    AND C.COMPANY_NR =&nbsp;:key  " +
        "      ";
+
      "    AND ((UPPER(C.NAME) LIKE '%'|| UPPER(:text)||'%') OR (UPPER(C.SHORT_NAME) LIKE '%'||UPPER(:text)||'%')) " +
  }</pre>  
+
      "      ";
 +
}
 +
</source>  
 
In principle a LookupService can be used for SmartFields, TreeBoxFields and ListBoxFields, however not all attributes are used for all fields (and behaviour between Swing and SWT differs for some of them).  
 
In principle a LookupService can be used for SmartFields, TreeBoxFields and ListBoxFields, however not all attributes are used for all fields (and behaviour between Swing and SWT differs for some of them).  
  

Revision as of 10:35, 8 October 2013

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

The Scout documentation has been moved to https://eclipsescout.github.io/. to propose multiple choices (hierarchical).

Description

Note.png
TODO
Add a description



Screenshot

RAP SWT Swing Swing Rayo
Scout 3.8 TreeBox RAP.png Scout 3.8 TreeBox SWT.png Scout 3.8 TreeBox Swing.png Scout 3.8 TreeBox 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.


getConfiguredLookupCall()

The fields of a TreeBox are populated through the use of a LookupCall:

@Override
protected Class<? extends LookupCall> getConfiguredLookupCall() {
  return MyLookupCall.class;
}

That lookup call in turn uses a lookup service:

public class MyLookupCall extends LookupCall{
  private static final long serialVersionUID = 1L;
  @Override
  protected Class<? extends ILookupService> getConfiguredService() {
    return IMyLookupService.class;
  }
}

The lookup service on the server uses an SQL query to return the content for those fields (see below).


getConfiguredAutoExpandAll()

By default the TreeBoxField shows a collapsed tree if not all elements of the tree can be shown in the field at the current size. This can be changed to always expand the tree by setting the AutoExpandAll property to true

@Override
protected boolean getConfiguredAutoExpandAll() {
  return true;
}

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.


execFilterLookupResult()

By default the entries in the list and tree are sorted by the text attribute (i.e. the visible text), not the key. This can be changed by defining a filtering function:

@Override
protected void execFilterLookupResult(LookupCall call, List&lt;LookupRow&gt; result) throws ProcessingException {
  java.util.Collections.sort(result, new MyLookupRowComparator());
}

This filter function requires a comparator class which implements Comparator<LookupRow>:

public class MyRowComparator implements Comparator&lt;LookupRow&gt; {
  @Override
  public int compare(LookupRow object1, LookupRow object2) {
    if (object1 == null) return -1;
    if (object2 == null) return 1;
    // sort on 'text' (default behaviour)
    //return object1.getText().compareTo(object2.getText());
 
    // sort on 'key'
    return ((Long) object1.getKey()).compareTo((Long) object2.getKey());
  }
}


LookupService

Warning2.png
Review needed
This section needs a review: There are 2 pages that mentioned LookupService: In my opinion the content of this section needs to be merged to one of these 2 pages (probably the second one).


The MiniCRM tutorial describes how to use a lookup service to populate SmartFields (e.g. dropdown boxes).

Populating TreeBoxFields and ListBoxFields require more fields to be returned.

The LookupService has a getConfiguredSqlSelect() method which returns a number of fields. The first two attributes (key and text) are compulsory, any of the other attributes are optional (and can be skipped by returning null or an empty string; if all remaining fields would be skipped, the query can just end early). The attributes are returned in the following order:

@Override
protected String getConfiguredSqlSelect() {
  return "" +
      "SELECT " +
      "   C.COMPANY_NR, " +                     // key
      "   C.SHORT_NAME || ': ' || C.NAME, " +   // text
      "   C.LOGO, " +                           // iconId
      "   C.TOOLTIP, " +                        // tooltip
      "   'F0F0F0', " +                         // background
      "   '404040', " +                         // foreground
      "   '" + Font.SERIF + "', " +             // font: not yet clear how this works
      "   1, "+                                 // enabled
      "   null, "+                              // parent
      "   1 "+                                  // active 
      "FROM COMPANY C " +
      "WHERE 1=1 " +
      "AND (C.TYPE_UID =&nbsp;:master OR&nbsp;:master IS NULL) " +
      "     AND C.COMPANY_NR =&nbsp;:key  " +
      "     AND ((UPPER(C.NAME) LIKE '%'|| UPPER(:text)||'%') OR (UPPER(C.SHORT_NAME) LIKE '%'||UPPER(:text)||'%')) " +
      "      ";
}

In principle a LookupService can be used for SmartFields, TreeBoxFields and ListBoxFields, however not all attributes are used for all fields (and behaviour between Swing and SWT differs for some of them).

The attributes have the following functions:

  • key
    This is the value which will be returned in the array T[]
  • text
    This is the text being displayed
  • iconId
    This is an icon id that needs to be resolvable using an IconProviderService/IconLocator. With TreeBoxFields and ListBoxFields the icon will only be shown for Swing but not SWT
  • tooltip
    The tooltip text will be shown when hovering over the entry with the mouse.
  • background
    The background colour used for this entry ("RRGGBB" in hex)
  • foreground
    The foreground colour used for this entry ("RRGGBB" in hex)
  • font
    The font to be used (TODO: needs more information on how to use this)
  • enabled
    TODO: needs more information on the difference between enabled and active
  • parent
    A reference to the key attribute of another entry and is used to build the hierarchy of elements
  • active
    TODO: needs more information on the difference between enabled and active
Note.png
TODO
Update description for font, enabled and active


See Also


Back to the top