use of com.intellij.openapi.wm.ex.ToolWindowManagerEx 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.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class ExternalProjectsViewImpl method init.
public void init() {
Disposer.register(myProject, this);
initTree();
final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {
boolean wasVisible = false;
@Override
public void stateChanged() {
if (myToolWindow.isDisposed())
return;
boolean visible = myToolWindow.isVisible();
if (!visible || wasVisible) {
wasVisible = visible;
return;
}
scheduleStructureUpdate();
wasVisible = true;
}
};
manager.addToolWindowManagerListener(listener, myProject);
getShortcutsManager().addListener(new ExternalSystemShortcutsManager.Listener() {
@Override
public void shortcutsUpdated() {
scheduleTasksUpdate();
scheduleStructureRequest(() -> {
assert myStructure != null;
myStructure.updateNodes(RunConfigurationNode.class);
});
}
});
getTaskActivator().addListener(new ExternalSystemTaskActivator.Listener() {
@Override
public void tasksActivationChanged() {
scheduleTasksUpdate();
scheduleStructureRequest(() -> {
assert myStructure != null;
myStructure.updateNodes(RunConfigurationNode.class);
});
}
});
((RunManagerEx) RunManager.getInstance(myProject)).addRunManagerListener(new RunManagerListener() {
private void changed() {
scheduleStructureRequest(() -> {
assert myStructure != null;
myStructure.visitNodes(ModuleNode.class, node -> node.updateRunConfigurations());
});
}
@Override
public void runConfigurationAdded(@NotNull RunnerAndConfigurationSettings settings) {
changed();
}
@Override
public void runConfigurationRemoved(@NotNull RunnerAndConfigurationSettings settings) {
changed();
}
@Override
public void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
changed();
}
});
ExternalSystemApiUtil.subscribe(myProject, myExternalSystemId, new ExternalSystemSettingsListenerAdapter() {
@Override
public void onUseAutoImportChange(boolean currentValue, @NotNull final String linkedProjectPath) {
scheduleStructureRequest(() -> {
assert myStructure != null;
final List<ProjectNode> projectNodes = myStructure.getNodes(ProjectNode.class);
for (ProjectNode projectNode : projectNodes) {
final ProjectData projectData = projectNode.getData();
if (projectData != null && projectData.getLinkedExternalProjectPath().equals(linkedProjectPath)) {
projectNode.updateProject();
break;
}
}
});
}
});
myToolWindow.setAdditionalGearActions(createAdditionalGearActionsGroup());
scheduleStructureUpdate();
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class DockablePopupManager method restorePopupBehavior.
protected void restorePopupBehavior() {
if (myToolWindow != null) {
PropertiesComponent.getInstance().setValue(getShowInToolWindowProperty(), Boolean.FALSE.toString());
ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(myProject);
toolWindowManagerEx.hideToolWindow(getToolwindowId(), false);
toolWindowManagerEx.unregisterToolWindow(getToolwindowId());
Disposer.dispose(myToolWindow.getContentManager());
myToolWindow = null;
restartAutoUpdate(false);
}
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class ToggleFloatingModeAction method setSelected.
public void setSelected(AnActionEvent event, boolean flag) {
Project project = event.getProject();
if (project == null) {
return;
}
String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
if (id == null) {
return;
}
ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
ToolWindowEx toolWindow = (ToolWindowEx) mgr.getToolWindow(id);
ToolWindowType type = toolWindow.getType();
if (ToolWindowType.FLOATING == type) {
toolWindow.setType(toolWindow.getInternalType(), null);
} else {
toolWindow.setType(ToolWindowType.FLOATING, null);
}
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class TogglePresentationModeAction method restoreToolWindows.
static void restoreToolWindows(Project project, boolean needsRestore, boolean inPresentation) {
if (project == null || !needsRestore)
return;
ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
DesktopLayout restoreLayout = manager.getLayoutToRestoreLater();
if (!inPresentation && restoreLayout != null) {
manager.setLayout(restoreLayout);
}
}
Aggregations