FacetDependentToolWindow introduced

This commit is contained in:
Dmitry Avdeev
2011-06-01 13:15:27 +04:00
parent e227da8bab
commit e55bb79318
4 changed files with 88 additions and 52 deletions
@@ -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<FacetDependentToolWindow> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.facet.toolWindow");
@Attribute("facetId")
public String facetId;
}
@@ -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<String> myRestoredToolWindowIds = new HashSet<String>();
private final FileEditorManager myFileEditorManager;
private final ProjectWideFacetListenersRegistry myFacetListenersRegistry;
private final ProjectFacetManager myFacetManager;
private final Map<String, Balloon> myWindow2Balloon = new HashMap<String, Balloon>();
@@ -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<Project> 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<FinalizableCommand> commandsList = new ArrayList<FinalizableCommand>();
final String[] ids = getToolWindowIds();
@@ -383,6 +383,8 @@
beanClass="com.intellij.ide.util.projectWizard.ModuleBuilderFactory"/>
<extensionPoint name="facetType"
interface="com.intellij.facet.FacetType"/>
<extensionPoint name="facet.toolWindow"
beanClass="com.intellij.facet.ui.FacetDependentToolWindow"/>
<extensionPoint name="methodNavigationOffsetProvider"
interface="com.intellij.codeInsight.navigation.MethodNavigationOffsetProvider"/>
@@ -209,6 +209,11 @@
<interface-class>com.intellij.facet.pointers.FacetPointersManager</interface-class>
<implementation-class>com.intellij.facet.impl.pointers.FacetPointersManagerImpl</implementation-class>
</component>
<component>
<implementation-class>com.intellij.facet.impl.ui.FacetDependentToolWindowManager</implementation-class>
<skipForDefaultProject/>
</component>
</project-components>
<module-components>