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

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

Introduction

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

Prototype

ToolWindowType getType();

Source Link

Usage

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

License:Apache License

protected void initToolWindow(final @NotNull String id, @NotNull Icon icon) {
    myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(id, false, getAnchor(),
            myProject, true);/*from  w  w  w.j  a va 2 s .  c  o  m*/
    myToolWindow.setIcon(icon);
    myToolWindow.setAvailable(false, null);
    myToolWindow.setAutoHide(false);
    myPreviousWindowType = myToolWindow.getType();
    myPreviousWindowAnchor = getEditorMode();
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject))
            .addToolWindowManagerListener(new ToolWindowManagerAdapter() {
                @Override
                public void stateChanged() {
                    if (myProject.isDisposed()) {
                        return;
                    }

                    final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(id);
                    ToolWindowType newWindowType = window.getType();
                    ToolWindowAnchor newWindowAnchor = getEditorMode();

                    if (newWindowType != myPreviousWindowType || newWindowAnchor != myPreviousWindowAnchor) {
                        // TODO: Report the window docking state
                        NlUsageTrackerManager.getInstance(myDesignSurface)
                                .logAction(LayoutEditorEvent.LayoutEditorEventType.UNKNOWN_EVENT_TYPE);

                        myPreviousWindowType = newWindowType;
                        myPreviousWindowAnchor = newWindowAnchor;
                    }
                }
            }, myProject);
    initGearActions();
}

From source file:com.intellij.ide.actions.ResizeToolWindowAction.java

License:Apache License

@Override
public final void update(AnActionEvent e) {
    Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
    if (project == null) {
        setDisabled(e);//ww  w .  ja  v  a 2s. c  o  m
        return;
    }

    if (!myListenerInstalled) {
        myListenerInstalled = true;
        ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
            @Override
            public void projectClosed(Project project) {
                setDisabled(null);
            }
        });
    }

    Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (owner == null) {
        setDisabled(e);
        return;
    }

    final Window windowAncestor = SwingUtilities.getWindowAncestor(owner);
    if (!(windowAncestor instanceof IdeFrame) || windowAncestor instanceof IdeFrame.Child) {
        setDisabled(e);
        return;
    }

    ToolWindowManager mgr = ToolWindowManager.getInstance(project);

    ToolWindow window = myToolWindow;

    if (window != null || mgr.getActiveToolWindowId() != null) {
        if (window == null) {
            window = mgr.getToolWindow(mgr.getActiveToolWindowId());
        }

        if (window == null || !window.isAvailable() || !window.isVisible()
                || window.getType() == ToolWindowType.FLOATING || !window.isActive()) {
            setDisabled(e);
            return;
        }

        update(e, window, mgr);
        if (e.getPresentation().isEnabled()) {
            myLastWindow = window;
            myLastManager = mgr;
        } else {
            setDisabled(e);
        }
    } else {
        setDisabled(e);
    }
}

From source file:com.intellij.ide.actions.ToggleDockModeAction.java

License:Apache License

public void setSelected(AnActionEvent event, boolean flag) {
    Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;// w w  w . j av a  2 s  . c  om
    }
    ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    String id = windowManager.getActiveToolWindowId();
    if (id == null) {
        return;
    }
    ToolWindow toolWindow = windowManager.getToolWindow(id);
    ToolWindowType type = toolWindow.getType();
    if (ToolWindowType.DOCKED == type) {
        toolWindow.setType(ToolWindowType.SLIDING, null);
    } else if (ToolWindowType.SLIDING == type) {
        toolWindow.setType(ToolWindowType.DOCKED, null);
    }
}

From source file:com.intellij.ide.actions.ToggleDockModeAction.java

License:Apache License

public void update(AnActionEvent event) {
    super.update(event);
    Presentation presentation = event.getPresentation();
    Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        presentation.setEnabled(false);//from   w  w  w  .j a va  2 s  .co  m
        return;
    }
    ToolWindowManager mgr = ToolWindowManager.getInstance(project);
    String id = mgr.getActiveToolWindowId();
    if (id == null) {
        presentation.setEnabled(false);
        return;
    }
    ToolWindow toolWindow = mgr.getToolWindow(id);
    presentation.setEnabled(toolWindow.isAvailable() && ToolWindowType.FLOATING != toolWindow.getType());
}

From source file:com.intellij.ide.actions.TogglePinnedModeAction.java

License:Apache License

@Override
protected void update(ToolWindow window, Presentation presentation) {
    presentation.setEnabled(window.isAvailable() && ToolWindowType.SLIDING != window.getType());
}

From source file:com.intellij.platform.PlatformProjectOpenProcessor.java

License:Apache License

public static void openProjectToolWindow(final Project project) {
    StartupManager.getInstance(project).registerPostStartupActivity(new DumbAwareRunnable() {
        @Override//  w w  w .j av a 2 s. c o m
        public void run() {
            // ensure the dialog is shown after all startup activities are done
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    ApplicationManager.getApplication().invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            if (project.isDisposed())
                                return;
                            final ToolWindow toolWindow = ToolWindowManager.getInstance(project)
                                    .getToolWindow(ToolWindowId.PROJECT_VIEW);
                            if (toolWindow != null && toolWindow.getType() != ToolWindowType.SLIDING) {
                                toolWindow.activate(null);
                            }
                        }
                    }, ModalityState.NON_MODAL);
                }
            });
        }
    });
}