Search in sources :

Example 6 with ToolWindowManagerAdapter

use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project intellij-community by JetBrains.

the class MavenProjectsNavigator method initToolWindow.

private void initToolWindow() {
    initTree();
    JPanel panel = new MavenProjectsNavigatorPanel(myProject, myTree);
    AnAction removeAction = EmptyAction.wrap(ActionManager.getInstance().getAction("Maven.RemoveRunConfiguration"));
    removeAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree, myProject);
    AnAction editSource = EmptyAction.wrap(ActionManager.getInstance().getAction("Maven.EditRunConfiguration"));
    editSource.registerCustomShortcutSet(CommonShortcuts.getEditSource(), myTree, myProject);
    final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
    myToolWindow = (ToolWindowEx) manager.registerToolWindow(TOOL_WINDOW_ID, false, ToolWindowAnchor.RIGHT, myProject, true);
    myToolWindow.setIcon(MavenIcons.ToolWindowMaven);
    final ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
    final Content content = contentFactory.createContent(panel, "", false);
    ContentManager contentManager = myToolWindow.getContentManager();
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, false);
    final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {

        boolean wasVisible = false;

        @Override
        public void stateChanged() {
            if (myToolWindow.isDisposed())
                return;
            boolean visible = myToolWindow.isVisible();
            if (!visible || wasVisible) {
                return;
            }
            scheduleStructureUpdate();
            wasVisible = true;
        }
    };
    manager.addToolWindowManagerListener(listener, myProject);
    ActionManager actionManager = ActionManager.getInstance();
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(actionManager.getAction("Maven.GroupProjects"));
    group.add(actionManager.getAction("Maven.ShowIgnored"));
    group.add(actionManager.getAction("Maven.ShowBasicPhasesOnly"));
    group.add(actionManager.getAction("Maven.AlwaysShowArtifactId"));
    group.add(actionManager.getAction("Maven.ShowVersions"));
    myToolWindow.setAdditionalGearActions(group);
}
Also used : Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ContentFactory(com.intellij.ui.content.ContentFactory) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 7 with ToolWindowManagerAdapter

use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project intellij-community by JetBrains.

the class PyDataView method init.

public void init(@NotNull ToolWindow toolWindow) {
    myTabs = new PyDataViewTabs(myProject);
    myTabs.setPopupGroup(new DefaultActionGroup(new ColoredAction()), ActionPlaces.UNKNOWN, true);
    myTabs.setTabDraggingEnabled(true);
    final Content content = ContentFactory.SERVICE.getInstance().createContent(myTabs, "", false);
    content.setCloseable(true);
    toolWindow.getContentManager().addContent(content);
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        @Override
        public void stateChanged() {
            ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(DATA_VIEWER_ID);
            if (window == null) {
                return;
            }
            if (toolWindow.isAvailable() && toolWindow.getType().equals(ToolWindowType.FLOATING) && !toolWindow.isVisible()) {
                toolWindow.setShowStripeButton(false);
                myTabs.removeAllTabs();
            }
        }
    });
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 8 with ToolWindowManagerAdapter

use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project android by JetBrains.

the class AndroidToolWindowFactory method createLogcatContent.

private static Content createLogcatContent(RunnerLayoutUi layoutUi, final Project project, DeviceContext deviceContext) {
    final AndroidLogcatView logcatView = new AndroidLogcatView(project, deviceContext) {

        @Override
        protected boolean isActive() {
            ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
            return window.isVisible();
        }
    };
    ToolWindowManagerEx.getInstanceEx(project).addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        boolean myToolWindowVisible;

        @Override
        public void stateChanged() {
            ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
            if (window != null) {
                boolean visible = window.isVisible();
                if (visible != myToolWindowVisible) {
                    myToolWindowVisible = visible;
                    logcatView.activate();
                    if (visible) {
                        ConsoleView console = logcatView.getLogConsole().getConsole();
                        if (console != null) {
                            checkFacetAndSdk(project, console);
                        }
                    }
                }
            }
        }
    });
    final MessageBusConnection connection = project.getMessageBus().connect(project);
    connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyAndroidPlatformListener(logcatView));
    JPanel logcatContentPanel = logcatView.getContentPanel();
    final Content logcatContent = layoutUi.createContent(ANDROID_LOGCAT_CONTENT_ID, logcatContentPanel, "logcat", AndroidIcons.Ddms.Logcat, null);
    logcatContent.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView);
    logcatContent.setDisposer(logcatView);
    logcatContent.setCloseable(false);
    logcatContent.setPreferredFocusableComponent(logcatContentPanel);
    return logcatContent;
}
Also used : AndroidLogcatView(com.android.tools.idea.logcat.AndroidLogcatView) ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ConsoleView(com.intellij.execution.ui.ConsoleView) Content(com.intellij.ui.content.Content) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)

Example 9 with ToolWindowManagerAdapter

use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project intellij-plugins by JetBrains.

the class MxmlPreviewToolWindowManager method initToolWindow.

private void initToolWindow() {
    toolWindowForm = new MxmlPreviewToolWindowForm();
    String toolWindowId = FlashUIDesignerBundle.message("mxml.preview.tool.window.title");
    toolWindow = ToolWindowManager.getInstance(project).registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, project, false);
    toolWindow.setIcon(PlatformIcons.UI_FORM_ICON);
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    toolWindowVisible = propertiesComponent.getBoolean(SETTINGS_TOOL_WINDOW_VISIBLE);
    if (toolWindowVisible) {
        toolWindow.show(null);
    } else {
        toolWindow.hide(null);
    }
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(project)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        @Override
        public void stateChanged() {
            if (project.isDisposed() || toolWindow == null || !toolWindow.isAvailable()) {
                return;
            }
            final boolean currentVisible = toolWindow.isVisible();
            if (currentVisible == toolWindowVisible) {
                return;
            }
            toolWindowVisible = currentVisible;
            PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
            if (currentVisible) {
                propertiesComponent.setValue(SETTINGS_TOOL_WINDOW_VISIBLE, true);
                if (!lastPreviewChecked) {
                    lastPreviewChecked = true;
                    if (checkLastImage()) {
                        return;
                    }
                }
                render(true, false);
            } else {
                propertiesComponent.unsetValue(SETTINGS_TOOL_WINDOW_VISIBLE);
            }
        }
    });
    JPanel contentPanel = toolWindowForm.getContentPanel();
    ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(contentPanel, null, false);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(contentPanel);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
    MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(project);
    connection.subscribe(DesignerApplicationManager.MESSAGE_TOPIC, new DocumentRenderedListener() {

        private boolean isApplicable(DocumentFactoryManager.DocumentInfo info) {
            return toolWindowVisible && toolWindowForm.getFile() != null && info.equals(DocumentFactoryManager.getInstance().getNullableInfo(toolWindowForm.getFile()));
        }

        @Override
        public void documentRendered(DocumentFactoryManager.DocumentInfo info) {
            if (isApplicable(info) && !toolWindowForm.waitingForGetDocument) {
                UIUtil.invokeLaterIfNeeded(() -> render(false, false));
            }
        }

        @Override
        public void errorOccurred() {
        }
    });
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ContentManager(com.intellij.ui.content.ContentManager) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx) Content(com.intellij.ui.content.Content) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 10 with ToolWindowManagerAdapter

use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project android by JetBrains.

the class NlAbstractWindowManager method initToolWindow.

protected void initToolWindow(@NotNull final String id, @NotNull Icon icon) {
    myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(id, false, getAnchor(), myProject, true);
    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();
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) LightToolWindow(com.intellij.designer.LightToolWindow) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowAnchor(com.intellij.openapi.wm.ToolWindowAnchor) ToolWindowType(com.intellij.openapi.wm.ToolWindowType) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Aggregations

ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)10 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)9 ToolWindow (com.intellij.openapi.wm.ToolWindow)5 Content (com.intellij.ui.content.Content)5 ContentManager (com.intellij.ui.content.ContentManager)3 Disposable (com.intellij.openapi.Disposable)2 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)2 AndroidLogcatView (com.android.tools.idea.logcat.AndroidLogcatView)1 LightToolWindow (com.intellij.designer.LightToolWindow)1 com.intellij.execution (com.intellij.execution)1 RunDashboardManager (com.intellij.execution.dashboard.RunDashboardManager)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 TreeState (com.intellij.ide.util.treeView.TreeState)1 NotificationGroup (com.intellij.notification.NotificationGroup)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ModalityState (com.intellij.openapi.application.ModalityState)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)1