Skip to content

Commit fecb503

Browse files
committed
Merge remote-tracking branch 'github/develop' into develop
2 parents b5c11de + 013e6de commit fecb503

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/main/java/com/ss/editor/ui/control/model/node/light/LightTreeNode.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import com.jme3.light.Light;
44
import com.ss.editor.annotation.FXThread;
55
import com.ss.editor.annotation.FromAnyThread;
6+
import com.ss.editor.model.undo.editor.ChangeConsumer;
67
import com.ss.editor.ui.Icons;
78
import com.ss.editor.ui.control.model.tree.action.RemoveLightAction;
89
import com.ss.editor.ui.control.model.tree.action.RenameNodeAction;
10+
import com.ss.editor.ui.control.model.tree.action.operation.RenameLightOperation;
911
import com.ss.editor.ui.control.tree.NodeTree;
1012
import com.ss.editor.ui.control.tree.node.TreeNode;
1113
import com.ss.rlib.util.StringUtils;
@@ -15,6 +17,8 @@
1517
import org.jetbrains.annotations.NotNull;
1618
import org.jetbrains.annotations.Nullable;
1719

20+
import static com.ss.rlib.util.ObjectUtils.notNull;
21+
1822
/**
1923
* The base implementation of {@link TreeNode} to present lights.
2024
*
@@ -40,6 +44,9 @@ public LightTreeNode(@NotNull final T element, final long objectId) {
4044
public void changeName(@NotNull final NodeTree<?> nodeTree, @NotNull final String newName) {
4145
final T element = getElement();
4246
element.setName(newName);
47+
48+
final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
49+
consumer.execute(new RenameLightOperation(element.getName(), newName, element));
4350
}
4451

4552
@Override
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.ss.editor.ui.control.model.tree.action.operation;
2+
3+
4+
import com.jme3.light.Light;
5+
import com.ss.editor.model.undo.editor.ModelChangeConsumer;
6+
import com.ss.editor.model.undo.impl.AbstractEditorOperation;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
public class RenameLightOperation extends AbstractEditorOperation<ModelChangeConsumer> {
10+
/**
11+
* The constant PROPERTY_NAME.
12+
*/
13+
public static final String PROPERTY_NAME = "name";
14+
15+
/**
16+
* The old name.
17+
*/
18+
@NotNull
19+
private final String oldName;
20+
21+
/**
22+
* The new name.
23+
*/
24+
@NotNull
25+
private final String newName;
26+
27+
/**
28+
* The node.
29+
*/
30+
@NotNull
31+
private final Light light;
32+
33+
/**
34+
* Instantiates a new Rename node operation.
35+
*
36+
* @param oldName the old name
37+
* @param newName the new name
38+
* @param light the light
39+
*/
40+
public RenameLightOperation(@NotNull final String oldName, @NotNull final String newName, @NotNull final Light light) {
41+
this.oldName = oldName;
42+
this.newName = newName;
43+
this.light = light;
44+
}
45+
46+
@Override
47+
protected void redoImpl(@NotNull final ModelChangeConsumer editor) {
48+
EXECUTOR_MANAGER.addJMETask(() -> {
49+
light.setName(newName);
50+
EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXChangeProperty(light, PROPERTY_NAME));
51+
});
52+
}
53+
54+
@Override
55+
protected void undoImpl(@NotNull final ModelChangeConsumer editor) {
56+
EXECUTOR_MANAGER.addJMETask(() -> {
57+
light.setName(oldName);
58+
EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXChangeProperty(light, PROPERTY_NAME));
59+
});
60+
}
61+
}

0 commit comments

Comments
 (0)