mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: do not send notifications if nothing was changed
This commit is contained in:
@@ -28,24 +28,32 @@ public class AddList implements ChangeListCommand {
|
||||
@Nullable private final Object myData;
|
||||
|
||||
private LocalChangeList myNewListCopy;
|
||||
private String myOldComment;
|
||||
|
||||
public AddList(@NotNull final String name, @Nullable final String comment, @Nullable Object data) {
|
||||
public AddList(@NotNull String name, @Nullable String comment, @Nullable Object data) {
|
||||
myName = name;
|
||||
myComment = comment;
|
||||
myData = data;
|
||||
}
|
||||
|
||||
public void apply(final ChangeListWorker worker) {
|
||||
if (! worker.findListByName(myName)) {
|
||||
myNewListCopy = worker.getCopyByName(myName);
|
||||
if (myNewListCopy != null) {
|
||||
myOldComment = worker.editComment(myName, myComment);
|
||||
}
|
||||
else {
|
||||
myNewListCopy = worker.addChangeList(myName, myComment, myData);
|
||||
} else {
|
||||
worker.editComment(myName, myComment);
|
||||
myNewListCopy = worker.getCopyByName(myName);
|
||||
myOldComment = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
|
||||
dispatcher.getMulticaster().changeListAdded(myNewListCopy);
|
||||
if (myOldComment != null) {
|
||||
dispatcher.getMulticaster().changeListCommentChanged(myNewListCopy, myOldComment);
|
||||
}
|
||||
else {
|
||||
dispatcher.getMulticaster().changeListAdded(myNewListCopy);
|
||||
}
|
||||
}
|
||||
|
||||
public LocalChangeList getNewListCopy() {
|
||||
|
||||
@@ -20,25 +20,29 @@ import com.intellij.openapi.vcs.changes.ChangeListListener;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListWorker;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EditComment implements ChangeListCommand {
|
||||
private final String myName;
|
||||
private final String myNewComment;
|
||||
|
||||
private String myOldComment;
|
||||
private LocalChangeList myListCopy;
|
||||
|
||||
public EditComment(final String name, final String newComment) {
|
||||
public EditComment(@NotNull String name, @Nullable String newComment) {
|
||||
myNewComment = newComment;
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public void apply(final ChangeListWorker worker) {
|
||||
myListCopy = worker.getCopyByName(myName);
|
||||
if (myListCopy != null) {
|
||||
myOldComment = worker.editComment(myName, myNewComment);
|
||||
if (Comparing.equal(myOldComment, myNewComment)) {
|
||||
myListCopy = null; // nothing changed, no notify
|
||||
}
|
||||
myOldComment = worker.editComment(myName, myNewComment);
|
||||
|
||||
if (myOldComment != null && !Comparing.equal(myOldComment, myNewComment)) {
|
||||
myListCopy = worker.getCopyByName(myName);
|
||||
}
|
||||
else {
|
||||
myListCopy = null; // nothing changed, no notify
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,28 +22,25 @@ import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EditName implements ChangeListCommand {
|
||||
@NotNull
|
||||
private final String myFromName;
|
||||
@NotNull
|
||||
private final String myToName;
|
||||
@NotNull private final String myFromName;
|
||||
@NotNull private final String myToName;
|
||||
|
||||
private boolean myResult;
|
||||
private LocalChangeList myListCopy;
|
||||
|
||||
public EditName(@NotNull final String fromName, @NotNull final String toName) {
|
||||
public EditName(@NotNull String fromName, @NotNull String toName) {
|
||||
myFromName = fromName;
|
||||
myToName = toName;
|
||||
}
|
||||
|
||||
public void apply(final ChangeListWorker worker) {
|
||||
final LocalChangeList fromList = worker.getCopyByName(myFromName);
|
||||
if (fromList != null && (! fromList.isReadOnly())) {
|
||||
myResult = worker.editName(myFromName, myToName);
|
||||
myListCopy = worker.getCopyByName(myToName);
|
||||
}
|
||||
myResult = worker.editName(myFromName, myToName);
|
||||
|
||||
myListCopy = worker.getCopyByName(myToName);
|
||||
}
|
||||
|
||||
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
|
||||
if (myListCopy != null && (! myListCopy.isReadOnly())) {
|
||||
if (myListCopy != null && myResult) {
|
||||
dispatcher.getMulticaster().changeListRenamed(myListCopy, myFromName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,23 +27,25 @@ import java.util.Collection;
|
||||
public class MoveChanges implements ChangeListCommand {
|
||||
private final String myName;
|
||||
private final Change[] myChanges;
|
||||
private MultiMap<LocalChangeList,Change> myMovedFrom;
|
||||
|
||||
private MultiMap<LocalChangeList, Change> myMovedFrom;
|
||||
private LocalChangeList myListCopy;
|
||||
|
||||
public MoveChanges(final String name, final Change[] changes) {
|
||||
public MoveChanges(String name, Change[] changes) {
|
||||
myName = name;
|
||||
myChanges = changes;
|
||||
}
|
||||
|
||||
public void apply(final ChangeListWorker worker) {
|
||||
myMovedFrom = worker.moveChangesTo(myName, myChanges);
|
||||
|
||||
myListCopy = worker.getCopyByName(myName);
|
||||
}
|
||||
|
||||
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
|
||||
if ((myMovedFrom != null) && (myListCopy != null)) {
|
||||
for(LocalChangeList fromList: myMovedFrom.keySet()) {
|
||||
final Collection<Change> changesInList = myMovedFrom.get(fromList);
|
||||
if (myMovedFrom != null && myListCopy != null) {
|
||||
for (LocalChangeList fromList : myMovedFrom.keySet()) {
|
||||
Collection<Change> changesInList = myMovedFrom.get(fromList);
|
||||
dispatcher.getMulticaster().changesMoved(changesInList, fromList, myListCopy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.util.EventDispatcher;
|
||||
public class RemoveList implements ChangeListCommand {
|
||||
private final String myName;
|
||||
private boolean myRemoved;
|
||||
|
||||
private LocalChangeList myListCopy;
|
||||
private LocalChangeList myDefaultListCopy;
|
||||
|
||||
@@ -37,8 +38,8 @@ public class RemoveList implements ChangeListCommand {
|
||||
}
|
||||
|
||||
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
|
||||
if (myRemoved) {
|
||||
final ChangeListListener multicaster = dispatcher.getMulticaster();
|
||||
if (myListCopy != null && myRemoved ) {
|
||||
ChangeListListener multicaster = dispatcher.getMulticaster();
|
||||
multicaster.changesMoved(myListCopy.getChanges(), myListCopy, myDefaultListCopy);
|
||||
multicaster.changeListRemoved(myListCopy);
|
||||
}
|
||||
|
||||
@@ -19,25 +19,37 @@ import com.intellij.openapi.vcs.changes.ChangeListListener;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListWorker;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SetDefault implements ChangeListCommand {
|
||||
private final String myNewDefaultName;
|
||||
|
||||
private String myPrevious;
|
||||
private LocalChangeList myOldDefaultListCopy;
|
||||
private LocalChangeList myNewDefaultListCopy;
|
||||
|
||||
public SetDefault(final String newDefaultName) {
|
||||
public SetDefault(@Nullable String newDefaultName) {
|
||||
myNewDefaultName = newDefaultName;
|
||||
}
|
||||
|
||||
public void apply(final ChangeListWorker worker) {
|
||||
public void apply(ChangeListWorker worker) {
|
||||
LocalChangeList list = worker.getCopyByName(myNewDefaultName);
|
||||
if (list == null || list.isDefault()) {
|
||||
myOldDefaultListCopy = null;
|
||||
myPrevious = null;
|
||||
myNewDefaultListCopy = null;
|
||||
return;
|
||||
}
|
||||
|
||||
myOldDefaultListCopy = worker.getDefaultListCopy();
|
||||
myPrevious = worker.setDefault(myNewDefaultName);
|
||||
myNewDefaultListCopy = worker.getDefaultListCopy();
|
||||
}
|
||||
|
||||
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
|
||||
dispatcher.getMulticaster().defaultListChanged(myOldDefaultListCopy, myNewDefaultListCopy);
|
||||
if (myPrevious != null) {
|
||||
dispatcher.getMulticaster().defaultListChanged(myOldDefaultListCopy, myNewDefaultListCopy);
|
||||
}
|
||||
}
|
||||
|
||||
public String getPrevious() {
|
||||
|
||||
@@ -23,26 +23,25 @@ import com.intellij.util.EventDispatcher;
|
||||
public class SetReadOnly implements ChangeListCommand {
|
||||
private final String myName;
|
||||
private final boolean myValue;
|
||||
|
||||
private boolean myResult;
|
||||
private LocalChangeList myListCopy;
|
||||
|
||||
public SetReadOnly(final String name, final boolean value) {
|
||||
public SetReadOnly(String name, boolean value) {
|
||||
myName = name;
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
public void apply(final ChangeListWorker worker) {
|
||||
myResult = worker.setReadOnly(myName, myValue);
|
||||
|
||||
myListCopy = worker.getCopyByName(myName);
|
||||
}
|
||||
|
||||
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
|
||||
// +-
|
||||
dispatcher.getMulticaster().changeListChanged(myListCopy);
|
||||
}
|
||||
|
||||
public void consume(final ChangeListWorker worker) {
|
||||
myResult = worker.setReadOnly(myName, myValue);
|
||||
if (myListCopy != null && myResult) {
|
||||
dispatcher.getMulticaster().changeListChanged(myListCopy);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isResult() {
|
||||
|
||||
Reference in New Issue
Block a user