use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project android by JetBrains.
the class NlPreviewManager method initToolWindow.
protected void initToolWindow() {
myToolWindowForm = new NlPreviewForm(this);
final String toolWindowId = getToolWindowId();
myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, myProject, true);
myToolWindow.setIcon(AndroidIcons.AndroidPreview);
((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {
@Override
public void stateChanged() {
if (myProject.isDisposed()) {
return;
}
final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
if (window != null && window.isAvailable()) {
final boolean visible = window.isVisible();
AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible);
if (myToolWindowForm != null) {
if (visible) {
myToolWindowForm.activate();
} else {
myToolWindowForm.deactivate();
}
}
}
}
});
final JComponent contentPanel = myToolWindowForm.getComponent();
final ContentManager contentManager = myToolWindow.getContentManager();
@SuppressWarnings("ConstantConditions") final Content content = contentManager.getFactory().createContent(contentPanel, null, false);
content.setDisposer(myToolWindowForm);
content.setCloseable(false);
content.setPreferredFocusableComponent(contentPanel);
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
myToolWindow.setAvailable(false, null);
myToolWindowForm.setUseInteractiveSelector(isUseInteractiveSelector());
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-code-outline by sitano.
the class CodeOutlinePlugin method unregForProject.
/**
* Removes the code outline tool window from the given project.
*
* @param project the project to unregister
*/
private synchronized void unregForProject(Project project) {
ToolWindowManager twm = ToolWindowManager.getInstance(project);
CodeOutlineToolWindow window = windows.get(project);
if (window != null) {
ToolWindowManagerEx twmEx = (ToolWindowManagerEx) twm;
twmEx.removeToolWindowManagerListener(window.getToolWindowManagerListener());
}
try {
twm.unregisterToolWindow(TOOLWINDOW_ID);
} catch (IllegalArgumentException ignored) {
}
CodeOutlineToolWindow win = windows.remove(project);
if (win == null)
return;
win.stop();
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class DockablePopupManager method createToolWindow.
public void createToolWindow(final PsiElement element, PsiElement originalElement) {
assert myToolWindow == null;
final T component = createComponent();
final ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(myProject);
final ToolWindow toolWindow = toolWindowManagerEx.getToolWindow(getToolwindowId());
myToolWindow = toolWindow == null ? toolWindowManagerEx.registerToolWindow(getToolwindowId(), true, ToolWindowAnchor.RIGHT, myProject) : toolWindow;
myToolWindow.setIcon(AllIcons.Toolwindows.Documentation);
myToolWindow.setAvailable(true, null);
myToolWindow.setToHideOnEmptyContent(false);
setToolwindowDefaultState();
((ToolWindowEx) myToolWindow).setTitleActions(createRestorePopupAction());
final ContentManager contentManager = myToolWindow.getContentManager();
final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
final Content content = contentFactory.createContent(component, getTitle(element), false);
contentManager.addContent(content);
contentManager.addContentManagerListener(new ContentManagerAdapter() {
@Override
public void contentRemoved(ContentManagerEvent event) {
restorePopupBehavior();
}
});
new UiNotifyConnector(component, new Activatable() {
@Override
public void showNotify() {
restartAutoUpdate(myAutoUpdateDocumentation);
}
@Override
public void hideNotify() {
restartAutoUpdate(false);
}
});
myToolWindow.show(null);
PropertiesComponent.getInstance().setValue(getShowInToolWindowProperty(), Boolean.TRUE.toString());
restartAutoUpdate(PropertiesComponent.getInstance().getBoolean(getAutoUpdateEnabledProperty(), true));
doUpdateComponent(element, originalElement, component);
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class RunContentManagerImpl method init.
// must be called on EDT
private void init() {
ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(myProject);
if (toolWindowManager == null) {
return;
}
for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
registerToolWindow(executor, toolWindowManager);
}
RunDashboardManager dashboardManager = RunDashboardManager.getInstance(myProject);
initToolWindow(null, dashboardManager.getToolWindowId(), dashboardManager.getToolWindowIcon(), dashboardManager.getDashboardContentManager());
toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() {
@Override
public void stateChanged() {
if (myProject.isDisposed()) {
return;
}
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
Set<String> currentWindows = new THashSet<>();
ContainerUtil.addAll(currentWindows, toolWindowManager.getToolWindowIds());
myToolwindowIdZBuffer.retainAll(currentWindows);
final String activeToolWindowId = toolWindowManager.getActiveToolWindowId();
if (activeToolWindowId != null) {
if (myToolwindowIdZBuffer.remove(activeToolWindowId)) {
myToolwindowIdZBuffer.addFirst(activeToolWindowId);
}
}
}
});
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class TogglePresentationModeAction method storeToolWindows.
static boolean storeToolWindows(@Nullable Project project) {
if (project == null)
return false;
ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
DesktopLayout layout = new DesktopLayout();
layout.copyFrom(manager.getLayout());
boolean hasVisible = hideAllToolWindows(manager);
if (hasVisible) {
manager.setLayoutToRestoreLater(layout);
manager.activateEditorComponent();
}
return hasVisible;
}
Aggregations