Example usage for com.intellij.openapi.wm ToolWindowAnchor RIGHT

List of usage examples for com.intellij.openapi.wm ToolWindowAnchor RIGHT

Introduction

In this page you can find the example usage for com.intellij.openapi.wm ToolWindowAnchor RIGHT.

Prototype

ToolWindowAnchor RIGHT

To view the source code for com.intellij.openapi.wm ToolWindowAnchor RIGHT.

Click Source Link

Usage

From source file:brainleg.app.intellij.BLProjectComponent.java

License:Apache License

public void projectOpened() {
    System.out.println("brainleg : project opened: " + myProject);
    if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
        return;/*from  w  ww  . jav a2  s .  c  o m*/
    }
    StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() {
        public void run() {
            //                System.out.println("RESETTING traces: ");
            //                BLSettingsService.getSettings().ignoreFullTracesNoLinesMD5s.clear();

            final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
            if (toolWindowManager != null) {
                myToolWindow = toolWindowManager.registerToolWindow(BL_WINDOW_ID, true, ToolWindowAnchor.RIGHT,
                        myProject, true);
                myToolWindow.setType(ToolWindowType.SLIDING, null);
                setNormalIcon();

                myToolWindow.setAvailable(true, null);

                final ContentManager contentManager = myToolWindow.getContentManager();

                Disposer.register(myProject, new Disposable() {
                    public void dispose() {
                        //                            contentManager.removeContentManagerListener(myContentManagerListener);
                    }
                });

                myContentManager = contentManager;
            }

            final RunContentManager contentManager = ExecutionManager.getInstance(myProject)
                    .getContentManager();
            contentManager.addRunContentListener(new RunContentListener() {
                public void contentSelected(RunContentDescriptor descriptor) {
                    //for some reason sometimes idea calls this lister twice on the same RunContentDescriptor
                    //check if we already registered a filter, otherwise we will have two filters watching the same console
                    if (runContentDescriptors.contains(System.identityHashCode(descriptor))) {
                        System.out.println(
                                "skipping because we already have registered a listener for: " + descriptor);
                        return;
                    }
                    runContentDescriptors.add(System.identityHashCode(descriptor));

                    System.out.println("contentSelected: " + descriptor);
                    ConsoleView view = (ConsoleView) descriptor.getExecutionConsole();
                    view.addMessageFilter(new BLExceptionFilter(myProject, BLProjectComponent.this));
                }

                public void contentRemoved(RunContentDescriptor descriptor) {
                    System.out.println("content removed: " + descriptor);
                }
            });

            BLDefaultPanel defaultPanel = new BLDefaultPanel(); //panel which we display until the first exception

            final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
            myDefaultPanelContent = contentFactory.createContent(defaultPanel.getRootComponent(), "", false);
            myContentManager.addContent(myDefaultPanelContent, 0);

            //                //for some reason this listener gets called only when BL tab is manually clicked on before first exception. Probably idea bug
            //                myToolWindow.getComponent().addFocusListener(new FocusListener() {
            //                    public void focusGained(FocusEvent e) {
            //                        System.out.println("focus on ");
            //                    }
            //
            //                    public void focusLost(FocusEvent e) {
            //                        System.out.println("focus off ");
            //                    }
            //                });
        }
    });
}

From source file:com.android.tools.adtui.workbench.FloatingToolWindow.java

License:Apache License

private void updateState(@NotNull AttachedToolWindow<T> correspondingWindow) {
    myCorrespondingToolWindow = correspondingWindow;
    ToolWindowAnchor anchor = correspondingWindow.isLeft() ? ToolWindowAnchor.LEFT : ToolWindowAnchor.RIGHT;
    myToolWindow.setAnchor(anchor, null);
}

From source file:com.android.tools.adtui.workbench.FloatingToolWindow.java

License:Apache License

private ToolWindowEx createToolWindow(@NotNull ToolWindowManager toolWindowManager,
        @NotNull ToolWindowDefinition<T> definition) {
    String id = definition.getTitle();
    ToolWindowEx window = (ToolWindowEx) toolWindowManager.getToolWindow(id);
    if (window == null) {
        ToolWindowAnchor anchor = definition.getSide().isLeft() ? ToolWindowAnchor.LEFT
                : ToolWindowAnchor.RIGHT;
        window = (ToolWindowEx) toolWindowManager.registerToolWindow(id, false, anchor, this, true);
        window.setIcon(definition.getIcon());
        window.setType(ToolWindowType.FLOATING, null);
        window.setAutoHide(false);/* ww  w .  j  a  v a  2s  .  c o m*/
        setToolWindowContent(window);
        setAdditionalGearPopupActions(window);
        setAdditionalActions(window);
    }
    return window;
}

From source file:com.android.tools.idea.assistant.OpenAssistSidePanelAction.java

License:Apache License

@Override
public final void actionPerformed(AnActionEvent event) {
    final Project thisProject = event.getProject();
    final String actionId = ActionManager.getInstance().getId(this);

    ApplicationManager.getApplication().invokeLater(() -> {

        AssistToolWindowFactory factory = new AssistToolWindowFactory(actionId);
        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(thisProject);
        ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOL_WINDOW_TITLE);

        if (toolWindow == null) {
            // NOTE: canWorkInDumbMode must be true or the window will close on gradle sync.
            toolWindow = toolWindowManager.registerToolWindow(TOOL_WINDOW_TITLE, false, ToolWindowAnchor.RIGHT,
                    thisProject, true);/*from   w w w  .ja  va 2 s .  c  om*/
        }
        toolWindow.setIcon(AndroidIcons.Assistant.Assist);

        factory.createToolWindowContent(thisProject, toolWindow);

        // Always active the window, in case it was previously minimized.
        toolWindow.activate(null);
    });
    onActionPerformed(event);
}

