use of com.intellij.openapi.wm.ex.ToolWindowManagerListener in project freeline by alibaba.
the class FreelineTerminal method initTerminal.
public void initTerminal(final ToolWindow toolWindow) {
toolWindow.setToHideOnEmptyContent(true);
LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
toolWindow.setStripeTitle("Freeline");
Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
toolWindow.getContentManager().addContent(content);
toolWindow.setShowStripeButton(true);
toolWindow.setTitle("Console");
((ToolWindowManagerEx) ToolWindowManager.getInstance(this.myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
@Override
public void toolWindowRegistered(@NotNull String s) {
}
@Override
public void stateChanged() {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(FreelineToolWindowFactory.TOOL_WINDOW_ID);
if (window != null) {
boolean visible = window.isVisible();
if (visible && toolWindow.getContentManager().getContentCount() == 0) {
initTerminal(window);
}
}
}
});
toolWindow.show(null);
JBTabbedTerminalWidget terminalWidget = getTerminalWidget(toolWindow);
if (terminalWidget != null && terminalWidget.getCurrentSession() != null) {
Terminal terminal = terminalWidget.getCurrentSession().getTerminal();
if (terminal != null) {
terminal.setCursorVisible(false);
}
}
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerListener in project intellij-community by JetBrains.
the class PythonConsoleToolWindow method doInit.
private void doInit(@NotNull final ToolWindow toolWindow) {
myInitialized = true;
toolWindow.setToHideOnEmptyContent(true);
((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
@Override
public void toolWindowRegistered(@NotNull String id) {
}
@Override
public void stateChanged() {
ToolWindow window = getToolWindow(myProject);
if (window != null) {
boolean visible = window.isVisible();
if (visible && toolWindow.getContentManager().getContentCount() == 0) {
PydevConsoleRunner runner = PythonConsoleRunnerFactory.getInstance().createConsoleRunner(myProject, null);
runner.run();
}
}
}
});
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerListener in project intellij-community by JetBrains.
the class TerminalToolWindowPanel method initTerminal.
public void initTerminal(final ToolWindow toolWindow) {
LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
toolWindow.setToHideOnEmptyContent(true);
Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
toolWindow.getContentManager().addContent(content);
((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
@Override
public void toolWindowRegistered(@NotNull String id) {
}
@Override
public void stateChanged() {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
if (window != null) {
boolean visible = window.isVisible();
if (visible && toolWindow.getContentManager().getContentCount() == 0) {
initTerminal(window);
}
}
}
});
Disposer.register(myProject, new Disposable() {
@Override
public void dispose() {
if (myTerminalWidget != null) {
myTerminalWidget.dispose();
myTerminalWidget = null;
}
}
});
if (myDockContainer == null) {
myDockContainer = new TerminalDockContainer(toolWindow);
Disposer.register(myProject, myDockContainer);
DockManager.getInstance(myProject).register(myDockContainer);
}
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerListener 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);
});
}
Aggregations