Search in sources :

Example 26 with Order

use of org.eclipse.scout.rt.platform.Order 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

Order (org.eclipse.scout.rt.platform.Order)26 ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)20 IDataModelEntity (org.eclipse.scout.rt.shared.data.model.IDataModelEntity)4 EntityNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode)3 LinkedList (java.util.LinkedList)2 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)2 EitherOrNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EitherOrNode)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 BookmarkServiceEvent (org.eclipse.scout.rt.client.services.common.bookmark.BookmarkServiceEvent)1 BookmarkServiceListener (org.eclipse.scout.rt.client.services.common.bookmark.BookmarkServiceListener)1 IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)1 FormFieldProvisioningContext (org.eclipse.scout.rt.client.services.lookup.FormFieldProvisioningContext)1 ILookupCallProvisioningService (org.eclipse.scout.rt.client.services.lookup.ILookupCallProvisioningService)1 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)1 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)1