Example usage for com.intellij.openapi.wm ToolWindow activate

List of usage examples for com.intellij.openapi.wm ToolWindow activate

Introduction

In this page you can find the example usage for com.intellij.openapi.wm ToolWindow activate.

Prototype

void activate(@Nullable Runnable runnable, boolean autoFocusContents);

Source Link

Usage

From source file:com.android.tools.idea.gradle.invoker.GradleTasksExecutor.java

License:Apache License

private void activateGradleConsole() {
    ToolWindow window = getToolWindowManager().getToolWindow(GradleConsoleToolWindowFactory.ID);
    if (window != null) {
        window.activate(null, false);
    }/*  www  . j ava  2 s .  co  m*/
}

From source file:com.android.tools.idea.gradle.invoker.GradleTasksExecutor.java

License:Apache License

private void activateMessageView() {
    synchronized (myMessageViewLock) {
        if (myErrorTreeView != null) {
            ToolWindow window = getToolWindowManager().getToolWindow(ToolWindowId.MESSAGES_WINDOW);
            if (window != null) {
                window.activate(null, false);
            }/*from   w ww .ja v a  2  s.  c om*/
        }
    }
}

From source file:com.android.tools.idea.gradle.invoker.messages.GradleBuildTreeViewPanel.java

License:Apache License

@Override
protected void fillRightToolbarGroup(DefaultActionGroup group) {
    super.fillRightToolbarGroup(group);
    group.add(new DumbAwareAction("Show Console Output", null, AndroidIcons.GradleConsole) {
        @Override/*w w  w . j a v  a  2  s. c o m*/
        public void actionPerformed(AnActionEvent e) {
            ToolWindow window = ToolWindowManager.getInstance(myProject)
                    .getToolWindow(GradleConsoleToolWindowFactory.ID);
            if (window != null) {
                window.activate(null, false);
            }
        }

        @Override
        public void update(AnActionEvent e) {
            e.getPresentation().setEnabledAndVisible(true);
        }
    });

    DefaultActionGroup filterGroup = new DefaultActionGroup("GradleBuildMessagesFilter", true) {
        @Override
        public void update(AnActionEvent e) {
            Presentation presentation = e.getPresentation();
            presentation.setDescription("Filter messages to display");
            presentation.setIcon(AllIcons.General.Filter);
        }

        @Override
        public boolean isDumbAware() {
            return true;
        }
    };

    // We could have iterated through ErrorTreeElementKind.values() and have less code, but we want to keep this order:
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.ERROR));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.WARNING));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.INFO));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.NOTE));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.GENERIC));
    group.add(filterGroup);
}

From source file:com.android.tools.idea.gradle.project.NewProjectImportGradleSyncListener.java

License:Apache License

public static void activateProjectView(@NotNull Project project) {
    ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(PROJECT_VIEW);
    if (window != null) {
        window.activate(null, false);
    }/*from  w w  w .  j a v a2  s  .c  o  m*/
}

From source file:com.android.tools.idea.run.tasks.ShowLogcatTask.java

License:Apache License

private static void showLogcatConsole(@NotNull final Project project, @NotNull final IDevice device,
        @Nullable final Client client) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override/*from   w  ww  .j av  a2s.c o m*/
        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);
        }
    });
}

From source file:com.facebook.buck.intellij.ideabuck.ui.BuckToolWindowFactory.java

License:Apache License

public static void showToolWindow(final Project project, String tooWindowId) {
    ApplicationManager.getApplication().getInvokator().invokeLater(new Runnable() {
        @Override/*  w  w w  .j a v  a 2  s. c  o  m*/
        public void run() {
            ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(tooWindowId);
            if (toolWindow != null) {
                toolWindow.activate(null, false);
            }
        }
    });
}

From source file:com.facebook.buck.intellij.ideabuck.ui.components.BuckToolWindowImpl.java

License:Apache License

private void showToolWindow(ToolWindow toolWindow) {
    ApplicationManager.getApplication().getInvokator().invokeLater(() -> {
        if (toolWindow != null) {
            toolWindow.activate(null, false);
        }/*from w  ww  . java  2  s  . c  o m*/
    });
}

From source file:com.headwire.aem.tooling.intellij.console.ConsoleLog.java

License:Apache License

public static void toggleLog(@Nullable final Project project, @Nullable final Notification notification) {
    final ToolWindow eventLog = getLogWindow(project);
    if (eventLog != null) {
        if (!eventLog.isVisible()) {
            eventLog.activate(new Runnable() {
                @Override/*  ww w .  j ava 2  s  . com*/
                public void run() {
                    if (notification == null) {
                        return;
                    }
                    String contentName = getContentName(notification);
                    Content content = eventLog.getContentManager().findContent(contentName);
                    if (content != null) {
                        eventLog.getContentManager().setSelectedContent(content);
                    }
                }
            }, true);
        } else {
            eventLog.hide(null);
        }
    }
}

From source file:com.intellij.ide.favoritesTreeView.FavoritesViewSelectInTarget.java

License:Apache License

public static ActionCallback select(@NotNull Project project, final Object toSelect,
        @Nullable final String viewId, @Nullable final String subviewId, final VirtualFile virtualFile,
        final boolean requestFocus) {
    final ActionCallback result = new ActionCallback();

    ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    final ToolWindow favoritesToolWindow = windowManager.getToolWindow(ToolWindowId.FAVORITES_VIEW);

    if (favoritesToolWindow != null) {
        final FavoritesTreeViewPanel panel = UIUtil.findComponentOfType(favoritesToolWindow.getComponent(),
                FavoritesTreeViewPanel.class);

        if (panel != null) {
            final Runnable runnable = new Runnable() {
                @Override//ww w  .  ja va  2 s  .co  m
                public void run() {
                    panel.selectElement(toSelect, virtualFile, requestFocus);
                    result.setDone();
                }
            };

            if (requestFocus) {
                favoritesToolWindow.activate(runnable, false);
            } else {
                favoritesToolWindow.show(runnable);
            }
        }
    }

    return result;
}

From source file:com.intellij.ide.impl.ProjectViewSelectInTarget.java

License:Apache License

public static ActionCallback select(@NotNull Project project, final Object toSelect,
        @Nullable final String viewId, @Nullable final String subviewId, final VirtualFile virtualFile,
        final boolean requestFocus) {
    final ActionCallback result = new ActionCallback();

    final ProjectView projectView = ProjectView.getInstance(project);
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        AbstractProjectViewPane pane = projectView.getProjectViewPaneById(ProjectViewPane.ID);
        pane.select(toSelect, virtualFile, requestFocus);
        return result;
    }//from   ww w  . j a  v  a2s . c  om

    ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    final ToolWindow projectViewToolWindow = windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
    final Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if (requestFocus) {
                projectView.changeView(viewId, subviewId);
            }

            projectView.selectCB(toSelect, virtualFile, requestFocus).notify(result);
        }
    };

    if (requestFocus) {
        projectViewToolWindow.activate(runnable, false);
    } else {
        projectViewToolWindow.show(runnable);
    }

    return result;
}