mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: allow to change data associated with changelist
This commit is contained in:
@@ -41,6 +41,11 @@ public class ChangeListAdapter implements ChangeListListener {
|
||||
changeListsChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeListDataChanged(ChangeList list) {
|
||||
changeListsChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeListCommentChanged(ChangeList list, String oldComment) {
|
||||
changeListsChanged();
|
||||
|
||||
@@ -31,6 +31,7 @@ public interface ChangeListListener extends EventListener {
|
||||
default void changeListAdded(ChangeList list) {}
|
||||
default void changeListRemoved(ChangeList list) {}
|
||||
default void changeListChanged(ChangeList list) {}
|
||||
default void changeListDataChanged(ChangeList list) {}
|
||||
default void changeListRenamed(ChangeList list, String oldName) {}
|
||||
default void changeListCommentChanged(ChangeList list, String oldComment) {}
|
||||
default void defaultListChanged(ChangeList oldDefaultList, ChangeList newDefaultList) {}
|
||||
|
||||
@@ -36,5 +36,5 @@ public interface ChangeListModification {
|
||||
|
||||
boolean editName(@NotNull String fromName, @NotNull String toName);
|
||||
@Nullable
|
||||
String editComment(@NotNull String fromName, final String newComment);
|
||||
String editComment(@NotNull String name, final String newComment);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public abstract class ChangeListManagerEx extends ChangeListManager {
|
||||
@NotNull
|
||||
public abstract LocalChangeList addChangeList(@NotNull String name, @Nullable String comment, @Nullable ChangeListData data);
|
||||
|
||||
public abstract boolean editChangeListData(@NotNull String name, @Nullable ChangeListData newData);
|
||||
|
||||
/**
|
||||
* @param automatic true is changelist switch operation was not triggered by user (and, for example, will be reverted soon)
|
||||
* 4ex: This flag disables automatic empty changelist deletion.
|
||||
|
||||
@@ -1023,16 +1023,27 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
@Override
|
||||
public String editComment(@NotNull String fromName, String newComment) {
|
||||
public String editComment(@NotNull String name, String newComment) {
|
||||
return ReadAction.compute(() -> {
|
||||
synchronized (myDataLock) {
|
||||
final String oldComment = myModifier.editComment(fromName, StringUtil.notNullize(newComment));
|
||||
final String oldComment = myModifier.editComment(name, StringUtil.notNullize(newComment));
|
||||
myChangesViewManager.scheduleRefresh();
|
||||
return oldComment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editChangeListData(@NotNull String name, @Nullable ChangeListData newData) {
|
||||
return ReadAction.compute(() -> {
|
||||
synchronized (myDataLock) {
|
||||
final boolean result = myModifier.editData(name, newData);
|
||||
myChangesViewManager.scheduleRefresh();
|
||||
return result;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveChangesTo(@NotNull LocalChangeList list, @NotNull Change... changes) {
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
|
||||
@@ -480,6 +480,15 @@ public class ChangeListWorker {
|
||||
return oldComment;
|
||||
}
|
||||
|
||||
public boolean editData(@NotNull String name, @Nullable ChangeListData newData) {
|
||||
final ListData list = getDataByName(name);
|
||||
if (list == null) return false;
|
||||
|
||||
list.data = newData;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public LocalChangeList addChangeList(@NotNull String name, @Nullable String description, @Nullable String id,
|
||||
|
||||
@@ -69,6 +69,11 @@ public class DelayedNotificator implements ChangeListListener {
|
||||
myScheduler.submit(() -> myDispatcher.getMulticaster().changeListRenamed(list, oldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeListDataChanged(ChangeList list) {
|
||||
myScheduler.submit(() -> myDispatcher.getMulticaster().changeListDataChanged(list));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeListCommentChanged(final ChangeList list, final String oldComment) {
|
||||
myScheduler.submit(() -> myDispatcher.getMulticaster().changeListCommentChanged(list, oldComment));
|
||||
|
||||
@@ -79,6 +79,12 @@ public class Modifier {
|
||||
return command.getOldComment();
|
||||
}
|
||||
|
||||
public boolean editData(@NotNull String fromName, @Nullable ChangeListData newData) {
|
||||
EditData command = new EditData(fromName, newData);
|
||||
impl(command);
|
||||
return command.isResult();
|
||||
}
|
||||
|
||||
|
||||
private void impl(@NotNull ChangeListCommand command) {
|
||||
if (myInsideUpdate) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs.changes.local;
|
||||
|
||||
import com.intellij.openapi.vcs.changes.ChangeListData;
|
||||
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 EditData implements ChangeListCommand {
|
||||
private final String myName;
|
||||
@Nullable private final ChangeListData myNewData;
|
||||
|
||||
private boolean myResult;
|
||||
private LocalChangeList myListCopy;
|
||||
|
||||
public EditData(@NotNull String name, @Nullable ChangeListData newData) {
|
||||
myName = name;
|
||||
myNewData = newData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(final ChangeListWorker worker) {
|
||||
myResult = worker.editData(myName, myNewData);
|
||||
myListCopy = worker.getChangeListByName(myName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
|
||||
if (myListCopy != null) {
|
||||
dispatcher.getMulticaster().changeListDataChanged(myListCopy);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isResult() {
|
||||
return myResult;
|
||||
}
|
||||
}
|
||||
@@ -397,6 +397,11 @@ public class MockChangeListManager extends ChangeListManagerEx {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editChangeListData(@NotNull String name, @Nullable ChangeListData newData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInUpdate() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
Reference in New Issue
Block a user