From 72f81ba46b9c8548f0b5dc53c719b815e94a8c2f Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 10 Sep 2009 20:17:19 +0400 Subject: [PATCH] leaking project through swing data strucutures --- .../openapi/wm/impl/status/StatusBarImpl.java | 7 +++--- .../committed/IncomingChangesIndicator.java | 25 ++++++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarImpl.java index c9ee971c6b..1d50667607 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarImpl.java @@ -234,7 +234,7 @@ public class StatusBarImpl extends JPanel implements StatusBarEx { private void disposeAppLevelCustomComponents() { if (myCustomComponentsFactoryList != null) { - for (StatusBarCustomComponentFactory factory : myCustomComponentsFactoryList) { + for (StatusBarCustomComponentFactory factory : myCustomComponentsFactoryList) { try { JComponent c = myFactory2Component.get(factory); if (c != null) { @@ -317,11 +317,10 @@ public class StatusBarImpl extends JPanel implements StatusBarEx { } public final void addCustomIndicationComponent(@NotNull JComponent c) { - addCustomIndicationComponent(c, myCustomIndicationsPanel); } - private void addCustomIndicationComponent(final JComponent c, final JPanel indicationsPanel) { + private static void addCustomIndicationComponent(final JComponent c, final JPanel indicationsPanel) { final GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.weightx = 0; @@ -337,7 +336,7 @@ public class StatusBarImpl extends JPanel implements StatusBarEx { removeCustomIndicationComponent(component, myCustomIndicationsPanel); } - private void removeCustomIndicationComponent(final JComponent component, final JPanel indicationsPanel) { + private static void removeCustomIndicationComponent(final JComponent component, final JPanel indicationsPanel) { indicationsPanel.remove(component); if (indicationsPanel.getComponentCount() == 0) { indicationsPanel.setVisible(false); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/IncomingChangesIndicator.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/IncomingChangesIndicator.java index 0377488ddb..b75cec569d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/IncomingChangesIndicator.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/IncomingChangesIndicator.java @@ -14,8 +14,11 @@ import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.Disposable; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.ui.SimpleColoredComponent; import com.intellij.util.messages.MessageBus; +import com.intellij.ide.DataManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -78,7 +81,7 @@ public class IncomingChangesIndicator implements ProjectComponent { private void refreshIndicator() { final List list = myCache.getCachedIncomingChanges(); - if (list == null || list.size() == 0) { + if (list == null || list.isEmpty()) { debug("Refreshing indicator: no changes"); myIndicatorComponent.clear(); myIndicatorComponent.setToolTipText(""); @@ -95,18 +98,22 @@ public class IncomingChangesIndicator implements ProjectComponent { LOG.debug(message); } - private class IndicatorComponent extends SimpleColoredComponent { - public IndicatorComponent() { + private static class IndicatorComponent extends SimpleColoredComponent { + private IndicatorComponent() { addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (!e.isPopupTrigger()) { - ToolWindow changesView = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID); - changesView.show(new Runnable() { - public void run() { - ChangesViewContentManager.getInstance(myProject).selectContent("Incoming"); - } - }); + DataContext dataContext = DataManager.getInstance().getDataContext(IndicatorComponent.this); + final Project project = PlatformDataKeys.PROJECT.getData(dataContext); + if (project != null) { + ToolWindow changesView = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID); + changesView.show(new Runnable() { + public void run() { + ChangesViewContentManager.getInstance(project).selectContent("Incoming"); + } + }); + } } } }); -- 2.11.4.GIT