Custom Filter Demo

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

Custom Filter Demo

Postby jameszhao » Fri Aug 20, 2010 12:48 pm

When processing large data set (e.g. 100,000 rows), switching "select a column" is slow, also switching "filters" is slow. I guess they are initializing Values combobox. Can you initializing Values combobox once in the very beginning when populating table?

I am interested in the component if you can make it faster.

Thanks,
James
jameszhao
 
Posts: 7
Joined: Wed Aug 18, 2010 7:56 am

Re: Custom Filter Demo

Postby JIDE Support » Fri Aug 20, 2010 1:58 pm

Please try to override FilterableTableModel#getPossibleValues() to cache it for different columns. We leave the choice to our customers since some other customers may have dynamically updated data and the cache consumes memory.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Filter Demo

Postby jameszhao » Sat Aug 21, 2010 12:45 pm

Thanks for your reply, it is helpful.

I have another questions:
1. When comparing float numbers, "is" is not working, I checked the DB and JTable, I didn't use Round. but "great than" or "less to" works.
2. Right now, the conditions are from JTable columns only. Is it possible to use use complex conditions, e.g. combined columns or some data beyond JTable.

Thanks,
James
jameszhao
 
Posts: 7
Joined: Wed Aug 18, 2010 7:56 am

Re: Custom Filter Demo

Postby JIDE Support » Mon Aug 23, 2010 6:59 am

Just tried the CustomFilterDemo in 2.9.5. The filters for float.class do work for me. The "ProductSales" column is a float-class column. B.T.W., do you mean "is" as "is in" or "equals" although I tried both?

I'm afraid you have to define your custom filter in FilterFactoryManager for your class to have more complicated filters. Below is a sample code for Number.class in FilterFactorManager.class.
Code: Select all
    private void registerFilterFactoriesForNumber(final Class type, final String resourceKey) {
        // For number
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new AllFilter<Number>();
            }

            public Class[] getExpectedDataTypes() {
                return new Class[0];
            }

            public String getName() {
                return "all";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new EqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "equal";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new NotEqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "not.equal";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new InFilter<Object>((Object[]) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{Array.newInstance(type, 0).getClass()};
            }

            public String getName() {
                return "in";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new NotFilter(new InFilter<Object>((Object[]) objects[0]));
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{Array.newInstance(type, 0).getClass()};
            }

            public String getName() {
                return "not.in";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new EmptyFilter<Number>();
            }

            public Class[] getExpectedDataTypes() {
                return new Class[0];
            }

            public String getName() {
                return "empty";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new NotFilter(new EmptyFilter<Number>());
            }

            public Class[] getExpectedDataTypes() {
                return new Class[0];
            }

            public String getName() {
                return "not.empty";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });

        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new GreaterThanFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "greater";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new GreaterOrEqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "greaterOrEqual";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new LessThanFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "less";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new LessOrEqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "lessOrEqual";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new BetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type, type};
            }

            public String getName() {
                return "between";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new NotBetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type, type};
            }

            public String getName() {
                return "not.between";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
    }

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Filter Demo

Postby jameszhao » Mon Aug 23, 2010 11:47 am

Sorry, the number filter works. If the parent follows the condition, all the children will show up.
jameszhao
 
Posts: 7
Joined: Wed Aug 18, 2010 7:56 am

Re: Custom Filter Demo

Postby jameszhao » Mon Aug 23, 2010 11:57 am

Can the table in customfilterdemo be replaced by treetable? similar to the table in AutoFilterTreeTableDemo, but without header filter.

James
jameszhao
 
Posts: 7
Joined: Wed Aug 18, 2010 7:56 am

Re: Custom Filter Demo

Postby JIDE Support » Mon Aug 23, 2010 1:02 pm

Yes. Please be noted that you need initialize a FilterableTreeTableModel instead of FilterableTableModel in the demo.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Issue Custom Filter

Postby brocade123 » Wed Oct 06, 2010 5:02 pm

Jide2.PNG
Jide2.PNG (101.32 KiB) Viewed 6839 times



Hi ,
My table has few columns of type Custom class which extends JLabel instead of primitive and I have custom cell renderer for them.
public class PortTableDataValues extends JLabel {

private static final long serialVersionUID = 1L;
public PortTableDataValues(){
super();
}
public PortTableDataValues(String label){
super(label);
}
@Override
public String toString(){
return this.getText();
}
public boolean equals(Object obj) {
if(obj instanceof PortTableDataValues){
return (this.getText().equals(((PortTableDataValues)obj).getText()));
}
else
return false;
}
public int hashCode() {
String hascodeVa=this.getText();
return hascodeVa.hashCode();

}


My table model returns object of type PortTableDataValues for these special column which displays text and icon .
I am pasing this table model to create FilterableTableModel-SortabletableModel to create SortableTable

Column data is fine and header list is also displaying text value but when I launch Custom Filter dialog when option "Custom" from list (it has all,custom and column values) is choseen.Dialogue is empty(see the screen shot).
I am overriding JLabel equals and ahshcode method also.

Please advice why the custom filter box is empty and does nt display (is anything,is etc)
brocade123
 
Posts: 3
Joined: Tue Sep 28, 2010 4:22 pm

Re: Custom Filter Demo

Postby JIDE Support » Wed Oct 06, 2010 10:30 pm

Please invoke FilterFactoryManager#registerFilterFactory() to register availabe filters for your class.

thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Filter Demo

Postby brocade123 » Thu Oct 07, 2010 12:38 pm

Thanks
so I have to extended Filter FilterFactoryManager and override registerDefaultFilterFactories method and define register Filter factories foe each filter (in,equal etc) for my specific class (non primitive) which is used by table model for these columns
Question is how to call where to use this new FilterFacoryManger. I know its used by CustomFilterEditor .How to access CustomFilterEditor for my table

Thanks
brocade123
 
Posts: 3
Joined: Tue Sep 28, 2010 4:22 pm

Re: Custom Filter Demo

Postby JIDE Support » Thu Oct 07, 2010 12:48 pm

Have sent email to you in another thread. Please check that out.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Filter Demo

Postby Praktikant » Thu Oct 27, 2011 12:05 am

I have the same problem as brocade123. The custom filter dialog is empty. What I should do to have all the values like in the Demo?

Thank you
Praktikant
 
Posts: 13
Joined: Thu Oct 06, 2011 11:17 pm

Re: Custom Filter Demo

Postby JIDE Support » Thu Oct 27, 2011 10:29 am

Please register filter factories for the custom class. This is the code fraction to show how we register filter factory for Number.class FYI.
Code: Select all
    private void registerFilterFactoriesForNumber(final Class type, final String resourceKey, boolean includeTwoParameters) {
        // For number
        FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new AllFilter<Number>();
            }

