Search in sources :

Example 16 with ITreeVisitor

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor 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

ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)16 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)16 HashSet (java.util.HashSet)4 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)4 ArrayList (java.util.ArrayList)3 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)3 IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)2 Holder (org.eclipse.scout.rt.platform.holders.Holder)2 BookmarkFolder (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1 Order (org.eclipse.scout.rt.platform.Order)1 ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)1 ExceptionHandler (org.eclipse.scout.rt.platform.exception.ExceptionHandler)1 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)1 Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)1