Search in sources :

Example 91 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class TreeProposalChooser method dataFetchedDelegateImpl.

@Override
protected void dataFetchedDelegateImpl(IContentAssistFieldDataFetchResult<LOOKUP_KEY> result, int maxCount) {
    if (result.getException() == null) {
        List<ITreeNode> subTree = getSubtree(result);
        ITreeNode parentNode = getParent(result);
        try {
            if (m_model != null) {
                m_model.setTreeChanging(true);
                updateSubTree(m_model, parentNode, subTree);
                expand();
                selectNode(result);
            }
        } finally {
            if (m_model != null) {
                m_model.setTreeChanging(false);
            }
        }
    }
    updateStatus(result);
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)

Example 92 with ITreeNode

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

Example 93 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class TreeProposalChooser method getSelectedLookupRow.

@Override
@SuppressWarnings("unchecked")
public ILookupRow<LOOKUP_KEY> getSelectedLookupRow() {
    ILookupRow<LOOKUP_KEY> row = null;
    ITreeNode node = null;
    if (m_model.isCheckable()) {
        Collection<ITreeNode> checkedNodes = m_model.getCheckedNodes();
        if (CollectionUtility.hasElements(checkedNodes)) {
            node = CollectionUtility.firstElement(checkedNodes);
        }
    } else {
        node = m_model.getSelectedNode();
    }
    if (node != null && node.isFilterAccepted() && node.isEnabled()) {
        row = (ILookupRow<LOOKUP_KEY>) node.getCell().getValue();
    }
    return row;
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)

Example 94 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class DefaultSearchFilterServiceTest method testComposerField.

@Test
public void testComposerField() {
    MyComposerField composer = new MyComposerField();
    composer.initField();
    runBasicAsserts(composer);
    CarEntity carEntity = composer.new CarEntity();
    ITreeNode carNode = composer.addEntityNode(composer.getTree().getRootNode(), carEntity, true, Collections.emptyList(), new ArrayList<String>());
    composer.addAttributeNode(carNode, carEntity.new ColorAttribute(), DataModelConstants.AGGREGATION_NONE, DataModelAttributeOp.create(DataModelConstants.OPERATOR_EQ), CollectionUtility.arrayList("blue key"), CollectionUtility.arrayList("blue value"));
    m_searchFilterService.applySearchDelegate(composer, m_searchFilter, false);
    StringBuilder result = new StringBuilder();
    new ComposerDisplayTextBuilder().build(composer.getTree().getRootNode(), result, "");
    Assert.assertEquals(result.toString().trim(), m_searchFilter.getDisplayTextsPlain());
}
Also used : CarEntity(org.eclipse.scout.rt.client.services.common.search.DefaultSearchFilterServiceTest.MyComposerField.CarEntity) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ComposerDisplayTextBuilder(org.eclipse.scout.rt.client.ui.form.fields.composer.internal.ComposerDisplayTextBuilder) Test(org.junit.Test)

Example 95 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class JsonOutlineTest method testPageDisposal.

@Test
public void testPageDisposal() {
    TablePage tablePage = new TablePage(1, new TablePage.NodePageWithFormFactory());
    NodePage nodePage = new NodePage();
    List<IPage<?>> pages = new ArrayList<IPage<?>>();
    pages.add(nodePage);
    IOutline outline = new Outline(pages);
    outline.addChildNode(nodePage, tablePage);
    outline.selectNode(tablePage);
    JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, null);
    List<ITreeNode> allNodes = JsonTreeTest.getAllTreeNodes(outline);
    List<String> allNodeIds = new LinkedList<String>();
    for (ITreeNode node : allNodes) {
        String nodeId = JsonTreeTest.getOrCreateNodeId(jsonOutline, node);
        allNodeIds.add(nodeId);
        assertNotNull(nodeId);
        assertNotNull(JsonTreeTest.getNode(jsonOutline, nodeId));
    }
    outline.removeNode(nodePage);
    JsonTestUtility.processBufferedEvents(m_uiSession);
    // Verify nodes get unregistered
    for (ITreeNode node : allNodes) {
        assertNull(JsonTreeTest.optNodeId(jsonOutline, node));
    }
    for (String nodeId : allNodeIds) {
        assertNull(JsonTreeTest.getNode(jsonOutline, nodeId));
    }
    // Verify table adapter gets unregistered
    assertNull(m_uiSession.getJsonAdapter(tablePage.getTable(), m_uiSession.getRootJsonAdapter()));
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) LinkedList(java.util.LinkedList) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) TablePage(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage) NodePage(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage) JsonTreeTest(org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest) Test(org.junit.Test)

Aggregations

ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)95 Test (org.junit.Test)34 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)29 ArrayList (java.util.ArrayList)23 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)16 JSONObject (org.json.JSONObject)14 TreeNode (org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeNode)12 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)11 JSONArray (org.json.JSONArray)10 HashSet (java.util.HashSet)9 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)6 EitherOrNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EitherOrNode)6 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)5 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)5 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)5 LinkedList (java.util.LinkedList)4 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)4 ITreeNodeFilter (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNodeFilter)3 StyleField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField)3