Package org.eclipse.nebula.widgets.nattable.config

Examples of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry


    private SelectionLayer selectionLayer;
    private RowSelectionProvider<RowDataFixture> selectionProvider;

    @Before
    public void setup() {
        IConfigRegistry configRegistry = new ConfigRegistry();

        // 10 rows in fixture
        eventListFixture = GlazedLists
                .eventList(RowDataListFixture.getList(10));
View Full Code Here


    @Override
    public boolean doCommand(TickUpdateCommand command) {
        PositionCoordinate[] selectedPositions = selectionLayer
                .getSelectedCellPositions();
        IConfigRegistry configRegistry = command.getConfigRegistry();

        // Tick update for multiple cells in selection
        if (selectedPositions.length > 1) {
            // Can all cells be updated ?
            if (EditUtils.allCellsEditable(selectionLayer, configRegistry)
View Full Code Here

    private void updateSingleCell(TickUpdateCommand command,
            PositionCoordinate selectedPosition) {
        ILayerCell cell = selectionLayer.getCellByPosition(
                selectedPosition.columnPosition, selectedPosition.rowPosition);

        IConfigRegistry configRegistry = command.getConfigRegistry();

        IEditableRule editableRule = configRegistry.getConfigAttribute(
                EditConfigAttributes.CELL_EDITABLE_RULE, DisplayMode.EDIT, cell
                        .getConfigLabels().getLabels());

        IDataValidator validator = configRegistry.getConfigAttribute(
                EditConfigAttributes.DATA_VALIDATOR, DisplayMode.EDIT, cell
                        .getConfigLabels().getLabels());

        if (editableRule.isEditable(cell, configRegistry)) {
            // process the tick update
View Full Code Here

    }

    @Override
    public boolean doCommand(final ExportCommand command) {
        Shell shell = command.getShell();
        IConfigRegistry configRegistry = command.getConfigRegistry();

        new NatExporter(shell).exportSingleLayer(layer, configRegistry);

        return true;
    }
View Full Code Here

        dataProvider = new ListDataProvider<RowDataFixture>(dataList,
                new ReflectiveColumnPropertyAccessor<RowDataFixture>(
                        RowDataListFixture.getPropertyNames()));

        IConfigRegistry configRegistry = new ConfigRegistry();

        dataLayer = new DataLayer(dataProvider);
        summaryRowLayer = new SummaryRowLayer(dataLayer, configRegistry);
        IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(
                summaryRowLayer);
View Full Code Here

        dataProvider.setDataValue(1, 1, "Cat");
        dataProvider.setDataValue(1, 2, "Rat");

        AutoResizeColumnCommandFixture command = new AutoResizeColumnCommandFixture();
        GCFactory gcFactory = command.getGCFactory();
        IConfigRegistry registry = command.getConfigRegistry();
        GC gc = gcFactory.createGC();
        int col0MaxTextWidth = new TextPainter().getPreferredWidth(
                new CellFixture("Longest Text"), gc, registry);
        int col1MaxTextWidth = new TextPainter().getPreferredWidth(
                new CellFixture("Elephant"), gc, registry);
View Full Code Here

        dataProvider.setDataValue(1, 1, "Cat");
        dataProvider.setDataValue(2, 1, "Rat");

        AutoResizeRowCommandFixture command = new AutoResizeRowCommandFixture();
        GCFactory gcFactory = command.getGCFactory();
        IConfigRegistry registry = command.getConfigRegistry();
        GC gc = gcFactory.createGC();
        int row0MaxTextHeight = new TextPainter().getPreferredHeight(
                new CellFixture(".."), gc, registry);
        int row1MaxTextHeight = new TextPainter().getPreferredHeight(
                new CellFixture("Elephant"), gc, registry);
View Full Code Here

    }

    @Test
    public void retrievedCellShouldBeConvertedUsingTheDisplayConverter()
            throws Exception {
        IConfigRegistry configRegistry = new ConfigRegistry();
        configRegistry.registerConfigAttribute(
                CellConfigAttributes.DISPLAY_CONVERTER,
                PricingTypeBean.getDisplayConverter());

        NatTableFixture natTableFixture = new NatTableFixture(
                new DefaultGridLayer(RowDataListFixture.getList(),
View Full Code Here

    private final ColumnGroupModel columnGroupModel = new ColumnGroupModel();
    private ColumnHeaderLayer columnHeaderLayer;

    @Override
    public Control createExampleControl(Composite parent) {
        IConfigRegistry configRegistry = new ConfigRegistry();

        // Underlying data source
        EventList<RowDataFixture> eventList = GlazedLists
                .eventList(RowDataListFixture.getList(200));
        FilterList<RowDataFixture> filterList = new FilterList<RowDataFixture>(
                eventList);
        String[] propertyNames = RowDataListFixture.getPropertyNames();
        Map<String, String> propertyToLabelMap = RowDataListFixture
                .getPropertyToLabelMap();

        // Body
        IColumnPropertyAccessor<RowDataFixture> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<RowDataFixture>(
                propertyNames);
        ListDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(
                filterList, columnPropertyAccessor);
        DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
        ColumnGroupBodyLayerStack bodyLayer = new ColumnGroupBodyLayerStack(
                bodyDataLayer, columnGroupModel);

        ColumnOverrideLabelAccumulator bodyLabelAccumulator = new ColumnOverrideLabelAccumulator(
                bodyDataLayer);
        bodyDataLayer.setConfigLabelAccumulator(bodyLabelAccumulator);

        bodyLabelAccumulator
                .registerColumnOverrides(
                        RowDataListFixture
                                .getColumnIndexOfProperty(RowDataListFixture.PRICING_TYPE_PROP_NAME),
                        "PRICING_TYPE_PROP_NAME");

        // Column header
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
                propertyNames, propertyToLabelMap);
        DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
                columnHeaderDataProvider);
        columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer,
                bodyLayer, bodyLayer.getSelectionLayer());
        ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(
                columnHeaderLayer, bodyLayer.getSelectionLayer(),
                columnGroupModel);

        columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 1", 1, 2);

        // calculate the height of the column header area dependent if column
        // groups exist or not
        columnGroupHeaderLayer.setCalculateHeight(true);

        // Note: The column header layer is wrapped in a filter row composite.
        // This plugs in the filter row functionality
        final FilterRowHeaderComposite<RowDataFixture> filterRowHeaderLayer = new FilterRowHeaderComposite<RowDataFixture>(
                new DefaultGlazedListsFilterStrategy<RowDataFixture>(
                        filterList, columnPropertyAccessor, configRegistry),
                columnGroupHeaderLayer, columnHeaderDataProvider,
                configRegistry);

        filterRowHeaderLayer.setFilterRowVisible(false);

        ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(
                columnHeaderDataLayer);
        columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);

        // Register labels
        labelAccumulator.registerColumnOverrides(RowDataListFixture
                .getColumnIndexOfProperty(RowDataListFixture.RATING_PROP_NAME),
                "CUSTOM_COMPARATOR_LABEL");

        // Row header

        final DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
                bodyDataProvider);
        DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(
                rowHeaderDataProvider);
        ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer,
                bodyLayer, bodyLayer.getSelectionLayer());

        // Corner

        final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
                columnHeaderDataProvider, rowHeaderDataProvider);
        DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
        ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer,
                filterRowHeaderLayer);

        // Grid
        GridLayer gridLayer = new GridLayer(bodyLayer, filterRowHeaderLayer,
                rowHeaderLayer, cornerLayer);

        NatTable natTable = new NatTable(parent, gridLayer, false);

        // Register create column group command handler

        // Register column chooser
        DisplayColumnChooserCommandHandler columnChooserCommandHandler = new DisplayColumnChooserCommandHandler(
                bodyLayer.getSelectionLayer(),
                bodyLayer.getColumnHideShowLayer(), columnHeaderLayer,
                columnHeaderDataLayer, columnGroupHeaderLayer, columnGroupModel);
        bodyLayer.registerCommandHandler(columnChooserCommandHandler);

        natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
        natTable.addConfiguration(new HeaderMenuConfiguration(natTable) {
            @Override
            protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
                return super.createColumnHeaderMenu(natTable)
                        .withColumnChooserMenuItem();
            }
        });
        natTable.addConfiguration(new AbstractRegistryConfiguration() {
            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {
                configRegistry.registerConfigAttribute(
                        ExportConfigAttributes.EXPORTER,
                        new HSSFExcelExporter());
            }
        });
        natTable.addConfiguration(new FilterRowCustomConfiguration());
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry

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.