RegisterSearchFAQ UsergroupsLog in
Attributes on extended filters gets deleted

 
Reply to topic    Citra Technologies Forum Index » Report a Bug View previous topic
View next topic

Attributes on extended filters gets deleted
Author Message
cone



Joined: 29 May 2007
Posts: 353

Post Attributes on extended filters gets deleted Reply with quote
Hi,

i have my own numerical filter which holds a formatter.
In the constructor of NumericAutoFilterPanel a new instance of the filter was created without the values of the attributes.
Can you do something like in abstractAutoFilterPanel and copy the attributes for the created object? Or is it neccessary that it was a fresh instance?

for example:
Code:

NumericAutoFilterPanel(NumberFilter numberFilter, String columnName) {
...
  NumberFilter f = (NumberFilter) numberFilter.getClass().newInstance();
  modify(numberFilter, f); // restore attributes


cheers, michael
Thu Jan 12, 2012 5:21 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

We are working on rewriting part of our filter framework, in order to deal with the problem you mention, as well as with some others. I will let you know.
Mon Jan 16, 2012 5:53 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

There were a lot of changes in our filter framework in the last release (4.0.4).
The part that interests you most is that the Filters are now being cloned in the AbstractAutoFilterPanel.initialize method (new one). The method that actually does the cloning is AbstractAutoFilterPanel.cloneFilter. This method creates a new instance of the Filter being cloned and copies over all primitive class variables. You can override this method if you want a different behaviour, and install your custom AutoFilterPanel. In order to install it, you can now do the following:

Create a concrete AutoFilterPanel subclass, making any customizations, setting filters, class variables etc.

Code:
public class MyAutoFilterPanel extends NumericAutoFilterPanel {
    public MyAutoFilterPanel() {
       ....
    }
    protected Filter cloneFilter(Filter from) throws InstantiationException, IllegalAccessException {
       ....
    }
    protected VisualFilter createVisualFilter() {
       NumericalVisualFilter nvf = (NumericalVisualFilter) super.createVisualFilter();
       nvf.setFilter(new MyFilter());
       return nvf;
    }
}


And then assign it to JAutoFilter:

Code:
CustomPopupFilterHeaderModel.getAutoFilter().setDefaultFilterClass(Number.class, MyAutoFilterPanel.class);


Although I doubt that the above code will be necessary, since you can assign the Filter object in the FilterHeaderModel directly.

Code:
FilterHeaderModel.setDefaultFilter(Number.class, new MyFilter());


Creating a VisualFilter subclass and installing it, is now only necessary if you need extra customizations performed, like creating a custom VisualFilter, or the default Filter cloning does not work for you.

I have been working into the new design for over a week now, taking care of backward compatibility. I really hope that it will work for everyone Smile
Thu Jan 19, 2012 9:08 am View user's profile Send private message
Display posts from previous:    

Reply to topic    Citra Technologies Forum Index » Report a Bug All times are GMT - 5 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group