Search in sources :

Example 66 with ITreeNode

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

the class SmartFieldTest method testHierarchicalBrowse.

@Test
public void testHierarchicalBrowse() {
    StyleField f = m_styleField;
    f.setBrowseHierarchy(true);
    m_styleField.getUIFacade().openProposalChooserFromUI("*", true, false);
    waitForProposalResult(IProposalChooser.PROP_SEARCH_RESULT);
    // single result
    assertTrue(m_styleField.isProposalChooserRegistered());
    assertEquals("*", m_styleField.getDisplayText());
    // verifies tree is loaded containing a single node
    @SuppressWarnings("unchecked") TreeProposalChooser<Long> treeProposalChooser = (TreeProposalChooser<Long>) f.getProposalChooser();
    ITree tree = treeProposalChooser.getModel();
    ITreeNode rootNode = tree.getRootNode();
    assertEquals(5, rootNode.getChildNodes().size());
    assertEquals("Red", rootNode.getChildNode(0).getCell().getText());
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) StyleField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField) Test(org.junit.Test)

Example 67 with ITreeNode

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

the class TreeBoxTest method testAutoSelectBehaviorExtended.

/**
 * Select a parent node in a tree box with auto check child nodes activated, and check whether this node and all child
 * nodes are selected (extended test). {@link AbstractTreeBox#getConfiguredAutoCheckChildNodes} returns true on the
 * {@link AutoSelectTreeBox}. Bug 368107 - Check child nodes when parent node is checked
 */
@Test
public void testAutoSelectBehaviorExtended() throws Exception {
    AutoSelectTreeBox treeBox = new AutoSelectTreeBox();
    treeBox.initField();
    ITree tree = treeBox.getTree();
    // C-B
    ITreeNode node = tree.findNode(9L);
    assertNotNull(node);
    tree.setNodeChecked(node, true);
    Set<Long> valueSet = new HashSet<Long>(treeBox.getValue());
    // parent node and 4 childs nodes selected
    assertEquals(5, valueSet.size());
    // and the selected ones are correct
    // C-B
    assertEquals(true, valueSet.contains(9L));
    // C-B-A
    assertEquals(true, valueSet.contains(11L));
    // C-B-B
    assertEquals(true, valueSet.contains(12L));
    // C-B-C
    assertEquals(true, valueSet.contains(13L));
    // C-B-D
    assertEquals(true, valueSet.contains(14L));
    // deselected node C-B-B
    // C-B-B
    node = tree.findNode(12L);
    assertNotNull(node);
    tree.setNodeChecked(node, false);
    valueSet = new HashSet<Long>(treeBox.getValue());
    // parent node and all minus one childs nodes selected
    assertEquals(4, valueSet.size());
    // and the selected ones are correct
    // C-B
    assertEquals(true, valueSet.contains(9L));
    // C-B-A
    assertEquals(true, valueSet.contains(11L));
    // C-B-C
    assertEquals(true, valueSet.contains(13L));
    // C-B-D
    assertEquals(true, valueSet.contains(14L));
    // deselected C-C node
    // C-B
    node = tree.findNode(9L);
    assertNotNull(node);
    tree.setNodeChecked(node, false);
    // no nodes selected
    Set<Long> values = treeBox.getValue();
    assertTrue(CollectionUtility.isEmpty(values));
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 68 with ITreeNode

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

the class MediumMemoryPolicy method afterOutlineSelectionChanged.

@Override
public void afterOutlineSelectionChanged(final IDesktop desktop) {
    try {
        final AtomicLong nodeCount = new AtomicLong();
        if (desktop.getOutline() != null && desktop.getOutline().getSelectedNode() != null) {
            final HashSet<IPage> preservationSet = new HashSet<IPage>();
            IPage<?> p = (IPage) desktop.getOutline().getSelectedNode();
            while (p != null) {
                // the tree in the selection is not the topic
                // of the analysis whether we should free up the memory
                // so we calculate only the other ones.
                preservationSet.add(p);
                p = p.getParentPage();
            }
            ITreeVisitor v = new ITreeVisitor() {

                @Override
                public boolean visit(ITreeNode node) {
                    IPage<?> page = (IPage) node;
                    if (preservationSet.contains(page)) {
                    // nop
                    } else if (page.getParentPage() == null) {
                    // nop, InvisibleRootPage
                    } else if (page.isChildrenLoaded()) {
                        nodeCount.getAndAdd(page.getChildNodeCount());
                    }
                    return true;
                }
            };
            for (IOutline outline : desktop.getAvailableOutlines()) {
                outline.visitNode(outline.getRootNode(), v);
            }
        }
        long memTotal = Runtime.getRuntime().totalMemory();
        long memUsed = (memTotal - Runtime.getRuntime().freeMemory());
        long memMax = Runtime.getRuntime().maxMemory();
        if (memUsed > memMax * 80L / 100L || nodeCount.get() > 10000) {
            m_release = true;
        }
    } catch (Exception e) {
        LOG.error("Unexpected Exception", e);
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) HashSet(java.util.HashSet) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 69 with ITreeNode

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

the class AbstractPageWithNodesTest method testPageNodeText.

@Test
public void testPageNodeText() throws Exception {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    desktop.setAvailableOutlines(CollectionUtility.arrayList(new PageWithNodeOutline()));
    desktop.setOutline(PageWithNodeOutline.class);
    desktop.activateFirstPage();
    ITreeNode parentPageNode = desktop.getOutline().getSelectedNode();
    assertEquals("Parent page", parentPageNode.getCell().getText());
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 70 with ITreeNode

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

the class OutlineTreeContextMenuNestedPageWithTablesTest method assertRowMenusExistOnTablePageNode.

private static void assertRowMenusExistOnTablePageNode(IOutline outline) throws Exception {
    outline.selectFirstNode();
    IPageWithTable<?> activePage = (IPageWithTable<?>) outline.getActivePage();
    List<IMenu> requiredMenus = resolveMenusOfPageWithTable(activePage, PageWithTableRowMenu.class);
    outline.selectNextChildNode();
    SubPageWithTable subTablePage = outline.findPage(SubPageWithTable.class);
    requiredMenus.addAll(resolveMenusOfPageWithTable(subTablePage, SubPageWithTableEmptySpaceMenu.class));
    for (IMenu iMenu : requiredMenus) {
        System.out.println(" r- " + iMenu);
    }
    ITreeNode selectedNode = outline.getSelectedNode();
    List<IMenu> menus = selectedNode.getTree().getMenus();
    for (IMenu iMenu : menus) {
        System.out.println(" m- " + iMenu);
    }
    assertTrue(containsAllMenus(menus, requiredMenus));
    // + 1 stands for menu separator
    assertEquals(sizeMenuListWithoutSeparators(menus), requiredMenus.size());
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) SubPageWithTableEmptySpaceMenu(org.eclipse.scout.rt.client.ui.desktop.outline.pages.OutlineTreeContextMenuNestedPageWithTablesTest.SubPageWithTable.Table.SubPageWithTableEmptySpaceMenu)

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