Search in sources :

Example 6 with MessageView

use of com.intellij.ui.content.MessageView in project intellij-community by JetBrains.

the class AbstractVcsHelperImpl method openMessagesView.

public void openMessagesView(final VcsErrorViewPanel errorTreeView, final String tabDisplayName) {
    CommandProcessor commandProcessor = CommandProcessor.getInstance();
    commandProcessor.executeCommand(myProject, new Runnable() {

        public void run() {
            final MessageView messageView = MessageView.SERVICE.getInstance(myProject);
            messageView.runWhenInitialized(new Runnable() {

                public void run() {
                    final Content content = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true);
                    messageView.getContentManager().addContent(content);
                    Disposer.register(content, errorTreeView);
                    messageView.getContentManager().setSelectedContent(content);
                    removeContents(content, tabDisplayName);
                    ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null);
                }
            });
        }
    }, VcsBundle.message("command.name.open.error.message.view"), null);
}
Also used : MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Example 7 with MessageView

use of com.intellij.ui.content.MessageView 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 8 with MessageView

use of com.intellij.ui.content.MessageView 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 9 with MessageView

use of com.intellij.ui.content.MessageView in project intellij-community by JetBrains.

the class AbstractVcsHelperImpl method removeContents.

protected void removeContents(Content notToRemove, final String tabDisplayName) {
    MessageView messageView = MessageView.SERVICE.getInstance(myProject);
    Content[] contents = messageView.getContentManager().getContents();
    for (Content content : contents) {
        LOG.assertTrue(content != null);
        if (content.isPinned())
            continue;
        if (tabDisplayName.equals(content.getDisplayName()) && content != notToRemove) {
            ErrorTreeView listErrorView = (ErrorTreeView) content.getComponent();
            if (listErrorView != null) {
                if (messageView.getContentManager().removeContent(content, true)) {
                    content.release();
                }
            }
        }
    }
}
Also used : MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) ErrorTreeView(com.intellij.util.ui.ErrorTreeView)

Example 10 with MessageView

use of com.intellij.ui.content.MessageView in project intellij-community by JetBrains.

the class MavenConsoleImpl method ensureAttachedToToolWindow.

private void ensureAttachedToToolWindow() {
    if (!isOpen.compareAndSet(false, true))
        return;
    MavenUtil.invokeLater(myProject, () -> {
        MessageView messageView = MessageView.SERVICE.getInstance(myProject);
        Content content = ContentFactory.SERVICE.getInstance().createContent(myConsoleView.getComponent(), myTitle, true);
        content.putUserData(CONSOLE_KEY, this);
        messageView.getContentManager().addContent(content);
        messageView.getContentManager().setSelectedContent(content);
        // remove unused tabs
        for (Content each : messageView.getContentManager().getContents()) {
            if (each.isPinned())
                continue;
            if (each == content)
                continue;
            MavenConsoleImpl console = each.getUserData(CONSOLE_KEY);
            if (console == null)
                continue;
            if (!myTitle.equals(console.myTitle))
                continue;
            if (console.isFinished()) {
                messageView.getContentManager().removeContent(each, true);
            }
        }
        ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
        if (!toolWindow.isActive()) {
            toolWindow.activate(null, false);
        }
    });
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content)

Aggregations

Content (com.intellij.ui.content.Content)10 MessageView (com.intellij.ui.content.MessageView)10 ToolWindow (com.intellij.openapi.wm.ToolWindow)4 CommandProcessor (com.intellij.openapi.command.CommandProcessor)2 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 ErrorTreeView (com.intellij.util.ui.ErrorTreeView)2 Notification (com.intellij.notification.Notification)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1