Search in sources :

Example 91 with Content

use of com.intellij.ui.content.Content in project android by JetBrains.

the class FloatingToolWindow method setToolWindowContent.

private void setToolWindowContent(@NotNull ToolWindowEx toolWindow) {
    ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getSelectedContent();
    if (content == null) {
        content = contentManager.getFactory().createContent(myContent.getComponent(), null, false);
        content.setCloseable(false);
        content.setComponent(myContent.getComponent());
        content.setPreferredFocusableComponent(myContent.getFocusedComponent());
        content.setShouldDisposeContent(true);
        contentManager.addContent(content);
        contentManager.setSelectedContent(content, true);
    }
}
Also used : Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Example 92 with Content

use of com.intellij.ui.content.Content 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;
}
Also used : AndroidLogcatView(com.android.tools.idea.logcat.AndroidLogcatView) ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ConsoleView(com.intellij.execution.ui.ConsoleView) Content(com.intellij.ui.content.Content) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)

Example 93 with Content

use of com.intellij.ui.content.Content in project android by JetBrains.

the class MonitorContentFactory method createMonitorContent.

public static void createMonitorContent(@NotNull final Project project, @NotNull DeviceContext deviceContext, @NotNull RunnerLayoutUi layoutUi) {
    BaseMonitorView[] monitors = new BaseMonitorView[] { new CpuMonitorView(project, deviceContext), new MemoryMonitorView(project, deviceContext), new NetworkMonitorView(project, deviceContext), new GpuMonitorView(project, deviceContext) };
    MonitorPanel monitorPanel = new MonitorPanel(monitors);
    JBScrollPane monitorScrollPane = new JBScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    monitorScrollPane.setViewportView(monitorPanel);
    monitorScrollPane.getVerticalScrollBar().setUnitIncrement(10);
    monitorScrollPane.getHorizontalScrollBar().setUnitIncrement(10);
    Content monitorContent = layoutUi.createContent("Monitors", monitorScrollPane, "Monitors", null, null);
    monitorContent.setCloseable(false);
    layoutUi.addContent(monitorContent);
}
Also used : NetworkMonitorView(com.android.tools.idea.monitor.network.NetworkMonitorView) GpuMonitorView(com.android.tools.idea.monitor.gpu.GpuMonitorView) MemoryMonitorView(com.android.tools.idea.monitor.memory.MemoryMonitorView) Content(com.intellij.ui.content.Content) CpuMonitorView(com.android.tools.idea.monitor.cpu.CpuMonitorView) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 94 with Content

use of com.intellij.ui.content.Content in project android by JetBrains.

the class GradleToolWindowFixture method runTask.

public void runTask(@NotNull final String taskName) {
    Content content = getContent("projects");
    final Tree tasksTree = findComponentOfType(content.getComponent(), Tree.class);
    Wait.seconds(1).expecting("tree to be populated").until(() -> !tasksTree.isEmpty() && !field("myBusy").ofType(boolean.class).in(tasksTree).get());
    execute(new GuiTask() {

        @Override
        protected void executeInEDT() throws Throwable {
            expandAll(tasksTree);
        }
    });
    Object root = tasksTree.getModel().getRoot();
    final TreePath treePath = findTaskPath((DefaultMutableTreeNode) root, taskName);
    Point clickLocation = GuiQuery.getNonNull(() -> {
        // We store screen location here because it shows weird (negative) values after 'scrollPathToVisible()' is called.
        Point locationOnScreen = tasksTree.getLocationOnScreen();
        tasksTree.expandPath(treePath.getParentPath());
        tasksTree.scrollPathToVisible(treePath);
        Rectangle bounds = tasksTree.getPathBounds(treePath);
        // Make sure we are not under the horizontal scroll bar
        bounds.translate(0, bounds.height / 2);
        tasksTree.scrollRectToVisible(bounds);
        Rectangle visibleRect = tasksTree.getVisibleRect();
        return new Point(locationOnScreen.x + bounds.x + bounds.width / 2 - visibleRect.x, locationOnScreen.y + bounds.y - visibleRect.y);
    });
    myRobot.click(clickLocation, LEFT_BUTTON, 2);
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) TreePath(javax.swing.tree.TreePath) Content(com.intellij.ui.content.Content) Tree(com.intellij.ui.treeStructure.Tree)

Example 95 with Content

use of com.intellij.ui.content.Content in project android by JetBrains.

the class NlAbstractWindowManager method createWindowContent.

protected void createWindowContent(@NotNull JComponent contentPane, @NotNull JComponent focusedComponent, @Nullable AnAction[] actions) {
    ContentManager contentManager = myToolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(contentPane, null, false);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(focusedComponent);
    if (actions != null) {
        ToolWindowEx toolWindow = (ToolWindowEx) myToolWindow;
        toolWindow.setTitleActions(actions);
    }
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
}
Also used : ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Aggregations

Content (com.intellij.ui.content.Content)157 ContentManager (com.intellij.ui.content.ContentManager)42 ToolWindow (com.intellij.openapi.wm.ToolWindow)37 NotNull (org.jetbrains.annotations.NotNull)19 ContentFactory (com.intellij.ui.content.ContentFactory)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)13 MessageView (com.intellij.ui.content.MessageView)10 Disposable (com.intellij.openapi.Disposable)8 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)7 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)7 ConsoleView (com.intellij.execution.ui.ConsoleView)6 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)6 TabbedContent (com.intellij.ui.content.TabbedContent)6 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)5 Ref (com.intellij.openapi.util.Ref)5 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)4 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)4 Assert.assertNotNull (junit.framework.Assert.assertNotNull)4