Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Problem with adding FilterRowHeaderComposite to CompositeLayer
Problem with adding FilterRowHeaderComposite to CompositeLayer [message #1693807] Tue, 28 April 2015 12:57 Go to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi,

When I add the FilterRowHeaderComposite to CompositeLayer , the filter text is being disabled on runtime

Test code is below
 @Override
    public Control createExampleControl(Composite parent) {
        // create a new ConfigRegistry which will be needed for GlazedLists
        // handling
        ConfigRegistry configRegistry = new ConfigRegistry();

        // property names of the Person class
        String[] propertyNames = { "firstName", "lastName", "gender",
                "married", "birthday", "address.street", "address.housenumber",
                "address.postalCode", "address.city" };

        // mapping from property to label, needed for column header labels
        Map propertyToLabelMap = new HashMap();
        propertyToLabelMap.put("firstName", "Firstname");
        propertyToLabelMap.put("lastName", "Lastname");
        propertyToLabelMap.put("gender", "Gender");
        propertyToLabelMap.put("married", "Married");
        propertyToLabelMap.put("birthday", "Birthday");
        propertyToLabelMap.put("address.street", "Street");
        propertyToLabelMap.put("address.housenumber", "Housenumber");
        propertyToLabelMap.put("address.postalCode", "Postal Code");
        propertyToLabelMap.put("address.city", "City");

        IColumnPropertyAccessor columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor(
                propertyNames);

        BodyLayerStack bodyLayerStack = new BodyLayerStack(
                PersonService.getPersonsWithAddress(50), columnPropertyAccessor);

        // build the column header layer
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
                propertyNames, propertyToLabelMap);
        DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
                columnHeaderDataProvider);
        ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer,
                bodyLayerStack, bodyLayerStack.getSelectionLayer());

        // Note: The column header layer is wrapped in a filter row composite.
        // This plugs in the filter row functionality
        FilterRowHeaderComposite filterRowHeaderLayer = new FilterRowHeaderComposite(
                new DefaultGlazedListsFilterStrategy(
                        bodyLayerStack.getFilterList(), columnPropertyAccessor,
                        configRegistry), columnHeaderLayer,
                columnHeaderDataLayer.getDataProvider(), configRegistry);

       
        
        CompositeLayer compositeLayer = new CompositeLayer(1,2);
        compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, filterRowHeaderLayer, 0, 0);
        
        compositeLayer.setChildLayer(GridRegion.BODY, bodyLayerStack, 0, 1);
        // turn the auto configuration off as we want to add our header menu
        // configuration
        NatTable natTable = new NatTable(parent, compositeLayer, false);

        // as the autoconfiguration of the NatTable is turned off, we have to
        // add the
        // DefaultNatTableStyleConfiguration and the ConfigRegistry manually
        natTable.setConfigRegistry(configRegistry);
        natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
        // add filter row configuration
        natTable.addConfiguration(new FilterRowConfiguration());



        natTable.configure();

        natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(
                natTable));

        return natTable;


What is the problem?

