From: Kirill Kalishev Date: Tue, 16 Feb 2010 09:55:38 +0000 (+0300) Subject: ComponentWithBrowseButton - optional remove listener on hide X-Git-Tag: review-1~10 X-Git-Url: https://repo.or.cz/w/fedora-idea.git/commitdiff_plain/87f43da9f90135d8dc72e60e496751ebe92959fc ComponentWithBrowseButton - optional remove listener on hide --- diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java index c0f4924fe4..9e7943e7a8 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java @@ -107,20 +107,34 @@ public class ComponentWithBrowseButton extends JPanel i public void addBrowseFolderListener(String title, String description, @Nullable Project project, FileChooserDescriptor fileChooserDescriptor, TextComponentAccessor accessor) { - addBrowseFolderListener(project, new BrowseFolderActionListener(title, description, this, project, fileChooserDescriptor, accessor)); + addBrowseFolderListener(title, description, project, fileChooserDescriptor, accessor, true); + } + + public void addBrowseFolderListener(String title, String description, @Nullable Project project, + FileChooserDescriptor fileChooserDescriptor, + TextComponentAccessor accessor, boolean autoRemoveOnHide) { + addBrowseFolderListener(project, new BrowseFolderActionListener(title, description, this, project, fileChooserDescriptor, accessor), autoRemoveOnHide); } public void addBrowseFolderListener(@Nullable Project project, final BrowseFolderActionListener actionListener) { - new LazyUiDisposable>(null, this, this) { - protected void initialize(@NotNull Disposable parent, @NotNull ComponentWithBrowseButton child, @Nullable Project project) { - addActionListener(actionListener); - Disposer.register(child, new Disposable() { - public void dispose() { - removeActionListener(actionListener); - } - }); - } - }; + addBrowseFolderListener(project, actionListener, true); + } + + public void addBrowseFolderListener(@Nullable Project project, final BrowseFolderActionListener actionListener, boolean autoRemoveOnHide) { + if (autoRemoveOnHide) { + new LazyUiDisposable>(null, this, this) { + protected void initialize(@NotNull Disposable parent, @NotNull ComponentWithBrowseButton child, @Nullable Project project) { + addActionListener(actionListener); + Disposer.register(child, new Disposable() { + public void dispose() { + removeActionListener(actionListener); + } + }); + } + }; + } else { + addActionListener(actionListener); + } } public void dispose() {