From e55bb79318b645a2e4b8fffea9803dd62ad499fa Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 31 May 2011 17:47:15 +0400 Subject: [PATCH] FacetDependentToolWindow introduced --- .../facet/ui/FacetDependentToolWindow.java | 16 +++ .../wm/impl/ToolWindowManagerImpl.java | 117 ++++++++++-------- .../src/META-INF/LangExtensionPoints.xml | 2 + .../src/componentSets/Lang.xml | 5 + 4 files changed, 88 insertions(+), 52 deletions(-) create mode 100644 platform/lang-api/src/com/intellij/facet/ui/FacetDependentToolWindow.java diff --git a/platform/lang-api/src/com/intellij/facet/ui/FacetDependentToolWindow.java b/platform/lang-api/src/com/intellij/facet/ui/FacetDependentToolWindow.java new file mode 100644 index 000000000000..9a070559e8b0 --- /dev/null +++ b/platform/lang-api/src/com/intellij/facet/ui/FacetDependentToolWindow.java @@ -0,0 +1,16 @@ +package com.intellij.facet.ui; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.wm.ToolWindowEP; +import com.intellij.util.xmlb.annotations.Attribute; + +/** + * @author Dmitry Avdeev + */ +public class FacetDependentToolWindow extends ToolWindowEP { + + public static final ExtensionPointName EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.facet.toolWindow"); + + @Attribute("facetId") + public String facetId; +} diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index cc1555f0611c..145cc69096b1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -16,9 +16,13 @@ package com.intellij.openapi.wm.impl; import com.intellij.Patches; +import com.intellij.facet.ProjectFacetManager; +import com.intellij.facet.ProjectWideFacetListenersRegistry; import com.intellij.ide.ui.LafManager; import com.intellij.ide.ui.LafManagerListener; -import com.intellij.notification.*; +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationListener; +import com.intellij.notification.Notifications; import com.intellij.notification.impl.NotificationsManagerImpl; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; @@ -119,6 +123,8 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements private final Set myRestoredToolWindowIds = new HashSet(); private final FileEditorManager myFileEditorManager; + private final ProjectWideFacetListenersRegistry myFacetListenersRegistry; + private final ProjectFacetManager myFacetManager; private final Map myWindow2Balloon = new HashMap(); @@ -151,10 +157,14 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements public ToolWindowManagerImpl(final Project project, WindowManagerEx windowManagerEx, final FileEditorManager fem, - ActionManager actionManager) { + ActionManager actionManager, + ProjectWideFacetListenersRegistry facetListenersRegistry, + ProjectFacetManager facetManager) { myProject = project; myWindowManager = windowManagerEx; myFileEditorManager = fem; + myFacetListenersRegistry = facetListenersRegistry; + myFacetManager = facetManager; myListenerList = new EventListenerList(); if (!project.isDefault()) { @@ -438,60 +448,63 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME); for (final ToolWindowEP bean : beans) { final Condition condition = bean.getCondition(); - if (condition != null && !condition.value(myProject)) { - continue; + if (condition == null || condition.value(myProject)) { + initToolWindow(bean); } - ToolWindowAnchor toolWindowAnchor; - try { - toolWindowAnchor = ToolWindowAnchor.fromText(bean.anchor); - } - catch (Exception e) { - LOG.error(e); - continue; - } - JLabel label = new JLabel("Initializing...", JLabel.CENTER); - label.setOpaque(true); - final Color treeBg = UIManager.getColor("Tree.background"); - label.setBackground(new Color(treeBg.getRed(), treeBg.getGreen(), treeBg.getBlue(), 180)); - final Color treeFg = UIUtil.getTreeForeground(); - label.setForeground(new Color(treeFg.getRed(), treeFg.getGreen(), treeFg.getBlue(), 180)); - final ToolWindowFactory factory = bean.getToolWindowFactory(); - final ToolWindowImpl toolWindow = - (ToolWindowImpl)registerToolWindow(bean.id, label, toolWindowAnchor, myProject, DumbService.isDumbAware(factory), bean.canCloseContents); - toolWindow.setContentFactory(factory); - if (bean.icon != null) { - Icon icon = IconLoader.findIcon(bean.icon, factory.getClass()); - if (icon == null) { - try { - icon = IconLoader.getIcon(bean.icon); - } - catch (Exception ignored) { - } - } - toolWindow.setIcon(icon); - } - - if (!getInfo(bean.id).isSplit() && bean.secondary && !myRestoredToolWindowIds.contains(bean.id)) { - toolWindow.setSplitMode(bean.secondary, null); - } - - final ActionCallback activation = toolWindow.setActivation(new ActionCallback()); - - UiNotifyConnector.doWhenFirstShown(label, new Runnable() { - public void run() { - ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() { - public void run() { - if (toolWindow.isDisposed()) return; - - toolWindow.ensureContentInitialized(); - activation.setDone(); - } - }); - } - }); } } + public void initToolWindow(ToolWindowEP bean) { + ToolWindowAnchor toolWindowAnchor; + try { + toolWindowAnchor = ToolWindowAnchor.fromText(bean.anchor); + } + catch (Exception e) { + LOG.error(e); + return; + } + JLabel label = new JLabel("Initializing...", JLabel.CENTER); + label.setOpaque(true); + final Color treeBg = UIManager.getColor("Tree.background"); + label.setBackground(new Color(treeBg.getRed(), treeBg.getGreen(), treeBg.getBlue(), 180)); + final Color treeFg = UIUtil.getTreeForeground(); + label.setForeground(new Color(treeFg.getRed(), treeFg.getGreen(), treeFg.getBlue(), 180)); + final ToolWindowFactory factory = bean.getToolWindowFactory(); + final ToolWindowImpl toolWindow = + (ToolWindowImpl)registerToolWindow(bean.id, label, toolWindowAnchor, myProject, DumbService.isDumbAware(factory), bean.canCloseContents); + toolWindow.setContentFactory(factory); + if (bean.icon != null) { + Icon icon = IconLoader.findIcon(bean.icon, factory.getClass()); + if (icon == null) { + try { + icon = IconLoader.getIcon(bean.icon); + } + catch (Exception ignored) { + } + } + toolWindow.setIcon(icon); + } + + if (!getInfo(bean.id).isSplit() && bean.secondary && !myRestoredToolWindowIds.contains(bean.id)) { + toolWindow.setSplitMode(bean.secondary, null); + } + + final ActionCallback activation = toolWindow.setActivation(new ActionCallback()); + + UiNotifyConnector.doWhenFirstShown(label, new Runnable() { + public void run() { + ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() { + public void run() { + if (toolWindow.isDisposed()) return; + + toolWindow.ensureContentInitialized(); + activation.setDone(); + } + }); + } + }); + } + public void projectClosed() { final ArrayList commandsList = new ArrayList(); final String[] ids = getToolWindowIds(); diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 33a4ba477b40..0c05b1250b0c 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -383,6 +383,8 @@ beanClass="com.intellij.ide.util.projectWizard.ModuleBuilderFactory"/> + diff --git a/platform/platform-resources/src/componentSets/Lang.xml b/platform/platform-resources/src/componentSets/Lang.xml index 31c34da12a54..e2e24a26d30d 100644 --- a/platform/platform-resources/src/componentSets/Lang.xml +++ b/platform/platform-resources/src/componentSets/Lang.xml @@ -209,6 +209,11 @@ com.intellij.facet.pointers.FacetPointersManager com.intellij.facet.impl.pointers.FacetPointersManagerImpl + + + com.intellij.facet.impl.ui.FacetDependentToolWindowManager + +