use of com.intellij.openapi.wm.ToolWindowEP in project intellij-community by JetBrains.
the class ExternalSystemUtil method ensureToolWindowInitialized.
public static void ensureToolWindowInitialized(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
try {
ToolWindowManager manager = ToolWindowManager.getInstance(project);
if (!(manager instanceof ToolWindowManagerEx)) {
return;
}
ToolWindowManagerEx managerEx = (ToolWindowManagerEx) manager;
String id = externalSystemId.getReadableName();
ToolWindow window = manager.getToolWindow(id);
if (window != null) {
return;
}
ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
for (final ToolWindowEP bean : beans) {
if (id.equals(bean.id)) {
managerEx.initToolWindow(bean);
}
}
} catch (Exception e) {
LOG.error(String.format("Unable to initialize %s tool window", externalSystemId.getReadableName()), e);
}
}
use of com.intellij.openapi.wm.ToolWindowEP in project intellij-community by JetBrains.
the class HiddenSidebarButtonTest method testHiddenButton.
public void testHiddenButton() throws Exception {
DesktopLayout layout = myManager.getLayout();
layout.readExternal(JdomKt.loadElement(LAYOUT));
for (String ID : IDS) {
assertFalse(layout.isToolWindowRegistered(ID));
assertTrue(layout.isToolWindowUnregistered(ID));
}
ToolWindowEP[] extensions = Extensions.getExtensions(ToolWindowEP.EP_NAME);
for (ToolWindowEP extension : extensions) {
if (Arrays.asList(ToolWindowId.TODO_VIEW, ToolWindowId.FIND, ToolWindowId.PROJECT_VIEW).contains(extension.id)) {
myManager.initToolWindow(extension);
}
}
new UsageViewManagerImpl(myManager.getProject(), myManager);
for (int i = 0; i < IDS.length; i++) {
assertTrue(layout.isToolWindowRegistered(IDS[i]));
assertFalse(layout.isToolWindowUnregistered(IDS[i]));
assertTrue(ESTIMATED_TO_SHOW[i] == layout.getInfo(IDS[i], true).isShowStripeButton());
assertTrue(ESTIMATED_VISIBILITY[i] == myManager.getStripeButton(IDS[i]).isVisible());
}
}
use of com.intellij.openapi.wm.ToolWindowEP in project intellij-community by JetBrains.
the class ProjectToolWindowTest method testProjectViewActivate.
public void testProjectViewActivate() throws Exception {
ToolWindowEP[] extensions = Extensions.getExtensions(ToolWindowEP.EP_NAME);
for (ToolWindowEP extension : extensions) {
if (ToolWindowId.PROJECT_VIEW.equals(extension.id)) {
myManager.initToolWindow(extension);
}
}
DesktopLayout layout = myManager.getLayout();
WindowInfoImpl info = layout.getInfo(ToolWindowId.PROJECT_VIEW, false);
assertFalse(info.isVisible());
info.setVisible(true);
ToolWindow window = myManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
assertTrue(window.isVisible());
ProjectView.getInstance(getProject());
ProjectViewSharedSettings.Companion.getInstance().setAutoscrollFromSource(true);
try {
window.activate(null);
} finally {
// cleanup
info.setVisible(false);
}
}
use of com.intellij.openapi.wm.ToolWindowEP in project intellij-community by JetBrains.
the class ProjectViewTestUtil method setupImpl.
public static void setupImpl(@NotNull Project project, boolean loadPaneExtensions) {
ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
ToolWindow toolWindow = toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
if (toolWindow == null) {
ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
for (final ToolWindowEP bean : beans) {
if (bean.id.equals(ToolWindowId.PROJECT_VIEW)) {
toolWindow = toolWindowManager.registerToolWindow(bean.id, new JLabel(), ToolWindowAnchor.fromText(bean.anchor), project, false, bean.canCloseContents);
break;
}
}
}
((ProjectViewImpl) ProjectView.getInstance(project)).setupImpl(toolWindow, loadPaneExtensions);
}
use of com.intellij.openapi.wm.ToolWindowEP in project intellij-community by JetBrains.
the class MvcModuleStructureSynchronizer method updateProjectViewVisibility.
private void updateProjectViewVisibility() {
if (ApplicationManager.getApplication().isUnitTestMode())
return;
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
@Override
public void run() {
ApplicationManager.getApplication().invokeLater(() -> {
if (myProject.isDisposed())
return;
for (ToolWindowEP ep : ToolWindowEP.EP_NAME.getExtensions()) {
if (MvcToolWindowDescriptor.class.isAssignableFrom(ep.getFactoryClass())) {
MvcToolWindowDescriptor descriptor = (MvcToolWindowDescriptor) ep.getToolWindowFactory();
String id = descriptor.getToolWindowId();
boolean shouldShow = descriptor.value(myProject);
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
if (shouldShow && toolWindow == null) {
toolWindow = toolWindowManager.registerToolWindow(id, true, ToolWindowAnchor.LEFT, myProject, true);
toolWindow.setIcon(descriptor.getFramework().getToolWindowIcon());
descriptor.createToolWindowContent(myProject, toolWindow);
} else if (!shouldShow && toolWindow != null) {
toolWindowManager.unregisterToolWindow(id);
Disposer.dispose(toolWindow.getContentManager());
}
}
}
});
}
});
}
Aggregations