Search in sources :

Example 36 with ITreeNode

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

the class AbstractPageWithNodesTest method testRenameChildPages.

@Test
public void testRenameChildPages() throws Exception {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    desktop.setAvailableOutlines(CollectionUtility.arrayList(new PageWithNodeOutline()));
    desktop.setOutline(PageWithNodeOutline.class);
    desktop.activateFirstPage();
    AbstractPageWithNodes parentPage = (AbstractPageWithNodes) desktop.getOutline().getActivePage();
    ITreeNode parentPageNode = desktop.getOutline().getSelectedNode();
    ITreeNode childPageNode = parentPageNode.getChildNode(0);
    assertEquals("Parent page", parentPageNode.getCell().getText());
    assertEquals("Child page", childPageNode.getCell().getText());
    // this is the childPages name in the table
    assertEquals("Child page", parentPage.getTable().getRow(0).getCell(0).getText());
    // update the child node's cell text
    childPageNode.getCellForUpdate().setText("my new long text");
    assertEquals("my new long text", childPageNode.getCell().getText());
    // text must also be changed in the parent's table
    assertEquals("my new long text", parentPage.getTable().getRow(0).getCell(0).getText());
    // rename again
    childPageNode.getCellForUpdate().setText("Child page");
    assertEquals("Parent page", parentPageNode.getCell().getText());
    assertEquals("Child page", childPageNode.getCell().getText());
    assertEquals("Child page", parentPage.getTable().getRow(0).getCell(0).getText());
    // rename on table, must be reflected to the tree
    parentPage.getTable().getRow(0).getCellForUpdate(0).setText("my new long text");
    assertEquals("my new long text", parentPage.getTable().getRow(0).getCell(0).getText());
    assertEquals("Parent page", parentPageNode.getCell().getText());
    assertEquals("my new long text", childPageNode.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 37 with ITreeNode

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

the class OutlineTreeContextMenuTest method assertRowMenusExistOnTablePageNode.

private static void assertRowMenusExistOnTablePageNode(IOutline outline) throws Exception {
    outline.selectFirstNode();
    List<IMenu> requiredMenus = resolveMenusOfActiveTablePage(outline, PageWithTableRowMenu.class);
    outline.selectNextChildNode();
    ITreeNode selectedNode = outline.getSelectedNode();
    List<IMenu> menus = selectedNode.getTree().getMenus();
    assertTrue(OutlineTreeContextMenuNestedPageWithTablesTest.containsAllMenus(menus, requiredMenus));
    assertEquals(OutlineTreeContextMenuNestedPageWithTablesTest.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)

Example 38 with ITreeNode

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

the class ComposerFieldTest method testExportEitherOrNode.

@Test
public void testExportEitherOrNode() throws Exception {
    // setup field
    ITreeNode parentNode = m_composerField.getTree().getRootNode();
    EitherOrNode eitherNode = m_composerField.addEitherNode(parentNode, false);
    m_composerField.addAdditionalOrNode(eitherNode, false);
    // export
    m_composerField.exportFormFieldData(m_fieldData);
    // verify export
    assertEquals(2, m_fieldData.getRootCount());
    // 
    TreeNodeData eitherNodeData = m_fieldData.getRoots().get(0);
    assertTrue(eitherNodeData instanceof ComposerEitherOrNodeData);
    assertTrue(((ComposerEitherOrNodeData) eitherNodeData).isBeginOfEitherOr());
    assertFalse(((ComposerEitherOrNodeData) eitherNodeData).isNegative());
    // 
    TreeNodeData orNodeData = m_fieldData.getRoots().get(1);
    assertTrue(orNodeData instanceof ComposerEitherOrNodeData);
    assertFalse(((ComposerEitherOrNodeData) orNodeData).isBeginOfEitherOr());
    assertFalse(((ComposerEitherOrNodeData) orNodeData).isNegative());
}
Also used : EitherOrNode(org.eclipse.scout.rt.client.ui.form.fields.composer.node.EitherOrNode) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) TreeNodeData(org.eclipse.scout.rt.shared.data.form.fields.treefield.TreeNodeData) ComposerEitherOrNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerEitherOrNodeData) Test(org.junit.Test)

Example 39 with ITreeNode

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

the class SmartFieldTest method testHierarchicalOpenProposal.

@Test
public void testHierarchicalOpenProposal() {
    StyleField f = m_styleField;
    f.setBrowseHierarchy(true);
    f.setValue(10L);
    f.getUIFacade().openProposalChooserFromUI("Red", false, true);
    waitForProposalResult(IProposalChooser.PROP_SEARCH_RESULT);
    // single result
    assertTrue(m_styleField.isProposalChooserRegistered());
    assertEquals("Red", 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());
    // current value should be selected
    assertTrue(rootNode.getChildNode(0).isSelectedNode());
}
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 40 with ITreeNode

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

the class TreeBoxTest method testAutoSelectBehavior.

/**
 * 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. {@link AbstractTreeBox#getConfiguredAutoCheckChildNodes} returns true on the
 * {@link AutoSelectTreeBox}. Bug 368107 - Check child nodes when parent node is checked
 */
@Test
public void testAutoSelectBehavior() throws Exception {
    AutoSelectTreeBox treeBox = new AutoSelectTreeBox();
    treeBox.initField();
    ITree tree = treeBox.getTree();
    // A
    ITreeNode node = tree.findNode(1L);
    assertNotNull(node);
    tree.setNodeChecked(node, true);
    Set<Long> valueSet = new HashSet<Long>(treeBox.getValue());
    // parent node and 3 childs nodes selected
    assertEquals(4, valueSet.size());
    // and the selected ones are correct
    // A
    assertEquals(true, valueSet.contains(1L));
    // A-A
    assertEquals(true, valueSet.contains(5L));
    // A-B
    assertEquals(true, valueSet.contains(6L));
    // A-C
    assertEquals(true, valueSet.contains(7L));
}
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)

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