{"action":"created","issue":{"url":"https://api.github.com/repos/mgarin/weblaf/issues/278","repository_url":"https://api.github.com/repos/mgarin/weblaf","labels_url":"https://api.github.com/repos/mgarin/weblaf/issues/278/labels{/name}","comments_url":"https://api.github.com/repos/mgarin/weblaf/issues/278/comments","events_url":"https://api.github.com/repos/mgarin/weblaf/issues/278/events","html_url":"https://github.com/mgarin/weblaf/issues/278","id":75246538,"number":278,"title":"JFileChooser file filters issues","user":{"login":"mgarin","id":2361389,"avatar_url":"https://avatars.githubusercontent.com/u/2361389?v=3","gravatar_id":"","url":"https://api.github.com/users/mgarin","html_url":"https://github.com/mgarin","followers_url":"https://api.github.com/users/mgarin/followers","following_url":"https://api.github.com/users/mgarin/following{/other_user}","gists_url":"https://api.github.com/users/mgarin/gists{/gist_id}","starred_url":"https://api.github.com/users/mgarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgarin/subscriptions","organizations_url":"https://api.github.com/users/mgarin/orgs","repos_url":"https://api.github.com/users/mgarin/repos","events_url":"https://api.github.com/users/mgarin/events{/privacy}","received_events_url":"https://api.github.com/users/mgarin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mgarin/weblaf/labels/bug","name":"bug","color":"eb6420"},{"url":"https://api.github.com/repos/mgarin/weblaf/labels/confirmed","name":"confirmed","color":"006b75"}],"state":"open","locked":false,"assignee":{"login":"mgarin","id":2361389,"avatar_url":"https://avatars.githubusercontent.com/u/2361389?v=3","gravatar_id":"","url":"https://api.github.com/users/mgarin","html_url":"https://github.com/mgarin","followers_url":"https://api.github.com/users/mgarin/followers","following_url":"https://api.github.com/users/mgarin/following{/other_user}","gists_url":"https://api.github.com/users/mgarin/gists{/gist_id}","starred_url":"https://api.github.com/users/mgarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgarin/subscriptions","organizations_url":"https://api.github.com/users/mgarin/orgs","repos_url":"https://api.github.com/users/mgarin/repos","events_url":"https://api.github.com/users/mgarin/events{/privacy}","received_events_url":"https://api.github.com/users/mgarin/received_events","type":"User","site_admin":false},"assignees":[{"login":"mgarin","id":2361389,"avatar_url":"https://avatars.githubusercontent.com/u/2361389?v=3","gravatar_id":"","url":"https://api.github.com/users/mgarin","html_url":"https://github.com/mgarin","followers_url":"https://api.github.com/users/mgarin/followers","following_url":"https://api.github.com/users/mgarin/following{/other_user}","gists_url":"https://api.github.com/users/mgarin/gists{/gist_id}","starred_url":"https://api.github.com/users/mgarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgarin/subscriptions","organizations_url":"https://api.github.com/users/mgarin/orgs","repos_url":"https://api.github.com/users/mgarin/repos","events_url":"https://api.github.com/users/mgarin/events{/privacy}","received_events_url":"https://api.github.com/users/mgarin/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/mgarin/weblaf/milestones/15","html_url":"https://github.com/mgarin/weblaf/milestones/v1.3.0","labels_url":"https://api.github.com/repos/mgarin/weblaf/milestones/15/labels","id":807992,"number":15,"title":"v1.3.0","description":"**Update v1.3.0 release**","creator":{"login":"mgarin","id":2361389,"avatar_url":"https://avatars.githubusercontent.com/u/2361389?v=3","gravatar_id":"","url":"https://api.github.com/users/mgarin","html_url":"https://github.com/mgarin","followers_url":"https://api.github.com/users/mgarin/followers","following_url":"https://api.github.com/users/mgarin/following{/other_user}","gists_url":"https://api.github.com/users/mgarin/gists{/gist_id}","starred_url":"https://api.github.com/users/mgarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgarin/subscriptions","organizations_url":"https://api.github.com/users/mgarin/orgs","repos_url":"https://api.github.com/users/mgarin/repos","events_url":"https://api.github.com/users/mgarin/events{/privacy}","received_events_url":"https://api.github.com/users/mgarin/received_events","type":"User","site_admin":false},"open_issues":57,"closed_issues":2,"state":"open","created_at":"2014-09-30T09:41:07Z","updated_at":"2016-08-19T18:09:39Z","due_on":"2016-02-21T21:00:00Z","closed_at":null},"comments":3,"created_at":"2015-05-11T14:46:00Z","updated_at":"2016-08-26T10:19:14Z","closed_at":null,"body":"By **invian-kmartimo**\r\n\r\nWe have a third party library (let's call it Foo) which does something similar to this when saving a file:\r\n\r\n```java\r\nJFileChooser chooser = new JFileChooser();\r\n\r\nfor (FooFileFilter f : saveFileFilters) {\r\n    // f is a class that inherits FooFileFilter\r\n    chooser.addChoosableFileFilter(f);\r\n}\r\n\r\nchooser.setFileFilter(saveFileFilters.get(0));\r\n\r\nif (c.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {\r\n    FileFilter filter = chooser.getFileFilter();\r\n    File file = chooser.getSelectedFile();\r\n\r\n    if (filter instanceof FooFileFilter) {\r\n        // the filter itself contains the logic for saving the data as the selected file format (!!!)\r\n        filter.save(sourceData, file);\r\n    } else {\r\n        new FooDefaultFileFilter().save(sourceData, file);\r\n    }\r\n}\r\n```\r\n\r\nNow, this doesn't work for two reasons:\r\n\r\n1) 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\r\n\r\nI fixed this by patching WebFileChooserPanel.setActiveFileFilter(AbstactFileFilter fileFilter, boolean select) to do fileChooser.setFileFilter(fileFilter) also, which fixed the problem.\r\n\r\nHowever, this didn't fix the overall situation, because\r\n2) 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 ;)\r\n\r\n**Original issue:**\r\nhttp://weblookandfeel.com/forum/viewtopic.php?f=4&t=215"},"comment":{"url":"https://api.github.com/repos/mgarin/weblaf/issues/comments/242691841","html_url":"https://github.com/mgarin/weblaf/issues/278#issuecomment-242691841","issue_url":"https://api.github.com/repos/mgarin/weblaf/issues/278","id":242691841,"user":{"login":"iMichka","id":3406519,"avatar_url":"https://avatars.githubusercontent.com/u/3406519?v=3","gravatar_id":"","url":"https://api.github.com/users/iMichka","html_url":"https://github.com/iMichka","followers_url":"https://api.github.com/users/iMichka/followers","following_url":"https://api.github.com/users/iMichka/following{/other_user}","gists_url":"https://api.github.com/users/iMichka/gists{/gist_id}","starred_url":"https://api.github.com/users/iMichka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iMichka/subscriptions","organizations_url":"https://api.github.com/users/iMichka/orgs","repos_url":"https://api.github.com/users/iMichka/repos","events_url":"https://api.github.com/users/iMichka/events{/privacy}","received_events_url":"https://api.github.com/users/iMichka/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T10:19:14Z","updated_at":"2016-08-26T10:19:14Z","body":"On the latest styling branch, ```getActiveFileFilter``` is now gone (which is good).\r\n```getFileFilter```  seems to work correctly now. @mgarin did you fix it or is this just some side-effect of the refactoring ?"}}
{"actor":{"display_login":"iMichka"}}