mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Unify and improve notifications after Update Project and after Push
* Use standard notifications instead of toolwindow ones. * IDEA-171836 Don't auto-focus the Update Info tab: provide a link to focus it on demand instead. * Always attach the updated info after push (without focusing), otherwise it was required to seek through the Event Log to view updated files. * Keep the auto-focus functionality for other clients for compatibility: they require much more work to do to rewrite their notifications. * Mark showUpdateInfo nullable and fix NPEs in several places.
This commit is contained in:
@@ -22,7 +22,9 @@ import com.intellij.openapi.vcs.update.ActionInfo;
|
||||
import com.intellij.openapi.vcs.update.UpdateInfoTree;
|
||||
import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,6 +33,7 @@ public abstract class ProjectLevelVcsManagerEx extends ProjectLevelVcsManager {
|
||||
return (ProjectLevelVcsManagerEx) PeriodicalTasksCloser.getInstance().safeGetComponent(project, ProjectLevelVcsManager.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract ContentManager getContentManager();
|
||||
|
||||
@NotNull
|
||||
@@ -45,6 +48,8 @@ public abstract class ProjectLevelVcsManagerEx extends ProjectLevelVcsManager {
|
||||
|
||||
public abstract void notifyDirectoryMappingChanged();
|
||||
|
||||
@CalledInAwt
|
||||
@Nullable
|
||||
public abstract UpdateInfoTree showUpdateProjectInfo(UpdatedFiles updatedFiles,
|
||||
String displayActionName,
|
||||
ActionInfo actionInfo,
|
||||
|
||||
@@ -72,6 +72,7 @@ import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.vcs.ViewUpdateInfoNotification;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.DataConversionException;
|
||||
import org.jdom.Element;
|
||||
@@ -358,6 +359,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
AllVcses.getInstance(myProject).unregisterManually(vcs);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ContentManager getContentManager() {
|
||||
if (myContentManager == null) {
|
||||
@@ -483,9 +485,12 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
|
||||
@Override
|
||||
public void showProjectOperationInfo(final UpdatedFiles updatedFiles, String displayActionName) {
|
||||
showUpdateProjectInfo(updatedFiles, displayActionName, ActionInfo.STATUS, false);
|
||||
UpdateInfoTree tree = showUpdateProjectInfo(updatedFiles, displayActionName, ActionInfo.STATUS, false);
|
||||
if (tree != null) ViewUpdateInfoNotification.focusUpdateInfoTree(myProject, tree);
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
@Nullable
|
||||
@Override
|
||||
public UpdateInfoTree showUpdateProjectInfo(UpdatedFiles updatedFiles, String displayActionName, ActionInfo actionInfo, boolean canceled) {
|
||||
if (!myProject.isOpen() || myProject.isDisposed()) return null;
|
||||
@@ -494,8 +499,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
return null; // content manager is made null during dispose; flag is set later
|
||||
}
|
||||
final UpdateInfoTree updateInfoTree = new UpdateInfoTree(contentManager, myProject, updatedFiles, displayActionName, actionInfo);
|
||||
ContentUtilEx.addTabbedContent(contentManager, updateInfoTree, "Update Info", DateFormatUtil.formatDateTime(System.currentTimeMillis()), true, updateInfoTree);
|
||||
ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS).activate(null);
|
||||
ContentUtilEx.addTabbedContent(contentManager, updateInfoTree, "Update Info", DateFormatUtil.formatDateTime(System.currentTimeMillis()), false, updateInfoTree);
|
||||
updateInfoTree.expandRootChildren();
|
||||
return updateInfoTree;
|
||||
}
|
||||
|
||||
+28
-12
@@ -19,6 +19,8 @@ import com.intellij.history.Label;
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.history.LocalHistoryAction;
|
||||
import com.intellij.ide.errorTreeView.HotfixData;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -26,9 +28,7 @@ import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.actions.AbstractVcsAction;
|
||||
import com.intellij.openapi.vcs.actions.DescindingFilesFilter;
|
||||
@@ -38,13 +38,13 @@ import com.intellij.openapi.vcs.changes.VcsAnnotationRefresher;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.WaitForProgressToShow;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.ui.OptionsDialog;
|
||||
import com.intellij.vcs.ViewUpdateInfoNotification;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -53,6 +53,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.openapi.util.text.StringUtil.pluralize;
|
||||
import static com.intellij.openapi.util.text.StringUtil.toLowerCase;
|
||||
import static com.intellij.openapi.vcs.VcsNotifier.STANDARD_NOTIFICATION;
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
private final boolean myAlwaysVisible;
|
||||
private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.update.AbstractCommonUpdateAction");
|
||||
@@ -423,8 +428,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
private void appendGroup(final StringBuffer text, final FileGroup group) {
|
||||
final int s = group.getFiles().size();
|
||||
if (s > 0) {
|
||||
text.append("\n");
|
||||
text.append(s).append(" ").append(StringUtil.pluralize("File", s)).append(" ").append(group.getUpdateName());
|
||||
text.append(s).append(" ").append(pluralize("File", s)).append(" ").append(toLowerCase(group.getUpdateName())).append("<br/>");
|
||||
}
|
||||
|
||||
final List<FileGroup> list = group.getChildren();
|
||||
@@ -502,24 +506,37 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
|
||||
final boolean noMerged = myUpdatedFiles.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID).isEmpty();
|
||||
if (myUpdatedFiles.isEmpty() && myGroupedExceptions.isEmpty()) {
|
||||
NotificationType type;
|
||||
String content;
|
||||
if (someSessionWasCancelled) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, VcsBundle.message("progress.text.updating.canceled"), MessageType.WARNING);
|
||||
content = VcsBundle.message("progress.text.updating.canceled");
|
||||
type = NotificationType.WARNING;
|
||||
}
|
||||
else {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, getAllFilesAreUpToDateMessage(myRoots), MessageType.INFO);
|
||||
content = getAllFilesAreUpToDateMessage(myRoots);
|
||||
type = NotificationType.INFORMATION;
|
||||
}
|
||||
VcsNotifier.getInstance(myProject).notify(STANDARD_NOTIFICATION.createNotification(content, type));
|
||||
}
|
||||
else if (!myUpdatedFiles.isEmpty()) {
|
||||
final UpdateInfoTree tree = showUpdateTree(continueChainFinal && updateSuccess && noMerged, someSessionWasCancelled);
|
||||
final CommittedChangesCache cache = CommittedChangesCache.getInstance(myProject);
|
||||
cache.processUpdatedFiles(myUpdatedFiles, incomingChangeLists -> tree.setChangeLists(incomingChangeLists));
|
||||
|
||||
NotificationType type;
|
||||
String title;
|
||||
if (someSessionWasCancelled) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, "VCS Update Incomplete" + prepareNotificationWithUpdateInfo(), MessageType.WARNING);
|
||||
title = "Project Partially Updated";
|
||||
type = NotificationType.WARNING;
|
||||
}
|
||||
else {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, "VCS Update Finished" + prepareNotificationWithUpdateInfo(), MessageType.INFO);
|
||||
title = "Project Updated";
|
||||
type = NotificationType.INFORMATION;
|
||||
}
|
||||
|
||||
Notification notification = STANDARD_NOTIFICATION.createNotification(title, prepareNotificationWithUpdateInfo(), type, null);
|
||||
notification.addAction(new ViewUpdateInfoNotification(myProject, tree, "View"));
|
||||
VcsNotifier.getInstance(myProject).notify(notification);
|
||||
}
|
||||
|
||||
ProjectManagerEx.getInstanceEx().unblockReloadingProjectOnExternalChanges();
|
||||
@@ -557,11 +574,10 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
RestoreUpdateTree restoreUpdateTree = RestoreUpdateTree.getInstance(myProject);
|
||||
restoreUpdateTree.registerUpdateInformation(myUpdatedFiles, myActionInfo);
|
||||
final String text = getTemplatePresentation().getText() + ((willBeContinued || (myUpdateNumber > 1)) ? ("#" + myUpdateNumber) : "");
|
||||
final UpdateInfoTree updateInfoTree = myProjectLevelVcsManager.showUpdateProjectInfo(myUpdatedFiles, text, myActionInfo, wasCanceled);
|
||||
|
||||
UpdateInfoTree updateInfoTree = notNull(myProjectLevelVcsManager.showUpdateProjectInfo(myUpdatedFiles, text, myActionInfo,
|
||||
wasCanceled));
|
||||
updateInfoTree.setBefore(myBefore);
|
||||
updateInfoTree.setAfter(myAfter);
|
||||
|
||||
updateInfoTree.setCanGroupByChangeList(canGroupByChangelist(myVcsToVirtualFiles.keySet()));
|
||||
return updateInfoTree;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.vcs;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||
import com.intellij.openapi.vcs.update.UpdateInfoTree;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.util.ContentUtilEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ViewUpdateInfoNotification extends NotificationAction {
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final UpdateInfoTree myTree;
|
||||
|
||||
public ViewUpdateInfoNotification(@NotNull Project project, @NotNull UpdateInfoTree updateInfoTree, @NotNull String actionName) {
|
||||
super(actionName);
|
||||
myProject = project;
|
||||
myTree = updateInfoTree;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
|
||||
focusUpdateInfoTree(myProject, myTree);
|
||||
}
|
||||
|
||||
public static void focusUpdateInfoTree(@NotNull Project project, @NotNull UpdateInfoTree updateInfoTree) {
|
||||
ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS).activate(() -> {
|
||||
ContentManager contentManager = ProjectLevelVcsManagerEx.getInstanceEx(project).getContentManager();
|
||||
if (contentManager != null) ContentUtilEx.selectContent(contentManager, updateInfoTree, true);
|
||||
}, true, true);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.junit.Assert
|
||||
import com.intellij.testFramework.UsefulTestCase.assertOrderedEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.picocontainer.MutablePicoContainer
|
||||
|
||||
inline fun <reified Int : Any, reified Impl : Int> overrideService(project: Project): Impl {
|
||||
@@ -39,13 +40,23 @@ inline fun <reified Int : Any, reified Impl : Int> overrideService(): Impl {
|
||||
return service<Int>() as Impl
|
||||
}
|
||||
|
||||
fun assertNotification(type: NotificationType, title: String, content: String, actual: Notification): Notification {
|
||||
Assert.assertEquals("Incorrect notification type: " + tos(actual), type, actual.type)
|
||||
Assert.assertEquals("Incorrect notification title: " + tos(actual), title, actual.title)
|
||||
Assert.assertEquals("Incorrect notification content: " + tos(actual), cleanupForAssertion(content), cleanupForAssertion(actual.content))
|
||||
fun assertNotification(type: NotificationType, title: String, content: String, actions: List<String>, actual: Notification): Notification {
|
||||
assertEquals("Incorrect notification type: " + tos(actual), type, actual.type)
|
||||
assertEquals("Incorrect notification title: " + tos(actual), title, actual.title)
|
||||
assertEquals("Incorrect notification content: " + tos(actual), cleanupForAssertion(content), cleanupForAssertion(actual.content))
|
||||
assertOrderedEquals("Incorrect notification actions", actions, actual.actions.map { it.templatePresentation.text })
|
||||
return actual
|
||||
}
|
||||
|
||||
fun assertNotification(type: NotificationType, title: String, content: String, actual: Notification) =
|
||||
assertNotification(type, title, content, listOf(), actual)
|
||||
|
||||
fun assertSuccessfulNotification(title: String, content: String, actual: Notification) =
|
||||
assertNotification(NotificationType.INFORMATION, title, content, actual)
|
||||
|
||||
fun assertSuccessfulNotification(title: String, content: String, actions: List<String>, actual: Notification) =
|
||||
assertNotification(NotificationType.INFORMATION, title, content, actions, actual)
|
||||
|
||||
fun cleanupForAssertion(content: String): String {
|
||||
val nobr = content.replace("<br/>", "\n").replace("<br>", "\n").replace("<hr/>", "\n")
|
||||
.replace(" ", " ").replace(" {2,}".toRegex(), " ")
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
import com.intellij.vcs.ViewUpdateInfoNotification;
|
||||
import git4idea.GitRevisionNumber;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.i18n.GitBundle;
|
||||
@@ -137,8 +138,11 @@ public class GitMergeUtil {
|
||||
GuiUtils.invokeLaterIfNeeded(() -> {
|
||||
ProjectLevelVcsManagerEx manager = (ProjectLevelVcsManagerEx)ProjectLevelVcsManager.getInstance(project);
|
||||
UpdateInfoTree tree = manager.showUpdateProjectInfo(files, actionName, actionInfo, false);
|
||||
tree.setBefore(beforeLabel);
|
||||
tree.setAfter(LocalHistory.getInstance().putSystemLabel(project, "After update"));
|
||||
if (tree != null) {
|
||||
tree.setBefore(beforeLabel);
|
||||
tree.setAfter(LocalHistory.getInstance().putSystemLabel(project, "After update"));
|
||||
ViewUpdateInfoNotification.focusUpdateInfoTree(project, tree);
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
|
||||
Collection<String> unmergedNames = files.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID).getFiles();
|
||||
|
||||
@@ -16,34 +16,33 @@
|
||||
package git4idea.push;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.history.Label;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||
import com.intellij.openapi.vcs.update.ActionInfo;
|
||||
import com.intellij.openapi.vcs.update.UpdateInfoTree;
|
||||
import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.ViewUpdateInfoNotification;
|
||||
import git4idea.branch.GitBranchUtil;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.update.GitUpdateResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.openapi.vcs.update.ActionInfo.UPDATE;
|
||||
|
||||
class GitPushResultNotification extends Notification {
|
||||
|
||||
public static final String VIEW_FILES_UPDATED_DURING_THE_PUSH = "<a href='UpdatedFiles'>View files updated during the push</a>";
|
||||
public static final String VIEW_FILES_UPDATED_DURING_THE_PUSH = "View files updated during the push";
|
||||
|
||||
public static final String UPDATE_WITH_RESOLVED_CONFLICTS = "push has been cancelled, because there were conflicts during update.<br/>" +
|
||||
"Check that conflicts were resolved correctly, and invoke push again.";
|
||||
@@ -57,9 +56,8 @@ class GitPushResultNotification extends Notification {
|
||||
public GitPushResultNotification(@NotNull String groupDisplayId,
|
||||
@NotNull String title,
|
||||
@NotNull String content,
|
||||
@NotNull NotificationType type,
|
||||
@Nullable NotificationListener listener) {
|
||||
super(groupDisplayId, title, content, type, listener);
|
||||
@NotNull NotificationType type) {
|
||||
super(groupDisplayId, title, content, type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -93,19 +91,24 @@ class GitPushResultNotification extends Notification {
|
||||
|
||||
String description = formDescription(pushResult.getResults(), multiRepoProject);
|
||||
|
||||
ViewUpdatedFilesNotificationListener listener = null;
|
||||
UpdatedFiles updatedFiles = pushResult.getUpdatedFiles();
|
||||
if (!updatedFiles.isEmpty()) {
|
||||
description += "<br/>" + VIEW_FILES_UPDATED_DURING_THE_PUSH;
|
||||
listener = new ViewUpdatedFilesNotificationListener(project, updatedFiles,
|
||||
pushResult.getBeforeUpdateLabel(), pushResult.getAfterUpdateLabel());
|
||||
}
|
||||
|
||||
NotificationGroup group = type == NotificationType.INFORMATION ?
|
||||
VcsNotifier.NOTIFICATION_GROUP_ID :
|
||||
VcsNotifier.STANDARD_NOTIFICATION :
|
||||
VcsNotifier.IMPORTANT_ERROR_NOTIFICATION;
|
||||
|
||||
return new GitPushResultNotification(group.getDisplayId(), title, description, type, listener);
|
||||
GitPushResultNotification notification = new GitPushResultNotification(group.getDisplayId(), title, description, type);
|
||||
|
||||
UpdatedFiles updatedFiles = pushResult.getUpdatedFiles();
|
||||
if (!updatedFiles.isEmpty()) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
UpdateInfoTree tree = ProjectLevelVcsManagerEx.getInstanceEx(project).showUpdateProjectInfo(updatedFiles, "Update", UPDATE, false);
|
||||
if (tree != null) {
|
||||
tree.setBefore(pushResult.getBeforeUpdateLabel());
|
||||
tree.setAfter(pushResult.getAfterUpdateLabel());
|
||||
notification.addAction(new ViewUpdateInfoNotification(project, tree, VIEW_FILES_UPDATED_DURING_THE_PUSH));
|
||||
}
|
||||
});
|
||||
}
|
||||
return notification;
|
||||
}
|
||||
|
||||
private static String formDescription(@NotNull Map<GitRepository, GitPushRepoResult> results, final boolean multiRepoProject) {
|
||||
@@ -210,37 +213,4 @@ class GitPushResultNotification extends Notification {
|
||||
return UPDATE_WITH_ERRORS;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ViewUpdatedFilesNotificationListener implements NotificationListener {
|
||||
|
||||
private final Project myProject;
|
||||
private final UpdatedFiles myUpdatedFiles;
|
||||
private final Label myBeforeUpdateLabel;
|
||||
private final Label myAfterUpdateLabel;
|
||||
|
||||
public ViewUpdatedFilesNotificationListener(@NotNull Project project, @NotNull UpdatedFiles updatedFiles,
|
||||
@Nullable Label beforeUpdate, @Nullable Label afterUpdate) {
|
||||
myProject = project;
|
||||
myUpdatedFiles = updatedFiles;
|
||||
myBeforeUpdateLabel = beforeUpdate;
|
||||
myAfterUpdateLabel = afterUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||
if (event.getDescription().equals("UpdatedFiles")) {
|
||||
ProjectLevelVcsManagerEx vcsManager = ProjectLevelVcsManagerEx.getInstanceEx(myProject);
|
||||
UpdateInfoTree tree = vcsManager.showUpdateProjectInfo(myUpdatedFiles, "Update", ActionInfo.UPDATE, false);
|
||||
tree.setBefore(myBeforeUpdateLabel);
|
||||
tree.setAfter(myAfterUpdateLabel);
|
||||
}
|
||||
else {
|
||||
BrowserUtil.browse(event.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.EdtTestUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.test.UtilsKt;
|
||||
import git4idea.GitLocalBranch;
|
||||
import git4idea.GitRemoteBranch;
|
||||
import git4idea.GitStandardRemoteBranch;
|
||||
@@ -95,10 +96,7 @@ public class GitPushResultNotificationTest extends GitPlatformTest {
|
||||
|
||||
public void test_success_with_update() {
|
||||
GitPushResultNotification notification = notification(singleResult(SUCCESS, "master", "origin/master", 2, GitUpdateResult.SUCCESS));
|
||||
assertNotification(NotificationType.INFORMATION, "Push successful",
|
||||
"Pushed 2 commits to origin/master<br/>" +
|
||||
GitPushResultNotification.VIEW_FILES_UPDATED_DURING_THE_PUSH, notification);
|
||||
|
||||
UtilsKt.assertSuccessfulNotification("Push successful", "Pushed 2 commits to origin/master", notification);
|
||||
}
|
||||
|
||||
public void test_success_and_resolved_conflicts() {
|
||||
@@ -110,8 +108,8 @@ public class GitPushResultNotificationTest extends GitPlatformTest {
|
||||
assertNotification(NotificationType.WARNING, "Push partially rejected",
|
||||
"ultimate: pushed 1 commit to origin/master<br/>" +
|
||||
"community: " + GitPushResultNotification.UPDATE_WITH_RESOLVED_CONFLICTS + "<br/>" +
|
||||
"contrib: " + GitPushResultNotification.UPDATE_WITH_RESOLVED_CONFLICTS + "<br/>" +
|
||||
GitPushResultNotification.VIEW_FILES_UPDATED_DURING_THE_PUSH, notification);
|
||||
"contrib: " + GitPushResultNotification.UPDATE_WITH_RESOLVED_CONFLICTS,
|
||||
notification);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vcs.update.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.ViewUpdateInfoNotification;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -50,6 +51,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.vcs.update.ActionInfo.INTEGRATE;
|
||||
|
||||
public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
private final ProjectLevelVcsManagerEx myProjectLevelVcsManager;
|
||||
private final SvnVcs myVcs;
|
||||
@@ -237,8 +240,9 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
private void showUpdateTree() {
|
||||
RestoreUpdateTree restoreUpdateTree = RestoreUpdateTree.getInstance(myProject);
|
||||
// action info is actually NOT used
|
||||
restoreUpdateTree.registerUpdateInformation(myAccumulatedFiles.getUpdatedFiles(), ActionInfo.INTEGRATE);
|
||||
myProjectLevelVcsManager.showUpdateProjectInfo(myAccumulatedFiles.getUpdatedFiles(), myTitle, ActionInfo.INTEGRATE, false);
|
||||
restoreUpdateTree.registerUpdateInformation(myAccumulatedFiles.getUpdatedFiles(), INTEGRATE);
|
||||
UpdateInfoTree tree = myProjectLevelVcsManager.showUpdateProjectInfo(myAccumulatedFiles.getUpdatedFiles(), myTitle, INTEGRATE, false);
|
||||
if (tree != null) ViewUpdateInfoNotification.focusUpdateInfoTree(myProject, tree);
|
||||
}
|
||||
|
||||
private void stepToNextChangeList() {
|
||||
|
||||
Reference in New Issue
Block a user