Open mgarin opened 9 years ago
We have the same issues here with the JasperViewer always returns the first one.
Same problem for me.
One quick solution was to use WebLaf's getActiveFileFilter
method instead of getFileFilter
to get the currently selected file filter. But this is not really a nice solution.
On the latest styling branch, getActiveFileFilter
is now gone (which is good).
getFileFilter
seems to work correctly now. @mgarin did you fix it or is this just some side-effect of the refactoring ?
That is a good question. I certainly did a lot of changes since the bug was submitted and this might have been fixed or it simply mutated into some other issue which is also highly possible. I'll have to investigate this again to see what exactly happened.
By invian-kmartimo
We have a third party library (let's call it Foo) which does something similar to this when saving a file:
Now, this doesn't work for two reasons:
1) When selecting a filter from the file chooser dropdown, WebFileChooserPanel doesn't tell the underlying JFileChooser instance that the filter has been changed, so chooser.getFileFilter() always returns the first one
I fixed this by patching WebFileChooserPanel.setActiveFileFilter(AbstactFileFilter fileFilter, boolean select) to do fileChooser.setFileFilter(fileFilter) also, which fixed the problem.
However, this didn't fix the overall situation, because 2) WebFileChooserPanel converts all FileFilters it gets to com.alee.utils.CustomFileFilter instances and throws away the originals, so chooser.getFileFilter() returns CustomFileFilter instances which is not what the Foo library expects and the end result is that FooDefaultFileFilter is always called. I think baking the file-format specific saving logic in the filter itself is fairly dumb, but I wouldn't expect the filters to be transformed when put through JFileChooser either ;)
Original issue: http://weblookandfeel.com/forum/viewtopic.php?f=4&t=215