Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 361261

Summary: Hierarchical SmartField only does prefix match with typed text
Product: z_Archived Reporter: Michael Schaufelberger <bsi.msa>
Component: ScoutAssignee: Project Inbox <scout.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan.motsch, zimmermann
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Michael Schaufelberger CLA 2011-10-18 10:29:09 EDT
When typing text ("a") in a SmartField that has getConfiguredBrowseHierarchy() == true the result set only contains rows matching to "a*".

I did not find a possibility to influence the matching criteria. I would like to find substrings, so that rows matching "*a*" are displayed in the drop-down.

How can I do that?
Comment 1 Ivan Motsch CLA 2011-10-18 10:52:11 EDT
I checked you request and in fact this possibility is not (yet) in place.

There are normally two ways to solve that in scout, either adding a property or exec method or letting specific models being subclassed.

1) there could be a new exec method on AbstractSmartField
boolean execAcceptTreeNodeInBrowseFilter(Pattern pattern, ITreeNode node, int level)
that lets you override the decision to accept nodes in the tree when filtering with text.
Pros: Easy, simply an override
Cons: another property on smartfield that is not very "common", limited decision space.

2) Since the smartfield lets you override createProposalForm() you could create an subclass of SmartTreeForm that adds that behaviour.
You could create your own custom smartfield template as follows

public abstract class AbstractAbcSmartField extends AbstractSmartField{
  @Override
  protected ISmartFieldProposalForm createProposalForm() throws ProcessingException {
    if (isBrowseHierarchy()) {
      ISmartFieldProposalForm form = new SmartAbcTreeForm(this);
      form.setAutoAddRemoveOnDesktop(false);
      return form;
    }
    return super....;
  }
  
}

public class SmartAbcTreeForm extends SmartTreeForm{

  @Override
  execFilterTreeNode(...)

  @Override
  getSingleMatch
}

Pros: Solution is at the right place, extensible
Cons: More todo for your to create that template field.


I would prefer solution 2) since it could be easily done and would have no further side effects and has code at the right place with sufficient customization potential.
Comment 2 Michael Schaufelberger CLA 2011-10-18 10:55:49 EDT
I prefer solution 2 as well, because it only has to do with hierarchical smart fields (=> SmartTreeForm)

Thank you.
Comment 3 Ivan Motsch CLA 2011-10-18 11:20:52 EDT
Ok, so i implemented the solution.

Added (exposed) the following methods:

SmartTableForm.execGetSingleMatch()

SmartTreeForm.execCreatePatternForTreeFilter(String filterText)
SmartTreeForm.execAcceptNodeByTreeFilter(Pattern filterPattern, ITreeNode node, int level)
SmartTreeForm.execGetSingleMatch()
Comment 4 Michael Schaufelberger CLA 2011-10-19 07:55:26 EDT
It works (tested on 2011-Jun).
Comment 5 Matthias Zimmermann CLA 2012-02-29 07:08:33 EST
shipped with eclipse scout 3.7.2 (indigo sr2)