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());
}
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));
}
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);
}
}
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());
}
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());
}
Aggregations