RegisterSearchFAQ UsergroupsLog in
Implemention of CustomPopupFilterHeaderModel fails at 4.0.6

 
Reply to topic    Citra Technologies Forum Index » Technical Support - Evaluation View previous topic
View next topic

Implemention of CustomPopupFilterHeaderModel fails at 4.0.6
Author Message
upv



Joined: 06 Feb 2007
Posts: 9

Post Implemention of CustomPopupFilterHeaderModel fails at 4.0.6 Reply with quote
Hello, we defined a class which extends CustomPopupFilterHeaderModel several years ago in order to filter the data of a table. That was working fine since now that we are trying to change from version 3.8.16 to version 4.0.6.

Our CustomPopupFilterHeaderModel has this overriden methods:
public Class inferColumnClass(int c)
protected void preparePopup (int c)
public Collection getFilterValues(int c, Collection list)
public void installFilter( Object filterValue, int c)
public void installFilter(TableFilter tableFilter, Object listValue, Object filterValue, int c)

We only have numeric and string columns. The last method fails only if column is numeric:
Code:
public void installFilter(TableFilter tableFilter, Object listValue, Object filterValue, int c) {
      String CUSTOM_STRING = "(Define filter)";
      if (listValue.equals(CUSTOM_STRING)) {
         super.installFilter(tableFilter, CUSTOM_STRING, CUSTOM_STRING, c);
      ....
      ....
      }
}


The line:
super.installFilter(tableFilter, CUSTOM_STRING, CUSTOM_STRING, c);

is failing and the trace is:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: filter is not a NumberFilter.
   at com.citra.filter.NumericalVisualFilter.setFilter(Unknown Source)
   at com.citra.filter.auto.AbstractAutoFilterPanel.initialize(Unknown Source)
   at com.citra.filter.auto.NumericAutoFilterPanel.initialize(Unknown Source)
   at com.citra.filter.auto.JAutoFilter.prepareAutoFilter(Unknown Source)
   at com.citra.filter.CustomPopupFilterHeaderModel.installFilter(Unknown Source)
   at es.upv.padrino.gui.components.filters.NotasPopupFilterHeaderModel.installFilter(NotasPopupFilterHeaderModel.java:159)
   at com.citra.filter.CustomPopupFilterHeaderModel.installFilter(Unknown Source)
   at com.citra.filter.CustomPopupFilterHeaderModel.installFilter(Unknown Source)
   at es.upv.padrino.gui.components.filters.NotasPopupFilterHeaderModel.installFilter(NotasPopupFilterHeaderModel.java:152)
   at com.citra.filter.PopupFilterHeaderModel$g.setSelectedItem(Unknown Source)
   at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
   at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
   at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
   at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
   at java.awt.EventQueue.access$000(Unknown Source)
   at java.awt.EventQueue$1.run(Unknown Source)
   at java.awt.EventQueue$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
   at java.awt.EventQueue$2.run(Unknown Source)
   at java.awt.EventQueue$2.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)


┐Could you help me please?. I'm lost.

Thanks in advance
Thu Mar 08, 2012 7:24 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

What is this string you are using?
CUSTOM_STRING = "(Define filter)";

Can you please send us your subclass?

Thanks
Thu Mar 08, 2012 8:59 am View user's profile Send private message
upv



Joined: 06 Feb 2007
Posts: 9

Post Reply with quote
Hi, I send you the subclass, in this post.
I put that variable in code, in order to make easier your understanding, sorry, that variable isnt inializated in our class, it comes from a property file (TableLibraryBundle_es_es.properties):
POPUP_FILTER_CUSTOM = (Definir filtro)



NotasPopupFilterHeaderModel.java
 Description:

Download
 Filename:  NotasPopupFilterHeaderModel.java
 Filesize:  5.94 KB
 Downloaded:  281 Time(s)

Thu Mar 08, 2012 10:19 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
I believe that the problem is within the inferColumnClass method.
Check to see whether values in the model correspond to numeric values, for which inferColumnClass returns a Number.
Fri Mar 09, 2012 8:07 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
On closer inspection, I noticed that you now also need to override inferColumnClassModel method, just as you did with inferColumnClass.

So, please disregard the previous comment.
Fri Mar 09, 2012 8:15 am View user's profile Send private message
upv



Joined: 06 Feb 2007
Posts: 9

Post Reply with quote
Hi, thanks for your help, I've overriden inferColumnClassModel method and now my application shows fine the popup filter. But I continue having problems, some filters doesnt work fine.
In numeric columns
These filters work fine: <, >, =<, >=, FILTER_EQ_TO
This fiters dont work (they dont show any exception but dont make well their job):
IS_EMPTY: never shows any cell even if it's empty
IS_NOT_EMPTY: shows everything, empty and not empty cells
FILTER_IS_IN: for example if i try to filter by 1;3;5 it only filters by the last one: 5
FILTER_IS_NOT_IN:for example if i try to filter by 1;3;5 it only filters by the last one: 5
FILTER_NE_TO: it only filters not empty values, for example : if i filter by 3 it shows all the cells which value is different from 3 and it is not empty

In String columns, all the filters work fine except: FILTER_IS_IN,FILTER_IS_NOT_IN. Both have the same problem in string columns than they have in numeric columns.

With my previous version of the library, this filters were not available: FILTER_IS_IN,FILTER_IS_NOT_IN, FILTER_NE_TO, FILTER_EQ_TO

Could you help me?, thanks in advance.
Mon Mar 12, 2012 11:34 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hello,

There was a bug with IS_EMPTY and IS_NOT_EMPTY with numerical filters that has now been fixed. For FILTER_IS_IN and FILTER_IS_NOT_IN, I think that the problem is with the override of the installFilter methods. Since you do not change the filter anyway, it is safe to delete both installFilter override methods in NotasPopupFilterHeaderModel.

As for FILTER_NE_TO, shouldn't the filter behave that way? It should show all values that are different than 3, null included. Should you require a different filtering behaviour, you can subclass the numeric filter, e.g. DoubleFilter, override its accept method so that it corresponds to your requirements, and then assign it with the FilterHeaderModel.setDefaultFilter method.

Thanks
Fri Mar 16, 2012 3:25 am View user's profile Send private message
upv



Joined: 06 Feb 2007
Posts: 9

Post Reply with quote
Hello,

after upgrading to new version, following your instructions and fixing a bug in our code all is working right.

You said: "As for FILTER_NE_TO, shouldn't the filter behave that way? It should show all values that are different than 3, null included."

Yes, i also think the filter should behave that way, but there was a bug in our subclass of DoubleFilter. I fixed it and now the filter FILTER_NE_TO works right.

thanks
Tue Mar 20, 2012 10:18 am View user's profile Send private message
Display posts from previous:    

Reply to topic    Citra Technologies Forum Index » Technical Support - Evaluation 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