From source file:com.android.tools.idea.editors.theme.AndroidThemePreviewToolWindowManager.java

License:Apache License

private void initToolWindow() {
    myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(TOOL_WINDOW_ID, false,
            ToolWindowAnchor.RIGHT, myProject, false);
    myToolWindow.setIcon(AndroidIcons.ThemesPreview);
    myToolWindow.setAvailable(false, null);
    myToolWindow.setAutoHide(false);//w w  w  . j a v a2  s .c o  m

    // Add a listener so we only update the preview when it's visible
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject))
            .addToolWindowManagerListener(new ToolWindowManagerAdapter() {
                @Override
                public void stateChanged() {
                    if (myProject.isDisposed()) {
                        return;
                    }

                    final ToolWindow window = ToolWindowManager.getInstance(myProject)
                            .getToolWindow(TOOL_WINDOW_ID);
                    if (window != null && window.isAvailable()) {
                        final boolean visible = window.isVisible();
                        AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible);

                        if (visible && !myIsToolWindowVisible) {
                            updatePreview();
                        }
                        myIsToolWindowVisible = visible;
                    }
                }
            });
}

From source file:com.android.tools.idea.gradle.structure.configurables.android.dependencies.module.ResolvedDependenciesPanel.java

License:Apache License

public ResolvedDependenciesPanel(@NotNull PsAndroidModule module, @NotNull PsContext context,
        @NotNull DependencySelection dependencySelection) {
    this("Resolved Dependencies", module, context, dependencySelection, ToolWindowAnchor.RIGHT);
}

From source file:com.android.tools.idea.gradle.structure.configurables.android.dependencies.module.TargetArtifactsPanel.java

License:Apache License

public TargetArtifactsPanel(@NotNull PsAndroidModule module, @NotNull PsContext context) {
    super("Target Artifacts", AndroidIcons.Variant, ToolWindowAnchor.RIGHT);
    myContext = context;/*  w  w  w .j a v  a  2 s  .  c  o m*/

    DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    myTree = new Tree(treeModel) {
        @Override
        protected void processMouseEvent(MouseEvent e) {
            int id = e.getID();
            if (id == MOUSE_PRESSED) {
                ModuleDependencyNode node = myHyperlinkSupport.getIfHyperlink(e);
                if (node != null) {
                    PsModuleAndroidDependency moduleDependency = node.getFirstModel();
                    String name = moduleDependency.getName();
                    myContext.setSelectedModule(name, TargetArtifactsPanel.this);
                    // Do not call super, to avoid selecting the 'module' node when clicking a hyperlink.
                    return;
                }
            }
            super.processMouseEvent(e);
        }
    };

    setHeaderActions();
    getHeader().setPreferredFocusedComponent(myTree);

    myTreeBuilder = new TargetArtifactsTreeBuilder(module, myTree, treeModel);
    JScrollPane scrollPane = setUp(myTreeBuilder);
    add(scrollPane, BorderLayout.CENTER);

    myHyperlinkSupport = new NodeHyperlinkSupport<>(myTree, ModuleDependencyNode.class, myContext, false);
}

From source file:com.android.tools.idea.gradle.structure.configurables.android.dependencies.project.TargetModulesPanel.java

License:Apache License

TargetModulesPanel(@NotNull PsContext context) {
    super("Target Modules", AllIcons.Nodes.ModuleGroup, ToolWindowAnchor.RIGHT);
    myContext = context;/*from   www.j a  va 2  s.c  o  m*/

    DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    myTree = new Tree(treeModel) {
        @Override
        protected void processMouseEvent(MouseEvent e) {
            int id = e.getID();
            if (id == MOUSE_PRESSED) {
                TargetAndroidModuleNode node = myHyperlinkSupport.getIfHyperlink(e);
                if (node != null) {
                    PsAndroidModule module = node.getFirstModel();
                    String name = module.getName();
                    myContext.setSelectedModule(name, TargetModulesPanel.this);
                    // Do not call super, to avoid selecting the 'module' node when clicking a hyperlink.
                    return;
                }
            }
            super.processMouseEvent(e);
        }
    };

    myTree.addMouseListener(new PopupHandler() {
        @Override
        public void invokePopup(Component comp, int x, int y) {
            popupInvoked(x, y);
        }
    });

    setHeaderActions();
    getHeader().setPreferredFocusedComponent(myTree);

    myTreeBuilder = new TargetModulesTreeBuilder(myTree, treeModel);

    JScrollPane scrollPane = setUp(myTreeBuilder);
    add(scrollPane, BorderLayout.CENTER);

    myHyperlinkSupport = new NodeHyperlinkSupport<>(myTree, TargetAndroidModuleNode.class, myContext, false);
}

From source file:com.android.tools.idea.profiling.view.AnalysisResultsManager.java

License:Apache License

@Override
protected ToolWindowAnchor getAnchor() {
    return ToolWindowAnchor.RIGHT;
}

From source file:com.android.tools.idea.uibuilder.editor.NlPreviewManager.java

License:Apache License

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/* w w  w  .j  a  va  2  s  .c  o m*/
                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());
}