Search in sources :

Example 36 with ILookupRow

use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow in project scout.rt by eclipse.

the class TreeProposalChooser method execGetSingleMatch.

/**
 * Override this method to change that behaviour of what is a single match. By default a single match is when there is
 * a single enabled LEAF node in the tree
 */
@ConfigOperation
@Order(40)
@Override
protected ILookupRow<LOOKUP_KEY> execGetSingleMatch() {
    final List<ILookupRow<LOOKUP_KEY>> foundLeafs = new ArrayList<>();
    ITreeVisitor v = new ITreeVisitor() {

        @Override
        public boolean visit(ITreeNode node) {
            if (node.isEnabled() && node.isLeaf()) {
                @SuppressWarnings("unchecked") ILookupRow<LOOKUP_KEY> row = (ILookupRow<LOOKUP_KEY>) node.getCell().getValue();
                if (row != null && row.isEnabled()) {
                    foundLeafs.add(row);
                }
            }
            return foundLeafs.size() <= 2;
        }
    };
    m_model.visitVisibleTree(v);
    if (foundLeafs.size() == 1) {
        return foundLeafs.get(0);
    } else {
        return null;
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Aggregations

ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)36 ArrayList (java.util.ArrayList)29 List (java.util.List)24 ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)19 BatchLookupResultCache (org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache)10 ILookupRowFetchedCallback (org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback)10 ClientRunContext (org.eclipse.scout.rt.client.context.ClientRunContext)9 ToStringBuilder (org.eclipse.scout.rt.platform.util.ToStringBuilder)8 Test (org.junit.Test)7 BatchLookupCall (org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)6 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)5 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 ILookupRowProvider (org.eclipse.scout.rt.client.ui.form.fields.smartfield.ILookupRowProvider)4 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)4 LookupRow (org.eclipse.scout.rt.shared.services.lookup.LookupRow)4 HashMap (java.util.HashMap)3 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)3 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)3 Pattern (java.util.regex.Pattern)2 IBatchLookupService (org.eclipse.scout.rt.shared.services.lookup.IBatchLookupService)2