Search in sources :

Example 1 with Node

use of org.eclipse.nebula.widgets.nattable.columnCategories.Node in project nebula.widgets.nattable by eclipse.

the class ColumnCategoriesModelTest method rootMustBeTheFirstNodeSet.

@Test
public void rootMustBeTheFirstNodeSet() throws Exception {
    boolean caughtEx = false;
    try {
        ColumnCategoriesModel model = new ColumnCategoriesModel();
        model.addCategory(new Node("1"), "1a");
    } catch (Exception e) {
        caughtEx = true;
    }
    assertTrue(caughtEx);
}
Also used : ColumnCategoriesModel(org.eclipse.nebula.widgets.nattable.columnCategories.ColumnCategoriesModel) Node(org.eclipse.nebula.widgets.nattable.columnCategories.Node) Test(org.junit.Test)

Example 2 with Node

use of org.eclipse.nebula.widgets.nattable.columnCategories.Node in project nebula.widgets.nattable by eclipse.

the class TreeTest method findElements.

@Test
public void findElements() throws Exception {
    Node found = this.tree.find(this.tree.getRootElement(), "b2");
    Assert.assertNotNull(found);
    Assert.assertEquals("b2", found.getData());
    found = this.tree.find(this.tree.getRootElement(), "b3b");
    Assert.assertNotNull(found);
}
Also used : Node(org.eclipse.nebula.widgets.nattable.columnCategories.Node) Test(org.junit.Test)

Example 3 with Node

use of org.eclipse.nebula.widgets.nattable.columnCategories.Node in project nebula.widgets.nattable by eclipse.

the class TreeTest method setup.

@Before
public void setup() {
    this.tree = new Tree();
    Node root = newNode("R");
    this.tree.setRootElement(root);
    root.addChild(newNode("a"));
    Node b = newNode("b");
    root.addChild(b);
    b.addChild(newNode("b1"));
    b.addChild(newNode("b2"));
    Node b3 = newNode("b3");
    b.addChild(b3);
    b3.addChild(newNode("b3a"));
    b3.addChild(newNode("b3b"));
    root.addChild(newNode("c"));
}
Also used : Node(org.eclipse.nebula.widgets.nattable.columnCategories.Node) Tree(org.eclipse.nebula.widgets.nattable.columnCategories.Tree) Before(org.junit.Before)

Example 4 with Node

use of org.eclipse.nebula.widgets.nattable.columnCategories.Node in project nebula.widgets.nattable by eclipse.

the class TreeTest method remove.

@Test
public void remove() throws Exception {
    Node root = this.tree.getRootElement();
    assertEquals(3, root.getNumberOfChildren());
    assertTrue(this.tree.remove(root.getChildren().get(1).getData()));
    assertEquals(2, root.getNumberOfChildren());
    assertFalse(this.tree.remove("Non Existent Node"));
}
Also used : Node(org.eclipse.nebula.widgets.nattable.columnCategories.Node) Test(org.junit.Test)

Example 5 with Node

use of org.eclipse.nebula.widgets.nattable.columnCategories.Node in project nebula.widgets.nattable by eclipse.

the class ColumnCategoriesDialog method getColumnIndexesFromTreeNodes.

/**
 * @return selected columns index(s) from the tree viewer
 */
private List<Integer> getColumnIndexesFromTreeNodes() {
    Object[] nodes = ((TreeSelection) this.treeViewer.getSelection()).toArray();
    List<Integer> indexes = new ArrayList<Integer>();
    for (Object object : nodes) {
        Node node = (Node) object;
        if (Type.COLUMN == node.getType()) {
            indexes.add(Integer.parseInt(node.getData()));
        }
    }
    return indexes;
}
Also used : TreeSelection(org.eclipse.jface.viewers.TreeSelection) Node(org.eclipse.nebula.widgets.nattable.columnCategories.Node) ArrayList(java.util.ArrayList)

Aggregations

Node (org.eclipse.nebula.widgets.nattable.columnCategories.Node)11 Test (org.junit.Test)7 ColumnCategoriesModel (org.eclipse.nebula.widgets.nattable.columnCategories.ColumnCategoriesModel)4 TableColumn (org.eclipse.nebula.widgets.nattable.extension.builder.model.TableColumn)3 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 Tree (org.eclipse.nebula.widgets.nattable.columnCategories.Tree)1 ColumnEntry (org.eclipse.nebula.widgets.nattable.columnChooser.ColumnEntry)1 Before (org.junit.Before)1