use of com.intellij.openapi.wm.ToolWindowManager 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.ToolWindowManager in project android by JetBrains.
the class AndroidUtils method activateConsoleToolWindow.
public static void activateConsoleToolWindow(@NotNull Project project, @NotNull final Runnable runAfterActivation) {
final ToolWindowManager manager = ToolWindowManager.getInstance(project);
final String toolWindowId = AndroidBundle.message("android.console.tool.window.title");
ToolWindow toolWindow = manager.getToolWindow(toolWindowId);
if (toolWindow != null) {
runAfterActivation.run();
return;
}
toolWindow = manager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM);
final ConsoleView console = new ConsoleViewImpl(project, false);
project.putUserData(CONSOLE_VIEW_KEY, console);
toolWindow.getContentManager().addContent(new ContentImpl(console.getComponent(), "", false));
final ToolWindowManagerListener listener = new ToolWindowManagerListener() {
@Override
public void toolWindowRegistered(@NotNull String id) {
}
@Override
public void stateChanged() {
ToolWindow window = manager.getToolWindow(toolWindowId);
if (window != null && !window.isVisible()) {
((ToolWindowManagerEx) manager).removeToolWindowManagerListener(this);
getApplication().invokeLater(() -> manager.unregisterToolWindow(toolWindowId));
}
}
};
toolWindow.show(() -> {
runAfterActivation.run();
((ToolWindowManagerEx) manager).addToolWindowManagerListener(listener);
});
}
use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class ActivateToolWindowAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
Project project = getEventProject(e);
if (project == null)
return;
ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
final ToolWindow window = windowManager.getToolWindow(myToolWindowId);
InputEvent event = e.getInputEvent();
Runnable run = null;
if (event instanceof KeyEvent && event.isShiftDown()) {
final Content[] contents = window.getContentManager().getContents();
if (contents.length > 0 && window.getContentManager().getSelectedContent() != contents[0]) {
run = () -> window.getContentManager().setSelectedContent(contents[0], true, true);
}
}
if (windowManager.isEditorComponentActive() || !myToolWindowId.equals(windowManager.getActiveToolWindowId()) || run != null) {
if (run != null && window.isActive()) {
run.run();
} else {
window.activate(run);
}
} else {
windowManager.getToolWindow(myToolWindowId).hide(null);
}
}
use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class RemoteServersViewImpl method showDeployment.
@Override
public void showDeployment(@NotNull final ServerConnection<?> connection, @NotNull final String deploymentName) {
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
final ToolWindow toolWindow = toolWindowManager.getToolWindow(getToolWindowId(connection));
if (toolWindow != null) {
toolWindowManager.invokeLater(() -> {
ServersToolWindowContent component = getServersViewComponent(toolWindow);
if (component != null) {
component.select(connection, deploymentName);
}
});
}
}
use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class PrevSplitAction method update.
public void update(final AnActionEvent event) {
final Project project = event.getProject();
final Presentation presentation = event.getPresentation();
if (project == null) {
presentation.setEnabled(false);
return;
}
final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
presentation.setEnabled(toolWindowManager.isEditorComponentActive() && manager.isInSplitter() && manager.getCurrentWindow() != null);
}
Aggregations