Skip to content

Commit d2d9322

Browse files
committed
added autoselect on creating nodes.
1 parent a3461b9 commit d2d9322

27 files changed

Lines changed: 62 additions & 45 deletions

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ dependencies {
5757
compile "com.github.JavaSaBr.jmonkeyengine:jme3-effects:$jmeVersion"
5858
compile "com.github.JavaSaBr.jmonkeyengine:jme3-blender:$jmeVersion"
5959
compile "com.github.JavaSaBr.jmonkeyengine:jme3-jogg:$jmeVersion"
60+
compile "com.github.JavaSaBr.jmonkeyengine:jme3-testdata:$jmeVersion"
6061

6162
// LWJGL
6263
compile "org.lwjgl:lwjgl:${lwjglVersion}"

src/main/java/com/ss/editor/model/undo/editor/ModelChangeConsumer.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ default void notifyFXChangeProperty(@NotNull Object object, @NotNull String prop
6565
/**
6666
* Notify about added child from FX thread.
6767
*
68-
* @param parent the parent
69-
* @param added the added
70-
* @param index the index
68+
* @param parent the parent.
69+
* @param added the added.
70+
* @param index the index of position.
71+
* @param needSelect true if need to select the child.
7172
*/
7273
@FXThread
73-
void notifyFXAddedChild(@NotNull Object parent, @NotNull Object added, int index);
74+
void notifyFXAddedChild(@NotNull Object parent, @NotNull Object added, int index, boolean needSelect);
7475

7576
/**
7677
* Notify about removed child from FX thread.
@@ -104,11 +105,13 @@ default void notifyFXChangeProperty(@NotNull Object object, @NotNull String prop
104105
/**
105106
* Notify about moved child from FX thread.
106107
*
107-
* @param prevParent the prev parent
108-
* @param newParent the new parent
109-
* @param child the child
110-
* @param index the index
108+
* @param prevParent the prev parent.
109+
* @param newParent the new parent.
110+
* @param child the child.
111+
* @param index the index of position.
112+
* @param needSelect true if need select this object.
111113
*/
112114
@FXThread
113-
void notifyFXMoved(@NotNull Node prevParent, @NotNull Node newParent, @NotNull Spatial child, int index);
115+
void notifyFXMoved(@NotNull Node prevParent, @NotNull Node newParent, @NotNull Spatial child, int index,
116+
boolean needSelect);
114117
}

src/main/java/com/ss/editor/ui/component/creator/impl/EmptyModelCreator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.ss.editor.FileExtensions;
77
import com.ss.editor.Messages;
88
import com.ss.editor.ui.component.creator.FileCreatorDescription;
9-
109
import org.jetbrains.annotations.NotNull;
1110

1211
import java.io.IOException;
@@ -51,7 +50,7 @@ protected void processOk() {
5150
final Path fileToCreate = notNull(getFileToCreate());
5251

5352
final BinaryExporter exporter = BinaryExporter.getInstance();
54-
final Node newNode = new Node("New node");
53+
final Node newNode = new Node("Model root");
5554

5655
try (final OutputStream out = Files.newOutputStream(fileToCreate)) {
5756
exporter.save(newNode, out);

src/main/java/com/ss/editor/ui/component/editor/area/EditorAreaComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ private void processOpenFileImpl(@NotNull final RequestedOpenFileEvent event, @N
446446
editor = description == null ? EDITOR_REGISTRY.createEditorFor(file) :
447447
EDITOR_REGISTRY.createEditorFor(description, file);
448448

449-
} catch (final Exception e) {
449+
} catch (final Throwable e) {
450450
EditorUtil.handleException(null, this, new Exception(e));
451451
EXECUTOR_MANAGER.addFXTask(scene::decrementLoading);
452452
return;
@@ -462,7 +462,7 @@ private void processOpenFileImpl(@NotNull final RequestedOpenFileEvent event, @N
462462
final long stamp = EDITOR.asyncLock();
463463
try {
464464
editor.openFile(file);
465-
} catch (final NoClassDefFoundError | Exception e) {
465+
} catch (final Throwable e) {
466466
EditorUtil.handleException(null, this, new Exception(e));
467467
EXECUTOR_MANAGER.addFXTask(() -> {
468468
scene.decrementLoading();

src/main/java/com/ss/editor/ui/component/editor/impl/ImageViewerEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private ImageView getImageView() {
7777
protected void processChangedFile(@NotNull final FileChangedEvent event) {
7878
final Path file = event.getFile();
7979
if (!getEditFile().equals(file)) return;
80-
showImage(file);
80+
EXECUTOR_MANAGER.schedule(() -> EXECUTOR_MANAGER.addFXTask(() -> showImage(file)), 1000);
8181
}
8282

8383
private void showImage(@NotNull final Path file) {

src/main/java/com/ss/editor/ui/component/editor/impl/model/ModelFileEditor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,9 @@ private void changeLight(@NotNull final Boolean newValue) {
277277
}
278278

279279
@Override
280-
public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index) {
281-
super.notifyFXAddedChild(parent, added, index);
280+
public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index,
281+
final boolean needSelect) {
282+
super.notifyFXAddedChild(parent, added, index, needSelect);
282283

283284
final ModelEditor3DState editor3DState = getEditor3DState();
284285

src/main/java/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,8 @@ public void notifyFXChangePropertyCount(@Nullable final Object parent, @NotNull
727727
}
728728

729729
@Override
730-
public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index) {
730+
public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index,
731+
final boolean needSelect) {
731732

732733
final MA editor3DState = getEditor3DState();
733734
final ModelNodeTree modelNodeTree = getModelNodeTree();
@@ -740,6 +741,10 @@ public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Obje
740741
} else if (added instanceof Spatial) {
741742
handleAddedObject((Spatial) added);
742743
}
744+
745+
if (needSelect) {
746+
EXECUTOR_MANAGER.addJMETask(() -> EXECUTOR_MANAGER.addFXTask(() -> modelNodeTree.select(added)));
747+
}
743748
}
744749

745750
@Override
@@ -780,9 +785,15 @@ public void notifyFXReplaced(@NotNull final Object parent, @Nullable final Objec
780785
}
781786

782787
@Override
783-
public void notifyFXMoved(@NotNull final Node prevParent, @NotNull final Node newParent, @NotNull final Spatial child, int index) {
788+
public void notifyFXMoved(@NotNull final Node prevParent, @NotNull final Node newParent,
789+
@NotNull final Spatial child, final int index, final boolean needSelect) {
790+
784791
final ModelNodeTree modelNodeTree = getModelNodeTree();
785792
modelNodeTree.notifyMoved(prevParent, newParent, child, index);
793+
794+
if (needSelect) {
795+
EXECUTOR_MANAGER.addJMETask(() -> EXECUTOR_MANAGER.addFXTask(() -> modelNodeTree.select(child)));
796+
}
786797
}
787798

788799
@Override

src/main/java/com/ss/editor/ui/component/editor/impl/scene/SceneFileEditor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,9 @@ protected void handleRemovedObject(@NotNull final Spatial model) {
555555
}
556556

557557
@Override
558-
public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index) {
559-
super.notifyFXAddedChild(parent, added, index);
558+
public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index,
559+
final boolean needSelect) {
560+
super.notifyFXAddedChild(parent, added, index, needSelect);
560561

561562
final LayerNodeTree layerNodeTree = getLayerNodeTree();
562563

src/main/java/com/ss/editor/ui/control/model/tree/action/operation/AddChildOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected void redoImpl(@NotNull final ModelChangeConsumer editor) {
4747
final TonegodTranslucentBucketFilter filter = EDITOR.getTranslucentBucketFilter();
4848
filter.refresh();
4949

50-
EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXAddedChild(parent, newChild, 0));
50+
EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXAddedChild(parent, newChild, -1, true));
5151
});
5252
}
5353

src/main/java/com/ss/editor/ui/control/model/tree/action/operation/AddControlOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public AddControlOperation(@NotNull final Control newControl, @NotNull final Spa
4141
protected void redoImpl(@NotNull final ModelChangeConsumer editor) {
4242
EXECUTOR_MANAGER.addJMETask(() -> {
4343
spatial.addControl(newControl);
44-
EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXAddedChild(spatial, newControl, -1));
44+
EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXAddedChild(spatial, newControl, -1, true));
4545
});
4646
}
4747

0 commit comments

Comments
 (0)