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);
}
}
}
});
});
}
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;
}
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;
}
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;
}
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;
}
Aggregations