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

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


        return natTable;
    }

    private void configureColumnCategoriesInChooser() {
        DefaultBodyLayerStack bodyLayer = this.gridLayer.getBodyLayerStack();
        ColumnCategoriesModel model = new ColumnCategoriesModelFixture();

        bodyLayer
        .registerCommandHandler(new ChooseColumnsFromCategoriesCommandHandler(
                bodyLayer.getColumnHideShowLayer(), this.gridLayer
                .getColumnHeaderLayerStack()
View Full Code Here


    @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);
    }
View Full Code Here

    @Test
    public void rootCanOnlyBeSetOnce() throws Exception {
        boolean caughtEx = false;
        try {
            ColumnCategoriesModel model = new ColumnCategoriesModel();
            model.addRootCategory("Root");
            model.addRootCategory("Root");
        } catch (Exception e) {
            caughtEx = true;
            assertEquals(
                    "Root has been set already. Clear using (clear()) to reset.",
                    e.getMessage());
        }
        assertTrue(caughtEx);

        model.clear();
        model.addRootCategory("Root");
    }
View Full Code Here

                new TableColumn(2, "c").setCategory("C1"),
                new TableColumn(3, "d").setCategory("C2"),
                new TableColumn(4, "e").setCategory("C3"),
                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());
View Full Code Here

        TableColumn[] columnProps = new TableColumn[] {
                new TableColumn(0, "a"), new TableColumn(1, "b"),
                new TableColumn(2, "c"), new TableColumn(3, "d"),
                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 class ColumnCategoriesModelAssembler {

    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

TOP

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

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.