            public Class[] getExpectedDataTypes() {
                return new Class[0];
            }

            public String getName() {
                return "all";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance(). registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new EqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "equal";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new NotEqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "not.equal";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new InFilter<Object>((Object[]) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{Array.newInstance(type, 0).getClass()};
            }

            public String getName() {
                return "in";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new NotFilter(new InFilter<Object>((Object[]) objects[0]));
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{Array.newInstance(type, 0).getClass()};
            }

            public String getName() {
                return "not.in";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new EmptyFilter<Number>();
            }

            public Class[] getExpectedDataTypes() {
                return new Class[0];
            }

            public String getName() {
                return "empty";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new NotFilter(new EmptyFilter<Number>());
            }

            public Class[] getExpectedDataTypes() {
                return new Class[0];
            }

            public String getName() {
                return "not.empty";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });

       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new GreaterThanFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "greater";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new GreaterOrEqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "greaterOrEqual";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new LessThanFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "less";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
       FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
            public Filter createFilter(Object... objects) {
                return new LessOrEqualFilter<Number>((Number) objects[0]);
            }

            public Class[] getExpectedDataTypes() {
                return new Class[]{type};
            }

            public String getName() {
                return "lessOrEqual";
            }

            public String getConditionString(Locale locale) {
                return AbstractFilter.getConditionString(locale, resourceKey, getName());
            }
        });
        if (includeTwoParameters) {
           FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
                public Filter createFilter(Object... objects) {
                    return new BetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
                }

                public Class[] getExpectedDataTypes() {
                    return new Class[]{type, type};
                }

                public String getName() {
                    return "between";
                }

                public String getConditionString(Locale locale) {
                    return AbstractFilter.getConditionString(locale, resourceKey, getName());
                }
            });
           FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
                public Filter createFilter(Object... objects) {
                    return new NotBetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
                }

                public Class[] getExpectedDataTypes() {
                    return new Class[]{type, type};
                }

                public String getName() {
                    return "not.between";
                }

                public String getConditionString(Locale locale) {
                    return AbstractFilter.getConditionString(locale, resourceKey, getName());
                }
            });
        }
    }

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Filter Demo

Postby Praktikant » Fri Oct 28, 2011 12:40 am

Thank you very much, it works perfectly!
Praktikant
 
Posts: 13
Joined: Thu Oct 06, 2011 11:17 pm

Re: Custom Filter Demo

Postby Praktikant » Thu Nov 03, 2011 6:45 am

I have another question.

I am using the FilterableTableModel to create a personalize filter when the user click in a value of the table, but when I do that, if I go to the header multiple choices list, I only have the filtered value.

I would like to have all the values in the header list, only checked the value/values of the added filter.

Thanks
Praktikant
 
Posts: 13
Joined: Thu Oct 06, 2011 11:17 pm

Re: Custom Filter Demo

Postby JIDE Support » Thu Nov 03, 2011 7:16 am

Please override FilterableTableModel#getPossibleValues() to customize the value list behavior.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Filter Demo

Postby Praktikant » Thu Nov 03, 2011 7:33 am

Could you show me a code example to see all the values of the original tableModel only checked the values filtered in the new tableModel?

Thank you!
Praktikant
 
Posts: 13
Joined: Thu Oct 06, 2011 11:17 pm

Re: Custom Filter Demo

Postby Praktikant » Fri Nov 04, 2011 1:07 am

I can control the values listed, but how can I set if I want to be checked or unchecked the value?

Thank you
Praktikant
 
Posts: 13
Joined: Thu Oct 06, 2011 11:17 pm

Re: Custom Filter Demo

Postby JIDE Support » Fri Nov 04, 2011 12:52 pm

The list of AutoFilterTableHeader can only read the values from MultipleValuesFilter. Please try to let your custom filter extends MultipleValuesFilter.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33455
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Filter Demo

Postby Praktikant » Mon Nov 07, 2011 1:06 am

I am using EqualFilter to create a new Filter that I want to apply into FilterableTableModel.

Anyway I have "solved" the problem doing this:

Code: Select all
filterableTableModel.addFilter(column, new MultipleValuesFilter(value));


I saw this in another thopic.

Thanks
Praktikant
 
Posts: 13
Joined: Thu Oct 06, 2011 11:17 pm


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron