Search in sources :

Example 86 with ToolWindow

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

the class ExternalSystemNotificationManager method clearNotifications.

public void clearNotifications(@Nullable final String groupName, @NotNull final NotificationSource notificationSource, @NotNull final ProjectSystemId externalSystemId) {
    myMessageCounter.remove(groupName, notificationSource, externalSystemId);
    myUpdater.submit(() -> {
        if (myProject.isDisposed())
            return;
        for (Iterator<Notification> iterator = myNotifications.iterator(); iterator.hasNext(); ) {
            Notification notification = iterator.next();
            if (groupName == null || groupName.equals(notification.getGroupId())) {
                notification.expire();
                iterator.remove();
            }
        }
        final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
        if (toolWindow == null)
            return;
        final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
        final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
        UIUtil.invokeLaterIfNeeded(() -> {
            if (myProject.isDisposed())
                return;
            for (Content content : messageView.getContentManager().getContents()) {
                if (!content.isPinned() && contentIdPair.equals(content.getUserData(CONTENT_ID_KEY))) {
                    if (groupName == null) {
                        messageView.getContentManager().removeContent(content, true);
                    } else {
                        assert content.getComponent() instanceof NewEditableErrorTreeViewPanel;
                        NewEditableErrorTreeViewPanel errorTreeView = (NewEditableErrorTreeViewPanel) content.getComponent();
                        ErrorViewStructure errorViewStructure = errorTreeView.getErrorViewStructure();
                        errorViewStructure.removeGroup(groupName);
                    }
                }
            }
        });
    });
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Notification(com.intellij.notification.Notification)

Example 87 with ToolWindow

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

the class ExternalSystemNotificationManager method prepareMessagesView.

@NotNull
public NewErrorTreeViewPanel prepareMessagesView(@NotNull final ProjectSystemId externalSystemId, @NotNull final NotificationSource notificationSource, boolean activateView) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final NewErrorTreeViewPanel errorTreeView;
    final String contentDisplayName = getContentDisplayName(notificationSource, externalSystemId);
    final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
    Content targetContent = findContent(contentIdPair, contentDisplayName);
    final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
    if (targetContent == null || !contentIdPair.equals(targetContent.getUserData(CONTENT_ID_KEY))) {
        errorTreeView = new NewEditableErrorTreeViewPanel(myProject, null, true, true, null);
        targetContent = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, contentDisplayName, true);
        targetContent.putUserData(CONTENT_ID_KEY, contentIdPair);
        messageView.getContentManager().addContent(targetContent);
        Disposer.register(targetContent, errorTreeView);
    } else {
        assert targetContent.getComponent() instanceof NewEditableErrorTreeViewPanel;
        errorTreeView = (NewEditableErrorTreeViewPanel) targetContent.getComponent();
    }
    messageView.getContentManager().setSelectedContent(targetContent);
    final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
    if (activateView && tw != null && !tw.isActive()) {
        tw.activate(null, false);
    }
    return errorTreeView;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) NotNull(org.jetbrains.annotations.NotNull)

Example 88 with ToolWindow

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

the class FavoritesViewSelectInTarget method select.

private static ActionCallback select(@NotNull Project project, Object toSelect, VirtualFile virtualFile, boolean requestFocus) {
    final ActionCallback result = new ActionCallback();
    ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    final ToolWindow favoritesToolWindow = windowManager.getToolWindow(ToolWindowId.FAVORITES_VIEW);
    if (favoritesToolWindow != null) {
        final Runnable runnable = () -> {
            final FavoritesTreeViewPanel panel = UIUtil.findComponentOfType(favoritesToolWindow.getComponent(), FavoritesTreeViewPanel.class);
            if (panel != null) {
                panel.selectElement(toSelect, virtualFile, requestFocus);
                result.setDone();
            }
        };
        if (requestFocus) {
            favoritesToolWindow.activate(runnable, false);
        } else {
            favoritesToolWindow.show(runnable);
        }
    }
    return result;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ActionCallback(com.intellij.openapi.util.ActionCallback) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager)

Example 89 with ToolWindow

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

the class QuickDocUtil method getActiveDocComponent.

@Nullable
public static DocumentationComponent getActiveDocComponent(@NotNull Project project) {
    DocumentationManager documentationManager = DocumentationManager.getInstance(project);
    DocumentationComponent component;
    JBPopup hint = documentationManager.getDocInfoHint();
    if (hint != null) {
        component = (DocumentationComponent) ((AbstractPopup) hint).getComponent();
    } else if (documentationManager.hasActiveDockedDocWindow()) {
        ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION);
        Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent();
        component = selectedContent == null ? null : (DocumentationComponent) selectedContent.getComponent();
    } else {
        component = null;
    }
    return component;
}
Also used : AbstractPopup(com.intellij.ui.popup.AbstractPopup) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) JBPopup(com.intellij.openapi.ui.popup.JBPopup) Nullable(org.jetbrains.annotations.Nullable)

Example 90 with ToolWindow

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

the class ExecutionHelper method findRunningConsole.

public static Collection<RunContentDescriptor> findRunningConsole(@NotNull Project project, @NotNull NotNullFunction<RunContentDescriptor, Boolean> descriptorMatcher) {
    RunContentManager contentManager = ExecutionManager.getInstance(project).getContentManager();
    final RunContentDescriptor selectedContent = contentManager.getSelectedContent();
    if (selectedContent != null) {
        final ToolWindow toolWindow = contentManager.getToolWindowByDescriptor(selectedContent);
        if (toolWindow != null && toolWindow.isVisible()) {
            if (descriptorMatcher.fun(selectedContent)) {
                return Collections.singletonList(selectedContent);
            }
        }
    }
    final ArrayList<RunContentDescriptor> result = ContainerUtil.newArrayList();
    for (RunContentDescriptor runContentDescriptor : contentManager.getAllDescriptors()) {
        if (descriptorMatcher.fun(runContentDescriptor)) {
            result.add(runContentDescriptor);
        }
    }
    return result;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RunContentManager(com.intellij.execution.ui.RunContentManager)

Aggregations

ToolWindow (com.intellij.openapi.wm.ToolWindow)124 Content (com.intellij.ui.content.Content)37 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)34 Project (com.intellij.openapi.project.Project)21 ContentManager (com.intellij.ui.content.ContentManager)14 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)13 Nullable (org.jetbrains.annotations.Nullable)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ConsoleView (com.intellij.execution.ui.ConsoleView)5 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)5 NotNull (org.jetbrains.annotations.NotNull)5 RunContentManager (com.intellij.execution.ui.RunContentManager)4 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)3 ProcessEvent (com.intellij.execution.process.ProcessEvent)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 ProjectView (com.intellij.ide.projectView.ProjectView)3 Presentation (com.intellij.openapi.actionSystem.Presentation)3 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)3 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)3 ToolWindowEP (com.intellij.openapi.wm.ToolWindowEP)3