Search in sources :

Example 31 with ITree

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

the class SmartFieldTest method testThrowingLookupCall.

@Test
public void testThrowingLookupCall() {
    StyleField f = m_styleField;
    f.setBrowseHierarchy(true);
    ((StyleLookupCall) f.getLookupCall()).allowLookup(false);
    m_styleField.getUIFacade().openProposalChooserFromUI("Red", false, false);
    waitForProposalResult(IProposalChooser.PROP_STATUS);
    @SuppressWarnings("unchecked") TreeProposalChooser<Long> treeProposalChooser = ((TreeProposalChooser<Long>) f.getProposalChooser());
    ITree tree = treeProposalChooser.getModel();
    ITreeNode rootNode = tree.getRootNode();
    assertEquals(0, rootNode.getChildNodes().size());
    assertEquals(IStatus.ERROR, treeProposalChooser.getStatus().getSeverity());
}
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 32 with ITree

use of org.eclipse.scout.rt.client.ui.basic.tree.ITree 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 33 with ITree

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

the class IncrementalTreeBuilderTest method testCreateParentMap_EmptyTree.

@Test
public void testCreateParentMap_EmptyTree() {
    ITree tree = createTestTree();
    Map<Long, ILookupRow<Long>> parentMap = new IncrementalTreeBuilder<Long>(null).createParentMap(tree);
    assertTrue(parentMap.isEmpty());
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) Test(org.junit.Test)

Example 34 with ITree

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

the class IncrementalTreeBuilderTest method testCreatePaths_Empty.

@Test
public void testCreatePaths_Empty() {
    ITree tree = createTestTree();
    IncrementalTreeBuilder<Long> builder = new IncrementalTreeBuilder<Long>(null);
    ArrayList<ILookupRow<Long>> rows = new ArrayList<>();
    List<List<ILookupRow<Long>>> paths = builder.createPaths(rows, tree);
    assertTrue(paths.isEmpty());
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) Test(org.junit.Test)

Example 35 with ITree

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

Aggregations

ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)54 Test (org.junit.Test)40 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)30 ArrayList (java.util.ArrayList)17 TreeNode (org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeNode)13 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)11 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)6 JSONObject (org.json.JSONObject)5 List (java.util.List)4 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)4 StyleField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 PropertyChangeListener (java.beans.PropertyChangeListener)3 HashSet (java.util.HashSet)3 ITreeNodeFilter (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNodeFilter)3 TreeAdapter (org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter)3 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)3 WeakReference (java.lang.ref.WeakReference)2 IAction (org.eclipse.scout.rt.client.ui.action.IAction)2 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)2