com.intellij.ui.content.MessageView Java Examples

The following examples show how to use com.intellij.ui.content.MessageView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterConsoles.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Shows a process's output on the appropriate console. (Asynchronous.)
 *
 * @param module if not null, show in this module's console.
 */
public static void displayProcessLater(@NotNull OSProcessHandler process,
                                       @NotNull Project project,
                                       @Nullable Module module,
                                       @NotNull Runnable onReady) {

  // Getting a MessageView has to happen on the UI thread.
  ApplicationManager.getApplication().invokeLater(() -> {
    final MessageView messageView = MessageView.SERVICE.getInstance(project);
    messageView.runWhenInitialized(() -> {
      final FlutterConsole console = findOrCreate(project, module);
      console.watchProcess(process);
      console.bringToFront();
      onReady.run();
    });
  });
}
 
Example #2
Source File: FlutterConsoles.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Shows a process's output on the appropriate console. (Asynchronous.)
 *
 * @param module if not null, show in this module's console.
 */
public static void displayProcessLater(@NotNull OSProcessHandler process,
                                       @NotNull Project project,
                                       @Nullable Module module,
                                       @NotNull Runnable onReady) {

  // Getting a MessageView has to happen on the UI thread.
  ApplicationManager.getApplication().invokeLater(() -> {
    final MessageView messageView = MessageView.SERVICE.getInstance(project);
    messageView.runWhenInitialized(() -> {
      final FlutterConsole console = findOrCreate(project, module);
      console.watchProcess(process);
      console.bringToFront();
      onReady.run();
    });
  });
}
 
Example #3
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void openMessagesView(final VcsErrorViewPanel errorTreeView, final String tabDisplayName) {
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      final MessageView messageView = MessageView.SERVICE.getInstance(myProject);
      messageView.runWhenInitialized(new Runnable() {
        @Override
        public void run() {
          final Content content =
                  ContentFactory.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);
}
 
Example #4
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
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();
        }
      }
    }
  }
}
 
Example #5
Source File: ExecutionHelper.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void removeContents(@Nullable final Content notToRemove, @Nonnull final Project myProject, @Nonnull final String tabDisplayName) {
  MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
  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();
        }
      }
    }
  }
}
 
Example #6
Source File: FlutterConsoles.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void displayMessage(@NotNull Project project, @Nullable Module module, @NotNull String message, boolean clearContent) {
  // Getting a MessageView has to happen on the UI thread.
  ApplicationManager.getApplication().invokeLater(() -> {
    final MessageView messageView = MessageView.SERVICE.getInstance(project);
    messageView.runWhenInitialized(() -> {
      final FlutterConsole console = findOrCreate(project, module);
      if (clearContent) {
        console.view.clear();
      }
      console.view.print(message, ConsoleViewContentType.NORMAL_OUTPUT);
      console.bringToFront();
    });
  });
}
 
Example #7
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Moves this console to the end of the tool window's tab list, selects it, and shows the tool window.
 */
void bringToFront() {
  // Move the tab to be last and select it.
  final MessageView messageView = MessageView.SERVICE.getInstance(project);
  final ContentManager contentManager = messageView.getContentManager();
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  // Show the panel.
  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
  if (toolWindow != null) {
    toolWindow.activate(null, true);
  }
}
 
Example #8
Source File: FlutterConsoles.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void displayMessage(@NotNull Project project, @Nullable Module module, @NotNull String message, boolean clearContent) {
  // Getting a MessageView has to happen on the UI thread.
  ApplicationManager.getApplication().invokeLater(() -> {
    final MessageView messageView = MessageView.SERVICE.getInstance(project);
    messageView.runWhenInitialized(() -> {
      final FlutterConsole console = findOrCreate(project, module);
      if (clearContent) {
        console.view.clear();
      }
      console.view.print(message, ConsoleViewContentType.NORMAL_OUTPUT);
      console.bringToFront();
    });
  });
}
 
Example #9
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Moves this console to the end of the tool window's tab list, selects it, and shows the tool window.
 */
void bringToFront() {
  // Move the tab to be last and select it.
  final MessageView messageView = MessageView.SERVICE.getInstance(project);
  final ContentManager contentManager = messageView.getContentManager();
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  // Show the panel.
  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
  if (toolWindow != null) {
    toolWindow.activate(null, true);
  }
}
 
Example #10
Source File: ExternalSystemNotificationManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private Content findContent(@Nonnull Pair<NotificationSource, ProjectSystemId> contentIdPair, @Nonnull String contentDisplayName) {
  Content targetContent = null;
  final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
  for (Content content : messageView.getContentManager().getContents()) {
    if (contentIdPair.equals(content.getUserData(CONTENT_ID_KEY))
        && StringUtil.equals(content.getDisplayName(), contentDisplayName) && !content.isPinned()) {
      targetContent = content;
    }
  }
  return targetContent;
}
 
Example #11
Source File: TestErrorViewAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void openView(Project project, JComponent component) {
  final MessageView messageView = MessageView.SERVICE.getInstance(project);
  final Content content = ContentFactory.getInstance().createContent(component, getContentName(), true);
  messageView.getContentManager().addContent(content);
  messageView.getContentManager().setSelectedContent(content);
  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
  if (toolWindow != null) {
    toolWindow.activate(null);
  }
}
 
Example #12
Source File: NewErrorTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void close() {
  MessageView messageView = MessageView.SERVICE.getInstance(myProject);
  Content content = messageView.getContentManager().getContent(this);
  if (content != null) {
    messageView.getContentManager().removeContent(content, true);
  }
}
 
Example #13
Source File: ExecutionHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void openMessagesView(@Nonnull final ErrorViewPanel errorTreeView, @Nonnull final Project myProject, @Nonnull final String tabDisplayName) {
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
      final Content content = ContentFactory.getInstance().createContent(errorTreeView, tabDisplayName, true);
      messageView.getContentManager().addContent(content);
      Disposer.register(content, errorTreeView);
      messageView.getContentManager().setSelectedContent(content);
      removeContents(content, myProject, tabDisplayName);
    }
  }, "Open message view", null);
}
 
Example #14
Source File: Unity3dConsoleToolWindowService.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@RequiredUIAccess
@Nonnull
private NewErrorTreeViewPanel getOrInitPanel()
{
	if(myErrorPanel != null)
	{
		return myErrorPanel;
	}

	if(myToolwindowInit.compareAndSet(false, true))
	{
		MessageView messageView = MessageView.SERVICE.getInstance(myProject);
		messageView.runWhenInitialized(() ->
		{
			final ContentManager contentManager = messageView.getContentManager();
			Content[] contents = contentManager.getContents();
			Content content = ContainerUtil.find(contents, content1 -> content1.getUserData(ourViewKey) != null);

			MyErrorPanel errorTreeViewPanel = null;
			if(content == null)
			{
				errorTreeViewPanel = new MyErrorPanel(myProject);

				content = ContentFactory.getInstance().createContent(errorTreeViewPanel, "Editor", false);
				content.putUserData(ourViewKey, Boolean.TRUE);

				contentManager.addContent(content);
			}
			else
			{
				errorTreeViewPanel = (MyErrorPanel) content.getComponent();
			}

			contentManager.setSelectedContent(content, true);

			myErrorPanel = errorTreeViewPanel;
		});
	}

	return myErrorPanel;
}