Package org.eclipse.nebula.widgets.nattable.columnCategories

Examples of org.eclipse.nebula.widgets.nattable.columnCategories.Node


    @Test
    public void shouldReturnLabelsFromIndexesFromTheColumnEntry()
            throws Exception {
        assertEquals("Index2",
                labelProvider.getText(new Node("2", Type.COLUMN)));
        assertEquals("11", labelProvider.getText(new Node("11", Type.COLUMN)));
    }
View Full Code Here


                new TableColumn(5, "f") };

        ColumnCategoriesModel model = ColumnCategoriesModelAssembler
                .setupColumnCategories(columnProps);

        Node rootCategory = model.getRootCategory().getChildren().get(0);
        Assert.assertEquals(5, rootCategory.getNumberOfChildren());

        Node c1 = rootCategory.getChildren().get(2);
        Assert.assertEquals("C1", c1.getData());
        Assert.assertEquals(2, c1.getChildren().size());

        Node c2 = rootCategory.getChildren().get(3);
        Assert.assertEquals("C2", c2.getData());
        Assert.assertEquals(1, c2.getChildren().size());

        Node c3 = rootCategory.getChildren().get(4);
        Assert.assertEquals("C3", c3.getData());
        Assert.assertEquals(1, c3.getChildren().size());
    }
View Full Code Here

                new TableColumn(4, "e"), new TableColumn(5, "f") };

        ColumnCategoriesModel model = ColumnCategoriesModelAssembler
                .setupColumnCategories(columnProps);

        Node rootCategory = model.getRootCategory().getChildren().get(0);
        Assert.assertEquals(6, rootCategory.getNumberOfChildren());
    }
View Full Code Here

    public static ColumnCategoriesModel setupColumnCategories(
            TableColumn[] columnProps) {

        ColumnCategoriesModel model = new ColumnCategoriesModel();
        Node rootNode = model.addRootCategory("Root");
        Node all = model.addCategory(rootNode, "All");

        Map<String, List<Integer>> columnCategoryToColumnIndexesMap = new LinkedHashMap<String, List<Integer>>();
        List<Integer> indexesNotCategorized = new LinkedList<Integer>();

        for (TableColumn tableColumn : columnProps) {
            indexesNotCategorized.add(tableColumn.index);
        }

        for (int columnIndex = 0; columnIndex < columnProps.length; columnIndex++) {
            String categoryName = columnProps[columnIndex].categoryName;

            // Column if part of a category
            if (categoryName != null) {
                List<Integer> columnCategoryIndexes = columnCategoryToColumnIndexesMap
                        .get(categoryName);

                // Create an entry in the map for the category
                if (columnCategoryIndexes == null) {
                    columnCategoryIndexes = new LinkedList<Integer>();
                    columnCategoryToColumnIndexesMap.put(categoryName,
                            columnCategoryIndexes);
                }
                // Add to map
                columnCategoryIndexes.add(columnIndex);
                indexesNotCategorized.remove(Integer.valueOf(columnIndex));
            }
        }

        // Transfer the map created to the category model
        all.addChildColumnIndexes(ArrayUtil.asIntArray(indexesNotCategorized));

        for (String columnGroupName : columnCategoryToColumnIndexesMap.keySet()) {
            List<Integer> columnIndexes = columnCategoryToColumnIndexesMap
                    .get(columnGroupName);

            int[] intColumnIndexes = new int[columnIndexes.size()];
            int i = 0;
            for (Integer columnIndex : columnIndexes) {
                intColumnIndexes[i] = columnIndex;
                i++;
            }
            Node node = model.addCategory(all, columnGroupName);
            node.addChildColumnIndexes(ArrayUtil.asIntArray(columnIndexes));
        }

        return model;
    }
View Full Code Here

     *
     * Root --a | -- 0 .. 6 --b | --b1 | | -- 7, 8 | --b2 | -- 9, 10, 11 --c |
     * -- 12 .. 16 -- 17 .. 19
     */
    public ColumnCategoriesModelFixture() {
        Node root = addRootCategory("Root");
        root.addChildColumnIndexes(17, 18, 19);

        // a
        Node A = addCategory(root, CATEGORY_A_LABEL);
        A.addChildColumnIndexes(0, 2, 3, 4, 5, 6);

        // b
        Node B = root.addChildCategory(CATEGORY_B_LABEL);
        B.addChildCategory(CATEGORY_B1_LABEL).addChildColumnIndexes(7, 8);
        B.addChildCategory(CATEGORY_B2_LABEL).addChildColumnIndexes(9, 10, 11);

        // c
        Node C = root.addChildCategory(CATEGORY_C_LABEL);
        addColumnsToCategory(C, 12, 13, 14, 15, 16);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.columnCategories.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.