IDEA-164300 Improve Sync branch control notification

Change the setting name and notification text and switched to actions.
This commit is contained in:
Dmitriy Smirnov
2017-08-22 12:20:05 +03:00
parent b401ef2cf0
commit 0438c8611a
2 changed files with 13 additions and 17 deletions
@@ -21,7 +21,8 @@ import com.intellij.dvcs.repo.Repository;
import com.intellij.dvcs.ui.BranchActionGroupPopup;
import com.intellij.dvcs.ui.DvcsBundle;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationAction;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.DumbAware;
@@ -34,9 +35,10 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
import java.util.List;
import static com.intellij.openapi.vcs.VcsNotifier.STANDARD_NOTIFICATION;
public abstract class DvcsBranchPopup<Repo extends Repository> {
@NotNull protected final Project myProject;
@NotNull protected final AbstractRepositoryManager<Repo> myRepositoryManager;
@@ -88,23 +90,17 @@ public abstract class DvcsBranchPopup<Repo extends Repository> {
}
private void notifyAboutSyncedBranches() {
String description =
"You have several " + myVcs.getDisplayName() + " roots in the project and they all are checked out at the same branch. " +
"We've enabled synchronous branch control for the project. <br/>" +
"If you wish to control branches in different roots separately, " +
"you may <a href='settings'>disable</a> the setting.";
NotificationListener listener = new NotificationListener() {
Notification notification = STANDARD_NOTIFICATION.createNotification("Branch operations are executed on all roots.", "", NotificationType.INFORMATION, null);
notification.addAction(new NotificationAction("Disable...") {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, myVcs.getConfigurable().getDisplayName());
if (myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) {
notification.expire();
}
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, myVcs.getConfigurable().getDisplayName());
if (myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) {
notification.expire();
}
}
};
VcsNotifier.getInstance(myProject).notifyImportantInfo("Synchronous branch control enabled", description, listener);
});
VcsNotifier.getInstance(myProject).notify(notification);
}
@NotNull
@@ -19,6 +19,6 @@ commit.amend=Amend commit
commit.amend.tooltip=<html>Merge this commit with the previous one</html>
push.force.confirmation.text = You''re going to force push{0}. It may overwrite commits at the remote. Are you sure you want to proceed?
sync.setting=Control repositories &synchronously
sync.setting=Execute branch operations on all roots
sync.setting.description=If selected, you would be able to checkout, compare, delete and create new branches in all {0} \
roots with a single action. It will also affect behavior of the push dialog.