use of com.intellij.openapi.wm.ToolWindow in project android by JetBrains.
the class AndroidToolWindowFactory method createLogcatContent.
private static Content createLogcatContent(RunnerLayoutUi layoutUi, final Project project, DeviceContext deviceContext) {
final AndroidLogcatView logcatView = new AndroidLogcatView(project, deviceContext) {
@Override
protected boolean isActive() {
ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
return window.isVisible();
}
};
ToolWindowManagerEx.getInstanceEx(project).addToolWindowManagerListener(new ToolWindowManagerAdapter() {
boolean myToolWindowVisible;
@Override
public void stateChanged() {
ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
if (window != null) {
boolean visible = window.isVisible();
if (visible != myToolWindowVisible) {
myToolWindowVisible = visible;
logcatView.activate();
if (visible) {
ConsoleView console = logcatView.getLogConsole().getConsole();
if (console != null) {
checkFacetAndSdk(project, console);
}
}
}
}
}
});
final MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyAndroidPlatformListener(logcatView));
JPanel logcatContentPanel = logcatView.getContentPanel();
final Content logcatContent = layoutUi.createContent(ANDROID_LOGCAT_CONTENT_ID, logcatContentPanel, "logcat", AndroidIcons.Ddms.Logcat, null);
logcatContent.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView);
logcatContent.setDisposer(logcatView);
logcatContent.setCloseable(false);
logcatContent.setPreferredFocusableComponent(logcatContentPanel);
return logcatContent;
}
use of com.intellij.openapi.wm.ToolWindow 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.ToolWindow in project android by JetBrains.
the class NlAbstractWindowManager method initToolWindow.
protected void initToolWindow(@NotNull final String id, @NotNull Icon icon) {
myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(id, false, getAnchor(), myProject, true);
myToolWindow.setIcon(icon);
myToolWindow.setAvailable(false, null);
myToolWindow.setAutoHide(false);
myPreviousWindowType = myToolWindow.getType();
myPreviousWindowAnchor = getEditorMode();
((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {
@Override
public void stateChanged() {
if (myProject.isDisposed()) {
return;
}
final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(id);
ToolWindowType newWindowType = window.getType();
ToolWindowAnchor newWindowAnchor = getEditorMode();
if (newWindowType != myPreviousWindowType || newWindowAnchor != myPreviousWindowAnchor) {
// TODO: Report the window docking state
NlUsageTrackerManager.getInstance(myDesignSurface).logAction(LayoutEditorEvent.LayoutEditorEventType.UNKNOWN_EVENT_TYPE);
myPreviousWindowType = newWindowType;
myPreviousWindowAnchor = newWindowAnchor;
}
}
}, myProject);
initGearActions();
}
use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.
the class SliceManager method getContentManager.
private ContentManager getContentManager(boolean dataFlowToThis) {
if (dataFlowToThis) {
if (myBackContentManager == null) {
ToolWindow backToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(BACK_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, myProject);
myBackContentManager = backToolWindow.getContentManager();
new ContentManagerWatcher(backToolWindow, myBackContentManager);
}
return myBackContentManager;
}
if (myForthContentManager == null) {
ToolWindow forthToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(FORTH_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, myProject);
myForthContentManager = forthToolWindow.getContentManager();
new ContentManagerWatcher(forthToolWindow, myForthContentManager);
}
return myForthContentManager;
}
use of com.intellij.openapi.wm.ToolWindow 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);
}
Aggregations