Search in sources :

Example 46 with Content

use of com.intellij.ui.content.Content 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());
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 47 with Content

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

the class ToolWindowFixture method getContent.

@Nullable
protected Content getContent(@NotNull final String displayName) {
    activateAndWaitUntilIsVisible();
    final Ref<Content> contentRef = new Ref<>();
    Wait.seconds(SECONDS_TO_WAIT).expecting("content '" + displayName + "' to be found").until(() -> {
        Content[] contents = getContents();
        for (Content content : contents) {
            if (displayName.equals(content.getDisplayName())) {
                contentRef.set(content);
                return true;
            }
        }
        return false;
    });
    return contentRef.get();
}
Also used : Ref(com.intellij.openapi.util.Ref) Content(com.intellij.ui.content.Content) Nullable(org.jetbrains.annotations.Nullable)

Example 48 with Content

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

the class AndroidModelView method createToolWindowContent.

public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JPanel toolWindowPanel = ToolWindowAlikePanel.createTreePanel(myProject.getName(), myTree);
    Content content = contentFactory.createContent(toolWindowPanel, "", false);
    toolWindow.getContentManager().addContent(content);
    updateContents();
}
Also used : Content(com.intellij.ui.content.Content) ContentFactory(com.intellij.ui.content.ContentFactory)

Example 49 with Content

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

the class InternalAndroidModelView method createToolWindowContent.

public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JPanel toolWindowPanel = ToolWindowAlikePanel.createTreePanel(myProject.getName(), myTree);
    Content content = contentFactory.createContent(toolWindowPanel, "", false);
    toolWindow.getContentManager().addContent(content);
    updateContents();
}
Also used : Content(com.intellij.ui.content.Content) ContentFactory(com.intellij.ui.content.ContentFactory)

Example 50 with Content

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

the class ShowLogcatTask method showLogcatConsole.

private static void showLogcatConsole(@NotNull final Project project, @NotNull final IDevice device, @Nullable final Client client) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            final ToolWindow androidToolWindow = ToolWindowManager.getInstance(project).getToolWindow(AndroidToolWindowFactory.TOOL_WINDOW_ID);
            // Activate the tool window, and once activated, make sure the right device is selected
            androidToolWindow.activate(new Runnable() {

                @Override
                public void run() {
                    int count = androidToolWindow.getContentManager().getContentCount();
                    for (int i = 0; i < count; i++) {
                        Content content = androidToolWindow.getContentManager().getContent(i);
                        DevicePanel devicePanel = content == null ? null : content.getUserData(AndroidToolWindowFactory.DEVICES_PANEL_KEY);
                        if (devicePanel != null) {
                            devicePanel.selectDevice(device);
                            devicePanel.selectClient(client);
                            break;
                        }
                    }
                }
            }, false);
        }
    });
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) DevicePanel(com.android.tools.idea.ddms.DevicePanel)

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