Can be used FilterRowHeaderComposite in CompositeLayer?
Re: Problem with adding FilterRowHeaderComposite to CompositeLayer [message #1693813 is a reply to message #1693807] Tue, 28 April 2015 13:15 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
Can be used FilterRowHeaderComposite in CompositeLayer?


Yes, but you need to configure it correctly

Quote:
What is the problem?


You forgot to make the filter row editable.

natTable.addConfiguration(new AbstractRegistryConfiguration() {

            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {
                configRegistry.registerConfigAttribute(
                        EditConfigAttributes.CELL_EDITABLE_RULE,
                        IEditableRule.ALWAYS_EDITABLE,
                        DisplayMode.NORMAL,
                        GridRegion.FILTER_ROW
            );

}

[Updated on: Tue, 28 April 2015 13:16]

Report message to a moderator

Re: Problem with adding FilterRowHeaderComposite to CompositeLayer [message #1693814 is a reply to message #1693813] Tue, 28 April 2015 13:25 Go to previous messageGo to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Thaknk You for your responce I added row editable. But result is same. The code is below. (I think the problem is setChildLayer of CompositeLayer.)
 public Control createExampleControl(Composite parent) {
        // create a new ConfigRegistry which will be needed for GlazedLists
        // handling
        ConfigRegistry configRegistry = new ConfigRegistry();

        // property names of the Person class
        String[] propertyNames = { "firstName", "lastName", "gender",
                "married", "birthday", "address.street", "address.housenumber",
                "address.postalCode", "address.city" };

        // mapping from property to label, needed for column header labels
        Map propertyToLabelMap = new HashMap();
        propertyToLabelMap.put("firstName", "Firstname");
        propertyToLabelMap.put("lastName", "Lastname");
        propertyToLabelMap.put("gender", "Gender");
        propertyToLabelMap.put("married", "Married");
        propertyToLabelMap.put("birthday", "Birthday");
        propertyToLabelMap.put("address.street", "Street");
        propertyToLabelMap.put("address.housenumber", "Housenumber");
        propertyToLabelMap.put("address.postalCode", "Postal Code");
        propertyToLabelMap.put("address.city", "City");

        IColumnPropertyAccessor columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor(
                propertyNames);

        BodyLayerStack bodyLayerStack = new BodyLayerStack(
                PersonService.getPersonsWithAddress(50), columnPropertyAccessor);

        // build the column header layer
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
                propertyNames, propertyToLabelMap);
        DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
                columnHeaderDataProvider);
        ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer,
                bodyLayerStack, bodyLayerStack.getSelectionLayer());

        // Note: The column header layer is wrapped in a filter row composite.
        // This plugs in the filter row functionality
        FilterRowHeaderComposite filterRowHeaderLayer = new FilterRowHeaderComposite(
                new DefaultGlazedListsFilterStrategy(
                        bodyLayerStack.getFilterList(), columnPropertyAccessor,
                        configRegistry), columnHeaderLayer,
                columnHeaderDataLayer.getDataProvider(), configRegistry);

       
        
        CompositeLayer compositeLayer = new CompositeLayer(1,2);
        compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, filterRowHeaderLayer, 0, 0);
        
        
        compositeLayer.setChildLayer(GridRegion.BODY, bodyLayerStack, 0, 1);
        // turn the auto configuration off as we want to add our header menu
        // configuration
        NatTable natTable = new NatTable(parent, compositeLayer, false);

        // as the autoconfiguration of the NatTable is turned off, we have to
        // add the
        // DefaultNatTableStyleConfiguration and the ConfigRegistry manually
        natTable.setConfigRegistry(configRegistry);
        natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
        // add filter row configuration


        natTable.addConfiguration(new AbstractRegistryConfiguration() {

            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {
                configRegistry.registerConfigAttribute(
                        EditConfigAttributes.CELL_EDITABLE_RULE,
                        IEditableRule.ALWAYS_EDITABLE,
                        DisplayMode.NORMAL,
                        GridRegion.FILTER_ROW
            );
            

            }
        });
        natTable.configure();

        natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(
                natTable));

        return natTable;
    }
Re: Problem with adding FilterRowHeaderComposite to CompositeLayer [message #1693815 is a reply to message #1693814] Tue, 28 April 2015 13:39 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Since your NatTable is not editable at all, the edit bindings are missing too.

There is an example for adding the filter row to a composite layer in the NatTable examples application. It should be under Tutorial Examples -> Integration

IIRC this should be sufficient:
// add edit configurations
compositeLayer.addConfiguration(new DefaultEditConfiguration());
compositeLayer.addConfiguration(new DefaultEditBindings());


https://github.com/eclipse/nebula.widgets.nattable/blob/master/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_801_VerticalCompositionWithFeaturesExample.java
Previous Topic:Dynamic conditional highlighting
Next Topic:Error :- Nattable
Goto Forum:
  


Current Time: Thu Apr 18 06:00:47 GMT 2024

Powered by FUDForum. Page generated in 0.02332 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top