Example usage for com.intellij.openapi.wm ToolWindowId FAVORITES_VIEW

List of usage examples for com.intellij.openapi.wm ToolWindowId FAVORITES_VIEW

Introduction

In this page you can find the example usage for com.intellij.openapi.wm ToolWindowId FAVORITES_VIEW.

Prototype

String FAVORITES_VIEW

To view the source code for com.intellij.openapi.wm ToolWindowId FAVORITES_VIEW.

Click Source Link

Usage

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// w w  w . j a  v  a  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;
}