diff --git a/README.md b/README.md index 74fc6105..cb44a017 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# jMonkeyBuilder 1.7.0 # +# jMonkeyBuilder 1.8.0 # ### It's 3D Editor to prepare/work/create graphics content for jMonkeyEngine 3.2 ### [![Join the chat at https://gitter.im/jME3-SpaceShift-Editor/Lobby](https://badges.gitter.im/jME3-SpaceShift-Editor/Lobby.svg)](https://gitter.im/jME3-SpaceShift-Editor/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/app.version b/app.version index 9dbb0c00..afa2b351 100644 --- a/app.version +++ b/app.version @@ -1 +1 @@ -1.7.0 \ No newline at end of file +1.8.0 \ No newline at end of file diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 12671b88..1d2b570c 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -5,7 +5,7 @@ # You can specify a custom docker image from Docker Hub as your build environment. # image: atlassian/default-image:latest -image: java:8 +image: java:10 pipelines: default: - step: diff --git a/build.gradle b/build.gradle index 051f0c86..8609991e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,11 @@ buildscript { repositories { mavenCentral() + jcenter() } dependencies { classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' } } @@ -11,9 +13,12 @@ apply plugin: 'java' apply plugin: 'maven' apply plugin: 'idea' apply plugin: 'org.junit.platform.gradle.plugin' +apply plugin: 'com.jfrog.bintray' +apply plugin: 'maven-publish' +apply plugin: 'application' group = 'com.spaceshift' -version = '1.7.0' +version = '1.8.0' compileJava { options.encoding = "UTF-8" @@ -36,24 +41,27 @@ compileJava { ]) } -sourceCompatibility = 1.9 -targetCompatibility = 1.9 +sourceCompatibility = 1.10 +targetCompatibility = 1.10 compileTestJava { - sourceCompatibility = 1.9 - targetCompatibility = 1.9 + sourceCompatibility = 1.10 + targetCompatibility = 1.10 options.compilerArgs += '-parameters' } +mainClassName = "com.ss.editor.JfxApplication" + ext.applicationMainClass = "com.ss.editor.JfxApplication" ext.applicationVendor = "javasabr@gmail.com" ext.applicationTitle = "jMonkeyBuilder" -ext.jmeVersion = "v3.3.dev-SNAPSHOT" -ext.jmbExtVersion = "2.1.1" +ext.jmeVersion = "3.2.1-SNAPSHOT" +ext.jmbExtVersion = "2.3.1" ext.jme3_xbuf_version = '0.9.1' ext.junitPlatformVersion = "1.0.0" ext.junitJupiterVersion = "5.0.0" ext.log4jVersion = '2.6.2' +ext.bintrayVersion = version junitPlatform { filters { @@ -66,9 +74,49 @@ junitPlatform { } repositories { - mavenCentral() jcenter() - maven { url 'https://jitpack.io' } + mavenCentral() + mavenLocal() + maven { + url 'https://jitpack.io' + } + maven { + url 'https://dl.bintray.com/javasabr/maven' + } +} + +publishing { + publications { + JmbArtifact(MavenPublication) { + from components.java + groupId 'com.spaceshift' + artifactId 'jmonkeybuilder' + version bintrayVersion + artifact sourcesJar + artifact javadocJar + } + } +} + +bintray { + user = System.getProperty('bintrayUser') + key = System.getProperty('bintrayKey') + publications = ['JmbArtifact'] + pkg { + repo = 'maven' + name = 'com.spaceshift.jmonkeybuilder' + licenses = ['Apache-2.0'] + websiteUrl = 'https://github.com/JavaSaBr/jmonkeybuilder' + vcsUrl = 'https://github.com/JavaSaBr/jmonkeybuilder.git' + issueTrackerUrl = 'https://github.com/JavaSaBr/jmonkeybuilder/issues' + githubRepo = 'JavaSaBr/jmonkeybuilder' + githubReleaseNotesFile = 'README.md' + version { + name = bintrayVersion + desc = bintrayVersion + released = new Date() + } + } } javadoc { @@ -78,11 +126,11 @@ javadoc { dependencies { // base - compile 'org.fxmisc.richtext:richtextfx:0.8.2' + compile group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.9.0' compile 'org.controlsfx:controlsfx:9.0.0' - compile 'com.github.JavaSaBr:RlibFX:4.1.3' - compile 'com.github.JavaSaBr:RLib:6.7.7' - compile ("com.github.JavaSaBr:JME3-JFX:1.7.4") { + compile 'com.spaceshift:rlib.fx:5.0.2' + compile 'com.spaceshift:rlib.common:7.1.2' + compile ('com.jme3:jfx:2.0.0') { exclude group: 'org.jmonkeyengine' } @@ -121,7 +169,7 @@ dependencies { compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3' // extensions - compile ("com.github.JavaSaBr:jmonkeybuilder-extension:$jmbExtVersion") { + compile ("com.spaceshift:jmonkeybuilder-extension:$jmbExtVersion") { exclude group: 'org.jmonkeyengine' } @@ -134,7 +182,7 @@ dependencies { // TESTS testRuntime "com.github.JavaSaBr.jmonkeyengine:jme3-lwjgl3:$jmeVersion" - testCompile ("com.github.JavaSaBr:jmonkeybuilder-extension:$jmbExtVersion") { + testCompile ("com.spaceshift:jmonkeybuilder-extension:$jmbExtVersion") { exclude group: 'org.jmonkeyengine' exclude group: 'com.github.JavaSaB.jmonkeyengine' } @@ -184,28 +232,5 @@ task javadocJar(type: Jar, dependsOn: javadoc) { } task wrapper(type: Wrapper) { - gradleVersion = '4.5.1' -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -defaultTasks 'clean', 'install' - -// To specify a license in the pom: -install { - repositories.mavenInstaller { - pom.version = version - pom.artifactId = 'jmonkeybuilder' - pom.project { - licenses { - license { - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - } - } + gradleVersion = '4.7' } \ No newline at end of file diff --git a/embedded-plugins/jmb-font-generator/jmb-font-generator-1.0.6.jar b/embedded-plugins/jmb-font-generator/jmb-font-generator-1.0.6.jar deleted file mode 100644 index 098de340..00000000 Binary files a/embedded-plugins/jmb-font-generator/jmb-font-generator-1.0.6.jar and /dev/null differ diff --git a/embedded-plugins/jmb-font-generator/jmb-font-generator-1.1.1.jar b/embedded-plugins/jmb-font-generator/jmb-font-generator-1.1.1.jar new file mode 100644 index 00000000..cd11499d Binary files /dev/null and b/embedded-plugins/jmb-font-generator/jmb-font-generator-1.1.1.jar differ diff --git a/embedded-plugins/jmb-shader-nodes/jmb-shader-nodes-1.1.1.jar b/embedded-plugins/jmb-shader-nodes/jmb-shader-nodes-1.1.1.jar new file mode 100644 index 00000000..38de7df3 Binary files /dev/null and b/embedded-plugins/jmb-shader-nodes/jmb-shader-nodes-1.1.1.jar differ diff --git a/embedded-plugins/jmb-shader-nodes/jmb-shader-nodes-1.1.3.jar b/embedded-plugins/jmb-shader-nodes/jmb-shader-nodes-1.1.3.jar deleted file mode 100644 index c9c7a2db..00000000 Binary files a/embedded-plugins/jmb-shader-nodes/jmb-shader-nodes-1.1.3.jar and /dev/null differ diff --git a/embedded-plugins/jmb-sky-control/jmb-sky-control-1.1.0.jar b/embedded-plugins/jmb-sky-control/jmb-sky-control-1.1.0.jar deleted file mode 100644 index 9e2191f6..00000000 Binary files a/embedded-plugins/jmb-sky-control/jmb-sky-control-1.1.0.jar and /dev/null differ diff --git a/embedded-plugins/jmb-sky-control/jmb-sky-control-1.2.1.jar b/embedded-plugins/jmb-sky-control/jmb-sky-control-1.2.1.jar new file mode 100644 index 00000000..10df5a95 Binary files /dev/null and b/embedded-plugins/jmb-sky-control/jmb-sky-control-1.2.1.jar differ diff --git a/embedded-plugins/jmb-sky-control/libs/SkyControl-0.9.11.jar b/embedded-plugins/jmb-sky-control/libs/SkyControl-0.9.12.jar similarity index 98% rename from embedded-plugins/jmb-sky-control/libs/SkyControl-0.9.11.jar rename to embedded-plugins/jmb-sky-control/libs/SkyControl-0.9.12.jar index 41429cee..5f81fd44 100644 Binary files a/embedded-plugins/jmb-sky-control/libs/SkyControl-0.9.11.jar and b/embedded-plugins/jmb-sky-control/libs/SkyControl-0.9.12.jar differ diff --git a/embedded-plugins/jmb-sky-control/libs/jme3-utilities-heart-2.0.0.jar b/embedded-plugins/jmb-sky-control/libs/jme3-utilities-heart-2.4.0.jar similarity index 64% rename from embedded-plugins/jmb-sky-control/libs/jme3-utilities-heart-2.0.0.jar rename to embedded-plugins/jmb-sky-control/libs/jme3-utilities-heart-2.4.0.jar index e2a7a8ec..e7906f82 100644 Binary files a/embedded-plugins/jmb-sky-control/libs/jme3-utilities-heart-2.0.0.jar and b/embedded-plugins/jmb-sky-control/libs/jme3-utilities-heart-2.4.0.jar differ diff --git a/embedded-plugins/jmb-tonegod-emitter/jmb-tonegod-emitter-1.0.2.jar b/embedded-plugins/jmb-tonegod-emitter/jmb-tonegod-emitter-1.0.2.jar deleted file mode 100644 index 28e138c0..00000000 Binary files a/embedded-plugins/jmb-tonegod-emitter/jmb-tonegod-emitter-1.0.2.jar and /dev/null differ diff --git a/embedded-plugins/jmb-tonegod-emitter/jmb-tonegod-emitter-1.1.2.jar b/embedded-plugins/jmb-tonegod-emitter/jmb-tonegod-emitter-1.1.2.jar new file mode 100644 index 00000000..4655f139 Binary files /dev/null and b/embedded-plugins/jmb-tonegod-emitter/jmb-tonegod-emitter-1.1.2.jar differ diff --git a/embedded-plugins/jmb-tonegod-emitter/libs/emitter-3.0.2.jar b/embedded-plugins/jmb-tonegod-emitter/libs/emitter-3.0.2.jar new file mode 100644 index 00000000..f653d7e1 Binary files /dev/null and b/embedded-plugins/jmb-tonegod-emitter/libs/emitter-3.0.2.jar differ diff --git a/embedded-plugins/jmb-tonegod-emitter/libs/tonegodemitter-2.6.3.jar b/embedded-plugins/jmb-tonegod-emitter/libs/tonegodemitter-2.6.3.jar deleted file mode 100644 index e1ecfd6b..00000000 Binary files a/embedded-plugins/jmb-tonegod-emitter/libs/tonegodemitter-2.6.3.jar and /dev/null differ diff --git a/embedded-plugins/jmb-tree-generator/jmb-tree-generator-1.1.1.jar b/embedded-plugins/jmb-tree-generator/jmb-tree-generator-1.1.1.jar deleted file mode 100644 index 1a96a3df..00000000 Binary files a/embedded-plugins/jmb-tree-generator/jmb-tree-generator-1.1.1.jar and /dev/null differ diff --git a/embedded-plugins/jmb-tree-generator/jmb-tree-generator-1.2.2.jar b/embedded-plugins/jmb-tree-generator/jmb-tree-generator-1.2.2.jar new file mode 100644 index 00000000..a9e47cef Binary files /dev/null and b/embedded-plugins/jmb-tree-generator/jmb-tree-generator-1.2.2.jar differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c44b679a..91ca28c8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 568c50bf..16d28051 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index f330c93a..00000000 --- a/jitpack.yml +++ /dev/null @@ -1,2 +0,0 @@ -jdk: - - oraclejdk9 diff --git a/native-build/.gitignore b/native-build/.gitignore deleted file mode 100644 index 4aa0d861..00000000 --- a/native-build/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/projectRefs/ -/project/ -/externalLibs/ -/dist/ -/deploy/ -/build/ -/licenses/ \ No newline at end of file diff --git a/src/main/java/com/jme3/scene/Spatial.java b/src/main/java/com/jme3/scene/Spatial.java index b33c26a8..534f46c7 100644 --- a/src/main/java/com/jme3/scene/Spatial.java +++ b/src/main/java/com/jme3/scene/Spatial.java @@ -1876,7 +1876,7 @@ public boolean isVisible() { * * @param visible the visible */ - public void setVisible(final boolean visible) { + public void setVisible(boolean visible) { this.visible = visible; } } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/DevelopPluginStarter.java b/src/main/java/com/ss/editor/DevelopPluginStarter.java index dc90a1f0..94809b62 100644 --- a/src/main/java/com/ss/editor/DevelopPluginStarter.java +++ b/src/main/java/com/ss/editor/DevelopPluginStarter.java @@ -3,7 +3,6 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; -import java.nio.file.Path; import java.nio.file.Paths; /** @@ -13,8 +12,8 @@ */ public class DevelopPluginStarter { - public static void main(@NotNull final String[] args) throws IOException { - final Path embeddedFolder = Paths.get("./embedded-plugins"); + public static void main(@NotNull String[] args) throws IOException { + var embeddedFolder = Paths.get("./embedded-plugins"); System.setProperty("editor.embedded.plugins.path", embeddedFolder.toAbsolutePath().toString()); JfxApplication.main(args); } diff --git a/src/main/java/com/ss/editor/EditorThread.java b/src/main/java/com/ss/editor/EditorThread.java index e4fe3294..631bcbe2 100644 --- a/src/main/java/com/ss/editor/EditorThread.java +++ b/src/main/java/com/ss/editor/EditorThread.java @@ -21,12 +21,12 @@ public EditorThread() { this.localObjects = new LocalObjects(); } - public EditorThread(@NotNull final Runnable target) { + public EditorThread(@NotNull Runnable target) { super(target); this.localObjects = new LocalObjects(); } - public EditorThread(@NotNull final ThreadGroup group, @NotNull final Runnable target, @NotNull final String name) { + public EditorThread(@NotNull ThreadGroup group, @NotNull Runnable target, @NotNull String name) { super(group, target, name); this.localObjects = new LocalObjects(); } diff --git a/src/main/java/com/ss/editor/FileExtensions.java b/src/main/java/com/ss/editor/FileExtensions.java index 2379c369..601d16bc 100644 --- a/src/main/java/com/ss/editor/FileExtensions.java +++ b/src/main/java/com/ss/editor/FileExtensions.java @@ -1,7 +1,6 @@ package com.ss.editor; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** @@ -49,7 +48,7 @@ public interface FileExtensions { @NotNull String MODEL_MESH_XML = "mesh.xml"; @NotNull String MODEL_XBUF = "xbuf"; - @NotNull Array IMAGE_EXTENSIONS = ArrayFactory.asArray( + @NotNull Array IMAGE_EXTENSIONS = Array.of( IMAGE_PNG, IMAGE_JPG, IMAGE_JPEG, @@ -58,24 +57,26 @@ public interface FileExtensions { IMAGE_HDR, IMAGE_BMP, IMAGE_GIF, - IMAGE_TIFF); + IMAGE_TIFF + ); - @NotNull Array TEXTURE_EXTENSIONS = ArrayFactory.asArray( + @NotNull Array TEXTURE_EXTENSIONS = Array.of( IMAGE_PNG, IMAGE_JPG, IMAGE_JPEG, IMAGE_TGA, IMAGE_DDS, - IMAGE_HDR); + IMAGE_HDR + ); - @NotNull Array SHADER_EXTENSIONS = ArrayFactory.asArray(GLSL_FRAGMENT, + @NotNull Array SHADER_EXTENSIONS = Array.of( + GLSL_FRAGMENT, GLSL_VERTEX, GLSL_TESSELLATION_CONTROL, GLSL_TESSELLATION_EVALUATION, GLSL_GEOM, - GLSL_LIB); + GLSL_LIB + ); - @NotNull Array AUDIO_EXTENSIONS = ArrayFactory.asArray(AUDIO_MP3, - AUDIO_WAV, - AUDIO_OGG); + @NotNull Array AUDIO_EXTENSIONS = Array.of(AUDIO_MP3, AUDIO_WAV, AUDIO_OGG); } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/JfxApplication.java b/src/main/java/com/ss/editor/JfxApplication.java index bd2d0fe9..d06ee5f7 100644 --- a/src/main/java/com/ss/editor/JfxApplication.java +++ b/src/main/java/com/ss/editor/JfxApplication.java @@ -1,19 +1,17 @@ package com.ss.editor; -import static com.jme3x.jfx.injfx.JmeToJFXIntegrator.bind; -import static com.jme3x.jfx.injfx.processor.FrameTransferSceneProcessor.TransferMode.ON_CHANGES; +import static com.jme3.jfx.injfx.JmeToJfxIntegrator.bind; +import static com.jme3.jfx.injfx.processor.FrameTransferSceneProcessor.TransferMode.ON_CHANGES; import static com.ss.editor.config.DefaultSettingsProvider.Defaults.PREF_DEFAULT_OPEN_GL; import static com.ss.editor.config.DefaultSettingsProvider.Defaults.PREF_DEFAULT_STOP_RENDER_ON_LOST_FOCUS; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.*; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.Utils.run; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.Utils.run; import static java.nio.file.Files.createDirectories; import static java.nio.file.Files.newOutputStream; -import com.jme3.renderer.Renderer; -import com.jme3.system.JmeContext; +import com.jme3.jfx.injfx.JmeToJfxApplication; +import com.jme3.jfx.injfx.processor.FrameTransferSceneProcessor; import com.jme3.util.LWJGLBufferAllocator; -import com.jme3x.jfx.injfx.JmeToJFXApplication; -import com.jme3x.jfx.injfx.processor.FrameTransferSceneProcessor; import com.ss.editor.analytics.google.GAEvent; import com.ss.editor.analytics.google.GAnalytics; import com.ss.editor.annotation.FromAnyThread; @@ -41,19 +39,19 @@ import com.ss.editor.util.EditorUtil; import com.ss.editor.util.OpenGLVersion; import com.ss.editor.util.svg.SvgImageLoaderFactory; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerLevel; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.logging.impl.FolderFileListener; -import com.ss.rlib.manager.InitializeManager; -import com.ss.rlib.util.ArrayUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.array.ConcurrentArray; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerLevel; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.logging.impl.FolderFileListener; +import com.ss.rlib.common.manager.InitializeManager; +import com.ss.rlib.common.util.ArrayUtils; +import com.ss.rlib.common.util.Utils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.ConcurrentArray; import javafx.application.Application; import javafx.application.Platform; import javafx.beans.value.ChangeListener; -import javafx.collections.ObservableList; import javafx.scene.control.ComboBoxBase; import javafx.scene.image.Image; import javafx.stage.Stage; @@ -67,9 +65,9 @@ import java.io.IOException; import java.io.PrintStream; import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; +import java.util.concurrent.CountDownLatch; import java.util.logging.Level; /** @@ -79,7 +77,6 @@ */ public class JfxApplication extends Application { - @NotNull private static final Logger LOGGER = LoggerManager.getLogger(JfxApplication.class); @Nullable @@ -97,12 +94,9 @@ public class JfxApplication extends Application { } /** - * Main. - * - * @param args the args - * @throws IOException the io exception + * The start application method. */ - public static void main(final String[] args) { + public static void main(@NotNull String[] args) { configureLogger(); // need to disable to work on macos @@ -112,11 +106,10 @@ public static void main(final String[] args) { // JavaFX System.setProperty("prism.lcdtext", "false"); - System.setProperty("prism.text", "t2k"); - System.setProperty("javafx.animation.fullspeed", "false"); + //System.setProperty("prism.text", "t2k"); - final EditorConfig editorConfig = EditorConfig.getInstance(); - final OpenGLVersion openGLVersion = editorConfig.getEnum(PREF_OPEN_GL, PREF_DEFAULT_OPEN_GL); + var editorConfig = EditorConfig.getInstance(); + var openGLVersion = editorConfig.getEnum(PREF_OPEN_GL, PREF_DEFAULT_OPEN_GL); // set a render if it isn't override if(System.getProperty("jfx.background.render") == null) { @@ -125,23 +118,9 @@ public static void main(final String[] args) { System.setProperty(LWJGLBufferAllocator.PROPERTY_CONCURRENT_BUFFER_ALLOCATOR, "true"); - // some settings for the render of JavaFX - System.setProperty("prism.printrendergraph", "false"); - System.setProperty("javafx.pulseLogger", "false"); - - //System.setProperty("prism.cacheshapes", "true"); - //System.setProperty("prism.scrollcacheopt", "true"); - //System.setProperty("prism.allowhidpi", "true"); - - //System.setProperty("prism.order", "sw"); - //System.setProperty("prism.showdirty", "true"); - //System.setProperty("prism.showoverdraw", "true"); - //System.setProperty("prism.debug", "true"); - //System.setProperty("prism.verbose", "true"); - CommandLineConfig.args(args); - JmeToJFXApplication application; + JmeToJfxApplication application; try { application = JmeApplication.prepareToStart(); } catch (final Throwable e) { @@ -167,8 +146,10 @@ public static void main(final String[] args) { private static void configureLogger() { // disable the standard logger - if (Config.DEV_DEBUG) { + if (!Config.DEV_DEBUG) { java.util.logging.Logger.getLogger("").setLevel(Level.WARNING); + } else { + java.util.logging.Logger.getLogger("").setLevel(Level.ALL); } // configure our logger @@ -177,7 +158,7 @@ private static void configureLogger() { LoggerLevel.ERROR.setEnabled(true); LoggerLevel.WARNING.setEnabled(true); - final Path logFolder = Config.getFolderForLog(); + var logFolder = Config.getFolderForLog(); if (!Files.exists(logFolder)) { run(() -> createDirectories(logFolder)); @@ -194,18 +175,18 @@ private static void configureLogger() { * @param application the new jME application. */ @JmeThread - private static void startJmeApplication(@NotNull final JmeToJFXApplication application) { + private static void startJmeApplication(@NotNull JmeToJfxApplication application) { - final InitializationManager initializationManager = InitializationManager.getInstance(); + var initializationManager = InitializationManager.getInstance(); initializationManager.onBeforeCreateJmeContext(); application.start(); - final JmeContext context = application.getContext(); - final Renderer renderer = context.getRenderer(); + var context = application.getContext(); + var renderer = context.getRenderer(); if (renderer == null) { - final EditorConfig editorConfig = EditorConfig.getInstance(); + var editorConfig = EditorConfig.getInstance(); editorConfig.set(PREF_OPEN_GL, OpenGLVersion.GL_20); editorConfig.save(); } @@ -220,22 +201,22 @@ private static void startJmeApplication(@NotNull final JmeToJFXApplication appli private static @NotNull ChangeListener makeFocusedListener() { return (observable, oldValue, newValue) -> { - final JmeApplication jmeApplication = JmeApplication.getInstance(); - final Stage stage = EditorUtil.getFxStage(); + var jmeApplication = JmeApplication.getInstance(); + var stage = EditorUtil.getFxStage(); if (newValue || stage.isFocused()) { jmeApplication.setPaused(false); return; } - final EditorConfig editorConfig = EditorConfig.getInstance(); + var editorConfig = EditorConfig.getInstance(); if (!editorConfig.getBoolean(PREF_STOP_RENDER_ON_LOST_FOCUS, PREF_DEFAULT_STOP_RENDER_ON_LOST_FOCUS)) { jmeApplication.setPaused(false); return; } - final JfxApplication application = JfxApplication.getInstance(); - final Window window = ArrayUtils.getInReadLock(application.openedWindows, + var application = JfxApplication.getInstance(); + var window = ArrayUtils.getInReadLock(application.openedWindows, windows -> windows.search(Window::isFocused)); jmeApplication.setPaused(window == null); @@ -251,15 +232,15 @@ public static void start() { } @FromAnyThread - private static void printError(@NotNull final Throwable throwable) { + private static void printError(@NotNull Throwable throwable) { throwable.printStackTrace(); - final String userHome = System.getProperty("user.home"); - final String fileName = "jmonkeybuilder-error.log"; + var userHome = System.getProperty("user.home"); + var fileName = "jmonkeybuilder-error.log"; - try (final PrintStream out = new PrintStream(newOutputStream(Paths.get(userHome, fileName)))) { + try (var out = new PrintStream(newOutputStream(Paths.get(userHome, fileName)))) { throwable.printStackTrace(out); - } catch (final IOException e) { + } catch (IOException e) { e.printStackTrace(); } } @@ -306,7 +287,7 @@ public void requestFocus() { * @param window the new opened window. */ @FxThread - public void addWindow(@NotNull final Window window) { + public void addWindow(@NotNull Window window) { window.focusedProperty().addListener(makeFocusedListener()); ArrayUtils.runInWriteLock(openedWindows, window, Collection::add); } @@ -317,7 +298,7 @@ public void addWindow(@NotNull final Window window) { * @param window the opened window. */ @FxThread - public void removeWindow(@NotNull final Window window) { + public void removeWindow(@NotNull Window window) { ArrayUtils.runInWriteLock(openedWindows, window, Array::slowRemove); } @@ -333,7 +314,7 @@ public void removeWindow(@NotNull final Window window) { @Override @FxThread - public void start(final Stage stage) throws Exception { + public void start(@NotNull Stage stage) throws Exception { JfxApplication.instance = this; this.stage = stage; @@ -343,20 +324,20 @@ public void start(final Stage stage) throws Exception { // initialize javaFX events in javaFX thread. ArrayFactory.asArray(ComboBoxBase.ON_SHOWN); - final ResourceManager resourceManager = ResourceManager.getInstance(); + var resourceManager = ResourceManager.getInstance(); resourceManager.reload(); - final InitializationManager initializationManager = InitializationManager.getInstance(); + var initializationManager = InitializationManager.getInstance(); initializationManager.onBeforeCreateJavaFxContext(); - final PluginManager pluginManager = PluginManager.getInstance(); + var pluginManager = PluginManager.getInstance(); pluginManager.handlePlugins(editorPlugin -> editorPlugin.register(CssRegistry.getInstance())); LogView.getInstance(); SvgImageLoaderFactory.install(); ImageIO.read(getClass().getResourceAsStream("/ui/icons/test/test.jpg")); - final ObservableList icons = stage.getIcons(); + var icons = stage.getIcons(); icons.add(new Image("/ui/icons/app/256x256.png")); icons.add(new Image("/ui/icons/app/128x128.png")); icons.add(new Image("/ui/icons/app/96x96.png")); @@ -366,7 +347,7 @@ public void start(final Stage stage) throws Exception { icons.add(new Image("/ui/icons/app/24x24.png")); icons.add(new Image("/ui/icons/app/16x16.png")); - final EditorConfig config = EditorConfig.getInstance(); + var config = EditorConfig.getInstance(); stage.initStyle(StageStyle.DECORATED); stage.setMinHeight(600); @@ -396,7 +377,7 @@ public void start(final Stage stage) throws Exception { buildScene(); - } catch (final Throwable e) { + } catch (Throwable e) { LOGGER.error(this, e); throw e; } @@ -418,16 +399,19 @@ protected void onExit() { GAnalytics.forceSendEvent(GAEvent.Category.APPLICATION, GAEvent.Action.APPLICATION_CLOSED, GAEvent.Label.THE_EDITOR_APP_WAS_CLOSED); - final EditorConfig config = EditorConfig.getInstance(); + var config = EditorConfig.getInstance(); config.save(); - final JmeThreadExecutor executor = JmeThreadExecutor.getInstance(); + var waiter = new CountDownLatch(1); + + var executor = JmeThreadExecutor.getInstance(); executor.addToExecute(() -> { - final JmeApplication jmeApplication = JmeApplication.getInstance(); - jmeApplication.destroy(); + JmeApplication.getInstance().destroy(); + waiter.countDown(); }); GAnalytics.waitForSend(); + Utils.run(waiter::await); } /** @@ -437,10 +421,10 @@ protected void onExit() { private void buildScene() { this.scene = EditorFxSceneBuilder.build(notNull(stage)); - final InitializationManager initializationManager = InitializationManager.getInstance(); + var initializationManager = InitializationManager.getInstance(); initializationManager.onAfterCreateJavaFxContext(); - final PluginManager pluginManager = PluginManager.getInstance(); + var pluginManager = PluginManager.getInstance(); pluginManager.handlePlugins(editorPlugin -> { editorPlugin.register(FileCreatorRegistry.getInstance()); editorPlugin.register(EditorRegistry.getInstance()); @@ -453,10 +437,10 @@ private void buildScene() { editorPlugin.register(SettingsProviderRegistry.getInstance()); }); - final EditorFxScene scene = getScene(); + var scene = getScene(); - final JmeApplication jmeApplication = JmeApplication.getInstance(); - final JmeThreadExecutor executor = JmeThreadExecutor.getInstance(); + var jmeApplication = JmeApplication.getInstance(); + var executor = JmeThreadExecutor.getInstance(); executor.addToExecute(() -> createSceneProcessor(scene, jmeApplication)); JmeFilePreviewManager.getInstance(); @@ -464,10 +448,10 @@ private void buildScene() { GAnalytics.forceSendEvent(GAEvent.Category.APPLICATION, GAEvent.Action.APPLICATION_LAUNCHED, GAEvent.Label.THE_EDITOR_APP_WAS_LAUNCHED); - final ExecutorManager executorManager = ExecutorManager.getInstance(); + var executorManager = ExecutorManager.getInstance(); executorManager.addBackgroundTask(new CheckNewVersionTask()); - final EditorConfig editorConfig = EditorConfig.getInstance(); + var editorConfig = EditorConfig.getInstance(); if (editorConfig.isAnalyticsQuestion()) { return; } @@ -477,8 +461,8 @@ private void buildScene() { Platform.runLater(() -> { - final Stage stage = notNull(getStage()); - final ConfirmDialog confirmDialog = new ConfirmDialog(result -> { + var stage = notNull(getStage()); + var confirmDialog = new ConfirmDialog(result -> { editorConfig.setAnalyticsQuestion(true); editorConfig.set(PREF_ANALYTICS_GOOGLE, Boolean.TRUE.equals(result)); @@ -491,15 +475,15 @@ private void buildScene() { } @FxThread - private void createSceneProcessor(@NotNull final EditorFxScene scene, @NotNull final JmeApplication jmeApplication) { + private void createSceneProcessor(@NotNull EditorFxScene scene, @NotNull JmeApplication jmeApplication) { - final FrameTransferSceneProcessor sceneProcessor = bind(jmeApplication, scene.getCanvas(), jmeApplication.getViewPort()); + var sceneProcessor = bind(jmeApplication, scene.getCanvas(), jmeApplication.getViewPort()); sceneProcessor.setEnabled(false); sceneProcessor.setTransferMode(ON_CHANGES); this.sceneProcessor = sceneProcessor; - final Stage stage = notNull(getStage()); + var stage = notNull(getStage()); stage.focusedProperty().addListener(makeFocusedListener()); Platform.runLater(scene::notifyFinishBuild); diff --git a/src/main/java/com/ss/editor/JmeApplication.java b/src/main/java/com/ss/editor/JmeApplication.java index 7c351508..641118a1 100644 --- a/src/main/java/com/ss/editor/JmeApplication.java +++ b/src/main/java/com/ss/editor/JmeApplication.java @@ -3,12 +3,10 @@ import static com.jme3.environment.LightProbeFactory.makeProbe; import static com.ss.editor.config.DefaultSettingsProvider.Defaults.*; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.app.DebugKeysAppState; -import com.jme3.asset.AssetManager; import com.jme3.asset.AssetNotFoundException; import com.jme3.asset.plugins.ClasspathLocator; -import com.jme3.audio.AudioRenderer; import com.jme3.audio.Environment; import com.jme3.bounding.BoundingSphere; import com.jme3.environment.EnvironmentCamera; @@ -16,7 +14,7 @@ import com.jme3.environment.generation.JobProgressAdapter; import com.jme3.environment.util.EnvMapUtils; import com.jme3.font.BitmapFont; -import com.jme3.light.LightList; +import com.jme3.jfx.injfx.JmeToJfxApplication; import com.jme3.light.LightProbe; import com.jme3.material.Material; import com.jme3.material.TechniqueDef; @@ -29,8 +27,6 @@ import com.jme3.renderer.RendererException; import com.jme3.renderer.ViewPort; import com.jme3.scene.Node; -import com.jme3.system.AppSettings; -import com.jme3x.jfx.injfx.JmeToJFXApplication; import com.ss.editor.analytics.google.GAnalytics; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; @@ -47,9 +43,9 @@ import com.ss.editor.ui.event.FxEventManager; import com.ss.editor.ui.event.impl.WindowChangeFocusEvent; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.os.OperatingSystem; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.os.OperatingSystem; import jme3_ext_xbuf.XbufLoader; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -61,17 +57,16 @@ * * @author JavaSaBr */ -public class JmeApplication extends JmeToJFXApplication { +public class JmeApplication extends JmeToJfxApplication { - @NotNull private static final Logger LOGGER = LoggerManager.getLogger(JmeApplication.class); /** * The empty job adapter for handling creating {@link LightProbe}. */ @NotNull - private static final JobProgressAdapter EMPTY_JOB_ADAPTER = new JobProgressAdapter() { - public void done(final LightProbe result) { + private static final JobProgressAdapter EMPTY_JOB_ADAPTER = new JobProgressAdapter<>() { + public void done(@NotNull LightProbe result) { } }; @@ -103,15 +98,15 @@ public void done(final LightProbe result) { try { - final EditorConfig config = EditorConfig.getInstance(); - final AppSettings settings = config.getSettings(); + var config = EditorConfig.getInstance(); + var settings = config.getSettings(); JME_APPLICATION.setSettings(settings); JME_APPLICATION.setShowSettings(false); JME_APPLICATION.setDisplayStatView(false); JME_APPLICATION.setDisplayFps(false); - } catch (final Exception e) { + } catch (Exception e) { LOGGER.warning(e); throw new RuntimeException(e); } @@ -207,7 +202,7 @@ public final long asyncLock() { * @param stamp the stamp */ @FromAnyThread - public final void asyncUnlock(final long stamp) { + public final void asyncUnlock(long stamp) { lock.unlockRead(stamp); } @@ -216,7 +211,7 @@ public final void asyncUnlock(final long stamp) { public void destroy() { super.destroy(); - final WorkspaceManager workspaceManager = WorkspaceManager.getInstance(); + var workspaceManager = WorkspaceManager.getInstance(); workspaceManager.save(); System.exit(0); @@ -238,12 +233,12 @@ public void simpleInitApp() { assetManager.registerLoader(XbufLoader.class, FileExtensions.MODEL_XBUF); - final EditorConfig editorConfig = EditorConfig.getInstance(); - final OperatingSystem system = new OperatingSystem(); + var editorConfig = EditorConfig.getInstance(); + var system = new OperatingSystem(); LOGGER.debug(this, "OS: " + system.getDistribution()); - final AssetManager assetManager = getAssetManager(); + var assetManager = getAssetManager(); assetManager.unregisterLocator("", ClasspathLocator.class); assetManager.unregisterLocator("/", ClasspathLocator.class); assetManager.registerLocator("", FolderAssetLocator.class); @@ -251,7 +246,7 @@ public void simpleInitApp() { assetManager.registerLocator("", ClasspathLocator.class); assetManager.addAssetEventListener(EditorConfig.getInstance()); - final AudioRenderer audioRenderer = getAudioRenderer(); + var audioRenderer = getAudioRenderer(); audioRenderer.setEnvironment(new Environment(Environment.Garage)); viewPort.setBackgroundColor(new ColorRGBA(50 / 255F, 50 / 255F, 50 / 255F, 1F)); @@ -267,7 +262,7 @@ public void simpleInitApp() { previewViewPort.attachScene(previewNode); previewViewPort.setBackgroundColor(viewPort.getBackgroundColor()); - final Node guiNode = getGuiNode(); + var guiNode = getGuiNode(); guiNode.detachAllChildren(); ExecutorManager.getInstance(); @@ -275,7 +270,7 @@ public void simpleInitApp() { flyCam.setDragToRotate(true); flyCam.setEnabled(false); - final FilterPostProcessor postProcessor = getPostProcessor(); + var postProcessor = getPostProcessor(); fxaaFilter = new EditorFxaaFilter(); fxaaFilter.setEnabled(editorConfig.getBoolean(PREF_FILTER_FXAA, PREF_DEFAULT_FXAA_FILTER)); @@ -303,7 +298,7 @@ public void simpleInitApp() { createLightProbes(); stateManager.detach(stateManager.getState(DebugKeysAppState.class)); - final InitializationManager initializationManager = InitializationManager.getInstance(); + var initializationManager = InitializationManager.getInstance(); initializationManager.onAfterCreateJmeContext(); new EditorThread(new ThreadGroup("JavaFX"), JfxApplication::start, "JavaFX Launch").start(); @@ -325,7 +320,7 @@ public long syncLock() { * @param stamp the stamp of the lock. */ @FromAnyThread - public void syncUnlock(final long stamp) { + public void syncUnlock(long stamp) { lock.unlockWrite(stamp); } @@ -344,10 +339,10 @@ public long trySyncLock() { public void loseFocus() { super.loseFocus(); - final WindowChangeFocusEvent event = new WindowChangeFocusEvent(); + var event = new WindowChangeFocusEvent(); event.setFocused(false); - final FxEventManager eventManager = FxEventManager.getInstance(); + var eventManager = FxEventManager.getInstance(); eventManager.notify(event); } @@ -356,16 +351,16 @@ public void loseFocus() { public void gainFocus() { super.gainFocus(); - final WindowChangeFocusEvent event = new WindowChangeFocusEvent(); + var event = new WindowChangeFocusEvent(); event.setFocused(true); - final FxEventManager eventManager = FxEventManager.getInstance(); + var eventManager = FxEventManager.getInstance(); eventManager.notify(event); } @Override @JmeThread - public void simpleUpdate(final float tpf) { + public void simpleUpdate(float tpf) { super.simpleUpdate(tpf); previewNode.updateLogicalState(tpf); @@ -375,10 +370,11 @@ public void simpleUpdate(final float tpf) { @Override @JmeThread public void update() { - final long stamp = syncLock(); + + var stamp = syncLock(); try { - final JmeThreadExecutor executor = JmeThreadExecutor.getInstance(); + var executor = JmeThreadExecutor.getInstance(); executor.execute(); //System.out.println(cam.getRotation()); @@ -388,8 +384,9 @@ public void update() { super.update(); } - } catch (final AssetNotFoundException | RendererException | AssertionError | ArrayIndexOutOfBoundsException | - NullPointerException | StackOverflowError | IllegalStateException | UnsupportedOperationException e) { + } catch (AssetNotFoundException | NoSuchMethodError | RendererException | AssertionError | + ArrayIndexOutOfBoundsException | NullPointerException | StackOverflowError | + IllegalStateException | UnsupportedOperationException e) { LOGGER.warning(e); finishWorkOnError(e); } finally { @@ -401,12 +398,12 @@ public void update() { } @JmeThread - private void finishWorkOnError(@NotNull final Throwable e) { + private void finishWorkOnError(@NotNull Throwable e) { GAnalytics.sendException(e, true); GAnalytics.waitForSend(); - final WorkspaceManager workspaceManager = WorkspaceManager.getInstance(); + var workspaceManager = WorkspaceManager.getInstance(); workspaceManager.clear(); System.exit(2); @@ -428,8 +425,8 @@ private void finishWorkOnError(@NotNull final Throwable e) { @JmeThread private void createLightProbes() { - final EnvironmentCamera environmentCamera = getEnvironmentCamera(); - final EnvironmentCamera previewEnvironmentCamera = getPreviewEnvironmentCamera(); + var environmentCamera = getEnvironmentCamera(); + var previewEnvironmentCamera = getPreviewEnvironmentCamera(); if (environmentCamera == null || previewEnvironmentCamera == null) { return; @@ -444,7 +441,7 @@ private void createLightProbes() { lightProbe = makeProbe(environmentCamera, rootNode, EnvMapUtils.GenerationType.Fast, EMPTY_JOB_ADAPTER); previewLightProbe = makeProbe(previewEnvironmentCamera, previewNode, EnvMapUtils.GenerationType.Fast, EMPTY_JOB_ADAPTER); - BoundingSphere bounds = (BoundingSphere) lightProbe.getBounds(); + var bounds = (BoundingSphere) lightProbe.getBounds(); bounds.setRadius(100); bounds = (BoundingSphere) previewLightProbe.getBounds(); @@ -460,17 +457,18 @@ private void createLightProbes() { * @param progressAdapter the progress adapter */ @JmeThread - public void updateLightProbe(@NotNull final JobProgressAdapter progressAdapter) { + public void updateLightProbe(@NotNull JobProgressAdapter progressAdapter) { - final LightProbe lightProbe = getLightProbe(); - final EnvironmentCamera environmentCamera = getEnvironmentCamera(); + var lightProbe = getLightProbe(); + var environmentCamera = getEnvironmentCamera(); if (lightProbe == null || environmentCamera == null) { progressAdapter.done(null); return; } - LightProbeFactory.updateProbe(lightProbe, environmentCamera, rootNode, EnvMapUtils.GenerationType.Fast, progressAdapter); + LightProbeFactory.updateProbe(lightProbe, environmentCamera, rootNode, + EnvMapUtils.GenerationType.Fast, progressAdapter); } /** @@ -479,7 +477,7 @@ public void updateLightProbe(@NotNull final JobProgressAdapter progr @JmeThread public void disableLightProbe() { - final LightProbe lightProbe = getLightProbe(); + var lightProbe = getLightProbe(); if (lightProbe != null) { rootNode.removeLight(lightProbe); @@ -492,12 +490,12 @@ public void disableLightProbe() { @JmeThread public void enableLightProbe() { - final LightProbe lightProbe = getLightProbe(); + var lightProbe = getLightProbe(); if (lightProbe == null) { return; } - final LightList lightList = rootNode.getLocalLightList(); + var lightList = rootNode.getLocalLightList(); for (int i = 0; i < lightList.size(); i++) { if (lightList.get(i) == lightProbe) { @@ -514,17 +512,18 @@ public void enableLightProbe() { * @param progressAdapter the progress adapter */ @JmeThread - public void updatePreviewLightProbe(@NotNull final JobProgressAdapter progressAdapter) { + public void updatePreviewLightProbe(@NotNull JobProgressAdapter progressAdapter) { - final LightProbe lightProbe = getPreviewLightProbe(); - final EnvironmentCamera environmentCamera = getPreviewEnvironmentCamera(); + var lightProbe = getPreviewLightProbe(); + var environmentCamera = getPreviewEnvironmentCamera(); if (lightProbe == null || environmentCamera == null) { progressAdapter.done(null); return; } - LightProbeFactory.updateProbe(lightProbe, environmentCamera, previewNode, EnvMapUtils.GenerationType.Fast, progressAdapter); + LightProbeFactory.updateProbe(lightProbe, environmentCamera, previewNode, + EnvMapUtils.GenerationType.Fast, progressAdapter); } /** @@ -623,7 +622,7 @@ public void updatePreviewLightProbe(@NotNull final JobProgressAdapter @Nullable T get(@NotNull final String id, @NotNull final Class type, @Nullable T def) { + private @Nullable T get(@NotNull String id, @NotNull Class type, @Nullable T def) { - final Object value = DictionaryUtils.getInReadLock(settings, id, (objects, s) -> objects.get(id)); + var value = DictionaryUtils.getInReadLock(settings, id, (objects, s) -> objects.get(id)); if (value == null) { return def; } else if (type.isInstance(value)) { @@ -173,21 +170,21 @@ public EditorConfig() { } } else if (type == Vector3f.class) { if (value instanceof String) { - final String[] values = value.toString().split(","); - final float x = Float.parseFloat(values[0]); - final float y = Float.parseFloat(values[1]); - final float z = Float.parseFloat(values[2]); + var values = value.toString().split(","); + var x = Float.parseFloat(values[0]); + var y = Float.parseFloat(values[1]); + var z = Float.parseFloat(values[2]); result = unsafeCast(new Vector3f(x, y, z)); } } else if (Enum.class.isAssignableFrom(type)) { final Class enumType = unsafeCast(type); if (value instanceof String) { - final Enum enumValue = Enum.valueOf(enumType, value.toString()); + var enumValue = Enum.valueOf(enumType, value.toString()); result = unsafeCast(enumValue); } } else if (Path.class.isAssignableFrom(type)) { if (value instanceof String) { - final URI uri = Utils.get(value.toString(), URI::new); + var uri = Utils.get(value.toString(), URI::new); result = unsafeCast(Paths.get(uri)); } } @@ -207,8 +204,8 @@ public EditorConfig() { * @param value the setting's value. */ @FromAnyThread - public void set(@NotNull final String id, @Nullable final Object value) { - final long stamp = settings.writeLock(); + public void set(@NotNull String id, @Nullable Object value) { + var stamp = settings.writeLock(); try { if (value == null) { @@ -223,47 +220,47 @@ public void set(@NotNull final String id, @Nullable final Object value) { } @FromAnyThread - public boolean getBoolean(@NotNull final String id, final boolean def) { + public boolean getBoolean(@NotNull String id, boolean def) { return Boolean.TRUE.equals(get(id, Boolean.class, def)); } @FromAnyThread - public @Nullable Boolean getBoolean(@NotNull final String id) { + public @Nullable Boolean getBoolean(@NotNull String id) { return get(id, Boolean.class, null); } @FromAnyThread - public int getInteger(@NotNull final String id, final int def) { + public int getInteger(@NotNull String id, int def) { return notNull(get(id, Integer.class, def)); } @FromAnyThread - public @Nullable Integer getInteger(@NotNull final String id) { + public @Nullable Integer getInteger(@NotNull String id) { return get(id, Integer.class, null); } @FromAnyThread - public > @Nullable T getEnum(@NotNull final String id, @NotNull final Class type) { + public > @Nullable T getEnum(@NotNull String id, @NotNull Class type) { return get(id, type, null); } @FromAnyThread - public > @NotNull T getEnum(@NotNull final String id, @NotNull final T def) { + public > @NotNull T getEnum(@NotNull String id, @NotNull T def) { return notNull(get(id, unsafeCast(def.getClass()), def)); } @FromAnyThread - public @NotNull Vector3f getVector3f(@NotNull final String id, @NotNull final Vector3f def) { + public @NotNull Vector3f getVector3f(@NotNull String id, @NotNull Vector3f def) { return notNull(get(id, Vector3f.class, def)); } @FromAnyThread - public @Nullable Path getFile(@NotNull final String id) { + public @Nullable Path getFile(@NotNull String id) { return get(id, Path.class, null); } @FromAnyThread - public @Nullable String getString(@NotNull final String id) { + public @Nullable String getString(@NotNull String id) { return get(id, String.class, null); } @@ -283,10 +280,10 @@ public int getInteger(@NotNull final String id, final int def) { * @param currentAsset the current asset */ @FromAnyThread - public synchronized void addOpenedAsset(@NotNull final Path currentAsset) { + public synchronized void addOpenedAsset(@NotNull Path currentAsset) { - final String filePath = currentAsset.toString(); - final List lastOpenedAssets = getLastOpenedAssets(); + var filePath = currentAsset.toString(); + var lastOpenedAssets = getLastOpenedAssets(); lastOpenedAssets.remove(filePath); lastOpenedAssets.add(0, filePath); @@ -296,15 +293,15 @@ public synchronized void addOpenedAsset(@NotNull final Path currentAsset) { } @Override - public void assetDependencyNotFound(@Nullable final AssetKey parentKey, @Nullable final AssetKey dependentAssetKey) { + public void assetDependencyNotFound(@Nullable AssetKey parentKey, @Nullable AssetKey dependentAssetKey) { } @Override - public void assetLoaded(@NotNull final AssetKey key) { + public void assetLoaded(@NotNull AssetKey key) { } @Override - public void assetRequested(@NotNull final AssetKey key) { + public void assetRequested(@NotNull AssetKey key) { if (key instanceof TextureKey) { ((TextureKey) key).setAnisotropy(getInteger(PREF_ANISOTROPY, PREF_DEFAULT_ANISOTROPY)); } @@ -326,7 +323,7 @@ public void assetRequested(@NotNull final AssetKey key) { * @param currentAsset the current asset folder. */ @FromAnyThread - public void setCurrentAsset(@Nullable final Path currentAsset) { + public void setCurrentAsset(@Nullable Path currentAsset) { this.currentAsset = currentAsset; } @@ -336,7 +333,7 @@ public void setCurrentAsset(@Nullable final Path currentAsset) { * @param screenHeight the height of this screen. */ @FromAnyThread - public void setScreenHeight(final int screenHeight) { + public void setScreenHeight(int screenHeight) { this.screenHeight = screenHeight; } @@ -346,7 +343,7 @@ public void setScreenHeight(final int screenHeight) { * @param screenWidth the width of this screen. */ @FromAnyThread - public void setScreenWidth(final int screenWidth) { + public void setScreenWidth(int screenWidth) { this.screenWidth = screenWidth; } @@ -386,7 +383,7 @@ public boolean isMaximized() { * @param maximized true is the editor's window is maximized. */ @FromAnyThread - public void setMaximized(final boolean maximized) { + public void setMaximized(boolean maximized) { this.maximized = maximized; } @@ -416,7 +413,7 @@ public int getGlobalBottomToolHeight() { * @param globalLeftToolWidth the global left tool width. */ @FromAnyThread - public void setGlobalLeftToolWidth(final int globalLeftToolWidth) { + public void setGlobalLeftToolWidth(int globalLeftToolWidth) { this.globalLeftToolWidth = globalLeftToolWidth; } @@ -426,7 +423,7 @@ public void setGlobalLeftToolWidth(final int globalLeftToolWidth) { * @param globalBottomToolHeight the global bottom tool height. */ @FromAnyThread - public void setGlobalBottomToolHeight(final int globalBottomToolHeight) { + public void setGlobalBottomToolHeight(int globalBottomToolHeight) { this.globalBottomToolHeight = globalBottomToolHeight; } @@ -436,7 +433,7 @@ public void setGlobalBottomToolHeight(final int globalBottomToolHeight) { * @param globalLeftToolCollapsed flag is for collapsing the global left tool. */ @FromAnyThread - public void setGlobalLeftToolCollapsed(final boolean globalLeftToolCollapsed) { + public void setGlobalLeftToolCollapsed(boolean globalLeftToolCollapsed) { this.globalLeftToolCollapsed = globalLeftToolCollapsed; } @@ -446,7 +443,7 @@ public void setGlobalLeftToolCollapsed(final boolean globalLeftToolCollapsed) { * @param globalBottomToolCollapsed flag is for collapsing the global bottom tool. */ @FromAnyThread - public void setGlobalBottomToolCollapsed(final boolean globalBottomToolCollapsed) { + public void setGlobalBottomToolCollapsed(boolean globalBottomToolCollapsed) { this.globalBottomToolCollapsed = globalBottomToolCollapsed; } @@ -484,7 +481,7 @@ public boolean isAnalyticsQuestion() { * * @param analyticsQuestion true if the question was showed. */ - public void setAnalyticsQuestion(final boolean analyticsQuestion) { + public void setAnalyticsQuestion(boolean analyticsQuestion) { this.analyticsQuestion = analyticsQuestion; } @@ -496,17 +493,17 @@ public void setAnalyticsQuestion(final boolean analyticsQuestion) { @FromAnyThread public AppSettings getSettings() { - final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); - final GraphicsDevice device = graphicsEnvironment.getDefaultScreenDevice(); - final DisplayMode displayMode = device.getDisplayMode(); + var graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); + var device = graphicsEnvironment.getDefaultScreenDevice(); + var displayMode = device.getDisplayMode(); - final AppSettings settings = new AppSettings(true); + var settings = new AppSettings(true); settings.setFrequency(displayMode.getRefreshRate()); settings.setGammaCorrection(getBoolean(PREF_GAMMA_CORRECTION, PREF_DEFAULT_GAMMA_CORRECTION)); settings.setResizable(true); // settings.putBoolean("GraphicsDebug", true); - JmeToJFXIntegrator.prepareSettings(settings, getInteger(PREF_FRAME_RATE, PREF_DEFAULT_FRAME_RATE)); + JmeToJfxIntegrator.prepareSettings(settings, getInteger(PREF_FRAME_RATE, PREF_DEFAULT_FRAME_RATE)); return settings; } @@ -516,15 +513,15 @@ public AppSettings getSettings() { */ private void init() { - final Preferences prefs = Preferences.userNodeForPackage(JmeApplication.class); - final long stamp = settings.writeLock(); + var prefs = Preferences.userNodeForPackage(JmeApplication.class); + var stamp = settings.writeLock(); try { - for (final String key : prefs.keys()) { + for (var key : prefs.keys()) { settings.put(key, prefs.get(key, null)); } - } catch (final BackingStoreException e) { + } catch (BackingStoreException e) { throw new RuntimeException(e); } finally { settings.writeUnlock(stamp); @@ -539,7 +536,7 @@ private void init() { this.globalBottomToolCollapsed = prefs.getBoolean(PREF_OTHER_GLOBAL_BOTTOM_TOOL_COLLAPSED, true); this.analyticsQuestion = prefs.getBoolean(PREF_OTHER_ANALYTICS_QUESTION, false); - final String currentAssetUri = prefs.get(PREF_ASSET_CURRENT_ASSET, null); + var currentAssetUri = prefs.get(PREF_ASSET_CURRENT_ASSET, null); if (currentAssetUri != null) { this.currentAsset = Utils.get(currentAssetUri, uri -> Paths.get(new URI(uri))); @@ -549,31 +546,31 @@ private void init() { this.currentAsset = null; } - final int cameraAngle = getInteger(PREF_CAMERA_ANGLE, PREF_DEFAULT_CAMERA_ANGLE); + var cameraAngle = getInteger(PREF_CAMERA_ANGLE, PREF_DEFAULT_CAMERA_ANGLE); System.setProperty("jfx.frame.transfer.camera.angle", String.valueOf(cameraAngle)); - final byte[] byteArray = prefs.getByteArray(PREF_ASSET_LAST_OPENED_ASSETS, null); + var byteArray = prefs.getByteArray(PREF_ASSET_LAST_OPENED_ASSETS, null); if (byteArray == null) { return; } - final List lastOpenedAssets = getLastOpenedAssets(); + var lastOpenedAssets = getLastOpenedAssets(); try { lastOpenedAssets.addAll(EditorUtil.deserialize(byteArray)); - for (Iterator iterator = lastOpenedAssets.iterator(); iterator.hasNext(); ) { + for (var iterator = lastOpenedAssets.iterator(); iterator.hasNext(); ) { - final String assetUrl = iterator.next(); - final Path assetPath = Utils.get(assetUrl, uri -> Paths.get(uri)); + var assetUrl = iterator.next(); + var assetPath = Utils.get(assetUrl, uri -> Paths.get(uri)); if (!Files.exists(assetPath)) { iterator.remove(); } } - } catch (final RuntimeException e) { + } catch (RuntimeException e) { LOGGER.warning(e); } } @@ -584,9 +581,9 @@ private void init() { @FromAnyThread public synchronized void save() { - final Preferences prefs = Preferences.userNodeForPackage(JmeApplication.class); + var prefs = Preferences.userNodeForPackage(JmeApplication.class); - final long stamp = settings.readLock(); + var stamp = settings.readLock(); try { settings.forEach((key, value) -> { @@ -629,12 +626,12 @@ public synchronized void save() { prefs.remove(PREF_ASSET_CURRENT_ASSET); } - final List lastOpenedAssets = getLastOpenedAssets(); + prefs.putByteArray(PREF_ASSET_LAST_OPENED_ASSETS, + EditorUtil.serialize((Serializable) getLastOpenedAssets())); - prefs.putByteArray(PREF_ASSET_LAST_OPENED_ASSETS, EditorUtil.serialize((Serializable) lastOpenedAssets)); try { prefs.flush(); - } catch (final BackingStoreException e) { + } catch (BackingStoreException e) { throw new RuntimeException(e); } } diff --git a/src/main/java/com/ss/editor/control/painting/spawn/SpawnToolControl.java b/src/main/java/com/ss/editor/control/painting/spawn/SpawnToolControl.java index 849f2618..59c08db2 100644 --- a/src/main/java/com/ss/editor/control/painting/spawn/SpawnToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/spawn/SpawnToolControl.java @@ -2,14 +2,13 @@ import static com.ss.editor.part3d.editor.impl.scene.AbstractSceneEditor3DPart.KEY_IGNORE_RAY_CAST; import static com.ss.editor.util.EditorUtil.getAssetManager; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayCollectors.toArray; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; import com.jme3.asset.ModelKey; -import com.jme3.collision.CollisionResult; -import com.jme3.collision.CollisionResults; +import com.jme3.bounding.BoundingBox; +import com.jme3.bounding.BoundingVolume; import com.jme3.math.ColorRGBA; import com.jme3.math.Quaternion; -import com.jme3.math.Ray; import com.jme3.math.Vector3f; import com.jme3.scene.AssetLinkNode; import com.jme3.scene.Geometry; @@ -22,17 +21,17 @@ import com.ss.editor.control.painting.PaintingInput; import com.ss.editor.control.painting.impl.AbstractPaintingControl; import com.ss.editor.model.undo.editor.ModelChangeConsumer; -import com.ss.editor.ui.component.painting.spawn.SpawnPaintingComponent; import com.ss.editor.model.undo.impl.AddChildOperation; +import com.ss.editor.ui.component.painting.spawn.SpawnPaintingComponent; import com.ss.editor.util.GeomUtils; -import com.ss.editor.util.LocalObjects; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import jme3tools.optimize.GeometryBatchFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Random; import java.util.concurrent.ThreadLocalRandom; /** @@ -47,10 +46,16 @@ public enum SpawnMethod { BATCH(Messages.PAINTING_COMPONENT_SPAWN_MODELS_METHOD_BATCH), LINK(Messages.PAINTING_COMPONENT_SPAWN_MODELS_METHOD_LINK); + private static final SpawnMethod[] SPAWN_METHODS = values(); + + public static @NotNull SpawnMethod valueOf(int index) { + return SPAWN_METHODS[index]; + } + @NotNull private final String label; - SpawnMethod(@NotNull final String label) { + SpawnMethod(@NotNull String label) { this.label = label; } @@ -73,10 +78,22 @@ public String toString() { private final Array examples; /** - * The models scale. + * The models min minScale. + */ + @NotNull + private final Vector3f minScale; + + /** + * The models max minScale. + */ + @NotNull + private final Vector3f maxScale; + + /** + * The models padding. */ @NotNull - private final Vector3f scale; + private final Vector3f padding; /** * The spawn method. @@ -89,12 +106,14 @@ public String toString() { */ private float time; - public SpawnToolControl(@NotNull final SpawnPaintingComponent component) { + public SpawnToolControl(@NotNull SpawnPaintingComponent component) { super(component); this.spawnedModels = ArrayFactory.newArray(Spatial.class); this.examples = ArrayFactory.newArray(Spatial.class); this.method = SpawnMethod.BATCH; - this.scale = new Vector3f(1F, 1F, 1F); + this.minScale = Vector3f.UNIT_XYZ.clone(); + this.maxScale = Vector3f.UNIT_XYZ.clone(); + this.padding = Vector3f.ZERO.clone(); } /** @@ -113,28 +132,68 @@ public SpawnToolControl(@NotNull final SpawnPaintingComponent component) { * @param method the spawn method. */ @JmeThread - public void setMethod(@NotNull final SpawnMethod method) { + public void setMethod(@NotNull SpawnMethod method) { this.method = method; } /** - * Get the models scale. + * Get the models min scale. + * + * @return the models min scale. + */ + @JmeThread + private @NotNull Vector3f getMinScale() { + return minScale; + } + + /** + * Get the models max scale. + * + * @return the models max scale. + */ + @JmeThread + private @NotNull Vector3f getMaxScale() { + return maxScale; + } + + /** + * Get the models padding. + * + * @return the models padding. + */ + @JmeThread + private @NotNull Vector3f getPadding() { + return minScale; + } + + /** + * Set the models min scale. * - * @return the models scale. + * @param minScale the models min scale. */ @JmeThread - private @NotNull Vector3f getScale() { - return scale; + public void setMinScale(@NotNull Vector3f minScale) { + this.minScale.set(minScale); } /** - * Set the models scale. + * Set the models min scale. * - * @param scale the models scale. + * @param minScale the models min scale. */ @JmeThread - public void setScale(@NotNull final Vector3f scale) { - this.scale.set(scale); + public void setMaxScale(@NotNull Vector3f minScale) { + this.maxScale.set(minScale); + } + + /** + * Set the models min scale. + * + * @param padding the models padding. + */ + @JmeThread + public void setPadding(@NotNull Vector3f padding) { + this.padding.set(padding); } @Override @@ -159,7 +218,7 @@ public void setScale(@NotNull final Vector3f scale) { * @param examples the list of available examples. */ @JmeThread - public void updateExamples(@NotNull final Array examples) { + public void updateExamples(@NotNull Array examples) { this.examples.clear(); this.examples.addAll(examples); } @@ -191,10 +250,13 @@ public void updateExamples(@NotNull final Array examples) { } @Override - public void startPainting(@NotNull final PaintingInput input, @NotNull final Quaternion brushRotation, - @NotNull final Vector3f contactPoint) { + public void startPainting( + @NotNull PaintingInput input, + @NotNull Quaternion brushRotation, + @NotNull Vector3f contactPoint + ) { - final Array spawnedModel = getExamples(); + var spawnedModel = getExamples(); if (spawnedModel.isEmpty()) { return; } @@ -207,8 +269,7 @@ public void startPainting(@NotNull final PaintingInput input, @NotNull final Qua @Override @JmeThread - public void updatePainting(@NotNull final Quaternion brushRotation, @NotNull final Vector3f contactPoint, - final float tpf) { + public void updatePainting(@NotNull Quaternion brushRotation, @NotNull Vector3f contactPoint, float tpf) { time += (tpf * 10F); @@ -217,7 +278,7 @@ public void updatePainting(@NotNull final Quaternion brushRotation, @NotNull fin return; } - final PaintingInput currentInput = notNull(getCurrentInput()); + var currentInput = notNull(getCurrentInput()); switch (currentInput) { case MOUSE_PRIMARY: { @@ -234,38 +295,45 @@ public void updatePainting(@NotNull final Quaternion brushRotation, @NotNull fin * @param contactPoint the contact point. */ @JmeThread - protected void spawn(@NotNull final Quaternion brushRotation, @NotNull final Vector3f contactPoint) { + protected void spawn(@NotNull Quaternion brushRotation, @NotNull Vector3f contactPoint) { - final float brushSize = getBrushSize(); + var brushSize = getBrushSize(); - final ThreadLocalRandom random = ThreadLocalRandom.current(); - final LocalObjects local = getLocalObjects(); - final Vector3f spawnPosition = local.nextVector(); + var random = ThreadLocalRandom.current(); + var local = getLocalObjects(); + var spawnPosition = local.nextVector(); - final Node paintedModel = getPaintedModel(); - final Vector3f direction = GeomUtils.getDirection(brushRotation, local.nextVector()) + var paintedModel = getPaintedModel(); + var direction = GeomUtils.getDirection(brushRotation, local.nextVector()) .negateLocal() .multLocal(10); - final Vector3f sourcePoint = contactPoint.subtract(direction, local.nextVector()); - final Ray ray = local.nextRay(); + var sourcePoint = contactPoint.subtract(direction, local.nextVector()); + var ray = local.nextRay(); ray.setOrigin(sourcePoint); - final Vector3f scale = getScale(); - final Vector3f resultPosition = local.nextVector(); - final CollisionResults collisions = local.nextCollisionResults(); - final CollisionResults spawnedCollisions = local.nextCollisionResults(); + var minScale = getMinScale(); + var maxScale = getMaxScale(); + var padding = getPadding(); + + var resultPosition = local.nextVector(); + var collisions = local.nextCollisionResults(); + var spawnedCollisions = local.nextCollisionResults(); + var resultScale = local.nextVector(); + var needCalculateScale = !minScale.equals(maxScale); - final int maxCount = (int) Math.max(getBrushPower() / 2F, 1F); + var maxCount = (int) Math.max(getBrushPower() / 2F, 1F); + var spawnedModels = getSpawnedModels(); + + for(var count = 0; count < maxCount; count++) { + for (var attempts = 0; attempts < 10; attempts++, attempts++) { - for(int count = 0; count < maxCount; count++) { - for (int attempts = 0; attempts < 10; attempts++, attempts++) { collisions.clear(); spawnedCollisions.clear(); - final float x = nextOffset(brushSize, random); - final float y = nextOffset(brushSize, random); - final float z = nextOffset(brushSize, random); + var x = nextOffset(brushSize, random); + var y = nextOffset(brushSize, random); + var z = nextOffset(brushSize, random); spawnPosition.set(x, y, z) .addLocal(contactPoint) @@ -276,7 +344,7 @@ protected void spawn(@NotNull final Quaternion brushRotation, @NotNull final Vec paintedModel.collideWith(ray, collisions); - final CollisionResult closest = collisions.getClosestCollision(); + var closest = collisions.getClosestCollision(); if (closest == null || contactPoint.distance(closest.getContactPoint()) > brushSize / 2) { continue; } @@ -284,23 +352,78 @@ protected void spawn(@NotNull final Quaternion brushRotation, @NotNull final Vec resultPosition.set(closest.getContactPoint()) .subtractLocal(paintedModel.getWorldTranslation()); - final Spatial clone = examples.get(random.nextInt(0, examples.size())).clone(); + Spatial clone = examples.get(random.nextInt(0, examples.size())).clone(); clone.setUserData(KEY_IGNORE_RAY_CAST, Boolean.TRUE); clone.setLocalTranslation(resultPosition); - clone.setLocalScale(scale); + + if (needCalculateScale) { + clone.setLocalScale(nextScale(minScale, maxScale, resultScale, random)); + } else { + clone.setLocalScale(minScale); + } + clone.updateModelBound(); - if (paintedModel.collideWith(clone.getWorldBound(), spawnedCollisions) > 2) { + var worldBound = clone.getWorldBound(); + + if (!Vector3f.ZERO.equals(padding)) { + worldBound = addPadding(worldBound, padding); + } + + if (paintedModel.collideWith(worldBound, spawnedCollisions) > 2) { continue; } - getSpawnedModels().add(clone); + spawnedModels.add(clone); paintedModel.attachChild(clone); break; } } } + protected BoundingVolume addPadding(@NotNull BoundingVolume boundingVolume, @NotNull Vector3f padding) { + + if (boundingVolume instanceof BoundingBox) { + var box = (BoundingBox) boundingVolume; + var xExtent = box.getXExtent() + padding.getX(); + var yExtent = box.getYExtent() + padding.getY(); + var zExtent = box.getZExtent() + padding.getZ(); + return new BoundingBox(box.getCenter(), xExtent, yExtent, zExtent); + } + + return boundingVolume; + } + + /** + * Calculate a new random scale. + * + * @param minScale the min scale. + * @param maxScale the max scale. + * @param result the result vector. + * @param random the random. + * @return the result vector. + */ + protected Vector3f nextScale( + @NotNull Vector3f minScale, + @NotNull Vector3f maxScale, + @NotNull Vector3f result, + @NotNull Random random + ) { + + float newX = nextScale(random, minScale.getX(), maxScale.getX()); + float newY = nextScale(random, minScale.getX(), maxScale.getX()); + float newZ = nextScale(random, minScale.getX(), maxScale.getX()); + + return result.set(newX, newY, newZ); + } + + protected float nextScale(@NotNull Random random, float min, float max) { + int minInt = (int) (Math.min(min, max) * 1000); + int maxInt = (int) (Math.max(max, min) * 1000); + int added = random.nextInt(maxInt - minInt); + return Math.min(min, max) + (added / 1000F); + } + /** * Calculate next random offset. * @@ -309,7 +432,7 @@ protected void spawn(@NotNull final Quaternion brushRotation, @NotNull final Vec * @return the new coordinate. */ @JmeThread - protected float nextOffset(final float brushSize, @NotNull final ThreadLocalRandom random) { + protected float nextOffset(float brushSize, @NotNull ThreadLocalRandom random) { float result = random.nextInt(0, (int) (brushSize * 100)) / 100F; result /= 2F; return random.nextBoolean() ? result * -1 : result; @@ -317,38 +440,43 @@ protected float nextOffset(final float brushSize, @NotNull final ThreadLocalRand @Override @JmeThread - public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull final Vector3f contactPoint) { + public void finishPainting(@NotNull Quaternion brushRotation, @NotNull Vector3f contactPoint) { super.finishPainting(brushRotation, contactPoint); - final Array spawnedModels = getSpawnedModels(); + var spawnedModels = getSpawnedModels(); if (spawnedModels.isEmpty()) { return; } - final LocalObjects local = getLocalObjects(); - final Vector3f location = local.nextVector(); - final Vector3f offset = local.nextVector(); - offset.set(contactPoint); + var local = getLocalObjects(); + var location = local.nextVector(); + var offset = local.nextVector() + .set(contactPoint); spawnedModels.stream().peek(Spatial::removeFromParent) .forEach(sp -> sp.setUserData(KEY_IGNORE_RAY_CAST, null)); - final Node paintedModel = notNull(getPaintedModel()); - final Node parent = paintedModel instanceof Terrain ? + var paintedModel = notNull(getPaintedModel()); + + Node parent = paintedModel instanceof Terrain ? NodeUtils.findParent(paintedModel, sp -> !(sp instanceof Terrain)) : paintedModel; if (parent != paintedModel) { - final Vector3f diff = local.nextVector(); - diff.set(parent.getWorldTranslation()).subtractLocal(paintedModel.getWorldTranslation()); + + var diff = local.nextVector(); + diff.set(parent.getWorldTranslation()) + .subtractLocal(paintedModel.getWorldTranslation()); + offset.addLocal(diff); } - final ModelChangeConsumer changeConsumer = getChangeConsumer(); + var changeConsumer = getChangeConsumer(); + + var method = getMethod(); - final SpawnMethod method = getMethod(); switch (method) { case AS_IS: { - final Node spawnedNode = new Node("Spawned"); + var spawnedNode = new Node("Spawned"); spawnedNode.setLocalTranslation(contactPoint); spawnedModels.forEach(geom -> updatePositionAndAttach(offset, location, spawnedNode, geom)); spawnedNode.updateModelBound(); @@ -357,7 +485,7 @@ public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull fin } case LINK: { - final Node spawnedNode = new Node("Spawned"); + var spawnedNode = new Node("Spawned"); spawnedNode.setLocalTranslation(contactPoint); spawnedModels.stream().map(this::linkSpatial) .forEach(geom -> updatePositionAndAttach(offset, location, spawnedNode, geom)); @@ -369,9 +497,10 @@ public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull fin } case BATCH: { - final Node spawnedNode = new Node("Spawned"); + var spawnedNode = new Node("Spawned"); spawnedNode.setLocalTranslation(contactPoint); - final Array geometries = spawnedModels.stream() + + var geometries = spawnedModels.stream() .flatMap(NodeUtils::children) .filter(Geometry.class::isInstance) .map(Geometry.class::cast) @@ -389,10 +518,14 @@ public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull fin } @JmeThread - protected void updatePositionAndAttach(@NotNull final Vector3f contactPoint, @NotNull final Vector3f location, - @NotNull final Node spawnedNode, @NotNull final Spatial geom) { - - final Vector3f newPosition = location.set(geom.getLocalTranslation()) + protected void updatePositionAndAttach( + @NotNull Vector3f contactPoint, + @NotNull Vector3f location, + @NotNull Node spawnedNode, + @NotNull Spatial geom + ) { + + var newPosition = location.set(geom.getLocalTranslation()) .subtractLocal(contactPoint); geom.setLocalTranslation(newPosition); @@ -406,11 +539,11 @@ protected void updatePositionAndAttach(@NotNull final Vector3f contactPoint, @No * @return the asset link node. */ @JmeThread - protected @NotNull AssetLinkNode linkSpatial(@NotNull final Spatial spatial) { - final AssetLinkNode linkNode = new AssetLinkNode(); + protected @NotNull AssetLinkNode linkSpatial(@NotNull Spatial spatial) { + var linkNode = new AssetLinkNode(); linkNode.setLocalTranslation(spatial.getLocalTranslation()); linkNode.setName(spatial.getName()); - linkNode.setLocalScale(getScale()); + linkNode.setLocalScale(getMinScale()); linkNode.attachLinkedChild(getAssetManager(), (ModelKey) spatial.getKey()); return linkNode; } diff --git a/src/main/java/com/ss/editor/control/painting/terrain/ChangeHeightTerrainToolControl.java b/src/main/java/com/ss/editor/control/painting/terrain/ChangeHeightTerrainToolControl.java index 1490423d..578c125f 100644 --- a/src/main/java/com/ss/editor/control/painting/terrain/ChangeHeightTerrainToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/terrain/ChangeHeightTerrainToolControl.java @@ -1,6 +1,6 @@ package com.ss.editor.control.painting.terrain; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.scene.Node; @@ -13,11 +13,11 @@ import com.ss.editor.ui.component.painting.terrain.TerrainPaintingComponent; import com.ss.editor.ui.control.property.operation.PropertyOperation; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.Dictionary; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.Dictionary; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; diff --git a/src/main/java/com/ss/editor/control/painting/terrain/LevelTerrainToolControl.java b/src/main/java/com/ss/editor/control/painting/terrain/LevelTerrainToolControl.java index f99f0883..c8d1b346 100644 --- a/src/main/java/com/ss/editor/control/painting/terrain/LevelTerrainToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/terrain/LevelTerrainToolControl.java @@ -1,25 +1,24 @@ package com.ss.editor.control.painting.terrain; -import static com.ss.editor.util.PaintingUtils.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.editor.util.PaintingUtils.isContains; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; import com.jme3.math.Quaternion; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.Node; -import com.jme3.scene.Spatial; +import com.jme3.scene.Spatial.CullHint; import com.jme3.scene.shape.Sphere; -import com.jme3.terrain.Terrain; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; import com.ss.editor.control.painting.PaintingInput; import com.ss.editor.ui.component.painting.terrain.TerrainPaintingComponent; -import com.ss.editor.util.LocalObjects; +import com.ss.editor.util.PaintingUtils; +import com.ss.rlib.common.util.ExtMath; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.List; /** * The implementation of terrain tool to change height by level. @@ -49,7 +48,7 @@ public class LevelTerrainToolControl extends ChangeHeightTerrainToolControl { */ private boolean precision; - public LevelTerrainToolControl(@NotNull final TerrainPaintingComponent component) { + public LevelTerrainToolControl(@NotNull TerrainPaintingComponent component) { super(component); this.levelMarker = new Geometry("LevelMarker", new Sphere(8, 8, 1)); @@ -58,34 +57,31 @@ public LevelTerrainToolControl(@NotNull final TerrainPaintingComponent component @Override @JmeThread - protected void onAttached(@NotNull final Node node) { + protected void onAttached(@NotNull Node node) { super.onAttached(node); - final Spatial editedModel = notNull(getPaintedModel()); - final Geometry levelMarker = getLevelMarker(); + var editedModel = notNull(getPaintedModel()); + var levelMarker = getLevelMarker(); - final Node markersNode = component.getMarkersNode(); - markersNode.attachChild(levelMarker); + component.getMarkersNode() + .attachChild(levelMarker); levelMarker.setLocalTranslation(editedModel.getWorldTranslation()); } @Override @JmeThread - protected void onDetached(@NotNull final Node node) { + protected void onDetached(@NotNull Node node) { super.onDetached(node); - - final Node markersNode = component.getMarkersNode(); - markersNode.detachChild(getLevelMarker()); + component.getMarkersNode() + .detachChild(getLevelMarker()); } @Override @JmeThread - protected void controlUpdate(final float tpf) { + protected void controlUpdate(float tpf) { super.controlUpdate(tpf); - - final Geometry levelMarker = getLevelMarker(); - levelMarker.setCullHint(isUseMarker() ? Spatial.CullHint.Never : Spatial.CullHint.Always); + getLevelMarker().setCullHint(isUseMarker() ? CullHint.Never : CullHint.Always); } @Override @@ -96,8 +92,11 @@ protected void controlUpdate(final float tpf) { @Override @JmeThread - public void startPainting(@NotNull final PaintingInput input, @NotNull final Quaternion brushRotation, - @NotNull final Vector3f contactPoint) { + public void startPainting( + @NotNull PaintingInput input, + @NotNull Quaternion brushRotation, + @NotNull Vector3f contactPoint + ) { super.startPainting(input, brushRotation, contactPoint); switch (input) { @@ -115,12 +114,10 @@ public void startPainting(@NotNull final PaintingInput input, @NotNull final Qua @Override @JmeThread - public void updatePainting(@NotNull final Quaternion brushRotation, @NotNull final Vector3f contactPoint, - final float tpf) { + public void updatePainting(@NotNull Quaternion brushRotation, @NotNull Vector3f contactPoint, float tpf) { + super.updatePainting(brushRotation, contactPoint, tpf); - final PaintingInput input = notNull(getCurrentInput()); - - switch (input) { + switch (notNull(getCurrentInput())) { case MOUSE_PRIMARY: { modifyHeight(contactPoint); break; @@ -134,12 +131,10 @@ public void updatePainting(@NotNull final Quaternion brushRotation, @NotNull fin @Override @JmeThread - public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull final Vector3f contactPoint) { + public void finishPainting(@NotNull Quaternion brushRotation, @NotNull Vector3f contactPoint) { super.finishPainting(brushRotation, contactPoint); - final PaintingInput input = notNull(getCurrentInput()); - - switch (input) { + switch (notNull(getCurrentInput())) { case MOUSE_PRIMARY: { modifyHeight(contactPoint); commitChanges(); @@ -158,38 +153,38 @@ public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull fin * @param contactPoint the contact point. */ @JmeThread - private void modifyHeight(@NotNull final Vector3f contactPoint) { + private void modifyHeight(@NotNull Vector3f contactPoint) { - final LocalObjects local = getLocalObjects(); - final Spatial paintedModel = notNull(getPaintedModel()); - final Geometry brush = getBrush(); - final Geometry levelMarker = getLevelMarker(); + var local = getLocalObjects(); + var paintedModel = notNull(getPaintedModel()); + var brush = getBrush(); + var levelMarker = getLevelMarker(); - final float brushSize = getBrushSize(); - final float brushPower = getBrushPower(); + var brushSize = getBrushSize(); + var brushPower = getBrushPower(); - final List locs = new ArrayList<>(); - final List heights = new ArrayList<>(); + var locs = new ArrayList(); + var heights = new ArrayList(); - for (final Terrain terrain : getTerrains()) { + for (var terrain : getTerrains()) { - final Node terrainNode = (Node) terrain; + var terrainNode = (Node) terrain; - final Vector3f markerTranslation = levelMarker.getLocalTranslation(); - final Vector3f worldTranslation = terrainNode.getWorldTranslation(); - final Vector3f localScale = terrainNode.getLocalScale(); - final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector()); - final Vector2f terrainLoc = local.nextVector2f(); - final Vector2f effectPoint = local.nextVector2f(); + var markerTranslation = levelMarker.getLocalTranslation(); + var worldTranslation = terrainNode.getWorldTranslation(); + var localScale = terrainNode.getLocalScale(); + var localPoint = contactPoint.subtract(worldTranslation, local.nextVector()); + var terrainLoc = local.nextVector2f(); + var effectPoint = local.nextVector2f(); - final float markerHeight = markerTranslation.getY() - worldTranslation.getY(); - final float desiredHeight = isUseMarker() ? markerHeight : getLevel(); + var markerHeight = markerTranslation.getY() - worldTranslation.getY(); + var desiredHeight = isUseMarker() ? markerHeight : getLevel(); - final int radiusStepsX = (int) (brushSize / localScale.getX()); - final int radiusStepsZ = (int) (brushSize / localScale.getZ()); + var radiusStepsX = (int) (brushSize / localScale.getX()); + var radiusStepsZ = (int) (brushSize / localScale.getZ()); - final float xStepAmount = localScale.getX(); - final float zStepAmount = localScale.getZ(); + var xStepAmount = localScale.getX(); + var zStepAmount = localScale.getZ(); locs.clear(); heights.clear(); @@ -197,8 +192,8 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) { for (int z = -radiusStepsZ; z < radiusStepsZ; z++) { for (int x = -radiusStepsX; x < radiusStepsX; x++) { - float locX = localPoint.getX() + (x * xStepAmount); - float locZ = localPoint.getZ() + (z * zStepAmount); + var locX = localPoint.getX() + (x * xStepAmount); + var locZ = localPoint.getZ() + (z * zStepAmount); effectPoint.set(locX - localPoint.getX(), locZ - localPoint.getZ()); @@ -209,30 +204,33 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) { terrainLoc.set(locX, locZ); // adjust height based on radius of the tool - final float currentHeight = terrain.getHeightmapHeight(terrainLoc) * localScale.getY(); + var currentHeight = terrain.getHeightmapHeight(terrainLoc) * localScale.getY(); if (isPrecision()) { locs.add(terrainLoc.clone()); heights.add(desiredHeight / localScale.getY()); } else { - float epsilon = 0.0001f * brushPower; // rounding error for snapping - float adj = 0; + var epsilon = 0.0001f * brushPower; // rounding error for snapping + var adj = 0F; - if (currentHeight < desiredHeight) adj = 1; - else if (currentHeight > desiredHeight) adj = -1; + if (currentHeight < desiredHeight) { + adj = 1; + } else if (currentHeight > desiredHeight) { + adj = -1; + } adj *= brushPower; - adj *= calculateRadiusPercent(brushSize, effectPoint.getX(), effectPoint.getY()); + adj *= PaintingUtils.calculateRadiusPercent(brushSize, effectPoint.getX(), effectPoint.getY()); // test if adjusting too far and then cap it - if (adj > 0 && floatGreaterThan((currentHeight + adj), desiredHeight, epsilon)) { + if (adj > 0 && ExtMath.greaterThan((currentHeight + adj), desiredHeight, epsilon)) { adj = desiredHeight - currentHeight; - } else if (adj < 0 && floatLessThan((currentHeight + adj), desiredHeight, epsilon)) { + } else if (adj < 0 && ExtMath.lessThan((currentHeight + adj), desiredHeight, epsilon)) { adj = desiredHeight - currentHeight; } - if (!floatEquals(adj, 0, 0.001f)) { + if (!ExtMath.equals(adj, 0, 0.001f)) { locs.add(terrainLoc.clone()); heights.add(currentHeight + adj); } @@ -256,7 +254,7 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) { * @param level the target level. */ @JmeThread - public void setLevel(final float level) { + public void setLevel(float level) { this.level = level; } @@ -286,7 +284,7 @@ private boolean isPrecision() { * @param precision the flag of using precision changing. */ @JmeThread - public void setPrecision(final boolean precision) { + public void setPrecision(boolean precision) { this.precision = precision; } @@ -296,7 +294,7 @@ public void setPrecision(final boolean precision) { * @param useMarker the flag of using marker. */ @JmeThread - public void setUseMarker(final boolean useMarker) { + public void setUseMarker(boolean useMarker) { this.useMarker = useMarker; } diff --git a/src/main/java/com/ss/editor/control/painting/terrain/PaintTerrainToolControl.java b/src/main/java/com/ss/editor/control/painting/terrain/PaintTerrainToolControl.java index 09c2e9cf..b0190ba6 100644 --- a/src/main/java/com/ss/editor/control/painting/terrain/PaintTerrainToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/terrain/PaintTerrainToolControl.java @@ -1,6 +1,6 @@ package com.ss.editor.control.painting.terrain; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; import com.jme3.math.Quaternion; import com.jme3.math.Vector2f; @@ -18,9 +18,9 @@ import com.ss.editor.ui.component.painting.terrain.TerrainPaintingComponent; import com.ss.editor.ui.control.property.operation.PropertyOperation; import com.ss.editor.util.LocalObjects; -import com.ss.rlib.function.ObjectFloatObjectConsumer; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.function.ObjectFloatObjectConsumer; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/control/painting/terrain/RaiseLowerTerrainToolControl.java b/src/main/java/com/ss/editor/control/painting/terrain/RaiseLowerTerrainToolControl.java index a590fbb9..80af451a 100644 --- a/src/main/java/com/ss/editor/control/painting/terrain/RaiseLowerTerrainToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/terrain/RaiseLowerTerrainToolControl.java @@ -2,7 +2,7 @@ import static com.ss.editor.util.PaintingUtils.calculateHeight; import static com.ss.editor.util.PaintingUtils.isContains; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; import com.jme3.math.Quaternion; import com.jme3.math.Vector2f; diff --git a/src/main/java/com/ss/editor/control/painting/terrain/RoughTerrainToolControl.java b/src/main/java/com/ss/editor/control/painting/terrain/RoughTerrainToolControl.java index 86534e41..76419d96 100644 --- a/src/main/java/com/ss/editor/control/painting/terrain/RoughTerrainToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/terrain/RoughTerrainToolControl.java @@ -1,7 +1,7 @@ package com.ss.editor.control.painting.terrain; import static com.ss.editor.util.PaintingUtils.isContains; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.lang.Math.max; import static java.lang.Math.min; import com.jme3.math.ColorRGBA; diff --git a/src/main/java/com/ss/editor/control/painting/terrain/SlopeTerrainToolControl.java b/src/main/java/com/ss/editor/control/painting/terrain/SlopeTerrainToolControl.java index ab488379..64d35c4c 100644 --- a/src/main/java/com/ss/editor/control/painting/terrain/SlopeTerrainToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/terrain/SlopeTerrainToolControl.java @@ -1,24 +1,25 @@ package com.ss.editor.control.painting.terrain; -import static com.ss.editor.util.PaintingUtils.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.editor.util.PaintingUtils.isContains; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.lang.Math.max; -import com.jme3.math.*; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.Node; -import com.jme3.scene.Spatial; import com.jme3.scene.shape.Line; import com.jme3.scene.shape.Sphere; -import com.jme3.terrain.Terrain; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; import com.ss.editor.control.painting.PaintingInput; import com.ss.editor.ui.component.painting.terrain.TerrainPaintingComponent; -import com.ss.editor.util.LocalObjects; +import com.ss.editor.util.PaintingUtils; +import com.ss.rlib.common.util.ExtMath; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.List; /** * The implementation of terrain tool to make slopes. @@ -55,7 +56,7 @@ public class SlopeTerrainToolControl extends ChangeHeightTerrainToolControl { */ private boolean lock; - public SlopeTerrainToolControl(@NotNull final TerrainPaintingComponent component) { + public SlopeTerrainToolControl(@NotNull TerrainPaintingComponent component) { super(component); this.baseMarker = new Geometry("BaseMarker", new Sphere(8, 8, 1)); @@ -74,15 +75,15 @@ public SlopeTerrainToolControl(@NotNull final TerrainPaintingComponent component @Override @JmeThread - protected void onAttached(@NotNull final Node node) { + protected void onAttached(@NotNull Node node) { super.onAttached(node); - final Spatial editedModel = notNull(getPaintedModel()); - final Geometry baseMarker = getBaseMarker(); - final Geometry targetMarker = getTargetMarker(); - final Geometry line = getLine(); + var editedModel = notNull(getPaintedModel()); + var baseMarker = getBaseMarker(); + var targetMarker = getTargetMarker(); + var line = getLine(); - final Node markersNode = component.getMarkersNode(); + var markersNode = component.getMarkersNode(); markersNode.attachChild(baseMarker); markersNode.attachChild(targetMarker); markersNode.attachChild(line); @@ -93,14 +94,14 @@ protected void onAttached(@NotNull final Node node) { @Override @JmeThread - protected void onDetached(@NotNull final Node node) { + protected void onDetached(@NotNull Node node) { super.onDetached(node); - final Geometry baseMarker = getBaseMarker(); - final Geometry targetMarker = getTargetMarker(); - final Geometry line = getLine(); + var baseMarker = getBaseMarker(); + var targetMarker = getTargetMarker(); + var line = getLine(); - final Node markersNode = component.getMarkersNode(); + var markersNode = component.getMarkersNode(); markersNode.detachChild(baseMarker); markersNode.detachChild(targetMarker); markersNode.detachChild(line); @@ -108,24 +109,27 @@ protected void onDetached(@NotNull final Node node) { @Override @JmeThread - protected void controlUpdate(final float tpf) { + protected void controlUpdate(float tpf) { super.controlUpdate(tpf); - final Geometry baseMarker = getBaseMarker(); - final Geometry targetMarker = getTargetMarker(); - final Geometry line = getLine(); + var baseMarker = getBaseMarker(); + var targetMarker = getTargetMarker(); + var line = getLine(); - final Vector3f firstPoint = baseMarker.getLocalTranslation(); - final Vector3f secondPoint = targetMarker.getLocalTranslation(); + var firstPoint = baseMarker.getLocalTranslation(); + var secondPoint = targetMarker.getLocalTranslation(); - final Line mesh = (Line) line.getMesh(); + var mesh = (Line) line.getMesh(); mesh.updatePoints(firstPoint, secondPoint); } @Override @JmeThread - public void startPainting(@NotNull final PaintingInput input, @NotNull final Quaternion brushRotation, - @NotNull final Vector3f contactPoint) { + public void startPainting( + @NotNull PaintingInput input, + @NotNull Quaternion brushRotation, + @NotNull Vector3f contactPoint + ) { super.startPainting(input, brushRotation, contactPoint); switch (input) { @@ -147,12 +151,10 @@ public void startPainting(@NotNull final PaintingInput input, @NotNull final Qua @Override @JmeThread - public void updatePainting(@NotNull final Quaternion brushRotation, @NotNull final Vector3f contactPoint, - final float tpf) { + public void updatePainting(@NotNull Quaternion brushRotation, @NotNull Vector3f contactPoint, float tpf) { + super.updatePainting(brushRotation, contactPoint, tpf); - final PaintingInput input = notNull(getCurrentInput()); - - switch (input) { + switch (notNull(getCurrentInput())) { case MOUSE_PRIMARY: { modifyHeight(contactPoint); break; @@ -170,7 +172,7 @@ public void updatePainting(@NotNull final Quaternion brushRotation, @NotNull fin @Override @JmeThread - public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull final Vector3f contactPoint) { + public void finishPainting(@NotNull Quaternion brushRotation, @NotNull Vector3f contactPoint) { super.finishPainting(brushRotation, contactPoint); final PaintingInput input = notNull(getCurrentInput()); @@ -198,33 +200,33 @@ public void finishPainting(@NotNull final Quaternion brushRotation, @NotNull fin * @param contactPoint the contact point. */ @JmeThread - private void modifyHeight(@NotNull final Vector3f contactPoint) { + private void modifyHeight(@NotNull Vector3f contactPoint) { - final LocalObjects local = getLocalObjects(); - final Spatial paintedModel = notNull(getPaintedModel()); + var local = getLocalObjects(); + var paintedModel = notNull(getPaintedModel()); - final Geometry brush = getBrush(); - final Geometry baseMarker = getBaseMarker(); - final Geometry targetMarker = getTargetMarker(); + var brush = getBrush(); + var baseMarker = getBaseMarker(); + var targetMarker = getTargetMarker(); - final float brushSize = getBrushSize(); - final float brushPower = getBrushPower(); + var brushSize = getBrushSize(); + var brushPower = getBrushPower(); - final List locs = new ArrayList<>(); - final List heights = new ArrayList<>(); + var locs = new ArrayList(); + var heights = new ArrayList(); - for (final Terrain terrain : getTerrains()) { + for (var terrain : getTerrains()) { - final Node terrainNode = (Node) terrain; + var terrainNode = (Node) terrain; locs.clear(); heights.clear(); - final Vector3f worldTranslation = terrainNode.getWorldTranslation(); - final Vector3f localScale = terrainNode.getLocalScale(); - final Vector3f firstPoint = baseMarker.getLocalTranslation(); - final Vector3f secondPoint = targetMarker.getLocalTranslation(); - final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector()); + var worldTranslation = terrainNode.getWorldTranslation(); + var localScale = terrainNode.getLocalScale(); + var firstPoint = baseMarker.getLocalTranslation(); + var secondPoint = targetMarker.getLocalTranslation(); + var localPoint = contactPoint.subtract(worldTranslation, local.nextVector()); Vector3f higher, lower; @@ -237,31 +239,31 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) { lower = firstPoint.subtract(worldTranslation, local.nextVector()); } - final Vector3f subtract = higher.subtract(lower, local.nextVector()); - final Vector3f normal = lower.subtract(higher, local.nextVector()).normalize(); - final Vector3f firstSide = local.nextVector(); - final Vector3f secondSide = local.nextVector(); - final Vector3f targetPoint = local.nextVector(); - final Vector2f terrainLoc = local.nextVector2f(); - final Vector2f effectPoint = local.nextVector2f(); + var subtract = higher.subtract(lower, local.nextVector()); + var normal = lower.subtract(higher, local.nextVector()).normalize(); + var firstSide = local.nextVector(); + var secondSide = local.nextVector(); + var targetPoint = local.nextVector(); + var terrainLoc = local.nextVector2f(); + var effectPoint = local.nextVector2f(); - final int radiusStepsX = (int) (brushSize / localScale.getX()); - final int radiusStepsZ = (int) (brushSize / localScale.getY()); + var radiusStepsX = (int) (brushSize / localScale.getX()); + var radiusStepsZ = (int) (brushSize / localScale.getY()); - final float xStepAmount = localScale.getX(); - final float zStepAmount = localScale.getZ(); + var xStepAmount = localScale.getX(); + var zStepAmount = localScale.getZ(); - final Plane firstPlane = local.nextPlane(); + var firstPlane = local.nextPlane(); firstPlane.setOriginNormal(lower, normal); - final Plane secondPlane = local.nextPlane(); + var secondPlane = local.nextPlane(); secondPlane.setOriginNormal(higher, normal); for (int z = -radiusStepsZ; z < radiusStepsZ; z++) { for (int x = -radiusStepsX; x < radiusStepsX; x++) { - float locX = localPoint.getX() + (x * xStepAmount); - float locZ = localPoint.getZ() + (z * zStepAmount); + var locX = localPoint.getX() + (x * xStepAmount); + var locZ = localPoint.getZ() + (z * zStepAmount); effectPoint.set(locX - localPoint.getX(), locZ - localPoint.getZ()); @@ -272,21 +274,21 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) { terrainLoc.set(locX, locZ); // adjust height based on radius of the tool - final float heightmapHeight = terrain.getHeightmapHeight(terrainLoc); + var heightmapHeight = terrain.getHeightmapHeight(terrainLoc); if (Float.isNaN(heightmapHeight)) { continue; } - float currentHeight = heightmapHeight * localScale.getY(); + var currentHeight = heightmapHeight * localScale.getY(); targetPoint.set(locX, currentHeight, locZ) .subtractLocal(lower) .projectLocal(subtract) .addLocal(lower); - final float lowerDist = lower.distance(targetPoint); - final float higherDist = higher.distance(targetPoint); - final float maxDistance = lower.distance(higher); + var lowerDist = lower.distance(targetPoint); + var higherDist = higher.distance(targetPoint); + var maxDistance = lower.distance(higher); float distance; @@ -296,7 +298,7 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) { distance = lower.distance(targetPoint) / max(lower.distance(higher), 0.00001F); } - final float desiredHeight = lower.getY() + (higher.getY() - lower.getY()) * distance; + var desiredHeight = lower.getY() + (higher.getY() - lower.getY()) * distance; firstSide.set(locX, 0f, locZ); secondSide.set(locX, 0f, locZ); @@ -308,23 +310,26 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) { if (!isPrecision()) { // rounding error for snapping - float epsilon = 0.0001f * brushPower; - float adj = 0; + var epsilon = 0.0001f * brushPower; + var adj = 0F; - if (currentHeight < desiredHeight) adj = 1; - else if (currentHeight > desiredHeight) adj = -1; + if (currentHeight < desiredHeight) { + adj = 1F; + } else if (currentHeight > desiredHeight) { + adj = -1F; + } adj *= brushPower; - adj *= calculateRadiusPercent(brushSize, effectPoint.getX(), effectPoint.getY()); + adj *= PaintingUtils.calculateRadiusPercent(brushSize, effectPoint.getX(), effectPoint.getY()); // test if adjusting too far and then cap it - if ((adj > 0) && floatGreaterThan((currentHeight + adj), desiredHeight, epsilon)) { + if ((adj > 0) && ExtMath.greaterThan((currentHeight + adj), desiredHeight, epsilon)) { adj = desiredHeight - currentHeight; - } else if (adj < 0 && floatLessThan((currentHeight + adj), desiredHeight, epsilon)) { + } else if (adj < 0 && ExtMath.lessThan((currentHeight + adj), desiredHeight, epsilon)) { adj = desiredHeight - currentHeight; } - if (!floatEquals(adj, 0, 0.001f)) { + if (!ExtMath.equals(adj, 0, 0.001f)) { locs.add(terrainLoc.clone()); heights.add(currentHeight + adj); } @@ -392,7 +397,7 @@ public boolean isPrecision() { * @param precision the flag of using precision changing. */ @JmeThread - public void setPrecision(final boolean precision) { + public void setPrecision(boolean precision) { this.precision = precision; } @@ -412,7 +417,7 @@ private boolean isLock() { * @param lock the flag of locking. */ @JmeThread - public void setLock(final boolean lock) { + public void setLock(boolean lock) { this.lock = lock; } } diff --git a/src/main/java/com/ss/editor/control/painting/terrain/SmoothTerrainToolControl.java b/src/main/java/com/ss/editor/control/painting/terrain/SmoothTerrainToolControl.java index d18e590e..9e801921 100644 --- a/src/main/java/com/ss/editor/control/painting/terrain/SmoothTerrainToolControl.java +++ b/src/main/java/com/ss/editor/control/painting/terrain/SmoothTerrainToolControl.java @@ -1,7 +1,7 @@ package com.ss.editor.control.painting.terrain; import static com.ss.editor.util.PaintingUtils.isContains; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.lang.Float.isNaN; import static java.lang.Math.min; import com.jme3.math.ColorRGBA; diff --git a/src/main/java/com/ss/editor/control/transform/AbstractTransformControl.java b/src/main/java/com/ss/editor/control/transform/AbstractTransformControl.java index 56c1bdc6..5e4ff4ee 100644 --- a/src/main/java/com/ss/editor/control/transform/AbstractTransformControl.java +++ b/src/main/java/com/ss/editor/control/transform/AbstractTransformControl.java @@ -1,6 +1,6 @@ package com.ss.editor.control.transform; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.collision.CollisionResult; import com.jme3.math.Quaternion; import com.jme3.math.Transform; @@ -10,8 +10,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; import com.ss.editor.control.transform.EditorTransformSupport.PickedAxis; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/control/transform/MoveToolControl.java b/src/main/java/com/ss/editor/control/transform/MoveToolControl.java index fa2ff02a..cdcb3f2c 100644 --- a/src/main/java/com/ss/editor/control/transform/MoveToolControl.java +++ b/src/main/java/com/ss/editor/control/transform/MoveToolControl.java @@ -1,7 +1,7 @@ package com.ss.editor.control.transform; import static com.ss.editor.util.GeomUtils.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.collision.CollisionResult; import com.jme3.collision.CollisionResults; import com.jme3.input.InputManager; diff --git a/src/main/java/com/ss/editor/control/transform/RotationToolControl.java b/src/main/java/com/ss/editor/control/transform/RotationToolControl.java index b5aa203a..eccba28d 100644 --- a/src/main/java/com/ss/editor/control/transform/RotationToolControl.java +++ b/src/main/java/com/ss/editor/control/transform/RotationToolControl.java @@ -1,6 +1,6 @@ package com.ss.editor.control.transform; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.input.InputManager; import com.jme3.math.*; import com.jme3.renderer.Camera; diff --git a/src/main/java/com/ss/editor/control/transform/ScaleToolControl.java b/src/main/java/com/ss/editor/control/transform/ScaleToolControl.java index f30bc63a..aa7fcae7 100644 --- a/src/main/java/com/ss/editor/control/transform/ScaleToolControl.java +++ b/src/main/java/com/ss/editor/control/transform/ScaleToolControl.java @@ -1,6 +1,6 @@ package com.ss.editor.control.transform; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.lang.Math.abs; import com.jme3.input.InputManager; import com.jme3.math.Transform; diff --git a/src/main/java/com/ss/editor/document/DocumentConfig.java b/src/main/java/com/ss/editor/document/DocumentConfig.java index af1fb687..edf53291 100644 --- a/src/main/java/com/ss/editor/document/DocumentConfig.java +++ b/src/main/java/com/ss/editor/document/DocumentConfig.java @@ -1,7 +1,7 @@ package com.ss.editor.document; -import com.ss.rlib.data.AbstractStreamDocument; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.data.AbstractStreamDocument; +import com.ss.rlib.common.util.VarTable; import org.jetbrains.annotations.NotNull; import org.w3c.dom.Document; import org.w3c.dom.Node; diff --git a/src/main/java/com/ss/editor/executor/impl/AbstractEditorTaskExecutor.java b/src/main/java/com/ss/editor/executor/impl/AbstractEditorTaskExecutor.java index 573deb63..87dfe2eb 100644 --- a/src/main/java/com/ss/editor/executor/impl/AbstractEditorTaskExecutor.java +++ b/src/main/java/com/ss/editor/executor/impl/AbstractEditorTaskExecutor.java @@ -3,13 +3,13 @@ import com.ss.editor.EditorThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.executor.EditorTaskExecutor; -import com.ss.rlib.concurrent.lock.LockFactory; -import com.ss.rlib.concurrent.lock.Lockable; -import com.ss.rlib.concurrent.util.ConcurrentUtils; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.concurrent.lock.LockFactory; +import com.ss.rlib.common.concurrent.lock.Lockable; +import com.ss.rlib.common.concurrent.util.ConcurrentUtils; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/src/main/java/com/ss/editor/executor/impl/BackgroundEditorTaskExecutor.java b/src/main/java/com/ss/editor/executor/impl/BackgroundEditorTaskExecutor.java index f8086b36..4f337ab2 100644 --- a/src/main/java/com/ss/editor/executor/impl/BackgroundEditorTaskExecutor.java +++ b/src/main/java/com/ss/editor/executor/impl/BackgroundEditorTaskExecutor.java @@ -1,7 +1,7 @@ package com.ss.editor.executor.impl; import static java.lang.Math.min; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/executor/impl/FxEditorTaskExecutor.java b/src/main/java/com/ss/editor/executor/impl/FxEditorTaskExecutor.java index edc04c0e..4ea7adbc 100644 --- a/src/main/java/com/ss/editor/executor/impl/FxEditorTaskExecutor.java +++ b/src/main/java/com/ss/editor/executor/impl/FxEditorTaskExecutor.java @@ -1,11 +1,10 @@ package com.ss.editor.executor.impl; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.concurrent.util.ConcurrentUtils; -import com.ss.rlib.concurrent.util.ThreadUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.concurrent.util.ConcurrentUtils; +import com.ss.rlib.common.util.array.Array; import javafx.application.Platform; import org.jetbrains.annotations.NotNull; @@ -27,36 +26,40 @@ public class FxEditorTaskExecutor extends AbstractEditorTaskExecutor { public FxEditorTaskExecutor() { setName(FxEditorTaskExecutor.class.getSimpleName()); setPriority(NORM_PRIORITY); - start(); + try { + Platform.startup(this::start); + } catch (IllegalStateException e) { + start(); + } } @Override @FxThread - protected void doExecute(@NotNull final Array execute, @NotNull final Array executed) { + protected void doExecute(@NotNull Array execute, @NotNull Array executed) { - final Runnable[] array = execute.array(); + var array = execute.array(); for (int i = 0, length = execute.size(); i < length; ) { try { for (int count = 0; count < EXECUTE_LIMIT && i < length; count++, i++) { - final Runnable task = array[i]; + var task = array[i]; try { task.run(); - } catch (final Exception e) { + } catch (Exception e) { EditorUtil.handleException(LOGGER, this, e); } executed.add(task); } - } catch (final Exception e) { + } catch (Exception e) { LOGGER.warning(e); } } - ConcurrentUtils.notifyAll(this); + ConcurrentUtils.notifyAll(fxTask); } @Override @@ -108,17 +111,9 @@ public void run() { @FromAnyThread private void executeInFxUiThread() { - while (true) { - try { - synchronized (this) { - Platform.runLater(fxTask); - ConcurrentUtils.waitInSynchronize(this); - } - break; - } catch (final IllegalStateException e) { - LOGGER.warning(this, e); - ThreadUtils.sleep(1000); - } + synchronized (fxTask) { + Platform.runLater(fxTask); + ConcurrentUtils.waitInSynchronize(fxTask); } } } diff --git a/src/main/java/com/ss/editor/executor/impl/JmeThreadExecutor.java b/src/main/java/com/ss/editor/executor/impl/JmeThreadExecutor.java index e62ffc48..db3d2276 100644 --- a/src/main/java/com/ss/editor/executor/impl/JmeThreadExecutor.java +++ b/src/main/java/com/ss/editor/executor/impl/JmeThreadExecutor.java @@ -6,12 +6,12 @@ import org.jetbrains.annotations.NotNull; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.ArrayUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.array.ConcurrentArray; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.ArrayUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.ConcurrentArray; /** * The executor to execute tasks in the editor thread. diff --git a/src/main/java/com/ss/editor/file/converter/FileConverterDescription.java b/src/main/java/com/ss/editor/file/converter/FileConverterDescription.java index fa921566..c6f0d22f 100644 --- a/src/main/java/com/ss/editor/file/converter/FileConverterDescription.java +++ b/src/main/java/com/ss/editor/file/converter/FileConverterDescription.java @@ -1,8 +1,8 @@ package com.ss.editor.file.converter; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/file/converter/FileConverterRegistry.java b/src/main/java/com/ss/editor/file/converter/FileConverterRegistry.java index 951c22c0..3ba05f18 100644 --- a/src/main/java/com/ss/editor/file/converter/FileConverterRegistry.java +++ b/src/main/java/com/ss/editor/file/converter/FileConverterRegistry.java @@ -1,13 +1,13 @@ package com.ss.editor.file.converter; -import static com.ss.rlib.util.FileUtils.containsExtensions; -import static com.ss.rlib.util.array.ArrayCollectors.toArray; +import static com.ss.rlib.common.util.FileUtils.containsExtensions; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.file.converter.impl.*; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.nio.file.Path; diff --git a/src/main/java/com/ss/editor/file/converter/impl/AbstractFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/AbstractFileConverter.java index a4c1b02e..ba3c065d 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/AbstractFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/AbstractFileConverter.java @@ -1,6 +1,6 @@ package com.ss.editor.file.converter.impl; -import static com.ss.rlib.util.FileUtils.containsExtensions; +import static com.ss.rlib.common.util.FileUtils.containsExtensions; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; @@ -9,11 +9,11 @@ import com.ss.editor.ui.event.FxEventManager; import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/file/converter/impl/AbstractModelFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/AbstractModelFileConverter.java index 04ff6844..bc1b2e11 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/AbstractModelFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/AbstractModelFileConverter.java @@ -4,9 +4,9 @@ import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_TANGENT_GENERATION; import static com.ss.editor.extension.property.EditablePropertyType.*; import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.FileUtils.containsExtensions; -import static com.ss.rlib.util.FileUtils.normalizeName; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.FileUtils.containsExtensions; +import static com.ss.rlib.common.util.FileUtils.normalizeName; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.nio.file.StandardOpenOption.*; import com.jme3.asset.AssetKey; import com.jme3.asset.AssetManager; @@ -26,13 +26,13 @@ import com.ss.editor.util.MaterialSerializer; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import java.awt.*; diff --git a/src/main/java/com/ss/editor/file/converter/impl/BlendToJ3oFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/BlendToJ3oFileConverter.java index 4145991b..657803be 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/BlendToJ3oFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/BlendToJ3oFileConverter.java @@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of {@link AbstractFileConverter} to convert .blend file to .j3o. diff --git a/src/main/java/com/ss/editor/file/converter/impl/FbxToJ3oFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/FbxToJ3oFileConverter.java index a6447a45..60dd52e4 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/FbxToJ3oFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/FbxToJ3oFileConverter.java @@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of {@link AbstractFileConverter} to convert .fbx file to .j3o. diff --git a/src/main/java/com/ss/editor/file/converter/impl/GltfToJ3oFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/GltfToJ3oFileConverter.java index d6a2e4f0..c8a3b0ea 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/GltfToJ3oFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/GltfToJ3oFileConverter.java @@ -3,8 +3,8 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.file.converter.FileConverterDescription; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/file/converter/impl/MeshXmlToJ3oFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/MeshXmlToJ3oFileConverter.java index 75b7b6c3..08589330 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/MeshXmlToJ3oFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/MeshXmlToJ3oFileConverter.java @@ -4,9 +4,9 @@ import com.ss.editor.Messages; import com.ss.editor.file.converter.FileConverterDescription; import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import java.nio.file.Path; diff --git a/src/main/java/com/ss/editor/file/converter/impl/ObjToJ3oFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/ObjToJ3oFileConverter.java index 809166af..b1c4f57b 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/ObjToJ3oFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/ObjToJ3oFileConverter.java @@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of {@link AbstractFileConverter} to convert .obj file to .j3o. diff --git a/src/main/java/com/ss/editor/file/converter/impl/SceneToJ3oFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/SceneToJ3oFileConverter.java index 5ac964f9..de3c1cb4 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/SceneToJ3oFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/SceneToJ3oFileConverter.java @@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of {@link AbstractFileConverter} to convert .scene file to .j3o. diff --git a/src/main/java/com/ss/editor/file/converter/impl/XbufToJ3oFileConverter.java b/src/main/java/com/ss/editor/file/converter/impl/XbufToJ3oFileConverter.java index aec3bcbf..bba7187f 100644 --- a/src/main/java/com/ss/editor/file/converter/impl/XbufToJ3oFileConverter.java +++ b/src/main/java/com/ss/editor/file/converter/impl/XbufToJ3oFileConverter.java @@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of {@link AbstractFileConverter} to convert .xbuf file to .j3o. diff --git a/src/main/java/com/ss/editor/file/delete/handler/FileDeleteHandlerFactory.java b/src/main/java/com/ss/editor/file/delete/handler/FileDeleteHandlerFactory.java index fb5a5a9e..5c940a4f 100644 --- a/src/main/java/com/ss/editor/file/delete/handler/FileDeleteHandlerFactory.java +++ b/src/main/java/com/ss/editor/file/delete/handler/FileDeleteHandlerFactory.java @@ -3,8 +3,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.file.delete.handler.impl.DeleteMaterialsModelFileDeleteHandler; import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import java.nio.file.Path; diff --git a/src/main/java/com/ss/editor/file/delete/handler/impl/AbstractFileDeleteHandler.java b/src/main/java/com/ss/editor/file/delete/handler/impl/AbstractFileDeleteHandler.java index 73d35b30..d3f85d33 100644 --- a/src/main/java/com/ss/editor/file/delete/handler/impl/AbstractFileDeleteHandler.java +++ b/src/main/java/com/ss/editor/file/delete/handler/impl/AbstractFileDeleteHandler.java @@ -1,8 +1,8 @@ package com.ss.editor.file.delete.handler.impl; import com.ss.editor.file.delete.handler.FileDeleteHandler; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import org.jetbrains.annotations.NotNull; import java.nio.file.Path; diff --git a/src/main/java/com/ss/editor/file/delete/handler/impl/DeleteMaterialsModelFileDeleteHandler.java b/src/main/java/com/ss/editor/file/delete/handler/impl/DeleteMaterialsModelFileDeleteHandler.java index b78a6ca9..a85515eb 100644 --- a/src/main/java/com/ss/editor/file/delete/handler/impl/DeleteMaterialsModelFileDeleteHandler.java +++ b/src/main/java/com/ss/editor/file/delete/handler/impl/DeleteMaterialsModelFileDeleteHandler.java @@ -3,7 +3,7 @@ import static com.ss.editor.FileExtensions.JME_OBJECT; import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.scene.Spatial; @@ -11,10 +11,10 @@ import com.ss.editor.ui.dialog.ConfirmDialog; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/manager/ClasspathManager.java b/src/main/java/com/ss/editor/manager/ClasspathManager.java index a2ed4642..6cc1f336 100644 --- a/src/main/java/com/ss/editor/manager/ClasspathManager.java +++ b/src/main/java/com/ss/editor/manager/ClasspathManager.java @@ -2,21 +2,21 @@ import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_USER_CLASSES_FOLDER; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_USER_LIBRARY_FOLDER; -import static com.ss.rlib.util.array.ArrayFactory.toArray; +import static com.ss.rlib.common.util.array.ArrayFactory.toArray; import com.jme3.asset.AssetManager; import com.ss.editor.FileExtensions; import com.ss.editor.JmeApplication; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.classpath.ClassPathScanner; -import com.ss.rlib.classpath.ClassPathScannerFactory; -import com.ss.rlib.manager.InitializeManager; -import com.ss.rlib.plugin.PluginContainer; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.Utils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.classpath.ClassPathScanner; +import com.ss.rlib.common.classpath.ClassPathScannerFactory; +import com.ss.rlib.common.manager.InitializeManager; +import com.ss.rlib.common.plugin.PluginContainer; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.Utils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -274,7 +274,7 @@ private void updateClasses() { * Load local libraries. */ @FromAnyThread - public synchronized void loadLocalLibraries(@NotNull final Array libraries) { + public synchronized @NotNull ClasspathManager loadLocalLibraries(@NotNull Array libraries) { final AssetManager assetManager = EditorUtil.getAssetManager(); final URLClassLoader currentClassLoader = getLocalLibrariesLoader(); @@ -286,7 +286,7 @@ public synchronized void loadLocalLibraries(@NotNull final Array libraries if (libraries.isEmpty()) { this.localLibrariesScanner = null; - return; + return this; } final URL[] urlArray = libraries.stream() @@ -310,13 +310,14 @@ public synchronized void loadLocalLibraries(@NotNull final Array libraries scanner.scan(); this.localLibrariesScanner = scanner; + return this; } /** * Load local classes. */ @FromAnyThread - public synchronized void loadLocalClasses(@Nullable final Path output) { + public synchronized @NotNull ClasspathManager loadLocalClasses(@Nullable final Path output) { final AssetManager assetManager = EditorUtil.getAssetManager(); final URLClassLoader currentClassLoader = getLocalClassesLoader(); @@ -328,7 +329,7 @@ public synchronized void loadLocalClasses(@Nullable final Path output) { if (output == null || !Files.exists(output)) { this.localClassesScanner = null; - return; + return this; } final Array folders = ArrayFactory.newArray(Path.class); @@ -365,6 +366,7 @@ public synchronized void loadLocalClasses(@Nullable final Path output) { scanner.scan(); this.localClassesScanner = scanner; + return this; } /** diff --git a/src/main/java/com/ss/editor/manager/ExecutorManager.java b/src/main/java/com/ss/editor/manager/ExecutorManager.java index 5baa7848..6625be51 100644 --- a/src/main/java/com/ss/editor/manager/ExecutorManager.java +++ b/src/main/java/com/ss/editor/manager/ExecutorManager.java @@ -5,9 +5,9 @@ import com.ss.editor.executor.impl.BackgroundEditorTaskExecutor; import com.ss.editor.executor.impl.FxEditorTaskExecutor; import com.ss.editor.executor.impl.JmeThreadExecutor; -import com.ss.rlib.concurrent.atomic.AtomicInteger; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.concurrent.atomic.AtomicInteger; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,13 +33,7 @@ public class ExecutorManager { @Nullable private static ExecutorManager instance; - /** - * Gets instance. - * - * @return the instance - */ - @NotNull - public static ExecutorManager getInstance() { + public static @NotNull ExecutorManager getInstance() { if (instance == null) instance = new ExecutorManager(); return instance; } @@ -99,10 +93,10 @@ private ExecutorManager() { @FromAnyThread public void addBackgroundTask(@NotNull final Runnable task) { - final EditorTaskExecutor[] executors = getBackgroundTaskExecutors(); - final AtomicInteger nextTaskExecutor = getNextBackgroundTaskExecutor(); + var executors = getBackgroundTaskExecutors(); + var nextTaskExecutor = getNextBackgroundTaskExecutor(); - final int index = nextTaskExecutor.incrementAndGet(); + var index = nextTaskExecutor.incrementAndGet(); if (index < executors.length) { executors[index].execute(task); @@ -113,14 +107,13 @@ public void addBackgroundTask(@NotNull final Runnable task) { } /** - * Add a new javaFX task. + * Add the new task to be executed in the JavaFX thread. * - * @param task the javaFX task. + * @param task the task. */ @FromAnyThread - public void addFxTask(@NotNull final Runnable task) { - final EditorTaskExecutor executor = getFxTaskExecutor(); - executor.execute(task); + public void addFxTask(@NotNull Runnable task) { + getFxTaskExecutor().execute(task); } /** @@ -129,12 +122,13 @@ public void addFxTask(@NotNull final Runnable task) { * @param task the editor task. */ @FromAnyThread - public void addJmeTask(@NotNull final Runnable task) { - final JmeThreadExecutor executor = getJmeTasksExecutor(); - executor.addToExecute(task); + public void addJmeTask(@NotNull Runnable task) { + getJmeTasksExecutor().addToExecute(task); } /** + * Get the list of background tasks executors. + * * @return the list of background tasks executors. */ @FromAnyThread @@ -143,6 +137,8 @@ public void addJmeTask(@NotNull final Runnable task) { } /** + * Get the executor of javaFX tasks. + * * @return the executor of javaFX tasks. */ @FromAnyThread @@ -151,6 +147,8 @@ public void addJmeTask(@NotNull final Runnable task) { } /** + * Get the index of a next background executor. + * * @return the index of a next background executor. */ @FromAnyThread @@ -159,7 +157,9 @@ public void addJmeTask(@NotNull final Runnable task) { } /** - * @return the executor of editor tasks. + * Get the executor of jME tasks. + * + * @return the executor of jME tasks. */ @FromAnyThread private @NotNull JmeThreadExecutor getJmeTasksExecutor() { @@ -173,7 +173,7 @@ public void addJmeTask(@NotNull final Runnable task) { * @param timeout the timeout. */ @FromAnyThread - public void schedule(@NotNull final Runnable runnable, final long timeout) { + public void schedule(@NotNull Runnable runnable, long timeout) { scheduledExecutorService.schedule(runnable, timeout, TimeUnit.MILLISECONDS); } @@ -184,7 +184,7 @@ public void schedule(@NotNull final Runnable runnable, final long timeout) { * @param delay the delay. */ @FromAnyThread - public void scheduleAtFixedRate(@NotNull final Runnable runnable, final long delay) { + public void scheduleAtFixedRate(@NotNull Runnable runnable, long delay) { scheduledExecutorService.scheduleAtFixedRate(runnable, delay, delay, TimeUnit.MILLISECONDS); } } diff --git a/src/main/java/com/ss/editor/manager/FileIconManager.java b/src/main/java/com/ss/editor/manager/FileIconManager.java index 2a50a648..12b8cc1d 100644 --- a/src/main/java/com/ss/editor/manager/FileIconManager.java +++ b/src/main/java/com/ss/editor/manager/FileIconManager.java @@ -3,7 +3,7 @@ import static com.ss.editor.config.DefaultSettingsProvider.Defaults.PREF_DEFAULT_THEME; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_UI_THEME; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.FileExtensions; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; @@ -11,15 +11,15 @@ import com.ss.editor.ui.css.CssColorTheme; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.svg.SvgImageLoader; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.manager.InitializeManager; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.IntegerDictionary; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.manager.InitializeManager; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.IntegerDictionary; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.scene.image.Image; import javafx.scene.paint.Color; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/manager/InitializationManager.java b/src/main/java/com/ss/editor/manager/InitializationManager.java index ddf3c668..4366c570 100644 --- a/src/main/java/com/ss/editor/manager/InitializationManager.java +++ b/src/main/java/com/ss/editor/manager/InitializationManager.java @@ -3,8 +3,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.JmeThread; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/manager/JavaFxImageManager.java b/src/main/java/com/ss/editor/manager/JavaFxImageManager.java index b8d8ed37..b45ec551 100644 --- a/src/main/java/com/ss/editor/manager/JavaFxImageManager.java +++ b/src/main/java/com/ss/editor/manager/JavaFxImageManager.java @@ -1,7 +1,7 @@ package com.ss.editor.manager; -import static com.ss.rlib.util.FileUtils.getExtension; -import static com.ss.rlib.util.array.ArrayFactory.asArray; +import static com.ss.rlib.common.util.FileUtils.getExtension; +import static com.ss.rlib.common.util.array.ArrayFactory.asArray; import static java.awt.Image.SCALE_DEFAULT; import static java.nio.file.StandardOpenOption.*; import com.jme3.asset.AssetManager; @@ -17,17 +17,17 @@ import com.ss.editor.ui.event.impl.ChangedCurrentAssetFolderEvent; import com.ss.editor.ui.event.impl.DeletedFileEvent; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.manager.InitializeManager; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.Utils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.IntegerDictionary; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.manager.InitializeManager; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.Utils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.IntegerDictionary; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.embed.swing.SwingFXUtils; import javafx.scene.image.Image; import jme3tools.converters.ImageToAwt; diff --git a/src/main/java/com/ss/editor/manager/JmeFilePreviewManager.java b/src/main/java/com/ss/editor/manager/JmeFilePreviewManager.java index 88e68241..058d9076 100644 --- a/src/main/java/com/ss/editor/manager/JmeFilePreviewManager.java +++ b/src/main/java/com/ss/editor/manager/JmeFilePreviewManager.java @@ -1,22 +1,20 @@ package com.ss.editor.manager; -import static com.jme3x.jfx.injfx.JmeToJFXIntegrator.bind; -import static com.jme3x.jfx.injfx.processor.FrameTransferSceneProcessor.TransferMode.ON_CHANGES; +import static com.jme3.jfx.injfx.JmeToJfxIntegrator.bind; +import static com.jme3.jfx.injfx.processor.FrameTransferSceneProcessor.TransferMode.ON_CHANGES; import static com.ss.editor.config.DefaultSettingsProvider.Defaults.PREF_DEFAULT_TANGENT_GENERATION; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_TANGENT_GENERATION; import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.FileUtils.getExtension; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.asset.AssetManager; +import static com.ss.rlib.common.util.FileUtils.getExtension; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetNotFoundException; import com.jme3.environment.generation.JobProgressAdapter; +import com.jme3.jfx.injfx.processor.FrameTransferSceneProcessor; import com.jme3.light.DirectionalLight; import com.jme3.light.LightProbe; -import com.jme3.material.Material; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.RendererException; import com.jme3.renderer.ViewPort; @@ -26,7 +24,6 @@ import com.jme3.scene.control.AbstractControl; import com.jme3.scene.shape.Box; import com.jme3.util.SkyFactory; -import com.jme3x.jfx.injfx.processor.FrameTransferSceneProcessor; import com.ss.editor.FileExtensions; import com.ss.editor.JmeApplication; import com.ss.editor.annotation.FromAnyThread; @@ -36,17 +33,15 @@ import com.ss.editor.config.EditorConfig; import com.ss.editor.executor.impl.JmeThreadExecutor; import com.ss.editor.model.EditorCamera; -import com.ss.editor.ui.scene.EditorFxScene; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.TangentGenerator; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.image.ImageView; -import javafx.scene.layout.StackPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,29 +54,21 @@ */ public class JmeFilePreviewManager extends AbstractControl { - @NotNull private static final Logger LOGGER = LoggerManager.getLogger(JmeFilePreviewManager.class); - @NotNull - private static final Vector3f LIGHT_DIRECTION = new Vector3f(0.007654993F, 0.39636374F, 0.9180617F).negate(); + private static final Vector3f LIGHT_DIRECTION = + new Vector3f(0.007654993F, 0.39636374F, 0.9180617F).negate(); - @NotNull - private static final Vector3f CAMERA_LOCATION = new Vector3f(13.660254F, 5.176381F, 13.660254F); + private static final Vector3f CAMERA_LOCATION = + new Vector3f(13.660254F, 5.176381F, 13.660254F); - @NotNull - private static final Quaternion CAMERA_ROTATION = new Quaternion(0.9159756F, 0.04995022F, -0.37940952F, - 0.12059049F); + private static final Quaternion CAMERA_ROTATION = + new Quaternion(0.9159756F, 0.04995022F, -0.37940952F, 0.12059049F); - @NotNull private static final Array JME_FORMATS = ArrayFactory.newArray(String.class); - - @NotNull private static final Array MODELS_FORMATS = ArrayFactory.newArray(String.class); - - @NotNull private static final Array AUDIO_FORMATS = ArrayFactory.newArray(String.class); - @NotNull private static final EditorConfig EDITOR_CONFIG = EditorConfig.getInstance(); static { @@ -95,7 +82,6 @@ public class JmeFilePreviewManager extends AbstractControl { MODELS_FORMATS.add(FileExtensions.MODEL_GLTF); } - @NotNull private static final JmeThreadExecutor EDITOR_THREAD_EXECUTOR = JmeThreadExecutor.getInstance(); @Nullable @@ -120,10 +106,8 @@ public class JmeFilePreviewManager extends AbstractControl { * @return true is the file is a file of a model. */ @FromAnyThread - public static boolean isModelFile(@Nullable final Path file) { - if (file == null) return false; - final String extension = getExtension(file); - return MODELS_FORMATS.contains(extension); + public static boolean isModelFile(@Nullable Path file) { + return file != null && MODELS_FORMATS.contains(getExtension(file)); } /** @@ -133,10 +117,9 @@ public static boolean isModelFile(@Nullable final Path file) { * @return true is the file is a file of a model. */ @FromAnyThread - public static boolean isModelFile(@Nullable final String assetPath) { - if (StringUtils.isEmpty(assetPath)) return false; - final String extension = getExtension(assetPath); - return MODELS_FORMATS.contains(extension); + public static boolean isModelFile(@Nullable String assetPath) { + return !StringUtils.isEmpty(assetPath) && + MODELS_FORMATS.contains(getExtension(assetPath)); } /** @@ -146,10 +129,8 @@ public static boolean isModelFile(@Nullable final String assetPath) { * @return true is the file is a JME file. */ @FromAnyThread - public static boolean isJmeFile(@Nullable final Path file) { - if (file == null) return false; - final String extension = getExtension(file); - return JME_FORMATS.contains(extension); + public static boolean isJmeFile(@Nullable Path file) { + return file != null && JME_FORMATS.contains(getExtension(file)); } /** @@ -159,10 +140,9 @@ public static boolean isJmeFile(@Nullable final Path file) { * @return true is the file is a JME file. */ @FromAnyThread - public static boolean isJmeFile(@Nullable final String assetPath) { - if (StringUtils.isEmpty(assetPath)) return false; - final String extension = getExtension(assetPath); - return JME_FORMATS.contains(extension); + public static boolean isJmeFile(@Nullable String assetPath) { + return !StringUtils.isEmpty(assetPath) && + JME_FORMATS.contains(getExtension(assetPath)); } /** @@ -172,10 +152,8 @@ public static boolean isJmeFile(@Nullable final String assetPath) { * @return true is the file is an audio file. */ @FromAnyThread - public static boolean isAudioFile(@Nullable final Path file) { - if (file == null) return false; - final String extension = getExtension(file); - return AUDIO_FORMATS.contains(extension); + public static boolean isAudioFile(@Nullable Path file) { + return file != null && AUDIO_FORMATS.contains(getExtension(file)); } /** @@ -185,13 +163,10 @@ public static boolean isAudioFile(@Nullable final Path file) { * @return true is the asset path is an audio file. */ @FromAnyThread - public static boolean isAudioFile(@Nullable final String assetPath) { - if (assetPath == null) return false; - final String extension = getExtension(assetPath); - return AUDIO_FORMATS.contains(extension); + public static boolean isAudioFile(@Nullable String assetPath) { + return assetPath != null && AUDIO_FORMATS.contains(getExtension(assetPath)); } - @NotNull private final JobProgressAdapter probeHandler = new JobProgressAdapter() { @Override @@ -234,27 +209,26 @@ private JmeFilePreviewManager() { this.testBox = new Geometry("Box", new Box(2, 2, 2)); this.modelNode = new Node("Model Node"); - final ExecutorManager executorManager = ExecutorManager.getInstance(); + var executorManager = ExecutorManager.getInstance(); executorManager.addFxTask(() -> { - final EditorFxScene scene = EditorUtil.getFxScene(); - final StackPane container = scene.getHideLayer(); - - FXUtils.addToPane(imageView, container); + var scene = EditorUtil.getFxScene(); + var container = scene.getHideLayer(); + FxUtils.addChild(container, imageView); TangentGenerator.useMikktspaceGenerator(testBox); - final JmeThreadExecutor executor = JmeThreadExecutor.getInstance(); + var executor = JmeThreadExecutor.getInstance(); executor.addToExecute(this::prepareScene); }); } @Override @JmeThread - protected void controlUpdate(final float tpf) { + protected void controlUpdate(float tpf) { if (frame == 2) { - final JmeApplication jmeApplication = JmeApplication.getInstance(); + var jmeApplication = JmeApplication.getInstance(); jmeApplication.updatePreviewLightProbe(probeHandler); } @@ -263,13 +237,13 @@ protected void controlUpdate(final float tpf) { @JmeThread private void notifyProbeComplete() { - final Node rootNode = EditorUtil.getPreviewNode(); + var rootNode = EditorUtil.getPreviewNode(); rootNode.attachChild(modelNode); } @Override @JmeThread - protected void controlRender(@NotNull final RenderManager renderManager, @NotNull final ViewPort viewPort) { + protected void controlRender(@NotNull RenderManager renderManager, @NotNull ViewPort viewPort) { } /** @@ -280,12 +254,13 @@ protected void controlRender(@NotNull final RenderManager renderManager, @NotNul * @param fitHeight the target height of preview. */ @FromAnyThread - public void show(@NotNull final Path file, final int fitWidth, final int fitHeight) { + public void show(@NotNull Path file, int fitWidth, int fitHeight) { + imageView.setFitHeight(fitHeight); imageView.setFitWidth(fitWidth); - final Path assetFile = notNull(getAssetFile(file), "File can't be null."); - final String path = toAssetPath(assetFile); + var assetFile = notNull(getAssetFile(file), "File can't be null."); + var path = toAssetPath(assetFile); showPreview(path, getExtension(assetFile), false); } @@ -298,7 +273,7 @@ public void show(@NotNull final Path file, final int fitWidth, final int fitHeig * @param fitHeight the target height of preview. */ @FromAnyThread - public void showExternal(@NotNull final Path file, final int fitWidth, final int fitHeight) { + public void showExternal(@NotNull Path file, int fitWidth, int fitHeight) { imageView.setFitHeight(fitHeight); imageView.setFitWidth(fitWidth); showPreview(file.toString(), getExtension(file), true); @@ -312,7 +287,7 @@ public void showExternal(@NotNull final Path file, final int fitWidth, final int * @param external true if the path is external path. */ @FromAnyThread - private void showPreview(@NotNull final String path, @NotNull final String extension, final boolean external) { + private void showPreview(@NotNull String path, @NotNull String extension, boolean external) { if (FileExtensions.JME_MATERIAL.equals(extension)) { EDITOR_THREAD_EXECUTOR.addToExecute(() -> showMaterial(path)); } else if (isModelFile(path)) { @@ -330,7 +305,7 @@ private void showPreview(@NotNull final String path, @NotNull final String exten * @param fitHeight the target height of preview. */ @FromAnyThread - public void show(@NotNull final String assetPath, final int fitWidth, final int fitHeight) { + public void show(@NotNull String assetPath, int fitWidth, int fitHeight) { imageView.setFitHeight(fitHeight); imageView.setFitWidth(fitWidth); showPreview(assetPath, getExtension(assetPath), false); @@ -343,11 +318,12 @@ public void show(@NotNull final String assetPath, final int fitWidth, final int * @param external true if the object is external object. */ @JmeThread - private void showObject(@NotNull final String path, final boolean external) { + private void showObject(@NotNull String path, boolean external) { prepareProcessor(); - final AssetManager assetManager = EditorUtil.getAssetManager(); - final Spatial model; + var assetManager = EditorUtil.getAssetManager(); + + Spatial model; FolderAssetLocator.setIgnore(external); try { @@ -364,7 +340,7 @@ private void showObject(@NotNull final String path, final boolean external) { tryToLoad(model); - final Node rootNode = EditorUtil.getPreviewNode(); + var rootNode = EditorUtil.getPreviewNode(); rootNode.detachChild(modelNode); } @@ -374,16 +350,15 @@ private void showObject(@NotNull final String path, final boolean external) { * @param model the model. */ @JmeThread - private void tryToLoad(@NotNull final Spatial model) { + private void tryToLoad(@NotNull Spatial model) { try { - final JmeApplication jmeApplication = JmeApplication.getInstance(); - final RenderManager renderManager = jmeApplication.getRenderManager(); + var renderManager = EditorUtil.getRenderManager(); renderManager.preloadScene(model); modelNode.attachChild(model); - } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) { + } catch (RendererException | AssetNotFoundException | UnsupportedOperationException e) { EditorUtil.handleException(LOGGER, this, e); } } @@ -400,7 +375,7 @@ private void prepareProcessor() { frame = 0; - final Camera camera = EditorUtil.getPreviewCamera(); + var camera = EditorUtil.getPreviewCamera(); camera.setLocation(CAMERA_LOCATION); camera.setRotation(CAMERA_ROTATION); @@ -413,16 +388,16 @@ private void prepareProcessor() { * @param path the path to material. */ @JmeThread - private void showMaterial(@NotNull final String path) { + private void showMaterial(@NotNull String path) { prepareProcessor(); - final AssetManager assetManager = EditorUtil.getAssetManager(); - final Material material = assetManager.loadMaterial(path); + var assetManager = EditorUtil.getAssetManager(); + var material = assetManager.loadMaterial(path); testBox.setMaterial(material); tryToLoad(testBox); - final Node rootNode = EditorUtil.getPreviewNode(); + var rootNode = EditorUtil.getPreviewNode(); rootNode.detachChild(modelNode); } @@ -437,8 +412,8 @@ public void clear() { @JmeThread private void clearImpl() { - final JmeApplication jmeApplication = JmeApplication.getInstance(); - final Node rootNode = jmeApplication.getPreviewNode(); + var jmeApplication = JmeApplication.getInstance(); + var rootNode = jmeApplication.getPreviewNode(); rootNode.detachChild(modelNode); if (processor != null) { @@ -447,7 +422,7 @@ private void clearImpl() { } /** - * Gets image view. + * Gets the image view with a preview. * * @return the image view with a preview. */ @@ -464,24 +439,24 @@ private void clearImpl() { @JmeThread private @NotNull FrameTransferSceneProcessor prepareScene() { - final JmeApplication jmeApplication = JmeApplication.getInstance(); - final AssetManager assetManager = jmeApplication.getAssetManager(); - final Spatial sky = SkyFactory.createSky(assetManager, "graphics/textures/sky/studio.hdr", + var jmeApplication = JmeApplication.getInstance(); + var assetManager = jmeApplication.getAssetManager(); + var sky = SkyFactory.createSky(assetManager, "graphics/textures/sky/studio.hdr", SkyFactory.EnvMapType.EquirectMap); - final DirectionalLight light = new DirectionalLight(); + var light = new DirectionalLight(); light.setDirection(LIGHT_DIRECTION); - final Node cameraNode = new Node("Camera node"); - final Node rootNode = jmeApplication.getPreviewNode(); + var cameraNode = new Node("Camera node"); + var rootNode = jmeApplication.getPreviewNode(); rootNode.addControl(this); rootNode.attachChild(sky); rootNode.addLight(light); rootNode.attachChild(cameraNode); rootNode.attachChild(modelNode); - final Camera camera = jmeApplication.getPreviewCamera(); - final EditorCamera editorCamera = new EditorCamera(camera, cameraNode); + var camera = jmeApplication.getPreviewCamera(); + var editorCamera = new EditorCamera(camera, cameraNode); editorCamera.setMaxDistance(10000); editorCamera.setMinDistance(0.01F); editorCamera.setSmoothMotion(false); diff --git a/src/main/java/com/ss/editor/manager/PluginManager.java b/src/main/java/com/ss/editor/manager/PluginManager.java index 83ad2dc3..31f36735 100644 --- a/src/main/java/com/ss/editor/manager/PluginManager.java +++ b/src/main/java/com/ss/editor/manager/PluginManager.java @@ -1,6 +1,6 @@ package com.ss.editor.manager; -import static com.ss.rlib.plugin.impl.PluginSystemFactory.newBasePluginSystem; +import static com.ss.rlib.common.plugin.impl.PluginSystemFactory.newBasePluginSystem; import com.jme3.asset.AssetManager; import com.ss.editor.JmeApplication; import com.ss.editor.annotation.FromAnyThread; @@ -9,16 +9,16 @@ import com.ss.editor.config.Config; import com.ss.editor.plugin.EditorPlugin; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.manager.InitializeManager; -import com.ss.rlib.plugin.ConfigurablePluginSystem; -import com.ss.rlib.plugin.Plugin; -import com.ss.rlib.plugin.PluginContainer; -import com.ss.rlib.plugin.exception.PreloadPluginException; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.Utils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.manager.InitializeManager; +import com.ss.rlib.common.plugin.ConfigurablePluginSystem; +import com.ss.rlib.common.plugin.Plugin; +import com.ss.rlib.common.plugin.PluginContainer; +import com.ss.rlib.common.plugin.exception.PreloadPluginException; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.Utils; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,16 +59,16 @@ private PluginManager() { this.pluginSystem = newBasePluginSystem(getClass().getClassLoader()); this.pluginSystem.setAppVersion(Config.APP_VERSION); - final Path folderInUserHome = Config.getAppFolderInUserHome(); - final String embeddedPath = System.getProperty("editor.embedded.plugins.path"); + var folderInUserHome = Config.getAppFolderInUserHome(); + var embeddedPath = System.getProperty("editor.embedded.plugins.path"); - if (embeddedPath != null) { - final Path embeddedPluginPath = Paths.get(embeddedPath); + if (embeddedPath != null && Files.exists(Paths.get(embeddedPath))) { + var embeddedPluginPath = Paths.get(embeddedPath); LOGGER.debug(this, "embedded plugin path: " + embeddedPluginPath); pluginSystem.configureEmbeddedPluginPath(embeddedPluginPath); } else { - final Path rootFolder = Utils.getRootFolderFromClass(JmeApplication.class); - final Path embeddedPluginPath = rootFolder.resolve("embedded-plugins"); + var rootFolder = Utils.getRootFolderFromClass(JmeApplication.class); + var embeddedPluginPath = rootFolder.resolve("embedded-plugins"); LOGGER.debug(this, "embedded plugin path: " + embeddedPluginPath); if (Files.exists(embeddedPluginPath)) { pluginSystem.configureEmbeddedPluginPath(embeddedPluginPath); @@ -77,31 +77,31 @@ private PluginManager() { } } - final Path userPluginsFolder = folderInUserHome.resolve("plugins"); + var userPluginsFolder = folderInUserHome.resolve("plugins"); LOGGER.debug(this, "installation plugin path: " + userPluginsFolder); if (!Files.exists(userPluginsFolder)) { - Utils.run(() -> Files.createDirectories(userPluginsFolder)); + FileUtils.createDirectories(userPluginsFolder); } pluginSystem.configureInstallationPluginsPath(userPluginsFolder); try { pluginSystem.preLoad(); - } catch (final PreloadPluginException e) { + } catch (PreloadPluginException e) { FileUtils.delete(e.getPath()); throw e; } pluginSystem.initialize(); - final InitializationManager initializationManager = InitializationManager.getInstance(); - initializationManager.addOnBeforeCreateJmeContext(this::onBeforeCreateJmeContext); - initializationManager.addOnAfterCreateJmeContext(this::onAfterCreateJmeContext); - initializationManager.addOnBeforeCreateJavaFxContext(this::onBeforeCreateJavaFxContext); - initializationManager.addOnAfterCreateJavaFxContext(this::onAfterCreateJavaFxContext); - initializationManager.addOnFinishLoading(this::onFinishLoading); + var initManager = InitializationManager.getInstance(); + initManager.addOnBeforeCreateJmeContext(this::onBeforeCreateJmeContext); + initManager.addOnAfterCreateJmeContext(this::onAfterCreateJmeContext); + initManager.addOnBeforeCreateJavaFxContext(this::onBeforeCreateJavaFxContext); + initManager.addOnAfterCreateJavaFxContext(this::onAfterCreateJavaFxContext); + initManager.addOnFinishLoading(this::onFinishLoading); } /** @@ -109,7 +109,7 @@ private PluginManager() { * * @param path the path to the plugin. */ - public void installPlugin(@NotNull final Path path) { + public void installPlugin(@NotNull Path path) { pluginSystem.installPlugin(path, false); } @@ -118,7 +118,7 @@ public void installPlugin(@NotNull final Path path) { * * @param plugin the plugin. */ - public void removePlugin(@NotNull final EditorPlugin plugin) { + public void removePlugin(@NotNull EditorPlugin plugin) { pluginSystem.removePlugin(plugin); } @@ -127,8 +127,8 @@ public void removePlugin(@NotNull final EditorPlugin plugin) { */ @JmeThread private void onBeforeCreateJmeContext() { - final Array plugins = pluginSystem.getPlugins(); - plugins.stream().filter(EditorPlugin.class::isInstance) + pluginSystem.getPlugins().stream() + .filter(EditorPlugin.class::isInstance) .map(EditorPlugin.class::cast) .forEach(editorPlugin -> editorPlugin.onBeforeCreateJmeContext(pluginSystem)); } @@ -138,15 +138,16 @@ private void onBeforeCreateJmeContext() { */ @JmeThread private void onAfterCreateJmeContext() { - final Array plugins = pluginSystem.getPlugins(); - plugins.stream().filter(EditorPlugin.class::isInstance) + pluginSystem.getPlugins().stream() + .filter(EditorPlugin.class::isInstance) .map(EditorPlugin.class::cast) .forEach(editorPlugin -> { + editorPlugin.onAfterCreateJmeContext(pluginSystem); - final PluginContainer container = editorPlugin.getContainer(); - final URLClassLoader classLoader = container.getClassLoader(); - final AssetManager assetManager = EditorUtil.getAssetManager(); + var container = editorPlugin.getContainer(); + var classLoader = container.getClassLoader(); + var assetManager = EditorUtil.getAssetManager(); assetManager.addClassLoader(classLoader); }); } @@ -156,8 +157,8 @@ private void onAfterCreateJmeContext() { */ @FxThread private void onBeforeCreateJavaFxContext() { - final Array plugins = pluginSystem.getPlugins(); - plugins.stream().filter(EditorPlugin.class::isInstance) + pluginSystem.getPlugins().stream() + .filter(EditorPlugin.class::isInstance) .map(EditorPlugin.class::cast) .forEach(editorPlugin -> editorPlugin.onBeforeCreateJavaFxContext(pluginSystem)); } @@ -167,8 +168,8 @@ private void onBeforeCreateJavaFxContext() { */ @FxThread private void onAfterCreateJavaFxContext() { - final Array plugins = pluginSystem.getPlugins(); - plugins.stream().filter(EditorPlugin.class::isInstance) + pluginSystem.getPlugins().stream() + .filter(EditorPlugin.class::isInstance) .map(EditorPlugin.class::cast) .forEach(editorPlugin -> editorPlugin.onAfterCreateJavaFxContext(pluginSystem)); } @@ -178,8 +179,8 @@ private void onAfterCreateJavaFxContext() { */ @FxThread private void onFinishLoading() { - final Array plugins = pluginSystem.getPlugins(); - plugins.stream().filter(EditorPlugin.class::isInstance) + pluginSystem.getPlugins().stream() + .filter(EditorPlugin.class::isInstance) .map(EditorPlugin.class::cast) .forEach(editorPlugin -> editorPlugin.onFinishLoading(pluginSystem)); } @@ -190,9 +191,9 @@ private void onFinishLoading() { * @param consumer the consumer. */ @FromAnyThread - public void handlePlugins(@NotNull final Consumer consumer) { - final Array plugins = pluginSystem.getPlugins(); - plugins.stream().filter(EditorPlugin.class::isInstance) + public void handlePlugins(@NotNull Consumer consumer) { + pluginSystem.getPlugins().stream() + .filter(EditorPlugin.class::isInstance) .map(EditorPlugin.class::cast) .forEach(consumer); } diff --git a/src/main/java/com/ss/editor/manager/RemoteControlManager.java b/src/main/java/com/ss/editor/manager/RemoteControlManager.java index b61f0031..cfccda3f 100644 --- a/src/main/java/com/ss/editor/manager/RemoteControlManager.java +++ b/src/main/java/com/ss/editor/manager/RemoteControlManager.java @@ -3,12 +3,12 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.Config; import com.ss.editor.manager.ClasspathManager.Scope; -import com.ss.rlib.network.NetworkConfig; -import com.ss.rlib.network.NetworkFactory; -import com.ss.rlib.network.packet.ReadablePacket; -import com.ss.rlib.network.packet.ReadablePacketRegistry; -import com.ss.rlib.network.server.AcceptHandler; -import com.ss.rlib.network.server.ServerNetwork; +import com.ss.rlib.common.network.NetworkConfig; +import com.ss.rlib.common.network.NetworkFactory; +import com.ss.rlib.common.network.packet.ReadablePacket; +import com.ss.rlib.common.network.packet.ReadablePacketRegistry; +import com.ss.rlib.common.network.server.AcceptHandler; +import com.ss.rlib.common.network.server.ServerNetwork; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/manager/ResourceManager.java b/src/main/java/com/ss/editor/manager/ResourceManager.java index 9d1ed0cf..f7aa52db 100644 --- a/src/main/java/com/ss/editor/manager/ResourceManager.java +++ b/src/main/java/com/ss/editor/manager/ResourceManager.java @@ -3,13 +3,13 @@ import static com.ss.editor.FileExtensions.*; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_FAST_SKY_FOLDER; import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.ArrayUtils.contains; -import static com.ss.rlib.util.FileUtils.getFiles; -import static com.ss.rlib.util.FileUtils.toUrl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.Utils.get; -import static com.ss.rlib.util.array.ArrayFactory.toArray; -import static com.ss.rlib.util.ref.ReferenceFactory.newRef; +import static com.ss.rlib.common.util.ArrayUtils.contains; +import static com.ss.rlib.common.util.FileUtils.getFiles; +import static com.ss.rlib.common.util.FileUtils.toUrl; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.Utils.get; +import static com.ss.rlib.common.util.array.ArrayFactory.toArray; +import static com.ss.rlib.common.util.ref.ReferenceFactory.newRef; import static java.lang.System.currentTimeMillis; import static java.nio.file.StandardWatchEventKinds.*; import com.jme3.asset.AssetEventListener; @@ -24,20 +24,20 @@ import com.ss.editor.util.EditorUtil; import com.ss.editor.util.SimpleFileVisitor; import com.ss.editor.util.SimpleFolderVisitor; -import com.ss.rlib.concurrent.util.ThreadUtils; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.manager.InitializeManager; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.Utils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayComparator; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; -import com.ss.rlib.util.ref.Reference; -import com.ss.rlib.util.ref.ReferenceType; +import com.ss.rlib.common.concurrent.util.ThreadUtils; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.manager.InitializeManager; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.Utils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayComparator; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.ref.Reference; +import com.ss.rlib.common.util.ref.ReferenceType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/manager/WorkspaceManager.java b/src/main/java/com/ss/editor/manager/WorkspaceManager.java index 00366381..ab3bb7cc 100644 --- a/src/main/java/com/ss/editor/manager/WorkspaceManager.java +++ b/src/main/java/com/ss/editor/manager/WorkspaceManager.java @@ -1,16 +1,16 @@ package com.ss.editor.manager; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.Utils.get; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.Utils.get; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.model.workspace.Workspace; import com.ss.editor.util.EditorUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.ss.rlib.manager.InitializeManager; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.manager.InitializeManager; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import java.nio.file.Files; import java.nio.file.Path; diff --git a/src/main/java/com/ss/editor/model/EditorCamera.java b/src/main/java/com/ss/editor/model/EditorCamera.java index 0b42dd04..2514eccf 100644 --- a/src/main/java/com/ss/editor/model/EditorCamera.java +++ b/src/main/java/com/ss/editor/model/EditorCamera.java @@ -1,7 +1,7 @@ package com.ss.editor.model; -import static com.ss.rlib.geom.util.AngleUtils.degreeToRadians; -import static com.ss.rlib.geom.util.AngleUtils.radiansToDegree; +import static com.ss.rlib.common.geom.util.AngleUtils.degreeToRadians; +import static com.ss.rlib.common.geom.util.AngleUtils.radiansToDegree; import static java.lang.Math.*; import com.jme3.export.InputCapsule; import com.jme3.export.JmeExporter; @@ -19,8 +19,8 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.config.Config; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import org.jetbrains.annotations.NotNull; import java.io.IOException; diff --git a/src/main/java/com/ss/editor/model/scene/EditorAudioNode.java b/src/main/java/com/ss/editor/model/scene/EditorAudioNode.java index 92971044..321b0243 100644 --- a/src/main/java/com/ss/editor/model/scene/EditorAudioNode.java +++ b/src/main/java/com/ss/editor/model/scene/EditorAudioNode.java @@ -1,7 +1,7 @@ package com.ss.editor.model.scene; import static com.ss.editor.util.GeomUtils.getDirection; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.audio.AudioNode; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; diff --git a/src/main/java/com/ss/editor/model/scene/EditorLightNode.java b/src/main/java/com/ss/editor/model/scene/EditorLightNode.java index 7c97aa6c..a7c735ca 100644 --- a/src/main/java/com/ss/editor/model/scene/EditorLightNode.java +++ b/src/main/java/com/ss/editor/model/scene/EditorLightNode.java @@ -1,7 +1,7 @@ package com.ss.editor.model.scene; import static com.ss.editor.util.GeomUtils.getDirection; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.light.DirectionalLight; import com.jme3.light.Light; import com.jme3.light.PointLight; diff --git a/src/main/java/com/ss/editor/model/scene/EditorPresentableNode.java b/src/main/java/com/ss/editor/model/scene/EditorPresentableNode.java index 0f61eb6d..0c0907b6 100644 --- a/src/main/java/com/ss/editor/model/scene/EditorPresentableNode.java +++ b/src/main/java/com/ss/editor/model/scene/EditorPresentableNode.java @@ -1,6 +1,6 @@ package com.ss.editor.model.scene; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.ss.editor.annotation.FromAnyThread; diff --git a/src/main/java/com/ss/editor/model/undo/EditorOperationControl.java b/src/main/java/com/ss/editor/model/undo/EditorOperationControl.java index e53dcdd3..b8544613 100644 --- a/src/main/java/com/ss/editor/model/undo/EditorOperationControl.java +++ b/src/main/java/com/ss/editor/model/undo/EditorOperationControl.java @@ -3,8 +3,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.application.Platform; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/model/undo/impl/AbstractEditorOperation.java b/src/main/java/com/ss/editor/model/undo/impl/AbstractEditorOperation.java index 057c17fb..26c71d60 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/AbstractEditorOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/AbstractEditorOperation.java @@ -1,12 +1,12 @@ package com.ss.editor.model.undo.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.model.undo.EditorOperation; import com.ss.editor.model.undo.UndoableEditor; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/model/undo/impl/AddVehicleWheelOperation.java b/src/main/java/com/ss/editor/model/undo/impl/AddVehicleWheelOperation.java index fa304f47..8a0ba5b7 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/AddVehicleWheelOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/AddVehicleWheelOperation.java @@ -1,6 +1,6 @@ package com.ss.editor.model.undo.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.control.VehicleControl; import com.jme3.bullet.objects.VehicleWheel; import com.jme3.math.Vector3f; diff --git a/src/main/java/com/ss/editor/model/undo/impl/ChangeControlsOperation.java b/src/main/java/com/ss/editor/model/undo/impl/ChangeControlsOperation.java index fedfde03..8ed9c8a7 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/ChangeControlsOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/ChangeControlsOperation.java @@ -5,7 +5,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.JmeThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/model/undo/impl/DisableControlsOperation.java b/src/main/java/com/ss/editor/model/undo/impl/DisableControlsOperation.java index ce3620bb..9005f075 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/DisableControlsOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/DisableControlsOperation.java @@ -4,7 +4,7 @@ import com.jme3.scene.control.Control; import com.ss.editor.Messages; import com.ss.editor.util.ControlUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/model/undo/impl/EnableControlsOperation.java b/src/main/java/com/ss/editor/model/undo/impl/EnableControlsOperation.java index f7fbf8ee..ec4c92bc 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/EnableControlsOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/EnableControlsOperation.java @@ -4,7 +4,7 @@ import com.jme3.scene.control.Control; import com.ss.editor.Messages; import com.ss.editor.util.ControlUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/model/undo/impl/RemoveElementsOperation.java b/src/main/java/com/ss/editor/model/undo/impl/RemoveElementsOperation.java index 95079c23..255a2e94 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/RemoveElementsOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/RemoveElementsOperation.java @@ -9,8 +9,8 @@ import com.ss.editor.annotation.JmeThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/model/undo/impl/RemoveVehicleWheelOperation.java b/src/main/java/com/ss/editor/model/undo/impl/RemoveVehicleWheelOperation.java index 38b52092..d66aaf9c 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/RemoveVehicleWheelOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/RemoveVehicleWheelOperation.java @@ -1,6 +1,6 @@ package com.ss.editor.model.undo.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.control.VehicleControl; import com.jme3.bullet.objects.VehicleWheel; import com.jme3.math.Vector3f; diff --git a/src/main/java/com/ss/editor/model/undo/impl/scene/RemoveSceneLayerOperation.java b/src/main/java/com/ss/editor/model/undo/impl/scene/RemoveSceneLayerOperation.java index 33239f33..b449c297 100644 --- a/src/main/java/com/ss/editor/model/undo/impl/scene/RemoveSceneLayerOperation.java +++ b/src/main/java/com/ss/editor/model/undo/impl/scene/RemoveSceneLayerOperation.java @@ -9,8 +9,8 @@ import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of the {@link AbstractEditorOperation} to remove a layer from a scene. diff --git a/src/main/java/com/ss/editor/model/workspace/Workspace.java b/src/main/java/com/ss/editor/model/workspace/Workspace.java index bfbf446b..5ee77603 100644 --- a/src/main/java/com/ss/editor/model/workspace/Workspace.java +++ b/src/main/java/com/ss/editor/model/workspace/Workspace.java @@ -2,19 +2,19 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.WorkspaceManager; import com.ss.editor.ui.component.editor.EditorDescription; import com.ss.editor.ui.component.editor.FileEditor; import com.ss.editor.ui.component.editor.state.EditorState; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/AbstractEditor3DPart.java b/src/main/java/com/ss/editor/part3d/editor/impl/AbstractEditor3DPart.java index d756061c..3702cea6 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/AbstractEditor3DPart.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/AbstractEditor3DPart.java @@ -6,8 +6,8 @@ import com.ss.editor.manager.ExecutorManager; import com.ss.editor.part3d.editor.Editor3DPart; import com.ss.editor.ui.component.editor.FileEditor; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/AdvancedAbstractEditor3DPart.java b/src/main/java/com/ss/editor/part3d/editor/impl/AdvancedAbstractEditor3DPart.java index e03d4ceb..f98394e1 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/AdvancedAbstractEditor3DPart.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/AdvancedAbstractEditor3DPart.java @@ -1,7 +1,7 @@ package com.ss.editor.part3d.editor.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayFactory.toArray; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayFactory.toArray; import com.jme3.app.Application; import com.jme3.app.state.AppStateManager; import com.jme3.input.InputManager; @@ -22,11 +22,11 @@ import com.ss.editor.ui.component.editor.FileEditor; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.LocalObjects; -import com.ss.rlib.function.BooleanFloatConsumer; -import com.ss.rlib.function.FloatFloatConsumer; -import com.ss.rlib.logging.LoggerLevel; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.function.BooleanFloatConsumer; +import com.ss.rlib.common.function.FloatFloatConsumer; +import com.ss.rlib.common.logging.LoggerLevel; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/Stats3DPart.java b/src/main/java/com/ss/editor/part3d/editor/impl/Stats3DPart.java index 12245d72..24e4e427 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/Stats3DPart.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/Stats3DPart.java @@ -1,6 +1,6 @@ package com.ss.editor.part3d.editor.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.app.Application; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; @@ -12,8 +12,8 @@ import com.ss.editor.manager.ExecutorManager; import com.ss.editor.part3d.editor.Editor3DPart; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ArrayUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.ArrayUtils; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.Pane; diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/audio/AudioViewer3DPart.java b/src/main/java/com/ss/editor/part3d/editor/impl/audio/AudioViewer3DPart.java index 03d38c4c..462475a1 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/audio/AudioViewer3DPart.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/audio/AudioViewer3DPart.java @@ -1,6 +1,6 @@ package com.ss.editor.part3d.editor.impl.audio; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.audio.AudioData; import com.jme3.audio.AudioKey; import com.jme3.audio.AudioNode; diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/model/ModelEditor3DPart.java b/src/main/java/com/ss/editor/part3d/editor/impl/model/ModelEditor3DPart.java index 18ebb623..09abef91 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/model/ModelEditor3DPart.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/model/ModelEditor3DPart.java @@ -13,8 +13,8 @@ import com.ss.editor.plugin.api.RenderFilterExtension; import com.ss.editor.ui.component.editor.impl.model.ModelFileEditor; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/scene/AbstractSceneEditor3DPart.java b/src/main/java/com/ss/editor/part3d/editor/impl/scene/AbstractSceneEditor3DPart.java index e5e2f7ca..28865cf5 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/scene/AbstractSceneEditor3DPart.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/scene/AbstractSceneEditor3DPart.java @@ -1,7 +1,7 @@ package com.ss.editor.part3d.editor.impl.scene; import static com.ss.editor.util.NodeUtils.findParent; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.app.state.AppState; import com.jme3.asset.AssetManager; import com.jme3.asset.AssetNotFoundException; @@ -51,13 +51,13 @@ import com.ss.editor.ui.component.editor.impl.scene.AbstractSceneFileEditor; import com.ss.editor.ui.control.property.operation.PropertyOperation; import com.ss.editor.util.*; -import com.ss.rlib.function.BooleanFloatConsumer; -import com.ss.rlib.geom.util.AngleUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.array.ArrayIterator; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.function.BooleanFloatConsumer; +import com.ss.rlib.common.geom.util.AngleUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.ArrayIterator; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.scene.input.KeyCode; import javafx.scene.input.MouseButton; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/ApplyScaleToPhysicsControlsHandler.java b/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/ApplyScaleToPhysicsControlsHandler.java index 6efdaa68..fcd78de1 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/ApplyScaleToPhysicsControlsHandler.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/ApplyScaleToPhysicsControlsHandler.java @@ -9,8 +9,8 @@ import com.ss.editor.part3d.editor.impl.scene.AbstractSceneEditor3DPart; import com.ss.editor.util.ControlUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/DisableControlsTransformationHandler.java b/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/DisableControlsTransformationHandler.java index 5cf51894..0a6d2bf9 100644 --- a/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/DisableControlsTransformationHandler.java +++ b/src/main/java/com/ss/editor/part3d/editor/impl/scene/handler/DisableControlsTransformationHandler.java @@ -1,6 +1,6 @@ package com.ss.editor.part3d.editor.impl.scene.handler; -import static com.ss.rlib.util.array.ArrayCollectors.toArray; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; import com.jme3.bullet.control.PhysicsControl; import com.jme3.bullet.control.RigidBodyControl; @@ -9,9 +9,9 @@ import com.ss.editor.annotation.JmeThread; import com.ss.editor.util.ControlUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/plugin/EditorPlugin.java b/src/main/java/com/ss/editor/plugin/EditorPlugin.java index 3e725545..05f3f012 100644 --- a/src/main/java/com/ss/editor/plugin/EditorPlugin.java +++ b/src/main/java/com/ss/editor/plugin/EditorPlugin.java @@ -14,9 +14,9 @@ import com.ss.editor.ui.control.tree.node.factory.TreeNodeFactoryRegistry; import com.ss.editor.ui.css.CssRegistry; import com.ss.editor.ui.preview.FilePreviewFactoryRegistry; -import com.ss.rlib.plugin.PluginContainer; -import com.ss.rlib.plugin.PluginSystem; -import com.ss.rlib.plugin.impl.BasePlugin; +import com.ss.rlib.common.plugin.PluginContainer; +import com.ss.rlib.common.plugin.PluginSystem; +import com.ss.rlib.common.plugin.impl.BasePlugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,7 +29,7 @@ */ public class EditorPlugin extends BasePlugin { - public EditorPlugin(@NotNull final PluginContainer pluginContainer) { + public EditorPlugin(@NotNull PluginContainer pluginContainer) { super(pluginContainer); } @@ -39,7 +39,7 @@ public EditorPlugin(@NotNull final PluginContainer pluginContainer) { * @param registry the CSS registry. */ @FromAnyThread - public void register(@NotNull final CssRegistry registry) { + public void register(@NotNull CssRegistry registry) { } /** @@ -48,7 +48,7 @@ public void register(@NotNull final CssRegistry registry) { * @param registry the file creator registry. */ @FromAnyThread - public void register(@NotNull final FileCreatorRegistry registry) { + public void register(@NotNull FileCreatorRegistry registry) { } /** @@ -57,7 +57,7 @@ public void register(@NotNull final FileCreatorRegistry registry) { * @param registry the file creator registry. */ @FromAnyThread - public void register(@NotNull final EditorRegistry registry) { + public void register(@NotNull EditorRegistry registry) { } /** @@ -66,7 +66,7 @@ public void register(@NotNull final EditorRegistry registry) { * @param iconManager the icon manager. */ @FromAnyThread - public void register(@NotNull final FileIconManager iconManager) { + public void register(@NotNull FileIconManager iconManager) { } /** @@ -75,7 +75,7 @@ public void register(@NotNull final FileIconManager iconManager) { * @param registry the converters registry. */ @FromAnyThread - public void register(@NotNull final FileConverterRegistry registry) { + public void register(@NotNull FileConverterRegistry registry) { } /** @@ -84,7 +84,7 @@ public void register(@NotNull final FileConverterRegistry registry) { * @param registry the menu fillers registry. */ @FromAnyThread - public void register(@NotNull final AssetTreeContextMenuFillerRegistry registry) { + public void register(@NotNull AssetTreeContextMenuFillerRegistry registry) { } /** @@ -93,7 +93,7 @@ public void register(@NotNull final AssetTreeContextMenuFillerRegistry registry) * @param registry the registry of tree node factories. */ @FromAnyThread - public void register(@NotNull final TreeNodeFactoryRegistry registry) { + public void register(@NotNull TreeNodeFactoryRegistry registry) { } /** @@ -102,7 +102,7 @@ public void register(@NotNull final TreeNodeFactoryRegistry registry) { * @param registry the registry of property builders. */ @FromAnyThread - public void register(@NotNull final PropertyBuilderRegistry registry) { + public void register(@NotNull PropertyBuilderRegistry registry) { } /** @@ -111,7 +111,7 @@ public void register(@NotNull final PropertyBuilderRegistry registry) { * @param registry the registry of file preview factories. */ @FromAnyThread - public void register(@NotNull final FilePreviewFactoryRegistry registry) { + public void register(@NotNull FilePreviewFactoryRegistry registry) { } /** @@ -120,7 +120,7 @@ public void register(@NotNull final FilePreviewFactoryRegistry registry) { * @param registry the registry of settings providers. */ @FxThread - public void register(@NotNull final SettingsProviderRegistry registry) { + public void register(@NotNull SettingsProviderRegistry registry) { } /** @@ -129,7 +129,7 @@ public void register(@NotNull final SettingsProviderRegistry registry) { * @param registry the registry of painting component's constructors. */ @FxThread - public void register(@NotNull final PaintingComponentRegistry registry) { + public void register(@NotNull PaintingComponentRegistry registry) { } /** @@ -138,7 +138,7 @@ public void register(@NotNull final PaintingComponentRegistry registry) { * @param pluginSystem the plugin system. */ @JmeThread - public void onBeforeCreateJmeContext(@NotNull final PluginSystem pluginSystem) { + public void onBeforeCreateJmeContext(@NotNull PluginSystem pluginSystem) { } /** @@ -147,7 +147,7 @@ public void onBeforeCreateJmeContext(@NotNull final PluginSystem pluginSystem) { * @param pluginSystem the plugin system. */ @JmeThread - public void onAfterCreateJmeContext(@NotNull final PluginSystem pluginSystem) { + public void onAfterCreateJmeContext(@NotNull PluginSystem pluginSystem) { } /** @@ -156,7 +156,7 @@ public void onAfterCreateJmeContext(@NotNull final PluginSystem pluginSystem) { * @param pluginSystem the plugin system. */ @FxThread - public void onBeforeCreateJavaFxContext(@NotNull final PluginSystem pluginSystem) { + public void onBeforeCreateJavaFxContext(@NotNull PluginSystem pluginSystem) { } /** @@ -165,7 +165,7 @@ public void onBeforeCreateJavaFxContext(@NotNull final PluginSystem pluginSystem * @param pluginSystem the plugin system. */ @FxThread - public void onAfterCreateJavaFxContext(@NotNull final PluginSystem pluginSystem) { + public void onAfterCreateJavaFxContext(@NotNull PluginSystem pluginSystem) { } /** @@ -174,7 +174,7 @@ public void onAfterCreateJavaFxContext(@NotNull final PluginSystem pluginSystem) * @param pluginSystem the plugin system. */ @FxThread - public void onFinishLoading(@NotNull final PluginSystem pluginSystem) { + public void onFinishLoading(@NotNull PluginSystem pluginSystem) { } @Override diff --git a/src/main/java/com/ss/editor/plugin/api/RenderFilterExtension.java b/src/main/java/com/ss/editor/plugin/api/RenderFilterExtension.java index 6d1aad61..dd2697a2 100644 --- a/src/main/java/com/ss/editor/plugin/api/RenderFilterExtension.java +++ b/src/main/java/com/ss/editor/plugin/api/RenderFilterExtension.java @@ -4,11 +4,11 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.ClassUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -51,7 +51,7 @@ private RenderFilterExtension() { * @param filter the filter. */ @JmeThread - public void register(@NotNull final Filter filter) { + public void register(@NotNull Filter filter) { this.filters.add(filter); EditorUtil.getGlobalFilterPostProcessor() .addFilter(filter); @@ -65,7 +65,7 @@ public void register(@NotNull final Filter filter) { * @param the filter's type. */ @JmeThread - public void setOnRefresh(@NotNull final T filter, @NotNull final Consumer<@NotNull T> handler) { + public void setOnRefresh(@NotNull T filter, @NotNull Consumer handler) { if (!filters.contains(filter)) { throw new IllegalArgumentException("The filter " + filter + "isn't registered."); @@ -80,7 +80,7 @@ public void setOnRefresh(@NotNull final T filter, @NotNull fi @JmeThread public void refreshFilters() { refreshActions.forEach((filter, consumer) -> { - final Consumer<@NotNull Filter> cast = ClassUtils.unsafeCast(consumer); + var cast = ClassUtils.>unsafeCast(consumer); cast.accept(filter); }); } diff --git a/src/main/java/com/ss/editor/plugin/api/dialog/GenericFactoryDialog.java b/src/main/java/com/ss/editor/plugin/api/dialog/GenericFactoryDialog.java index 0967a242..3b8959af 100644 --- a/src/main/java/com/ss/editor/plugin/api/dialog/GenericFactoryDialog.java +++ b/src/main/java/com/ss/editor/plugin/api/dialog/GenericFactoryDialog.java @@ -1,17 +1,15 @@ package com.ss.editor.plugin.api.dialog; import static com.ss.editor.plugin.api.property.control.PropertyEditorControlFactory.build; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.plugin.api.property.control.PropertyEditorControl; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import javafx.collections.ObservableList; -import javafx.scene.Node; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,7 +25,6 @@ */ public class GenericFactoryDialog extends AbstractSimpleEditorDialog { - @NotNull private static final Point DIALOG_SIZE = new Point(400, -1); /** @@ -66,14 +63,15 @@ public class GenericFactoryDialog extends AbstractSimpleEditorDialog { @Nullable private VBox root; - public GenericFactoryDialog(@NotNull final Array definitions, - @NotNull final Consumer handler) { + public GenericFactoryDialog(@NotNull Array definitions, @NotNull Consumer handler) { this(definitions, handler, varTable -> true); } - public GenericFactoryDialog(@NotNull final Array definitions, - @NotNull final Consumer handler, - @NotNull final Predicate validator) { + public GenericFactoryDialog( + @NotNull Array definitions, + @NotNull Consumer handler, + @NotNull Predicate validator + ) { this.definitions = definitions; this.handler = handler; this.validator = validator; @@ -89,7 +87,7 @@ public GenericFactoryDialog(@NotNull final Array definitions * @param title the new title. */ @FxThread - public void setTitle(@NotNull final String title) { + public void setTitle(@NotNull String title) { getDialog().setTitle(title); } @@ -99,7 +97,7 @@ public void setTitle(@NotNull final String title) { * @param text the new text. */ @FxThread - public void setButtonOkText(@NotNull final String text) { + public void setButtonOkText(@NotNull String text) { notNull(getOkButton()).setText(text); } @@ -109,7 +107,7 @@ public void setButtonOkText(@NotNull final String text) { * @param text the new text. */ @FxThread - public void setButtonCloseText(@NotNull final String text) { + public void setButtonCloseText(@NotNull String text) { notNull(getCloseButton()).setText(text); } @@ -121,7 +119,7 @@ public void setButtonCloseText(@NotNull final String text) { @Override @FxThread - protected void createContent(@NotNull final VBox root) { + protected void createContent(@NotNull VBox root) { super.createContent(root); this.root = root; } @@ -142,11 +140,11 @@ protected void createContent(@NotNull final VBox root) { @FxThread private void createControls() { - final ObservableList children = getRoot().getChildren(); + var children = getRoot().getChildren(); - final Array definitions = getDefinitions(); + var definitions = getDefinitions(); definitions.forEach(definition -> { - final PropertyEditorControl control = build(vars, definition, validateCallback); + var control = build(vars, definition, validateCallback); control.prefWidthProperty().bind(widthProperty()); children.add(control); }); diff --git a/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithRightTool.java b/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithRightTool.java index 87008b41..20d005c7 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithRightTool.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithRightTool.java @@ -1,6 +1,6 @@ package com.ss.editor.plugin.api.editor; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.editor.part3d.Advanced3DEditorPart; import com.ss.editor.ui.component.editor.state.impl.Editor3DWithEditorToolEditorState; @@ -9,7 +9,7 @@ import com.ss.editor.ui.component.tab.ScrollableEditorToolComponent; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.event.Event; import javafx.scene.input.DragEvent; import javafx.scene.layout.BorderPane; diff --git a/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithSplitRightTool.java b/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithSplitRightTool.java index 4d7dad44..fbb272c2 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithSplitRightTool.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/Advanced3DFileEditorWithSplitRightTool.java @@ -4,7 +4,7 @@ import com.ss.editor.plugin.api.editor.part3d.Advanced3DEditorPart; import com.ss.editor.ui.component.editor.state.impl.Editor3DWithEditorToolEditorState; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.Node; import javafx.scene.control.SplitPane; import javafx.scene.layout.Region; diff --git a/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditor.java b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditor.java index 1c584ec6..b6688e60 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditor.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditor.java @@ -1,6 +1,6 @@ package com.ss.editor.plugin.api.editor; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.WorkspaceManager; diff --git a/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithRightTool.java b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithRightTool.java index b8877821..aa7b74e8 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithRightTool.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithRightTool.java @@ -1,6 +1,6 @@ package com.ss.editor.plugin.api.editor; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.editor.state.impl.EditorWithEditorToolEditorState; import com.ss.editor.ui.component.split.pane.EditorToolSplitPane; @@ -8,7 +8,7 @@ import com.ss.editor.ui.component.tab.ScrollableEditorToolComponent; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.input.DragEvent; import javafx.scene.layout.StackPane; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithSplitRightTool.java b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithSplitRightTool.java index 738b636c..69fad2f7 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithSplitRightTool.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithSplitRightTool.java @@ -3,7 +3,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.editor.state.impl.EditorWithEditorToolEditorState; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.Node; import javafx.scene.control.SplitPane; import javafx.scene.layout.Region; diff --git a/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialEditor3DPart.java b/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialEditor3DPart.java index 1762b6a5..d39831e9 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialEditor3DPart.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialEditor3DPart.java @@ -1,6 +1,6 @@ package com.ss.editor.plugin.api.editor.material; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.app.Application; import com.jme3.app.state.AppStateManager; import com.jme3.asset.AssetNotFoundException; @@ -26,9 +26,9 @@ import com.ss.editor.plugin.api.editor.part3d.AdvancedPbrWithStudioSky3DEditorPart; import com.ss.editor.ui.component.editor.impl.material.MaterialFileEditor; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.function.BooleanFloatConsumer; -import com.ss.rlib.geom.util.AngleUtils; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.function.BooleanFloatConsumer; +import com.ss.rlib.common.geom.util.AngleUtils; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.scene.input.KeyCode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialFileEditor.java b/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialFileEditor.java index 631ae566..00ee97cd 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialFileEditor.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialFileEditor.java @@ -2,8 +2,8 @@ import static com.jme3.renderer.queue.RenderQueue.Bucket.Inherit; import static com.jme3.renderer.queue.RenderQueue.Bucket.values; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static javafx.collections.FXCollections.observableArrayList; import com.jme3.material.Material; import com.jme3.renderer.queue.RenderQueue; @@ -22,8 +22,8 @@ import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; import javafx.collections.ObservableList; import javafx.scene.control.*; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorPart.java b/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorPart.java index 5c9cee98..1a7f7b71 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorPart.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorPart.java @@ -1,6 +1,6 @@ package com.ss.editor.plugin.api.editor.part3d; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.Vector3f; import com.jme3.scene.Node; import com.ss.editor.annotation.FromAnyThread; diff --git a/src/main/java/com/ss/editor/plugin/api/file/creator/GenericFileCreator.java b/src/main/java/com/ss/editor/plugin/api/file/creator/GenericFileCreator.java index 0f4b03f4..2d265abc 100644 --- a/src/main/java/com/ss/editor/plugin/api/file/creator/GenericFileCreator.java +++ b/src/main/java/com/ss/editor/plugin/api/file/creator/GenericFileCreator.java @@ -1,17 +1,16 @@ package com.ss.editor.plugin.api.file.creator; import static com.ss.editor.plugin.api.property.control.PropertyEditorControlFactory.build; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.plugin.api.property.control.PropertyEditorControl; import com.ss.editor.ui.component.creator.impl.AbstractFileCreator; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import javafx.scene.control.Button; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.layout.GridPane; import javafx.stage.Window; import org.jetbrains.annotations.NotNull; @@ -46,17 +45,16 @@ public GenericFileCreator() { } @Override - protected void createSettings(@NotNull final GridPane root) { + protected void createSettings(@NotNull GridPane root) { super.createSettings(root); this.settingsContainer = root; this.vars = VarTable.newInstance(); - int rowIndex = 1; + var rowIndex = 1; - final Array definitions = getPropertyDefinitions(); - for (final PropertyDefinition definition : definitions) { - final PropertyEditorControl control = build(vars, definition, this::validateFileName); + for (var definition : getPropertyDefinitions()) { + var control = build(vars, definition, this::validateFileName); control.prefWidthProperty().bind(widthProperty()); root.add(control, 0, rowIndex++, 2, 1); } @@ -64,7 +62,7 @@ protected void createSettings(@NotNull final GridPane root) { @Override @FxThread - public void show(@NotNull final Window owner) { + public void show(@NotNull Window owner) { super.show(owner); validateFileName(); } @@ -92,16 +90,18 @@ public void show(@NotNull final Window owner) { protected void validateFileName() { super.validateFileName(); - final GridPane settingsContainer = getSettingsContainer(); + var settingsContainer = getSettingsContainer(); settingsContainer.getChildren().stream() .filter(PropertyEditorControl.class::isInstance) .map(PropertyEditorControl.class::cast) .forEach(PropertyEditorControl::checkDependency); - final Button okButton = getOkButton(); - if (okButton == null) return; + var okButton = getOkButton(); + if (okButton == null) { + return; + } - final boolean result = validate(getVars()); + var result = validate(getVars()); if (!okButton.isDisabled()) { okButton.setDisable(!result); @@ -115,13 +115,13 @@ protected void validateFileName() { * @return true if the all variables are valid. */ @FxThread - protected boolean validate(@NotNull final VarTable vars) { + protected boolean validate(@NotNull VarTable vars) { return true; } @Override @BackgroundThread - protected void writeData(@NotNull final Path resultFile) throws IOException { + protected void writeData(@NotNull Path resultFile) throws IOException { writeData(getVars(), resultFile); } @@ -133,7 +133,7 @@ protected void writeData(@NotNull final Path resultFile) throws IOException { * @throws IOException if was some problem with writing to the result file. */ @BackgroundThread - protected void writeData(@NotNull final VarTable vars, @NotNull final Path resultFile) throws IOException { + protected void writeData(@NotNull VarTable vars, @NotNull Path resultFile) throws IOException { } /** diff --git a/src/main/java/com/ss/editor/plugin/api/messages/MessagesPluginFactory.java b/src/main/java/com/ss/editor/plugin/api/messages/MessagesPluginFactory.java index 540fca86..5be7faa2 100644 --- a/src/main/java/com/ss/editor/plugin/api/messages/MessagesPluginFactory.java +++ b/src/main/java/com/ss/editor/plugin/api/messages/MessagesPluginFactory.java @@ -5,7 +5,7 @@ import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.EditorPlugin; -import com.ss.rlib.util.PropertyLoader; +import com.ss.rlib.common.util.PropertyLoader; import org.jetbrains.annotations.NotNull; import java.util.Enumeration; @@ -22,10 +22,10 @@ public class MessagesPluginFactory { /** * The empty resource bundle. */ - @NotNull private static final ResourceBundle EMPTY_RESOURCE_BUNDLE = new ResourceBundle() { + @Override - protected Object handleGetObject(@NotNull final String key) { + protected Object handleGetObject(@NotNull String key) { return null; } @@ -44,7 +44,7 @@ public Enumeration getKeys() { * @return the resource bundle. */ @FromAnyThread - public static @NotNull ResourceBundle getResourceBundle(@NotNull final Class pluginClass) { + public static @NotNull ResourceBundle getResourceBundle(@NotNull Class pluginClass) { return getResourceBundle(pluginClass, Messages.BUNDLE_NAME); } @@ -56,11 +56,14 @@ public Enumeration getKeys() { * @return the resource bundle. */ @FromAnyThread - public static @NotNull ResourceBundle getResourceBundle(@NotNull final Class pluginClass, - @NotNull final String bundleName) { - final Locale locale = Locale.getDefault(); - final ClassLoader classLoader = pluginClass.getClassLoader(); - final ResourceBundle resourceBundle = getBundle(bundleName, locale, classLoader, PropertyLoader.getInstance()); + public static @NotNull ResourceBundle getResourceBundle( + @NotNull Class pluginClass, + @NotNull String bundleName + ) { + + var locale = Locale.getDefault(); + var classLoader = pluginClass.getClassLoader(); + var resourceBundle = getBundle(bundleName, locale, classLoader, PropertyLoader.getInstance()); if (resourceBundle == null) { return EMPTY_RESOURCE_BUNDLE; diff --git a/src/main/java/com/ss/editor/plugin/api/property/PropertyDefinition.java b/src/main/java/com/ss/editor/plugin/api/property/PropertyDefinition.java index 726d2744..5dc57ef3 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/PropertyDefinition.java +++ b/src/main/java/com/ss/editor/plugin/api/property/PropertyDefinition.java @@ -2,8 +2,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditablePropertyType; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,10 +14,7 @@ */ public class PropertyDefinition { - @NotNull private static final Array EMPTY_OPTIONS = ArrayFactory.asArray(); - - @NotNull private static final Array EMPTY_DEPENDENCIES = ArrayFactory.newArray(String.class); /** @@ -72,14 +69,22 @@ public class PropertyDefinition { */ private final float max; - public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @Nullable final Object defaultValue) { + public PropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @Nullable Object defaultValue + ) { this(propertyType, null, name, id, defaultValue); } - public PropertyDefinition(@NotNull final EditablePropertyType propertyType, - @Nullable final Array dependencies, @NotNull final String name, - @NotNull final String id, @Nullable final Object defaultValue) { + public PropertyDefinition( + @NotNull EditablePropertyType propertyType, + @Nullable Array dependencies, + @NotNull String name, + @NotNull String id, + @Nullable Object defaultValue + ) { this.propertyType = propertyType; this.name = name; this.id = id; @@ -91,16 +96,24 @@ public PropertyDefinition(@NotNull final EditablePropertyType propertyType, this.dependencies = dependencies == null ? EMPTY_DEPENDENCIES : dependencies; } - public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @Nullable final Object defaultValue, - @Nullable final String extension) { + public PropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @Nullable Object defaultValue, + @Nullable String extension + ) { this(propertyType, null, name, id, defaultValue, extension); } - public PropertyDefinition(@NotNull final EditablePropertyType propertyType, - @Nullable final Array dependencies, @NotNull final String name, - @NotNull final String id, @Nullable final Object defaultValue, - @Nullable final String extension) { + public PropertyDefinition( + @NotNull EditablePropertyType propertyType, + @Nullable Array dependencies, + @NotNull String name, + @NotNull String id, + @Nullable Object defaultValue, + @Nullable String extension + ) { this.propertyType = propertyType; this.name = name; this.id = id; @@ -112,9 +125,13 @@ public PropertyDefinition(@NotNull final EditablePropertyType propertyType, this.dependencies = dependencies == null ? EMPTY_DEPENDENCIES : dependencies; } - public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @Nullable final Object defaultValue, - @NotNull final Array options) { + public PropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull final String name, + @NotNull String id, + @Nullable Object defaultValue, + @NotNull Array options + ) { this.propertyType = propertyType; this.name = name; this.id = id; @@ -126,9 +143,14 @@ public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @Not this.dependencies = EMPTY_DEPENDENCIES; } - public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @Nullable final Object defaultValue, final float min, - final float max) { + public PropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @Nullable Object defaultValue, + float min, + float max + ) { this.propertyType = propertyType; this.name = name; this.id = id; diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/AssetResourcePropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/AssetResourcePropertyEditorControl.java index 99de0b9b..6988a677 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/AssetResourcePropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/AssetResourcePropertyEditorControl.java @@ -1,12 +1,12 @@ package com.ss.editor.plugin.api.property.control; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.nio.file.Path; @@ -19,15 +19,15 @@ */ public abstract class AssetResourcePropertyEditorControl extends ResourcePropertyEditorControl { - @NotNull private static final Predicate> DEFAULT_ACTION_TESTER = type -> false; - @NotNull private static final Array DEFAULT_EXTENSIONS = ArrayFactory.newArray(String.class); - protected AssetResourcePropertyEditorControl(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected AssetResourcePropertyEditorControl( + @NotNull final VarTable vars, + @NotNull final PropertyDefinition definition, + @NotNull final Runnable validationCallback + ) { super(vars, definition, validationCallback); } @@ -53,18 +53,18 @@ protected AssetResourcePropertyEditorControl(@NotNull final VarTable vars, @Override @FxThread - protected void processSelect() { - super.processSelect(); - UiUtils.openFileAssetDialog(this::processSelect, getExtensions(), getActionTester()); + protected void chooseNew() { + super.chooseNew(); + UiUtils.openFileAssetDialog(this::chooseNew, getExtensions(), getActionTester()); } /** - * Handles the selected file. + * Choose the new resource by the file. * * @param file the selected file. */ @FxThread - protected void processSelect(@NotNull final Path file) { + protected void chooseNew(@NotNull Path file) { change(); reload(); } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/AwtFontPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/AwtFontPropertyEditorControl.java index 524ece0a..4d643297 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/AwtFontPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/AwtFontPropertyEditorControl.java @@ -1,16 +1,17 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; +import com.ss.editor.manager.ExecutorManager; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; +import com.ss.editor.ui.util.AwtFontSuggestionProvider; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding; -import impl.org.controlsfx.autocompletion.SuggestionProvider; import javafx.scene.control.ComboBox; -import javafx.scene.control.SingleSelectionModel; import javafx.util.StringConverter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,22 +26,18 @@ */ public class AwtFontPropertyEditorControl extends PropertyEditorControl { - @NotNull private static final GraphicsEnvironment GRAPHICS_ENVIRONMENT = GraphicsEnvironment.getLocalGraphicsEnvironment(); - - @NotNull private static final Font[] FONTS = GRAPHICS_ENVIRONMENT.getAllFonts(); - @NotNull - private static final StringConverter STRING_CONVERTER = new StringConverter() { + private static final StringConverter STRING_CONVERTER = new StringConverter<>() { @Override - public @NotNull String toString(@Nullable final Font font) { + public @NotNull String toString(@Nullable Font font) { return font == null ? StringUtils.EMPTY : font.getFontName(); } @Override - public @Nullable Font fromString(@NotNull final String fontName) { + public @Nullable Font fromString(@NotNull String fontName) { return Arrays.stream(FONTS) .filter(font -> font.getFontName().equals(fontName)) .findAny().orElse(null); @@ -53,8 +50,11 @@ public class AwtFontPropertyEditorControl extends PropertyEditorControl { @Nullable private ComboBox comboBox; - protected AwtFontPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected AwtFontPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @@ -64,23 +64,34 @@ protected void createComponents() { super.createComponents(); comboBox = new ComboBox<>(); - comboBox.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); comboBox.getItems().addAll(FONTS); comboBox.setVisibleRowCount(20); comboBox.setConverter(STRING_CONVERTER); comboBox.setEditable(true); + comboBox.prefWidthProperty() + .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); - selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) -> change()); + var selectionModel = comboBox.getSelectionModel(); - final AutoCompletionTextFieldBinding binding = - new AutoCompletionTextFieldBinding<>(comboBox.getEditor(), - SuggestionProvider.create(comboBox.getItems()), STRING_CONVERTER); + var editor = comboBox.getEditor(); + var binding = new AutoCompletionTextFieldBinding(editor, + new AwtFontSuggestionProvider(comboBox.getItems()), STRING_CONVERTER); binding.setOnAutoCompleted(event -> selectionModel.select(event.getCompletion())); + binding.prefWidthProperty().bind(comboBox.widthProperty().multiply(1.3)); + + FxControlUtils.onSelectedItemChange(comboBox, newValue -> { + var executorManager = ExecutorManager.getInstance(); + executorManager.addFxTask(() -> editor.positionCaret(newValue.getFontName().length())); + }); + + FxControlUtils.onSelectedItemChange(comboBox, this::change); + + FxUtils.addClass(editor, + CssClasses.TRANSPARENT_TEXT_FIELD, CssClasses.TEXT_FIELD_IN_COMBO_BOX) + .addClass(comboBox, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); - FXUtils.addClassesTo(comboBox.getEditor(), CssClasses.TRANSPARENT_TEXT_FIELD, CssClasses.TEXT_FIELD_IN_COMBO_BOX); - FXUtils.addClassTo(comboBox, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(comboBox, this); + FxUtils.addChild(this, comboBox); } /** @@ -95,17 +106,21 @@ protected void createComponents() { @FxThread public void reload() { super.reload(); - final Font value = getPropertyValue(); - final ComboBox enumComboBox = getComboBox(); - enumComboBox.getSelectionModel().select(value); + var value = getPropertyValue(); + getComboBox().getSelectionModel() + .select(value); } @Override @FxThread protected void changeImpl() { - final ComboBox comboBox = getComboBox(); - final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); - setPropertyValue(selectionModel.getSelectedItem()); + + var selectionItem = getComboBox() + .getSelectionModel() + .getSelectedItem(); + + setPropertyValue(selectionItem); + super.changeImpl(); } } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/BooleanPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/BooleanPropertyEditorControl.java index dd5863e4..52766ca3 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/BooleanPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/BooleanPropertyEditorControl.java @@ -1,11 +1,12 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; -import com.ss.editor.ui.css.CssClasses; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; +import com.ss.editor.ui.css.CssClasses; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.CheckBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,8 +24,11 @@ public class BooleanPropertyEditorControl extends PropertyEditorControl @Nullable private CheckBox checkBox; - protected BooleanPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected BooleanPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @@ -34,15 +38,19 @@ protected void createComponents() { super.createComponents(); checkBox = new CheckBox(); - checkBox.selectedProperty().addListener((observable, oldValue, newValue) -> change()); - checkBox.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + checkBox.prefWidthProperty() + .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + + FxControlUtils.onSelectedChange(checkBox, this::change); - FXUtils.addToPane(checkBox, this); - FXUtils.addClassTo(checkBox, CssClasses.ABSTRACT_PARAM_CONTROL_CHECK_BOX); + FxUtils.addClass(checkBox, CssClasses.PROPERTY_CONTROL_CHECK_BOX); + FxUtils.addChild(this, checkBox); } /** - * @return the CheckBox with current value. + * Get the check box with current value. + * + * @return the check box with current value. */ @FxThread private @NotNull CheckBox getCheckBox() { @@ -53,8 +61,7 @@ protected void createComponents() { @FxThread public void reload() { super.reload(); - final Boolean value = getPropertyValue(); - getCheckBox().setSelected(value == null ? false : value); + getCheckBox().setSelected(Boolean.TRUE.equals(getPropertyValue())); } @Override diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/ClasspathResourcePropertyControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/ClasspathResourcePropertyControl.java index 13c73b21..b95ac5a4 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/ClasspathResourcePropertyControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/ClasspathResourcePropertyControl.java @@ -1,16 +1,14 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import javafx.scene.control.Label; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; import org.jetbrains.annotations.NotNull; /** @@ -26,30 +24,33 @@ public class ClasspathResourcePropertyControl extends ResourcePropertyEditorCont @NotNull private final String extension; - public ClasspathResourcePropertyControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public ClasspathResourcePropertyControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); this.extension = notNull(definition.getExtension()); } @Override @FxThread - protected void processSelect() { - super.processSelect(); + protected void chooseNew() { + super.chooseNew(); - final ResourceManager resourceManager = ResourceManager.getInstance(); - final Array resources = resourceManager.getAvailableResources(extension); + var resourceManager = ResourceManager.getInstance(); + var resources = resourceManager.getAvailableResources(extension); - UiUtils.openResourceAssetDialog(this::processSelect, this::validate, resources); + UiUtils.openResourceAssetDialog(this::chooseNew, this::validate, resources); } /** - * Handle selected resource. + * Choose the new resource by the path * * @param resource the selected resource. */ @FxThread - private void processSelect(@NotNull final String resource) { + private void chooseNew(@NotNull String resource) { setPropertyValue(resource); change(); reload(); @@ -64,7 +65,7 @@ private void processSelect(@NotNull final String resource) { @FxThread private String validate(@NotNull final String resource) { - final String extension = FileUtils.getExtension(resource); + var extension = FileUtils.getExtension(resource); if (StringUtils.isEmpty(extension)) { return Messages.ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE; } @@ -76,8 +77,8 @@ private String validate(@NotNull final String resource) { @FxThread public void reload() { - final String resource = getPropertyValue(); - final Label resourceLabel = getResourceLabel(); + var resource = getPropertyValue(); + var resourceLabel = getResourceLabel(); resourceLabel.setText(resource == null ? NOT_SELECTED : resource); super.reload(); diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/ColorPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/ColorPropertyEditorControl.java index 0b2c7292..eb35d7d5 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/ColorPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/ColorPropertyEditorControl.java @@ -1,13 +1,14 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.ColorPicker; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,8 +26,11 @@ public class ColorPropertyEditorControl extends PropertyEditorControl @Nullable private ColorPicker colorPicker; - protected ColorPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected ColorPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @@ -36,14 +40,18 @@ protected void createComponents() { super.createComponents(); colorPicker = new ColorPicker(); - colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> change()); - colorPicker.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + colorPicker.prefWidthProperty() + .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - FXUtils.addClassTo(colorPicker, CssClasses.ABSTRACT_PARAM_CONTROL_COLOR_PICKER); - FXUtils.addToPane(colorPicker, this); + FxControlUtils.onColorChange(colorPicker, this::change); + + FxUtils.addClass(colorPicker, CssClasses.PROPERTY_CONTROL_COLOR_PICKER); + FxUtils.addChild(this, colorPicker); } /** + * Get the color picker. + * * @return the color picker. */ @FxThread @@ -55,14 +63,13 @@ protected void createComponents() { @FxThread public void reload() { super.reload(); - final ColorPicker colorPicker = getColorPicker(); - colorPicker.setValue(UiUtils.from(getPropertyValue())); + getColorPicker().setValue(UiUtils.from(getPropertyValue())); } @Override @FxThread protected void changeImpl() { - final ColorPicker colorPicker = getColorPicker(); + var colorPicker = getColorPicker(); setPropertyValue(UiUtils.from(colorPicker.getValue())); super.changeImpl(); } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/ComboBoxPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/ComboBoxPropertyEditorControl.java new file mode 100644 index 00000000..d061e6fe --- /dev/null +++ b/src/main/java/com/ss/editor/plugin/api/property/control/ComboBoxPropertyEditorControl.java @@ -0,0 +1,77 @@ +package com.ss.editor.plugin.api.property.control; + +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.plugin.api.property.PropertyDefinition; +import com.ss.editor.ui.css.CssClasses; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; +import javafx.scene.control.ComboBox; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The combo box based property control. + * + * @author JavaSaBr + */ +public class ComboBoxPropertyEditorControl extends PropertyEditorControl { + + /** + * The list of available options. + */ + @Nullable + private ComboBox comboBox; + + protected ComboBoxPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { + super(vars, definition, validationCallback); + } + + @Override + @FxThread + protected void createComponents() { + super.createComponents(); + + comboBox = new ComboBox<>(); + comboBox.setVisibleRowCount(20); + comboBox.prefWidthProperty() + .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + + FxControlUtils.onSelectedItemChange(comboBox, this::change); + + FxUtils.addClass(comboBox, CssClasses.PROPERTY_CONTROL_COMBO_BOX); + FxUtils.addChild(this, comboBox); + } + + /** + * Get the list of available options. + * + * @return the list of available options. + */ + @FxThread + protected @NotNull ComboBox getComboBox() { + return notNull(comboBox); + } + + @Override + @FxThread + public void reload() { + super.reload(); + getComboBox().getSelectionModel() + .select(getPropertyValue()); + } + + @Override + @FxThread + protected void changeImpl() { + var comboBox = getComboBox(); + var selectionModel = comboBox.getSelectionModel(); + setPropertyValue(selectionModel.getSelectedItem()); + super.changeImpl(); + } +} diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/EnumPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/EnumPropertyEditorControl.java index b1ac7662..7c2ceb8d 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/EnumPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/EnumPropertyEditorControl.java @@ -1,78 +1,30 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; -import javafx.scene.control.ComboBox; -import javafx.scene.control.SingleSelectionModel; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.VarTable; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** - * The control to edit enum values. + * The property control to edit enum values. * * @author JavaSaBr */ -public class EnumPropertyEditorControl> extends PropertyEditorControl { +public class EnumPropertyEditorControl> extends ComboBoxPropertyEditorControl { - /** - * The list of available options of the {@link Enum} value. - */ - @Nullable - private ComboBox enumComboBox; - - protected EnumPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected EnumPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); - final T defaultValue = unsafeCast(notNull(definition.getDefaultValue())); - final T[] enumConstants = unsafeCast(defaultValue.getClass().getEnumConstants()); - - final ComboBox enumComboBox = getEnumComboBox(); - enumComboBox.getItems().addAll(enumConstants); - } - - @Override - @FxThread - protected void createComponents() { - super.createComponents(); - - enumComboBox = new ComboBox<>(); - enumComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> change()); - enumComboBox.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - enumComboBox.setVisibleRowCount(20); - - FXUtils.addClassTo(enumComboBox, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(enumComboBox, this); - } - - /** - * @return the list of available options of the {@link Enum} value. - */ - @FxThread - private @NotNull ComboBox getEnumComboBox() { - return notNull(enumComboBox); - } - - @Override - @FxThread - public void reload() { - super.reload(); - final T value = getPropertyValue(); - final ComboBox enumComboBox = getEnumComboBox(); - enumComboBox.getSelectionModel().select(value); - } + var defaultValue = ClassUtils.unsafeCast(notNull(definition.getDefaultValue())); + var enumConstants = EditorUtil.getEnumValues(defaultValue.getClass()); - @Override - @FxThread - protected void changeImpl() { - final ComboBox enumComboBox = getEnumComboBox(); - final SingleSelectionModel selectionModel = enumComboBox.getSelectionModel(); - setPropertyValue(selectionModel.getSelectedItem()); - super.changeImpl(); + getComboBox().getItems() + .addAll(enumConstants); } } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/ExternalFileResourcePropertyControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/ExternalFileResourcePropertyControl.java index 955744e4..339f6e81 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/ExternalFileResourcePropertyControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/ExternalFileResourcePropertyControl.java @@ -4,8 +4,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.dialog.file.chooser.ExternalFileEditorDialog; -import com.ss.rlib.util.VarTable; -import javafx.scene.control.Label; +import com.ss.rlib.common.util.VarTable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,19 +24,21 @@ public class ExternalFileResourcePropertyControl extends ResourcePropertyEditorC @Nullable private final String extension; - public ExternalFileResourcePropertyControl(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public ExternalFileResourcePropertyControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); this.extension = definition.getExtension(); } @Override @FxThread - protected void processSelect() { - super.processSelect(); + protected void chooseNew() { + super.chooseNew(); - final ExternalFileEditorDialog dialog = new ExternalFileEditorDialog(this::openExternalFile); + var dialog = new ExternalFileEditorDialog(this::openExternalFile); dialog.setTitleText(Messages.ASSET_EDITOR_DIALOG_TITLE); dialog.setInitDirectory(Paths.get(System.getProperty("user.home"))); dialog.show(); @@ -49,7 +50,7 @@ protected void processSelect() { * @param path the selected file. */ @FxThread - private void openExternalFile(@NotNull final Path path) { + private void openExternalFile(@NotNull Path path) { setPropertyValue(path); change(); reload(); @@ -60,8 +61,8 @@ private void openExternalFile(@NotNull final Path path) { @FxThread public void reload() { - final Path resource = getPropertyValue(); - final Label resourceLabel = getResourceLabel(); + var resource = getPropertyValue(); + var resourceLabel = getResourceLabel(); resourceLabel.setText(resource == null ? NOT_SELECTED : resource.toString()); super.reload(); diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/FileAssetResourcePropertyControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/FileAssetResourcePropertyControl.java index c12adcad..742ce025 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/FileAssetResourcePropertyControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/FileAssetResourcePropertyControl.java @@ -2,15 +2,14 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.component.asset.tree.context.menu.action.NewFileAction; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import javafx.scene.control.Label; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.nio.file.Path; @@ -32,8 +31,11 @@ public class FileAssetResourcePropertyControl extends AssetResourcePropertyEdito @NotNull private final Array extensions; - public FileAssetResourcePropertyControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public FileAssetResourcePropertyControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); this.extensions = ArrayFactory.asArray(notNull(definition.getExtension())); } @@ -52,18 +54,18 @@ public FileAssetResourcePropertyControl(@NotNull final VarTable vars, @NotNull f @Override @FxThread - protected void processSelect(@NotNull final Path file) { + protected void chooseNew(@NotNull Path file) { setPropertyValue(notNull(getAssetFile(file))); - super.processSelect(file); + super.chooseNew(file); } @Override @FxThread public void reload() { - final Path file = getPropertyValue(); + var file = getPropertyValue(); - final Label resourceLabel = getResourceLabel(); + var resourceLabel = getResourceLabel(); resourceLabel.setText(file == null ? NOT_SELECTED : toAssetPath(file)); super.reload(); diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/FloatPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/FloatPropertyEditorControl.java index 38976ec8..8b0c90c6 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/FloatPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/FloatPropertyEditorControl.java @@ -1,52 +1,30 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.control.input.FloatTextField; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * The control to edit float values. * * @author JavaSaBr */ -public class FloatPropertyEditorControl extends PropertyEditorControl { +public class FloatPropertyEditorControl extends TypedTextFieldPropertyEditorControl { - /** - * The value field. - */ - @Nullable - private FloatTextField valueField; - - protected FloatPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public FloatPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @Override @FxThread - protected void createComponents() { - super.createComponents(); - - valueField = new FloatTextField(); - valueField.addChangeListener((observable, oldValue, newValue) -> change()); - valueField.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, this); - } - - /** - * @return the value field. - */ - @FxThread - private @NotNull FloatTextField getValueField() { - return notNull(valueField); + protected @NotNull FloatTextField createField() { + return new FloatTextField(); } /** @@ -56,7 +34,7 @@ protected void createComponents() { * @param max the max value. */ @FxThread - public void setMinMax(final float min, final float max) { + public void setMinMax(float min, float max) { if (Float.isNaN(min) || Float.isNaN(max)) return; getValueField().setMinMax(min, max); } @@ -65,7 +43,7 @@ public void setMinMax(final float min, final float max) { @FxThread public void reload() { super.reload(); - final Float value = getPropertyValue(); + var value = getPropertyValue(); getValueField().setValue(value == null ? 0 : value); } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/FolderAssetResourcePropertyControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/FolderAssetResourcePropertyControl.java index c393f3d4..e7a79b99 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/FolderAssetResourcePropertyControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/FolderAssetResourcePropertyControl.java @@ -2,15 +2,14 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.component.asset.tree.context.menu.action.NewFileAction; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import javafx.scene.control.Label; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; import org.jetbrains.annotations.NotNull; import java.nio.file.Path; @@ -26,9 +25,11 @@ public class FolderAssetResourcePropertyControl extends AssetResourcePropertyEdi @NotNull private static final Predicate> ACTION_TESTER = type -> type == NewFileAction.class; - public FolderAssetResourcePropertyControl(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public FolderAssetResourcePropertyControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @@ -40,25 +41,25 @@ public FolderAssetResourcePropertyControl(@NotNull final VarTable vars, @Override @FxThread - protected void processSelect() { - UiUtils.openFolderAssetDialog(this::processSelect, getActionTester()); + protected void chooseNew() { + UiUtils.openFolderAssetDialog(this::chooseNew, getActionTester()); } @Override @FxThread - protected void processSelect(@NotNull final Path file) { + protected void chooseNew(@NotNull Path file) { setPropertyValue(notNull(getAssetFile(file))); - super.processSelect(file); + super.chooseNew(file); } @Override @FxThread public void reload() { - final Path file = getPropertyValue(); - final String assetPath = file == null ? NOT_SELECTED : toAssetPath(file); + var file = getPropertyValue(); + var assetPath = file == null ? NOT_SELECTED : toAssetPath(file); - final Label resourceLabel = getResourceLabel(); + var resourceLabel = getResourceLabel(); resourceLabel.setText(StringUtils.isEmpty(assetPath) ? "/" : assetPath); super.reload(); diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/GeometryAssetResourcePropertyControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/GeometryAssetResourcePropertyControl.java index 471e1a65..f7beb1ac 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/GeometryAssetResourcePropertyControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/GeometryAssetResourcePropertyControl.java @@ -3,11 +3,10 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.scene.Geometry; -import com.jme3.scene.Spatial; import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.VarTable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,16 +17,17 @@ */ public class GeometryAssetResourcePropertyControl extends SpatialAssetResourcePropertyControl { - public GeometryAssetResourcePropertyControl(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public GeometryAssetResourcePropertyControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @Override @FxThread - protected @Nullable Geometry findResource(@NotNull final AssetManager assetManager, @NotNull final ModelKey modelKey) { - final Spatial spatial = assetManager.loadModel(modelKey); - return NodeUtils.findGeometry(spatial); + protected @Nullable Geometry findResource(@NotNull AssetManager assetManager, @NotNull ModelKey modelKey) { + return NodeUtils.findGeometry(assetManager.loadModel(modelKey)); } } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/IntegerPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/IntegerPropertyEditorControl.java index 87ae30ce..4e4d2f61 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/IntegerPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/IntegerPropertyEditorControl.java @@ -1,44 +1,31 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.ifNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.control.input.IntegerTextField; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.control.input.IntegerTextField; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** - * The control to edit integer values. + * The property control to edit integer values. * * @author JavaSaBr */ -public class IntegerPropertyEditorControl extends PropertyEditorControl { +public class IntegerPropertyEditorControl extends TypedTextFieldPropertyEditorControl { - /** - * The value field. - */ - @Nullable - private IntegerTextField valueField; - - protected IntegerPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public IntegerPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @Override @FxThread - protected void createComponents() { - super.createComponents(); - - valueField = new IntegerTextField(); - valueField.addChangeListener((observable, oldValue, newValue) -> change()); - valueField.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, this); + protected @NotNull IntegerTextField createField() { + return new IntegerTextField(); } /** @@ -48,25 +35,16 @@ protected void createComponents() { * @param max the max value. */ @FxThread - public void setMinMax(final float min, final float max) { + public void setMinMax(float min, float max) { if (Float.isNaN(min) || Float.isNaN(max)) return; getValueField().setMinMax((int) min, (int) max); } - /** - * @return the value field. - */ - @FxThread - private @NotNull IntegerTextField getValueField() { - return notNull(valueField); - } - @Override @FxThread public void reload() { super.reload(); - final Integer value = getPropertyValue(); - getValueField().setValue(value == null ? 0 : value); + getValueField().setValue(ifNull(getPropertyValue(), 0)); } @Override diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/ObjectFromListPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/ObjectFromListPropertyEditorControl.java index e69877ff..97c52f4d 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/ObjectFromListPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/ObjectFromListPropertyEditorControl.java @@ -1,76 +1,26 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import javafx.scene.control.ComboBox; -import javafx.scene.control.SingleSelectionModel; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * The control to choose object value from list. * * @author JavaSaBr */ -public class ObjectFromListPropertyEditorControl extends PropertyEditorControl { - - /** - * The list of available options. - */ - @Nullable - private ComboBox comboBox; - - protected ObjectFromListPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback, @NotNull final Array options) { +public class ObjectFromListPropertyEditorControl extends ComboBoxPropertyEditorControl { + + public ObjectFromListPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback, + @NotNull Array options + ) { super(vars, definition, validationCallback); - final ComboBox comboBox = getComboBox(); - options.forEach(comboBox.getItems(), (option, items) -> items.add(option.toString())); - } - - @Override - @FxThread - protected void createComponents() { - super.createComponents(); - - comboBox = new ComboBox<>(); - comboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> change()); - comboBox.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - comboBox.setVisibleRowCount(20); - - FXUtils.addClassTo(comboBox, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(comboBox, this); - } - - /** - * Get the list of available options . - * - * @return the list of available options . - */ - @FxThread - private @NotNull ComboBox getComboBox() { - return notNull(comboBox); - } - - @Override - @FxThread - public void reload() { - super.reload(); - final Object value = getPropertyValue(); - final ComboBox comboBox = getComboBox(); - comboBox.getSelectionModel().select(value); - } - - @Override - @FxThread - protected void changeImpl() { - final ComboBox comboBox = getComboBox(); - final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); - setPropertyValue(selectionModel.getSelectedItem()); - super.changeImpl(); + var comboBox = getComboBox(); + options.forEach(comboBox.getItems(), + (option, items) -> items.add(option)); } } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControl.java index 19019585..222888d3 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControl.java @@ -7,9 +7,9 @@ import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.fx.util.FxUtils; import javafx.geometry.Pos; import javafx.scene.control.Label; import javafx.scene.layout.HBox; @@ -25,15 +25,11 @@ */ public class PropertyEditorControl extends HBox { - /** - * The constant DEFAULT_LABEL_W_PERCENT. - */ - public static final double DEFAULT_LABEL_W_PERCENT = AbstractSimpleEditorDialog.DEFAULT_LABEL_W_PERCENT; + public static final double DEFAULT_LABEL_W_PERCENT = + AbstractSimpleEditorDialog.DEFAULT_LABEL_W_PERCENT; - /** - * The constant DEFAULT_FIELD_W_PERCENT. - */ - public static final double DEFAULT_FIELD_W_PERCENT = AbstractSimpleEditorDialog.DEFAULT_FIELD_W_PERCENT; + public static final double DEFAULT_FIELD_W_PERCENT = + AbstractSimpleEditorDialog.DEFAULT_FIELD_W_PERCENT; /** * The validation callback to call re-validating. @@ -88,8 +84,11 @@ public class PropertyEditorControl extends HBox { */ private boolean ignoreListener; - protected PropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected PropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { this.vars = vars; this.id = definition.getId(); this.name = definition.getName(); @@ -98,7 +97,7 @@ protected PropertyEditorControl(@NotNull final VarTable vars, @NotNull final Pro this.dependencies = definition.getDependencies(); this.defaultValue = definition.getDefaultValue(); - final Object defaultValue = definition.getDefaultValue(); + var defaultValue = definition.getDefaultValue(); if (defaultValue != null) { vars.set(id, defaultValue); @@ -107,6 +106,7 @@ protected PropertyEditorControl(@NotNull final VarTable vars, @NotNull final Pro setOnKeyReleased(UiUtils::consumeIfIsNotHotKey); setOnKeyPressed(UiUtils::consumeIfIsNotHotKey); createComponents(); + setIgnoreListener(true); try { reload(); @@ -114,7 +114,7 @@ protected PropertyEditorControl(@NotNull final VarTable vars, @NotNull final Pro setIgnoreListener(false); } - FXUtils.addClassTo(this, CssClasses.ABSTRACT_PARAM_EDITOR_CONTROL); + FxUtils.addClass(this, CssClasses.PROPERTY_EDITOR_CONTROL); } /** @@ -123,19 +123,21 @@ protected PropertyEditorControl(@NotNull final VarTable vars, @NotNull final Pro @FxThread public void checkDependency() { - final Array dependencies = getDependencies(); - if (dependencies.isEmpty()) return; + var dependencies = getDependencies(); + if (dependencies.isEmpty()) { + return; + } setDisable(false); - for (final String dependency : dependencies) { + for (var dependency : dependencies) { if (!vars.has(dependency)) { setDisable(true); return; } - final Object value = vars.get(dependency); + var value = vars.get(dependency); if (value instanceof Boolean) { setDisable(!(Boolean) value); @@ -212,8 +214,8 @@ protected void createComponents() { propertyNameLabel = new Label(getName() + ":"); propertyNameLabel.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_LABEL_W_PERCENT)); - FXUtils.addClassTo(propertyNameLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); - FXUtils.addToPane(propertyNameLabel, this); + FxUtils.addClass(propertyNameLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); + FxUtils.addChild(this, propertyNameLabel); } /** @@ -243,7 +245,7 @@ protected void createComponents() { * @param propertyValue the new current property value. */ @FxThread - protected void setPropertyValue(@Nullable final T propertyValue) { + protected void setPropertyValue(@Nullable T propertyValue) { if (propertyValue == null) { vars.clear(id); } else { @@ -257,7 +259,7 @@ protected void setPropertyValue(@Nullable final T propertyValue) { * @param ignoreListener the flag for ignoring listeners. */ @FxThread - protected void setIgnoreListener(final boolean ignoreListener) { + protected void setIgnoreListener(boolean ignoreListener) { this.ignoreListener = ignoreListener; } @@ -278,8 +280,8 @@ protected boolean isIgnoreListener() { */ @FxThread public boolean isNotDefault() { - final T propertyValue = getPropertyValue(); - final Object defaultValue = getDefaultValue(); + var propertyValue = getPropertyValue(); + var defaultValue = getDefaultValue(); return !Objects.equals(defaultValue, propertyValue); } } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControlFactory.java b/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControlFactory.java index 5217b215..1c3fb521 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControlFactory.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/PropertyEditorControlFactory.java @@ -2,7 +2,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.VarTable; import org.jetbrains.annotations.NotNull; /** @@ -21,13 +21,15 @@ public class PropertyEditorControlFactory { * @return the new property control. */ @FxThread - public static @NotNull PropertyEditorControl build(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validation) { + public static @NotNull PropertyEditorControl build( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validation + ) { switch (definition.getPropertyType()) { case FLOAT: { - final FloatPropertyEditorControl control = new FloatPropertyEditorControl(vars, definition, validation); + var control = new FloatPropertyEditorControl(vars, definition, validation); control.setMinMax(definition.getMin(), definition.getMax()); return control; } @@ -36,7 +38,7 @@ public class PropertyEditorControlFactory { case BOOLEAN: return new BooleanPropertyEditorControl(vars, definition, validation); case INTEGER: { - final IntegerPropertyEditorControl control = new IntegerPropertyEditorControl(vars, definition, validation); + var control = new IntegerPropertyEditorControl(vars, definition, validation); control.setMinMax(definition.getMin(), definition.getMax()); return control; } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/ResourcePropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/ResourcePropertyEditorControl.java index 79d113d1..d07f2c66 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/ResourcePropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/ResourcePropertyEditorControl.java @@ -1,21 +1,20 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; +import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.Icons; import com.ss.editor.ui.css.CssClasses; -import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.image.ImageView; import javafx.scene.input.DataFormat; import javafx.scene.input.DragEvent; -import javafx.scene.input.Dragboard; import javafx.scene.input.TransferMode; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; @@ -23,7 +22,6 @@ import java.io.File; import java.util.List; -import java.util.Set; /** * The control to edit resource values. @@ -32,11 +30,8 @@ */ public abstract class ResourcePropertyEditorControl extends PropertyEditorControl { - /** - * The constant NOT_SELECTED. - */ - @NotNull - protected static final String NOT_SELECTED = Messages.RESOURCE_PROPERTY_EDIT_CONTROL_NOTHING_IS_SELECTED; + protected static final String NOT_SELECTED = + Messages.RESOURCE_PROPERTY_EDIT_CONTROL_NOTHING_IS_SELECTED; /** * The label with name of the resource. @@ -44,13 +39,16 @@ public abstract class ResourcePropertyEditorControl extends PropertyEditorCon @Nullable private Label resourceLabel; - protected ResourcePropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected ResourcePropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); setOnDragOver(this::dragOver); setOnDragDropped(this::dragDropped); setOnDragExited(this::dragExited); - FXUtils.addClassTo(this, CssClasses.ABSTRACT_RESOURCE_PROPERTY_CONTROL); + FxUtils.addClass(this, CssClasses.PROPERTY_CONTROL_RESOURCE); } @Override @@ -60,53 +58,74 @@ protected void createComponents() { resourceLabel = new Label(NOT_SELECTED); - final Button changeButton = new Button(); + var changeButton = new Button(); changeButton.setGraphic(new ImageView(Icons.ADD_16)); - changeButton.setOnAction(event -> processSelect()); + changeButton.setOnAction(event -> chooseNew()); + + var removeButton = new Button(); + removeButton.setGraphic(new ImageView(Icons.REMOVE_12)); + removeButton.setOnAction(event -> removeCurrent()); + removeButton.disableProperty() + .bind(resourceLabel.textProperty().isEqualTo(NOT_SELECTED)); - final HBox container = new HBox(resourceLabel, changeButton); - container.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + var container = new HBox(resourceLabel, changeButton, removeButton); + container.prefWidthProperty() + .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - resourceLabel.prefWidthProperty().bind(container.widthProperty()); + resourceLabel.prefWidthProperty() + .bind(container.widthProperty()); - FXUtils.addToPane(container, this); + FxUtils.addChild(this, container); - FXUtils.addClassesTo(container, CssClasses.DEF_HBOX, CssClasses.TEXT_INPUT_CONTAINER); - FXUtils.addClassesTo(changeButton, CssClasses.FLAT_BUTTON, CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); - FXUtils.addClassTo(resourceLabel, CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL); + FxUtils.addClass(container, + CssClasses.DEF_HBOX, CssClasses.TEXT_INPUT_CONTAINER) + .addClass(changeButton, removeButton, + CssClasses.FLAT_BUTTON, CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON) + .addClass(resourceLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL); DynamicIconSupport.addSupport(changeButton); } /** - * Process select a resource. + * Choose a new resource. */ @FxThread - protected void processSelect() { + protected void chooseNew() { } + /** + * Remove the current resource. + */ + @FxThread + protected void removeCurrent() { + setPropertyValue(null); + change(); + reload(); + } + /** * Handle grad exiting. */ @FxThread - private void dragExited(@NotNull final DragEvent dragEvent) { + private void dragExited(@NotNull DragEvent dragEvent) { } /** * Handle dropped files to editor. */ @FxThread - private void dragDropped(@NotNull final DragEvent dragEvent) { + private void dragDropped(@NotNull DragEvent dragEvent) { - final Dragboard dragboard = dragEvent.getDragboard(); - final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); + var dragboard = dragEvent.getDragboard(); + var files = ClassUtils.>unsafeCast(dragboard.getContent(DataFormat.FILES)); if (files == null || files.size() != 1) { return; } - final File file = files.get(0); + var file = files.get(0); if (!canAccept(file)) { return; } @@ -120,36 +139,36 @@ private void dragDropped(@NotNull final DragEvent dragEvent) { * @param file the dropped file. */ @FxThread - protected void handleFile(@NotNull final File file) { + protected void handleFile(@NotNull File file) { } /** * Handle drag over. */ @FxThread - private void dragOver(@NotNull final DragEvent dragEvent) { + private void dragOver(@NotNull DragEvent dragEvent) { - final Dragboard dragboard = dragEvent.getDragboard(); - final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); + var dragboard = dragEvent.getDragboard(); + var files = ClassUtils.>unsafeCast(dragboard.getContent(DataFormat.FILES)); if (files == null || files.size() != 1) { return; } - final File file = files.get(0); + var file = files.get(0); if (!canAccept(file)) { return; } - final Set transferModes = dragboard.getTransferModes(); - final boolean isCopy = transferModes.contains(TransferMode.COPY); + var transferModes = dragboard.getTransferModes(); + var isCopy = transferModes.contains(TransferMode.COPY); dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE); dragEvent.consume(); } @FxThread - protected boolean canAccept(@NotNull final File file) { + protected boolean canAccept(@NotNull File file) { return false; } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/SpatialAssetResourcePropertyControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/SpatialAssetResourcePropertyControl.java index 5eb52ff3..1447d333 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/SpatialAssetResourcePropertyControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/SpatialAssetResourcePropertyControl.java @@ -2,23 +2,20 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.editor.util.NodeUtils.findParent; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.asset.AssetKey; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.scene.Spatial; import com.ss.editor.FileExtensions; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import javafx.scene.control.Label; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,9 +36,11 @@ public class SpatialAssetResourcePropertyControl extends Asse EXTENSIONS.add(FileExtensions.JME_OBJECT); } - public SpatialAssetResourcePropertyControl(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + public SpatialAssetResourcePropertyControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @@ -53,53 +52,52 @@ public SpatialAssetResourcePropertyControl(@NotNull final VarTable vars, @Override @FxThread - protected void processSelect(@NotNull final Path file) { + protected void chooseNew(@NotNull Path file) { - final AssetManager assetManager = EditorUtil.getAssetManager(); + var assetManager = EditorUtil.getAssetManager(); - final Path assetFile = notNull(getAssetFile(file)); - final ModelKey modelKey = new ModelKey(toAssetPath(assetFile)); - final T spatial = findResource(assetManager, modelKey); + var assetFile = notNull(getAssetFile(file)); + var modelKey = new ModelKey(toAssetPath(assetFile)); + var spatial = findResource(assetManager, modelKey); setPropertyValue(unsafeCast(spatial)); - super.processSelect(file); + super.chooseNew(file); } /** - * Finds a resource rom asset folder by the model key. + * Find a resource rom asset folder by the model key. * * @param assetManager the asset manager. * @param modelKey the model key. * @return the target resource. */ @FxThread - protected @Nullable T findResource(@NotNull final AssetManager assetManager, @NotNull final ModelKey modelKey) { + protected @Nullable T findResource(@NotNull AssetManager assetManager, @NotNull ModelKey modelKey) { return unsafeCast(assetManager.loadModel(modelKey)); } @Override @FxThread - protected boolean canAccept(@NotNull final File file) { + protected boolean canAccept(@NotNull File file) { return EXTENSIONS.contains(FileUtils.getExtension(file.getName())); } @Override @FxThread - protected void handleFile(@NotNull final File file) { - processSelect(file.toPath()); + protected void handleFile(@NotNull File file) { + chooseNew(file.toPath()); } @Override @FxThread public void reload() { - final T model = getPropertyValue(); - final Spatial root = model == null ? null : findParent(model, spatial -> spatial.getKey() != null); - final AssetKey key = root == null ? null : root.getKey(); + var model = getPropertyValue(); + var rootKey = EditorUtil.findRootKey(model); - final Label resourceLabel = getResourceLabel(); - resourceLabel.setText(key == null ? NOT_SELECTED : key.getName() + "[" + model.getName() + "]"); + var resourceLabel = getResourceLabel(); + resourceLabel.setText(rootKey == null ? NOT_SELECTED : rootKey + "[" + model.getName() + "]"); super.reload(); } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/StringFromListPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/StringFromListPropertyEditorControl.java index 7b3077c9..8ece920c 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/StringFromListPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/StringFromListPropertyEditorControl.java @@ -1,53 +1,56 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import com.ss.editor.manager.ExecutorManager; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import javafx.scene.control.ComboBox; -import javafx.scene.control.SingleSelectionModel; -import javafx.scene.control.TextField; -import org.controlsfx.control.textfield.AutoCompletionBinding; -import org.controlsfx.control.textfield.TextFields; +import com.ss.editor.ui.util.SimpleStringSuggestionProvider; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; +import impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * The control to choose string value from list. * * @author JavaSaBr */ -public class StringFromListPropertyEditorControl extends PropertyEditorControl { - - /** - * The list of available options of the string value. - */ - @Nullable - private ComboBox comboBox; - - protected StringFromListPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback, @NotNull final Array options) { +public class StringFromListPropertyEditorControl extends ComboBoxPropertyEditorControl { + + public StringFromListPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback, + @NotNull Array options + ) { super(vars, definition, validationCallback); - final ComboBox comboBox = getComboBox(); - options.forEach(comboBox.getItems(), (option, items) -> items.add(option.toString())); + var comboBox = getComboBox(); + options.forEach(comboBox.getItems(), + (option, items) -> items.add(option.toString())); if (options.size() > comboBox.getVisibleRowCount()) { setIgnoreListener(true); try { - //FIXME need to find more userfriendly control comboBox.setEditable(true); - final TextField editor = comboBox.getEditor(); - final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); - final AutoCompletionBinding binding = TextFields.bindAutoCompletion(editor, comboBox.getItems()); + var selectionModel = comboBox.getSelectionModel(); + var editor = comboBox.getEditor(); + + var binding = new AutoCompletionTextFieldBinding(editor, + new SimpleStringSuggestionProvider(comboBox.getItems())); binding.setOnAutoCompleted(event -> selectionModel.select(event.getCompletion())); + binding.prefWidthProperty().bind(comboBox.widthProperty().multiply(1.3)); + + FxControlUtils.onSelectedItemChange(comboBox, newValue -> { + var executorManager = ExecutorManager.getInstance(); + executorManager.addFxTask(() -> editor.positionCaret(newValue.length())); + }); - FXUtils.addClassesTo(editor, CssClasses.TRANSPARENT_TEXT_FIELD, + FxUtils.addClass(editor, + CssClasses.TRANSPARENT_TEXT_FIELD, CssClasses.TEXT_FIELD_IN_COMBO_BOX); reload(); @@ -57,44 +60,4 @@ protected StringFromListPropertyEditorControl(@NotNull final VarTable vars, @Not } } } - - @Override - @FxThread - protected void createComponents() { - super.createComponents(); - - comboBox = new ComboBox<>(); - comboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> change()); - comboBox.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - comboBox.setVisibleRowCount(20); - - FXUtils.addClassTo(comboBox, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(comboBox, this); - } - - /** - * @return The list of available options of the string value. - */ - @FxThread - private @NotNull ComboBox getComboBox() { - return notNull(comboBox); - } - - @Override - @FxThread - public void reload() { - super.reload(); - final String value = getPropertyValue(); - final ComboBox comboBox = getComboBox(); - comboBox.getSelectionModel().select(value); - } - - @Override - @FxThread - protected void changeImpl() { - final ComboBox comboBox = getComboBox(); - final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); - setPropertyValue(selectionModel.getSelectedItem()); - super.changeImpl(); - } } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/StringPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/StringPropertyEditorControl.java index d5a58dc6..51b16f8c 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/StringPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/StringPropertyEditorControl.java @@ -1,11 +1,12 @@ package com.ss.editor.plugin.api.property.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.TextField; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,8 +24,11 @@ public class StringPropertyEditorControl extends PropertyEditorControl { @Nullable private TextField valueField; - protected StringPropertyEditorControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + protected StringPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { super(vars, definition, validationCallback); } @@ -34,14 +38,18 @@ protected void createComponents() { super.createComponents(); valueField = new TextField(); - valueField.textProperty().addListener((observable, oldValue, newValue) -> change()); - valueField.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + valueField.prefWidthProperty() + .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, this); + FxControlUtils.onTextChange(valueField, this::change); + + FxUtils.addClass(valueField, CssClasses.PROPERTY_CONTROL_COMBO_BOX); + FxUtils.addChild(this, valueField); } /** + * Get the value field. + * * @return the value field. */ @FxThread @@ -53,7 +61,7 @@ protected void createComponents() { @FxThread public void reload() { super.reload(); - final String value = getPropertyValue(); + var value = getPropertyValue(); getValueField().setText(value == null ? "" : value); } diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/TypedTextFieldPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/TypedTextFieldPropertyEditorControl.java new file mode 100644 index 00000000..64fe6b3a --- /dev/null +++ b/src/main/java/com/ss/editor/plugin/api/property/control/TypedTextFieldPropertyEditorControl.java @@ -0,0 +1,68 @@ +package com.ss.editor.plugin.api.property.control; + +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.plugin.api.property.PropertyDefinition; +import com.ss.editor.ui.css.CssClasses; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.control.input.TypedTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The typed text field base property control. + * + * @author JavaSaBr + */ +public abstract class TypedTextFieldPropertyEditorControl> + extends PropertyEditorControl { + + /** + * The value field. + */ + @Nullable + private F valueField; + + protected TypedTextFieldPropertyEditorControl( + @NotNull VarTable vars, + @NotNull PropertyDefinition definition, + @NotNull Runnable validationCallback + ) { + super(vars, definition, validationCallback); + } + + @Override + @FxThread + protected void createComponents() { + super.createComponents(); + + valueField = createField(); + valueField.prefWidthProperty() + .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + + FxControlUtils.onTextChange(valueField, this::change); + + FxUtils.addClass(valueField, CssClasses.PROPERTY_CONTROL_COMBO_BOX); + FxUtils.addChild(this, valueField); + } + + /** + * Create a new field. + * + * @return the new field. + */ + @FxThread + protected abstract @NotNull F createField(); + + /** + * Get the value field. + * + * @return the value field. + */ + @FxThread + protected @NotNull F getValueField() { + return notNull(valueField); + } +} diff --git a/src/main/java/com/ss/editor/plugin/api/property/control/Vector3fPropertyEditorControl.java b/src/main/java/com/ss/editor/plugin/api/property/control/Vector3fPropertyEditorControl.java index 0985723c..3145a6e2 100644 --- a/src/main/java/com/ss/editor/plugin/api/property/control/Vector3fPropertyEditorControl.java +++ b/src/main/java/com/ss/editor/plugin/api/property/control/Vector3fPropertyEditorControl.java @@ -1,13 +1,15 @@ package com.ss.editor.plugin.api.property.control; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.Vector3f; import com.ss.editor.annotation.FxThread; -import com.ss.editor.ui.css.CssClasses; import com.ss.editor.plugin.api.property.PropertyDefinition; +import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.layout.GridPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,8 +39,11 @@ public class Vector3fPropertyEditorControl extends PropertyEditorControl change()); - xField.prefWidthProperty().bind(gridPane.widthProperty().divide(3)); + xField.prefWidthProperty().bind(fieldWidth); yField = new FloatTextField(); - yField.addChangeListener((observable, oldValue, newValue) -> change()); - yField.prefWidthProperty().bind(gridPane.widthProperty().divide(3)); + yField.prefWidthProperty().bind(fieldWidth); zField = new FloatTextField(); - zField.addChangeListener((observable, oldValue, newValue) -> change()); - zField.prefWidthProperty().bind(gridPane.widthProperty().divide(3)); + zField.prefWidthProperty().bind(fieldWidth); gridPane.add(xField, 0, 0); gridPane.add(yField, 1, 0); gridPane.add(zField, 2, 0); - FXUtils.addClassesTo(gridPane, CssClasses.DEF_GRID_PANE, CssClasses.TEXT_INPUT_CONTAINER); - FXUtils.addClassesTo(xField, yField, zField, CssClasses.ABSTRACT_PARAM_CONTROL_VECTOR3F_FIELD, - CssClasses.TRANSPARENT_TEXT_FIELD); - FXUtils.addToPane(gridPane, this); + FxControlUtils.onValueChange(xField, this::change); + FxControlUtils.onValueChange(yField, this::change); + FxControlUtils.onValueChange(zField, this::change); + + FxUtils.addClass(gridPane, + CssClasses.DEF_GRID_PANE, CssClasses.TEXT_INPUT_CONTAINER) + .addClass(xField, yField, zField, + CssClasses.TRANSPARENT_TEXT_FIELD, + CssClasses.PROPERTY_CONTROL_VECTOR_3F_FIELD); + + FxUtils.addChild(this, gridPane); UiUtils.addFocusBinding(gridPane, xField, yField, zField); } /** + * Get the field X. + * * @return the field X. */ @FxThread private @NotNull FloatTextField getXField() { - return xField; + return notNull(xField); } /** + * Get the field Y. + * * @return the field Y. */ @FxThread private @NotNull FloatTextField getYField() { - return yField; + return notNull(yField); } /** + * Get the field Z. + * * @return the field Z. */ @FxThread private @NotNull FloatTextField getZField() { - return zField; + return notNull(zField); } @Override @@ -103,24 +125,24 @@ protected void createComponents() { public void reload() { super.reload(); - final Vector3f value = getPropertyValue(); + var value = getPropertyValue(); - final FloatTextField xField = getXField(); + var xField = getXField(); xField.setValue(value == null ? 0 : value.getX()); - final FloatTextField yField = getYField(); + var yField = getYField(); yField.setValue(value == null ? 0 : value.getY()); - final FloatTextField zField = getZField(); + var zField = getZField(); zField.setValue(value == null ? 0 : value.getZ()); } @Override @FxThread protected void changeImpl() { - final FloatTextField xField = getXField(); - final FloatTextField yField = getYField(); - final FloatTextField zField = getZField(); + var xField = getXField(); + var yField = getYField(); + var zField = getZField(); setPropertyValue(new Vector3f(xField.getValue(), yField.getValue(), zField.getValue())); super.changeImpl(); } diff --git a/src/main/java/com/ss/editor/plugin/api/settings/SettingsCategory.java b/src/main/java/com/ss/editor/plugin/api/settings/SettingsCategory.java index 9203623c..b196026f 100644 --- a/src/main/java/com/ss/editor/plugin/api/settings/SettingsCategory.java +++ b/src/main/java/com/ss/editor/plugin/api/settings/SettingsCategory.java @@ -2,6 +2,7 @@ import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The class to describe a settings category. @@ -27,7 +28,7 @@ public class SettingsCategory implements Comparable { */ private final int order; - public SettingsCategory(@NotNull final String id, @NotNull final String label, final int order) { + public SettingsCategory(@NotNull String id, @NotNull String label, int order) { this.id = id; this.label = label; this.order = order; @@ -54,7 +55,7 @@ public SettingsCategory(@NotNull final String id, @NotNull final String label, f } @Override - public boolean equals(final Object o) { + public boolean equals(@Nullable Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final SettingsCategory that = (SettingsCategory) o; @@ -67,7 +68,7 @@ public int hashCode() { } @Override - public int compareTo(@NotNull final SettingsCategory o) { + public int compareTo(@NotNull SettingsCategory o) { return order - o.order; } } diff --git a/src/main/java/com/ss/editor/plugin/api/settings/SettingsPropertyDefinition.java b/src/main/java/com/ss/editor/plugin/api/settings/SettingsPropertyDefinition.java index 2e0d141b..b1200e25 100644 --- a/src/main/java/com/ss/editor/plugin/api/settings/SettingsPropertyDefinition.java +++ b/src/main/java/com/ss/editor/plugin/api/settings/SettingsPropertyDefinition.java @@ -3,7 +3,7 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditablePropertyType; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,46 +20,75 @@ public class SettingsPropertyDefinition extends PropertyDefinition { @NotNull private final SettingsCategory category; - public SettingsPropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @NotNull final SettingsCategory category, - @Nullable final Object defaultValue) { + public SettingsPropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @NotNull SettingsCategory category, + @Nullable Object defaultValue + ) { super(propertyType, name, id, defaultValue); this.category = category; } - public SettingsPropertyDefinition(@NotNull final EditablePropertyType propertyType, - @Nullable final Array dependencies, @NotNull final String name, - @NotNull final String id, @NotNull final SettingsCategory category, - @Nullable final Object defaultValue) { + public SettingsPropertyDefinition( + @NotNull EditablePropertyType propertyType, + @Nullable Array dependencies, + @NotNull String name, + @NotNull String id, + @NotNull SettingsCategory category, + @Nullable Object defaultValue + ) { super(propertyType, dependencies, name, id, defaultValue); this.category = category; } - public SettingsPropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @NotNull final SettingsCategory category, - @Nullable final Object defaultValue, @Nullable final String extension) { + public SettingsPropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @NotNull SettingsCategory category, + @Nullable Object defaultValue, + @Nullable String extension + ) { super(propertyType, name, id, defaultValue, extension); this.category = category; } - public SettingsPropertyDefinition(@NotNull final EditablePropertyType propertyType, - @Nullable final Array dependencies, @NotNull final String name, - @NotNull final String id, @NotNull final SettingsCategory category, - @Nullable final Object defaultValue, @Nullable final String extension) { + public SettingsPropertyDefinition( + @NotNull EditablePropertyType propertyType, + @Nullable Array dependencies, + @NotNull String name, + @NotNull String id, + @NotNull SettingsCategory category, + @Nullable Object defaultValue, + @Nullable String extension + ) { super(propertyType, dependencies, name, id, defaultValue, extension); this.category = category; } - public SettingsPropertyDefinition(@NotNull final EditablePropertyType propertyType, final @NotNull String name, - @NotNull final String id, @NotNull final SettingsCategory category, - @Nullable final Object defaultValue, @NotNull final Array options) { + public SettingsPropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @NotNull SettingsCategory category, + @Nullable Object defaultValue, + @NotNull Array options + ) { super(propertyType, name, id, defaultValue, options); this.category = category; } - public SettingsPropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @NotNull final SettingsCategory category, - @Nullable final Object defaultValue, final float min, final float max) { + public SettingsPropertyDefinition( + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @NotNull SettingsCategory category, + @Nullable Object defaultValue, + float min, + float max + ) { super(propertyType, name, id, defaultValue, min, max); this.category = category; } diff --git a/src/main/java/com/ss/editor/plugin/api/settings/SettingsProvider.java b/src/main/java/com/ss/editor/plugin/api/settings/SettingsProvider.java index ad2631c1..05a4e2a4 100644 --- a/src/main/java/com/ss/editor/plugin/api/settings/SettingsProvider.java +++ b/src/main/java/com/ss/editor/plugin/api/settings/SettingsProvider.java @@ -1,7 +1,7 @@ package com.ss.editor.plugin.api.settings; import com.ss.editor.annotation.FxThread; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** @@ -26,7 +26,7 @@ public interface SettingsProvider { * @return true if need restart to apply changes for this property. */ @FxThread - default boolean isRequiredRestart(@NotNull final String propertyId) { + default boolean isRequiredRestart(@NotNull String propertyId) { return false; } @@ -37,7 +37,7 @@ default boolean isRequiredRestart(@NotNull final String propertyId) { * @return true if need to update classpath to apply changes for this property. */ @FxThread - default boolean isRequiredUpdateClasspath(@NotNull final String propertyId) { + default boolean isRequiredUpdateClasspath(@NotNull String propertyId) { return false; } @@ -48,7 +48,7 @@ default boolean isRequiredUpdateClasspath(@NotNull final String propertyId) { * @return true if need to reshape 3D view to apply changes for this property. */ @FxThread - default boolean isRequiredReshape3DView(@NotNull final String propertyId) { + default boolean isRequiredReshape3DView(@NotNull String propertyId) { return false; } } diff --git a/src/main/java/com/ss/editor/plugin/api/settings/SettingsProviderRegistry.java b/src/main/java/com/ss/editor/plugin/api/settings/SettingsProviderRegistry.java index c0903154..a6c0cba6 100644 --- a/src/main/java/com/ss/editor/plugin/api/settings/SettingsProviderRegistry.java +++ b/src/main/java/com/ss/editor/plugin/api/settings/SettingsProviderRegistry.java @@ -3,8 +3,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.config.DefaultSettingsProvider; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; /** @@ -38,7 +38,7 @@ private SettingsProviderRegistry() { * @param settingsProvider the new settings provider. */ @FxThread - public void register(@NotNull final SettingsProvider settingsProvider) { + public void register(@NotNull SettingsProvider settingsProvider) { this.providers.add(settingsProvider); } @@ -49,8 +49,12 @@ public void register(@NotNull final SettingsProvider settingsProvider) { */ @FxThread public @NotNull Array getDefinitions() { - final Array result = ArrayFactory.newArray(SettingsPropertyDefinition.class); - providers.forEach(result, (provider, definitions) -> definitions.addAll(provider.getDefinitions())); + + var result = ArrayFactory.newArray(SettingsPropertyDefinition.class); + + providers.forEach(result, + (provider, definitions) -> definitions.addAll(provider.getDefinitions())); + return result; } @@ -61,8 +65,9 @@ public void register(@NotNull final SettingsProvider settingsProvider) { * @return true if need to restart to apply changes for this property. */ @FxThread - public boolean isRequiredRestart(@NotNull final String propertyId) { - return providers.search(propertyId, (provider, id) -> provider.isRequiredRestart(propertyId)) != null; + public boolean isRequiredRestart(@NotNull String propertyId) { + return providers.search(propertyId, + (provider, id) -> provider.isRequiredRestart(propertyId)) != null; } /** @@ -72,8 +77,9 @@ public boolean isRequiredRestart(@NotNull final String propertyId) { * @return true if need to update classpath to apply changes for this property. */ @FxThread - public boolean isRequiredUpdateClasspath(@NotNull final String propertyId) { - return providers.search(propertyId, (provider, id) -> provider.isRequiredRestart(propertyId)) != null; + public boolean isRequiredUpdateClasspath(@NotNull String propertyId) { + return providers.search(propertyId, + (provider, id) -> provider.isRequiredRestart(propertyId)) != null; } /** @@ -83,7 +89,8 @@ public boolean isRequiredUpdateClasspath(@NotNull final String propertyId) { * @return true if need to reshape 3D view to apply changes for this property. */ @FxThread - public boolean isRequiredReshape3DView(@NotNull final String propertyId) { - return providers.search(propertyId, (provider, id) -> provider.isRequiredRestart(propertyId)) != null; + public boolean isRequiredReshape3DView(@NotNull String propertyId) { + return providers.search(propertyId, + (provider, id) -> provider.isRequiredRestart(propertyId)) != null; } } diff --git a/src/main/java/com/ss/editor/remote/control/client/ClientCommand.java b/src/main/java/com/ss/editor/remote/control/client/ClientCommand.java index 252b0892..4f3bc524 100644 --- a/src/main/java/com/ss/editor/remote/control/client/ClientCommand.java +++ b/src/main/java/com/ss/editor/remote/control/client/ClientCommand.java @@ -1,8 +1,8 @@ package com.ss.editor.remote.control.client; import com.ss.editor.annotation.BackgroundThread; -import com.ss.rlib.network.ConnectionOwner; -import com.ss.rlib.network.packet.impl.AbstractReadablePacket; +import com.ss.rlib.common.network.ConnectionOwner; +import com.ss.rlib.common.network.packet.impl.AbstractReadablePacket; import org.jetbrains.annotations.NotNull; import java.nio.ByteBuffer; @@ -16,5 +16,5 @@ public abstract class ClientCommand extends AbstractReadablePacket { @Override @BackgroundThread - protected abstract void readImpl(@NotNull final ConnectionOwner owner, @NotNull final ByteBuffer buffer); + protected abstract void readImpl(@NotNull ConnectionOwner owner, @NotNull ByteBuffer buffer); } diff --git a/src/main/java/com/ss/editor/remote/control/client/InitLocalClasspathClientCommand.java b/src/main/java/com/ss/editor/remote/control/client/InitLocalClasspathClientCommand.java index 2cd427ef..3d5e3351 100644 --- a/src/main/java/com/ss/editor/remote/control/client/InitLocalClasspathClientCommand.java +++ b/src/main/java/com/ss/editor/remote/control/client/InitLocalClasspathClientCommand.java @@ -2,11 +2,10 @@ import com.ss.editor.annotation.BackgroundThread; import com.ss.editor.manager.ClasspathManager; -import com.ss.rlib.network.ConnectionOwner; -import com.ss.rlib.network.annotation.PacketDescription; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.network.ConnectionOwner; +import com.ss.rlib.common.network.annotation.PacketDescription; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.nio.ByteBuffer; @@ -23,19 +22,19 @@ public class InitLocalClasspathClientCommand extends ClientCommand { @Override @BackgroundThread - protected void readImpl(@NotNull final ConnectionOwner owner, @NotNull final ByteBuffer buffer) { + protected void readImpl(@NotNull ConnectionOwner owner, @NotNull ByteBuffer buffer) { - final Array libraries = ArrayFactory.newArray(Path.class); + var libraries = ArrayFactory.newArray(Path.class); for (int i = 0, length = readInt(buffer); i < length; i++) { libraries.add(Paths.get(readString(buffer))); } - final String outputPath = readString(buffer); - final Path output = StringUtils.isEmpty(outputPath) ? null : Paths.get(outputPath); + var outputPath = readString(buffer); + var output = StringUtils.isEmpty(outputPath) ? null : Paths.get(outputPath); - final ClasspathManager classpathManager = ClasspathManager.getInstance(); - classpathManager.loadLocalLibraries(libraries); - classpathManager.loadLocalClasses(output); + ClasspathManager.getInstance() + .loadLocalLibraries(libraries) + .loadLocalClasses(output); } } diff --git a/src/main/java/com/ss/editor/remote/control/client/LoadLocalClassesClientCommand.java b/src/main/java/com/ss/editor/remote/control/client/LoadLocalClassesClientCommand.java index c49f4074..f4c90971 100644 --- a/src/main/java/com/ss/editor/remote/control/client/LoadLocalClassesClientCommand.java +++ b/src/main/java/com/ss/editor/remote/control/client/LoadLocalClassesClientCommand.java @@ -4,13 +4,12 @@ import com.ss.editor.manager.ClasspathManager; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.network.ConnectionOwner; -import com.ss.rlib.network.annotation.PacketDescription; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.network.ConnectionOwner; +import com.ss.rlib.common.network.annotation.PacketDescription; +import com.ss.rlib.common.util.StringUtils; import org.jetbrains.annotations.NotNull; import java.nio.ByteBuffer; -import java.nio.file.Path; import java.nio.file.Paths; /** @@ -21,17 +20,17 @@ @PacketDescription(id = 3) public class LoadLocalClassesClientCommand extends ClientCommand { - @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); @Override @BackgroundThread - protected void readImpl(@NotNull final ConnectionOwner owner, @NotNull final ByteBuffer buffer) { + protected void readImpl(@NotNull ConnectionOwner owner, @NotNull ByteBuffer buffer) { - final String outputPath = readString(buffer); - final Path output = StringUtils.isEmpty(outputPath) ? null : Paths.get(outputPath); - final ClasspathManager classpathManager = ClasspathManager.getInstance(); - classpathManager.loadLocalClasses(output); + var outputPath = readString(buffer); + var output = StringUtils.isEmpty(outputPath) ? null : Paths.get(outputPath); + + ClasspathManager.getInstance() + .loadLocalClasses(output); EXECUTOR_MANAGER.addJmeTask(() -> EditorUtil.getAssetManager().clearCache()); } diff --git a/src/main/java/com/ss/editor/remote/control/client/LoadLocalLibrariesClientCommand.java b/src/main/java/com/ss/editor/remote/control/client/LoadLocalLibrariesClientCommand.java index 2fe66d42..d6d3c7f5 100644 --- a/src/main/java/com/ss/editor/remote/control/client/LoadLocalLibrariesClientCommand.java +++ b/src/main/java/com/ss/editor/remote/control/client/LoadLocalLibrariesClientCommand.java @@ -2,10 +2,9 @@ import com.ss.editor.annotation.BackgroundThread; import com.ss.editor.manager.ClasspathManager; -import com.ss.rlib.network.ConnectionOwner; -import com.ss.rlib.network.annotation.PacketDescription; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.network.ConnectionOwner; +import com.ss.rlib.common.network.annotation.PacketDescription; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.nio.ByteBuffer; @@ -22,15 +21,15 @@ public class LoadLocalLibrariesClientCommand extends ClientCommand { @Override @BackgroundThread - protected void readImpl(@NotNull final ConnectionOwner owner, @NotNull final ByteBuffer buffer) { + protected void readImpl(@NotNull ConnectionOwner owner, @NotNull ByteBuffer buffer) { - final Array libraries = ArrayFactory.newArray(Path.class); + var libraries = ArrayFactory.newArray(Path.class); for (int i = 0, length = readInt(buffer); i < length; i++) { libraries.add(Paths.get(readString(buffer))); } - final ClasspathManager classpathManager = ClasspathManager.getInstance(); - classpathManager.loadLocalLibraries(libraries); + ClasspathManager.getInstance(). + loadLocalLibraries(libraries); } } diff --git a/src/main/java/com/ss/editor/remote/control/client/OpenFileClientCommand.java b/src/main/java/com/ss/editor/remote/control/client/OpenFileClientCommand.java index 1fa91e98..5e28ae3c 100644 --- a/src/main/java/com/ss/editor/remote/control/client/OpenFileClientCommand.java +++ b/src/main/java/com/ss/editor/remote/control/client/OpenFileClientCommand.java @@ -8,9 +8,8 @@ import com.ss.editor.ui.event.impl.AssetComponentLoadedEvent; import com.ss.editor.ui.event.impl.RequestedOpenFileEvent; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.network.ConnectionOwner; -import com.ss.rlib.network.annotation.PacketDescription; -import javafx.event.Event; +import com.ss.rlib.common.network.ConnectionOwner; +import com.ss.rlib.common.network.annotation.PacketDescription; import javafx.event.EventHandler; import org.jetbrains.annotations.NotNull; @@ -26,23 +25,20 @@ @PacketDescription(id = 1) public class OpenFileClientCommand extends ClientCommand { - @NotNull private static final FxEventManager FX_EVENT_MANAGER = FxEventManager.getInstance(); - - @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); @Override @BackgroundThread - protected void readImpl(@NotNull final ConnectionOwner owner, @NotNull final ByteBuffer buffer) { + protected void readImpl(@NotNull ConnectionOwner owner, @NotNull ByteBuffer buffer) { - final Path assetPath = Paths.get(readString(buffer)); - final Path fileToOpen = Paths.get(readString(buffer)); + var assetPath = Paths.get(readString(buffer)); + var fileToOpen = Paths.get(readString(buffer)); - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); - if (currentAsset != null && assetPath.equals(currentAsset)) { + if (assetPath.equals(currentAsset)) { EXECUTOR_MANAGER.addFxTask(() -> openFile(fileToOpen)); } else { EXECUTOR_MANAGER.addFxTask(() -> { @@ -50,10 +46,10 @@ protected void readImpl(@NotNull final ConnectionOwner owner, @NotNull final Byt final OpenAssetAction action = new OpenAssetAction(); action.openAssetFolder(assetPath); - final EventHandler eventHandler = new EventHandler() { + var eventHandler = new EventHandler() { @Override - public void handle(final Event event) { + public void handle(@NotNull AssetComponentLoadedEvent event) { FX_EVENT_MANAGER.removeEventHandler(AssetComponentLoadedEvent.EVENT_TYPE, this); openFile(fileToOpen); } @@ -70,7 +66,7 @@ public void handle(final Event event) { * * @param fileToOpen the file. */ - private void openFile(@NotNull final Path fileToOpen) { + private void openFile(@NotNull Path fileToOpen) { FX_EVENT_MANAGER.notify(new RequestedOpenFileEvent(fileToOpen)); EditorUtil.requestFxFocus(); } diff --git a/src/main/java/com/ss/editor/task/CheckNewVersionTask.java b/src/main/java/com/ss/editor/task/CheckNewVersionTask.java index d6fdefa2..f0013723 100644 --- a/src/main/java/com/ss/editor/task/CheckNewVersionTask.java +++ b/src/main/java/com/ss/editor/task/CheckNewVersionTask.java @@ -1,29 +1,20 @@ package com.ss.editor.task; import static org.apache.http.impl.client.HttpClients.createMinimal; -import com.ss.editor.JfxApplication; import com.ss.editor.Messages; import com.ss.editor.config.Config; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.plugin.Version; -import javafx.application.HostServices; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.plugin.Version; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.DialogPane; import javafx.scene.control.Hyperlink; import org.apache.commons.io.IOUtils; -import org.apache.http.Header; -import org.apache.http.HttpEntity; -import org.apache.http.StatusLine; -import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.jetbrains.annotations.NotNull; import java.io.IOException; -import java.io.InputStream; /** * The task to check new versions of the editor. @@ -32,35 +23,31 @@ */ public class CheckNewVersionTask implements Runnable { - @NotNull private static final Logger LOGGER = LoggerManager.getLogger(CheckNewVersionTask.class); - @NotNull private static final String APP_VERSION_URL = "https://api.bitbucket.org/1.0/repositories/javasabr/" + "jmonkey-builder/raw/master/app.version"; - - @NotNull private static final String DOWNLOAD_APP_PATH_URL = "https://api.bitbucket.org/1.0/repositories/javasabr/" + "jmonkey-builder/raw/master/download.app.path"; @Override public void run() { - try (final CloseableHttpClient httpClient = createMinimal()) { + try (var httpClient = createMinimal()) { - CloseableHttpResponse response = httpClient.execute(new HttpGet(APP_VERSION_URL)); - StatusLine statusLine = response.getStatusLine(); + var response = httpClient.execute(new HttpGet(APP_VERSION_URL)); + var statusLine = response.getStatusLine(); if (statusLine.getStatusCode() != 200) { return; } - HttpEntity entity = response.getEntity(); - InputStream content = entity.getContent(); - Header encoding = entity.getContentEncoding(); - String enc = encoding == null ? "UTF-8" : encoding.getValue(); + var entity = response.getEntity(); + var content = entity.getContent(); + var encoding = entity.getContentEncoding(); + var enc = encoding == null ? "UTF-8" : encoding.getValue(); - final String targetVersion = IOUtils.toString(content, enc) + var targetVersion = IOUtils.toString(content, enc) .trim() .replace("v.", ""); @@ -80,27 +67,27 @@ public void run() { encoding = entity.getContentEncoding(); enc = encoding == null ? "UTF-8" : encoding.getValue(); - final String targetLink = IOUtils.toString(content, enc).trim(); + var targetLink = IOUtils.toString(content, enc) + .trim(); Platform.runLater(() -> { - final JfxApplication jfxApplication = JfxApplication.getInstance(); - final HostServices hostServices = jfxApplication.getHostServices(); + var hostServices = EditorUtil.getHostServices(); - final Hyperlink hyperlink = new Hyperlink(Messages.CHECK_NEW_VERSION_DIALOG_HYPERLINK + targetLink); + var hyperlink = new Hyperlink(Messages.CHECK_NEW_VERSION_DIALOG_HYPERLINK + targetLink); hyperlink.setOnAction(event -> hostServices.showDocument(targetLink)); - final Alert alert = new Alert(AlertType.INFORMATION); + var alert = new Alert(AlertType.INFORMATION); alert.setTitle(Messages.CHECK_NEW_VERSION_DIALOG_TITLE); alert.setHeaderText(Messages.CHECK_NEW_VERSION_DIALOG_HEADER_TEXT + targetVersion); - final DialogPane dialogPane = alert.getDialogPane(); + var dialogPane = alert.getDialogPane(); dialogPane.setContent(hyperlink); alert.show(); }); - } catch (final IOException e) { + } catch (IOException e) { LOGGER.warning(e); } } diff --git a/src/main/java/com/ss/editor/ui/FXConstants.java b/src/main/java/com/ss/editor/ui/FxConstants.java similarity index 88% rename from src/main/java/com/ss/editor/ui/FXConstants.java rename to src/main/java/com/ss/editor/ui/FxConstants.java index 5708eb41..6dfe52f7 100644 --- a/src/main/java/com/ss/editor/ui/FXConstants.java +++ b/src/main/java/com/ss/editor/ui/FxConstants.java @@ -5,7 +5,7 @@ * * @author JavaSaBr */ -public interface FXConstants { +public interface FxConstants { int PROPERTY_LIST_OFFSET = 17; diff --git a/src/main/java/com/ss/editor/ui/builder/EditorFxSceneBuilder.java b/src/main/java/com/ss/editor/ui/builder/EditorFxSceneBuilder.java index 2258be64..c469f2ac 100644 --- a/src/main/java/com/ss/editor/ui/builder/EditorFxSceneBuilder.java +++ b/src/main/java/com/ss/editor/ui/builder/EditorFxSceneBuilder.java @@ -2,7 +2,6 @@ import static com.ss.editor.config.DefaultSettingsProvider.Defaults.PREF_DEFAULT_THEME; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_UI_THEME; -import static javafx.application.Platform.runLater; import static javafx.scene.paint.Color.TRANSPARENT; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; @@ -16,14 +15,11 @@ import com.ss.editor.ui.component.tab.GlobalBottomToolComponent; import com.ss.editor.ui.component.tab.GlobalLeftToolComponent; import com.ss.editor.ui.css.CssClasses; -import com.ss.editor.ui.css.CssColorTheme; import com.ss.editor.ui.css.CssRegistry; import com.ss.editor.ui.event.EventRedirector; import com.ss.editor.ui.scene.EditorFxScene; -import com.ss.rlib.ui.util.FXUtils; -import javafx.collections.ObservableList; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.Group; -import javafx.scene.image.ImageView; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; @@ -36,34 +32,26 @@ */ public class EditorFxSceneBuilder { - /** - * The CSS registry. - */ - @NotNull private static final CssRegistry CSS_REGISTRY = CssRegistry.getInstance(); /** * The path to the base CSS styles. */ - @NotNull public static final String CSS_FILE_BASE = "ui/css/base.css"; /** * The path to the external CSS styles. */ - @NotNull public static final String CSS_FILE_EXTERNAL = "ui/css/external.css"; /** * The path to the custom ids CSS styles. */ - @NotNull public static final String CSS_FILE_CUSTOM_IDS = "ui/css/custom_ids.css"; /** * The path to the custom classes CSS styles. */ - @NotNull public static final String CSS_FILE_CUSTOM_CLASSES = "ui/css/custom_classes.css"; static { @@ -80,23 +68,22 @@ public class EditorFxSceneBuilder { * @return the editor fx scene */ @FxThread - public static @NotNull EditorFxScene build(@NotNull final Stage stage) { + public static @NotNull EditorFxScene build(@NotNull Stage stage) { - final EditorConfig editorConfig = EditorConfig.getInstance(); - final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME); + var editorConfig = EditorConfig.getInstance(); + var theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME); - final Group root = new Group(); - //root.getTransforms().add(new Scale(1.5, 1.5)); + var root = new Group(); - final EditorFxScene scene = new EditorFxScene(root); + var scene = new EditorFxScene(root); scene.setFill(TRANSPARENT); scene.setRoot(root); - final ObservableList stylesheets = scene.getStylesheets(); + var stylesheets = scene.getStylesheets(); stylesheets.addAll(CSS_REGISTRY.getAvailableCssFiles()); stylesheets.add(theme.getCssFile()); - final StackPane container = scene.getContainer(); + var container = scene.getContainer(); build(scene, container, stage); @@ -106,36 +93,36 @@ public class EditorFxSceneBuilder { } @FxThread - private static void build(@NotNull final EditorFxScene scene, - @NotNull final StackPane container, - @NotNull final Stage stage) { + private static void build(@NotNull EditorFxScene scene, @NotNull StackPane container, @NotNull Stage stage) { - final ImageView canvas = scene.getCanvas(); - final EditorMenuBarComponent barComponent = new EditorMenuBarComponent(); - final EditorAreaComponent editorAreaComponent = new EditorAreaComponent(); + var canvas = scene.getCanvas(); + var barComponent = new EditorMenuBarComponent(); + var editorAreaComponent = new EditorAreaComponent(); new EventRedirector(editorAreaComponent, canvas, stage); - final GlobalLeftToolSplitPane leftSplitContainer = new GlobalLeftToolSplitPane(scene); - leftSplitContainer.prefHeightProperty().bind(container.heightProperty()); + var leftSplitContainer = new GlobalLeftToolSplitPane(scene); + leftSplitContainer.prefHeightProperty() + .bind(container.heightProperty()); - final GlobalBottomToolSplitPane bottomSplitContainer = new GlobalBottomToolSplitPane(scene); - final GlobalLeftToolComponent globalLeftToolComponent = new GlobalLeftToolComponent(leftSplitContainer); + var bottomSplitContainer = new GlobalBottomToolSplitPane(scene); + var globalLeftToolComponent = new GlobalLeftToolComponent(leftSplitContainer); globalLeftToolComponent.addComponent(new AssetComponent(), Messages.EDITOR_TOOL_ASSET); - final GlobalBottomToolComponent globalBottomToolComponent = new GlobalBottomToolComponent(bottomSplitContainer); + var globalBottomToolComponent = new GlobalBottomToolComponent(bottomSplitContainer); globalBottomToolComponent.addComponent(LogView.getInstance(), Messages.LOG_VIEW_TITLE); leftSplitContainer.initFor(globalLeftToolComponent, bottomSplitContainer); bottomSplitContainer.initFor(globalBottomToolComponent, editorAreaComponent); - // to fix with layout bottom panel - bottomSplitContainer.heightProperty() - .addListener((observable, oldValue, newValue) -> runLater(editorAreaComponent::requestLayout)); + FxUtils.addClass(leftSplitContainer, bottomSplitContainer, + CssClasses.MAIN_SPLIT_PANEL); + + FxUtils.addChild(container, new VBox(barComponent, leftSplitContainer)); - FXUtils.addToPane(new VBox(barComponent, leftSplitContainer), container); - FXUtils.bindFixedWidth(leftSplitContainer, container.widthProperty()); - FXUtils.bindFixedWidth(barComponent, container.widthProperty()); - FXUtils.addClassTo(leftSplitContainer, bottomSplitContainer, CssClasses.MAIN_SPLIT_PANEL); + leftSplitContainer.prefWidthProperty() + .bind(container.widthProperty()); + barComponent.prefWidthProperty() + .bind(container.widthProperty()); } } diff --git a/src/main/java/com/ss/editor/ui/component/asset/AssetBarComponent.java b/src/main/java/com/ss/editor/ui/component/asset/AssetBarComponent.java index 6888ec92..44e43f04 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/AssetBarComponent.java +++ b/src/main/java/com/ss/editor/ui/component/asset/AssetBarComponent.java @@ -3,7 +3,7 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.event.FxEventManager; import com.ss.editor.ui.event.impl.RequestedRefreshAssetEvent; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Button; import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; diff --git a/src/main/java/com/ss/editor/ui/component/asset/AssetComponent.java b/src/main/java/com/ss/editor/ui/component/asset/AssetComponent.java index bf590d5e..c699a4e4 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/AssetComponent.java +++ b/src/main/java/com/ss/editor/ui/component/asset/AssetComponent.java @@ -1,12 +1,11 @@ package com.ss.editor.ui.component.asset; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.manager.WorkspaceManager; -import com.ss.editor.model.workspace.Workspace; import com.ss.editor.ui.component.ScreenComponent; import com.ss.editor.ui.component.asset.tree.ResourceTree; import com.ss.editor.ui.component.asset.tree.resource.FolderResourceElement; @@ -17,9 +16,9 @@ import com.ss.editor.ui.event.FxEventManager; import com.ss.editor.ui.event.impl.*; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.TreeItem; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; @@ -37,20 +36,11 @@ public class AssetComponent extends VBox implements ScreenComponent { @NotNull private static final String COMPONENT_ID = "AssetComponent"; - /** - * The executor manager. - */ - @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); - - /** - * The event manager. - */ - @NotNull private static final FxEventManager FX_EVENT_MANAGER = FxEventManager.getInstance(); /** - * The list of waited files to select. + * The list of waited files to be selected. */ @NotNull private final Array waitedFilesToSelect; @@ -79,17 +69,17 @@ public AssetComponent() { this.waitedFilesToSelect = ArrayFactory.newArray(Path.class); setId(CssIds.ASSET_COMPONENT); createComponents(); - FX_EVENT_MANAGER.addEventHandler(RequestedRefreshAssetEvent.EVENT_TYPE, event -> processRefresh()); - FX_EVENT_MANAGER.addEventHandler(ChangedCurrentAssetFolderEvent.EVENT_TYPE, event -> processChangeAsset()); - FX_EVENT_MANAGER.addEventHandler(CreatedFileEvent.EVENT_TYPE, event -> processEvent((CreatedFileEvent) event)); - FX_EVENT_MANAGER.addEventHandler(RequestSelectFileEvent.EVENT_TYPE, event -> processEvent((RequestSelectFileEvent) event)); - FX_EVENT_MANAGER.addEventHandler(DeletedFileEvent.EVENT_TYPE, event -> processEvent((DeletedFileEvent) event)); + FX_EVENT_MANAGER.addEventHandler(RequestedRefreshAssetEvent.EVENT_TYPE, event -> refreshAssetFolder()); + FX_EVENT_MANAGER.addEventHandler(ChangedCurrentAssetFolderEvent.EVENT_TYPE, event -> switchAssetFolder()); + FX_EVENT_MANAGER.addEventHandler(CreatedFileEvent.EVENT_TYPE, this::handleCreatedFile); + FX_EVENT_MANAGER.addEventHandler(RequestSelectFileEvent.EVENT_TYPE, this::handleRequestToSelectFile); + FX_EVENT_MANAGER.addEventHandler(DeletedFileEvent.EVENT_TYPE, this::handleDeletedFile); } /** - * Gets waited files to select. + * Get the list of waited files to be selected. * - * @return the list of waited files to select. + * @return the list of waited files to be selected. */ @FromAnyThread private @NotNull Array getWaitedFilesToSelect() { @@ -97,16 +87,16 @@ public AssetComponent() { } /** - * Handle request for selection a file. + * Handle of the request to select a file. */ @FxThread - private void processEvent(@NotNull final RequestSelectFileEvent event) { + private void handleRequestToSelectFile(@NotNull RequestSelectFileEvent event) { - final Path file = event.getFile(); + var file = event.getFile(); - final ResourceTree resourceTree = getResourceTree(); - final ResourceElement element = ResourceElementFactory.createFor(file); - final TreeItem treeItem = UiUtils.findItemForValue(resourceTree.getRoot(), element); + var resourceTree = getResourceTree(); + var element = ResourceElementFactory.createFor(file); + var treeItem = UiUtils.findItemForValue(resourceTree.getRoot(), element); if (treeItem == null) { getWaitedFilesToSelect().add(file); @@ -117,55 +107,61 @@ private void processEvent(@NotNull final RequestSelectFileEvent event) { } /** - * Handle a created file. + * Handle of the created file. */ @FxThread - private void processEvent(@NotNull final CreatedFileEvent event) { + private void handleCreatedFile(@NotNull CreatedFileEvent event) { - final Path file = event.getFile(); + var file = event.getFile(); - final Array waitedFilesToSelect = getWaitedFilesToSelect(); - final boolean waitedSelect = waitedFilesToSelect.contains(file); + var waitedFilesToSelect = getWaitedFilesToSelect(); + var wasWaitedToSelect = waitedFilesToSelect.contains(file); - final ResourceTree resourceTree = getResourceTree(); + var resourceTree = getResourceTree(); resourceTree.notifyCreated(file); - if (waitedSelect) waitedFilesToSelect.fastRemove(file); - if (waitedSelect || event.isNeedSelect()) resourceTree.expandTo(file, true); + if (wasWaitedToSelect) { + waitedFilesToSelect.fastRemove(file); + } + + if (wasWaitedToSelect || event.isNeedSelect()) { + resourceTree.expandTo(file, true); + } } /** - * Handle a deleted file. + * Handle of the deleted file. */ @FxThread - private void processEvent(@NotNull final DeletedFileEvent event) { + private void handleDeletedFile(@NotNull DeletedFileEvent event) { - final Path file = event.getFile(); + var file = event.getFile(); - final ResourceTree resourceTree = getResourceTree(); + var resourceTree = getResourceTree(); resourceTree.notifyDeleted(file); - final WorkspaceManager workspaceManager = WorkspaceManager.getInstance(); - final Workspace workspace = workspaceManager.getCurrentWorkspace(); - if (workspace == null) return; - workspace.removeEditorState(file); + var workspaceManager = WorkspaceManager.getInstance(); + var workspace = workspaceManager.getCurrentWorkspace(); + + if (workspace != null) { + workspace.removeEditorState(file); + } } /** - * Handle changing an asset folder. + * Switch to a new asset folder. */ @FxThread - private void processChangeAsset() { + private void switchAssetFolder() { loadAssetFolder(); } /** - * Handle refreshing. + * Refresh the current asset folder. */ @FxThread - private void processRefresh() { - final ResourceTree resourceTree = getResourceTree(); - resourceTree.refresh(); + private void refreshAssetFolder() { + getResourceTree().refresh(); } /** @@ -175,38 +171,39 @@ private void processRefresh() { private void createComponents() { setIgnoreExpanded(true); - this.barComponent = new AssetBarComponent(); - this.resourceTree = new ResourceTree(false); - this.resourceTree.setExpandHandler(this::updateExpanded); - this.resourceTree.setOnLoadHandler(this::handleTreeLoading); + barComponent = new AssetBarComponent(); + + resourceTree = new ResourceTree(false); + resourceTree.setExpandHandler(this::updateExpanded); + resourceTree.setOnLoadHandler(this::handleTreeLoading); + resourceTree.prefHeightProperty().bind(heightProperty()); //FIXME пока он не нужен //FXUtils.addToPane(barComponent, this); //FXUtils.bindFixedHeight(resourceTree, heightProperty().subtract(barComponent.heightProperty())); - FXUtils.addToPane(resourceTree, this); - FXUtils.bindFixedHeight(resourceTree, heightProperty()); - FXUtils.addClassTo(resourceTree, CssClasses.TRANSPARENT_LIST_VIEW); + FxUtils.addClass(resourceTree, CssClasses.TRANSPARENT_LIST_VIEW); + FxUtils.addChild(this, resourceTree); } /** - * Handle changing loading state of the tree. + * Handle of changing loading state of the tree. */ @FxThread - private void handleTreeLoading(@NotNull final Boolean finished) { + private void handleTreeLoading(@NotNull Boolean finished) { - final WorkspaceManager workspaceManager = WorkspaceManager.getInstance(); - final Workspace workspace = workspaceManager.getCurrentWorkspace(); + var workspaceManager = WorkspaceManager.getInstance(); + var workspace = workspaceManager.getCurrentWorkspace(); if (finished && workspace != null) { - final Array expandedFolders = workspace.getExpandedAbsoluteFolders(); - expandedFolders.forEach(getResourceTree()::markExpand); + workspace.getExpandedAbsoluteFolders() + .forEach(getResourceTree()::markExpand); } if (finished) { - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); EXECUTOR_MANAGER.addFxTask(() -> setIgnoreExpanded(false)); @@ -220,7 +217,7 @@ private void handleTreeLoading(@NotNull final Boolean finished) { } /** - * Is ignore expanded boolean. + * Return true if the expand listener is ignored. * * @return true if the expand listener is ignored. */ @@ -230,12 +227,12 @@ private boolean isIgnoreExpanded() { } /** - * Sets ignore expanded. + * Set true if the expand listener is ignored. * - * @param ignoreExpanded the flag for ignoring expand changes. + * @param ignoreExpanded true if the expand listener is ignored. */ @FromAnyThread - private void setIgnoreExpanded(final boolean ignoreExpanded) { + private void setIgnoreExpanded(boolean ignoreExpanded) { this.ignoreExpanded = ignoreExpanded; } @@ -243,15 +240,20 @@ private void setIgnoreExpanded(final boolean ignoreExpanded) { * Handle changes count of expanded folders. */ @FxThread - private void updateExpanded(final int count, final ResourceTree tree) { - if (isIgnoreExpanded()) return; + private void updateExpanded(int count, ResourceTree tree) { + + if (isIgnoreExpanded()) { + return; + } - final WorkspaceManager workspaceManager = WorkspaceManager.getInstance(); - final Workspace workspace = workspaceManager.getCurrentWorkspace(); - if (workspace == null) return; + var workspaceManager = WorkspaceManager.getInstance(); + var workspace = workspaceManager.getCurrentWorkspace(); + if (workspace == null) { + return; + } - final Array expanded = ArrayFactory.newArray(Path.class); - final Array> allItems = UiUtils.getAllItems(tree); + var expanded = ArrayFactory.newArray(Path.class); + var allItems = UiUtils.getAllItems(tree); allItems.stream().filter(TreeItem::isExpanded) .filter(treeItem -> !treeItem.isLeaf()) .map(TreeItem::getValue) @@ -263,6 +265,8 @@ private void updateExpanded(final int count, final ResourceTree tree) { } /** + * Get the toolbar of this component. + * * @return the toolbar of this component. */ @FxThread @@ -271,6 +275,8 @@ private void updateExpanded(final int count, final ResourceTree tree) { } /** + * Get the resource tree. + * * @return the resource tree. */ @FxThread @@ -293,11 +299,12 @@ public void notifyFinishBuild() { @FxThread private void loadAssetFolder() { - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); - if (currentAsset == null) return; + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); + if (currentAsset == null) { + return; + } - final ResourceTree resourceTree = getResourceTree(); - resourceTree.fill(currentAsset); + getResourceTree().fill(currentAsset); } } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/AssetTreeContextMenuFillerRegistry.java b/src/main/java/com/ss/editor/ui/component/asset/tree/AssetTreeContextMenuFillerRegistry.java index c845a7d6..9abb9172 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/AssetTreeContextMenuFillerRegistry.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/AssetTreeContextMenuFillerRegistry.java @@ -5,8 +5,8 @@ import com.ss.editor.ui.component.asset.tree.context.menu.filler.AssetTreeSingleContextMenuFiller; import com.ss.editor.ui.component.asset.tree.context.menu.filler.impl.FileAssetTreeSingleContextMenuFiller; import com.ss.editor.ui.component.asset.tree.context.menu.filler.impl.ResourceAssetTreeSingleContextMenuFiller; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTree.java b/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTree.java index f3f8afb0..fcdcd6eb 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTree.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTree.java @@ -3,29 +3,30 @@ import static com.ss.editor.ui.component.asset.tree.resource.ResourceElementFactory.createFor; import static com.ss.editor.ui.util.UiUtils.findItemForValue; import static com.ss.editor.ui.util.UiUtils.hasFileInClipboard; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.BackgroundThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.manager.ExecutorManager; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.component.asset.tree.context.menu.action.*; -import com.ss.editor.ui.component.asset.tree.context.menu.filler.AssetTreeMultiContextMenuFiller; -import com.ss.editor.ui.component.asset.tree.context.menu.filler.AssetTreeSingleContextMenuFiller; import com.ss.editor.ui.component.asset.tree.resource.*; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.function.IntObjectConsumer; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayComparator; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.array.ConcurrentArray; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.common.function.IntObjectConsumer; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayComparator; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.ConcurrentArray; import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; import javafx.event.EventHandler; -import javafx.scene.control.*; +import javafx.scene.control.ContextMenu; +import javafx.scene.control.SelectionMode; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeItem.TreeModificationEvent; +import javafx.scene.control.TreeView; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import org.jetbrains.annotations.NotNull; @@ -33,6 +34,7 @@ import java.nio.file.Path; import java.util.Objects; +import java.util.Optional; import java.util.function.Consumer; import java.util.function.Predicate; @@ -46,70 +48,62 @@ public class ResourceTree extends TreeView { /** * The executor manager. */ - @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); /** * The resource elements comparator. */ - @NotNull private static final ArrayComparator COMPARATOR = ResourceElement::compareTo; /** * The name comparator. */ - @NotNull private static final ArrayComparator NAME_COMPARATOR = (first, second) -> { - final int firstLevel = getLevel(first); - final int secondLevel = getLevel(second); + var firstLevel = getLevel(first); + var secondLevel = getLevel(second); if (firstLevel != secondLevel) { return firstLevel - secondLevel; } - final Path firstFile = notNull(first).getFile(); - final Path firstFileFileName = firstFile.getFileName(); - final String firstName = firstFileFileName == null ? firstFile.toString() : firstFileFileName.toString(); - - final Path secondFile = notNull(second).getFile(); - final Path secondFileName = secondFile.getFileName(); - final String secondName = secondFileName == null ? secondFile.toString() : secondFileName.toString(); - - return StringUtils.compareIgnoreCase(firstName, secondName); + return StringUtils.compareIgnoreCase(getNameToSort(first), getNameToSort(second)); }; + private static @NotNull String getNameToSort(@NotNull ResourceElement element) { + var file = notNull(element).getFile(); + var fileName = file.getFileName(); + return fileName == null ? file.toString() : fileName.toString(); + } + /** * The tree items comparator. */ - @NotNull private static final ArrayComparator> ITEM_COMPARATOR = (first, second) -> { - final ResourceElement firstElement = notNull(first).getValue(); - final ResourceElement secondElement = notNull(second).getValue(); + var firstElement = notNull(first).getValue(); + var secondElement = notNull(second).getValue(); return NAME_COMPARATOR.compare(firstElement, secondElement); }; /** * The context menu filler registry. */ - @NotNull - private static final AssetTreeContextMenuFillerRegistry CONTEXT_MENU_FILLER_REGISTRY = AssetTreeContextMenuFillerRegistry.getInstance(); + private static final AssetTreeContextMenuFillerRegistry CONTEXT_MENU_FILLER_REGISTRY = + AssetTreeContextMenuFillerRegistry.getInstance(); @FromAnyThread - private static int getLevel(@Nullable final ResourceElement element) { - if (element instanceof FolderResourceElement) return 1; - return 2; + private static int getLevel(@Nullable ResourceElement element) { + return element instanceof FolderResourceElement ? 1 : 2; } /** * The default open function. */ @NotNull - private static final Consumer DEFAULT_OPEN_FUNCTION = element -> { - final OpenFileAction action = new OpenFileAction(element); - final EventHandler onAction = action.getOnAction(); - onAction.handle(null); - }; + private static final Consumer DEFAULT_OPEN_FUNCTION = + element -> new OpenFileAction(element) + .getOnAction() + .handle(null); /** * The list of expanded elements. @@ -129,6 +123,12 @@ private static int getLevel(@Nullable final ResourceElement element) { @Nullable private final Consumer openFunction; + /** + * The tree item event handler. + */ + @NotNull + private final EventHandler> treeItemEventHandler; + /** * The action tester. */ @@ -173,39 +173,50 @@ private static int getLevel(@Nullable final ResourceElement element) { */ private boolean needCleanup; - public ResourceTree(final boolean readOnly) { + public ResourceTree(boolean readOnly) { this(DEFAULT_OPEN_FUNCTION, readOnly); } - public ResourceTree(@Nullable final Consumer openFunction, final boolean readOnly) { + public ResourceTree(@Nullable Consumer openFunction, boolean readOnly) { this.openFunction = openFunction; this.readOnly = readOnly; this.expandedElements = ArrayFactory.newConcurrentAtomicARSWLockArray(ResourceElement.class); this.selectedElements = ArrayFactory.newConcurrentAtomicARSWLockArray(ResourceElement.class); this.extensionFilter = ArrayFactory.newArray(String.class, 0); this.actionTester = actionClass -> true; - - expandedItemCountProperty() - .addListener((observable, oldValue, newValue) -> processChangedExpands(newValue)); + this.treeItemEventHandler = this::processChangedExpands; getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); - setFixedCellSize(FXConstants.RESOURCE_TREE_CELL_HEIGHT); + setFixedCellSize(FxConstants.RESOURCE_TREE_CELL_HEIGHT); setCellFactory(param -> new ResourceTreeCell()); setOnKeyPressed(this::processKey); setShowRoot(true); setContextMenu(new ContextMenu()); setFocusTraversable(true); + + rootProperty().addListener((observable, oldValue, newValue) -> { + if (oldValue != null) { + oldValue.removeEventHandler(TreeItem.treeNotificationEvent(), treeItemEventHandler); + } + if (newValue != null) { + newValue.addEventHandler(TreeItem.treeNotificationEvent(), treeItemEventHandler); + } + }); } /** + * Set true if need to use lazy mode. + * * @param lazyMode true if need to use lazy mode. */ @FromAnyThread - public void setLazyMode(final boolean lazyMode) { + public void setLazyMode(boolean lazyMode) { this.lazyMode = lazyMode; } /** + * Return true if need to use lazy mode. + * * @return true if need to use lazy mode. */ @FromAnyThread @@ -214,15 +225,19 @@ private boolean isLazyMode() { } /** - * @param needCleanup true of need to cleanup this tree. + * Set true if need to cleanup this tree. + * + * @param needCleanup true if need to cleanup this tree. */ @FromAnyThread - public void setNeedCleanup(final boolean needCleanup) { + public void setNeedCleanup(boolean needCleanup) { this.needCleanup = needCleanup; } /** - * @return true of need to cleanup this tree. + * Return true if need to cleanup this tree. + * + * @return true if need to cleanup this tree. */ @FromAnyThread private boolean isNeedCleanup() { @@ -233,18 +248,32 @@ private boolean isNeedCleanup() { * Handle changed count of expanded elements. */ @FxThread - private void processChangedExpands(@NotNull final Number newValue) { + private void processChangedExpands(@NotNull TreeModificationEvent event) { + + if (!(event.wasExpanded() || event.wasCollapsed())) { + return; + } if (isLazyMode()) { EXECUTOR_MANAGER.addFxTask(this::lazyLoadChildren); } - final IntObjectConsumer expandHandler = getExpandHandler(); - if (expandHandler == null) { - return; - } + getExpandHandler().ifPresent(handler -> + handler.accept(getExpandedItemCount(), this)); + + repaint(); + } - expandHandler.accept(newValue.intValue(), this); + private void repaint() { + + //FIXME temp fix how to refresh + var stage = EditorUtil.getFxStage(); + var old = stage.getWidth(); + //stage.setWidth(old + 3); + //setLayoutX(20F); + + //Platform.runLater(() -> stage.setWidth(old)); + //Platform.runLater(() -> setLayoutX(0)); } /** @@ -253,15 +282,16 @@ private void processChangedExpands(@NotNull final Number newValue) { @FxThread private void lazyLoadChildren() { - final Array> expanded = ArrayFactory.newArray(TreeItem.class); - final Array> allItems = UiUtils.getAllItems(getRoot()); - allItems.stream().filter(TreeItem::isExpanded) + Array> expanded = ArrayFactory.newArray(TreeItem.class); + + UiUtils.allItems(getRoot()) + .filter(TreeItem::isExpanded) .filter(treeItem -> !treeItem.isLeaf()) .filter(item -> item.getChildren().size() == 1) .filter(item -> item.getChildren().get(0).getValue() == LoadingResourceElement.getInstance()) .forEach(expanded::add); - for (final TreeItem treeItem : expanded) { + for (var treeItem : expanded) { EXECUTOR_MANAGER.addBackgroundTask(() -> lazyLoadChildren(treeItem, null)); } } @@ -272,11 +302,17 @@ private void lazyLoadChildren() { * @param treeItem the tree item. */ @BackgroundThread - private void lazyLoadChildren(@NotNull final TreeItem treeItem, - @Nullable final Consumer> callback) { + private void lazyLoadChildren( + @NotNull TreeItem treeItem, + @Nullable Consumer> callback + ) { + + var element = treeItem.getValue(); + var children = element.getChildren(extensionFilter, isOnlyFolders()); + if (children == null) { + return; + } - final ResourceElement element = treeItem.getValue(); - final Array children = element.getChildren(extensionFilter, isOnlyFolders()); children.sort(NAME_COMPARATOR); EXECUTOR_MANAGER.addFxTask(() -> lazyLoadChildren(treeItem, children, callback)); @@ -290,11 +326,13 @@ private void lazyLoadChildren(@NotNull final TreeItem treeItem, * @param callback the loading callback. */ @FxThread - private void lazyLoadChildren(@NotNull final TreeItem treeItem, - @NotNull final Array children, - @Nullable final Consumer> callback) { + private void lazyLoadChildren( + @NotNull TreeItem treeItem, + @NotNull Array children, + @Nullable Consumer> callback + ) { - final ObservableList> items = treeItem.getChildren(); + var items = treeItem.getChildren(); if (items.size() != 1 || items.get(0).getValue() != LoadingResourceElement.getInstance()) { if (callback != null) callback.accept(treeItem); return; @@ -315,44 +353,48 @@ private void lazyLoadChildren(@NotNull final TreeItem treeItem, } /** - * Sets expand handler. + * Set the expand handler. * - * @param expandHandler the handler for listening expand items. + * @param expandHandler the expand handler. */ @FromAnyThread - public void setExpandHandler(@Nullable final IntObjectConsumer expandHandler) { + public void setExpandHandler(@Nullable IntObjectConsumer expandHandler) { this.expandHandler = expandHandler; } /** - * Sets action tester. + * Set the action tester. * * @param actionTester the action tester. */ @FromAnyThread - public void setActionTester(@NotNull final Predicate> actionTester) { + public void setActionTester(@NotNull Predicate> actionTester) { this.actionTester = actionTester; } /** - * @return the handler for listening expand items. + * Get the expand handler. + * + * @return the expand handler. */ @FromAnyThread - private @Nullable IntObjectConsumer getExpandHandler() { - return expandHandler; + private @NotNull Optional> getExpandHandler() { + return Optional.ofNullable(expandHandler); } /** - * Sets extension filter. + * Set the list of filtered extensions. * * @param extensionFilter the list of filtered extensions. */ @FromAnyThread - public void setExtensionFilter(@NotNull final Array extensionFilter) { + public void setExtensionFilter(@NotNull Array extensionFilter) { this.extensionFilter = extensionFilter; } /** + * Get the list of filtered extensions. + * * @return the list of filtered extensions. */ @FromAnyThread @@ -361,16 +403,18 @@ public void setExtensionFilter(@NotNull final Array extensionFilter) { } /** - * Sets on load handler. + * Set the on load handler. * - * @param onLoadHandler the post loading handler. + * @param onLoadHandler the on load handler. */ @FromAnyThread - public void setOnLoadHandler(@Nullable final Consumer onLoadHandler) { + public void setOnLoadHandler(@Nullable Consumer onLoadHandler) { this.onLoadHandler = onLoadHandler; } /** + * Get the post loading handler. + * * @return the post loading handler. */ @FromAnyThread @@ -379,7 +423,9 @@ public void setOnLoadHandler(@Nullable final Consumer onLoadHandler) { } /** - * @return the flag of read only mode. + * Return true if this tree is read only. + * + * @return true if this tree is read only. */ @FromAnyThread private boolean isReadOnly() { @@ -387,6 +433,8 @@ private boolean isReadOnly() { } /** + * Get the action tester. + * * @return the action tester. */ @FromAnyThread @@ -395,43 +443,40 @@ private boolean isReadOnly() { } /** - * Gets context menu. + * Get a new context menu. * - * @param element the element + * @param element the current selected element. * @return the context menu for the element. */ @FxThread - protected @Nullable ContextMenu getContextMenu(@NotNull final ResourceElement element) { + protected @Nullable ContextMenu getContextMenu(@NotNull ResourceElement element) { if (isReadOnly()) { return null; } - final ContextMenu contextMenu = new ContextMenu(); - final ObservableList items = contextMenu.getItems(); + var contextMenu = new ContextMenu(); + var items = contextMenu.getItems(); + var actionTester = getActionTester(); - final Predicate> actionTester = getActionTester(); - - final MultipleSelectionModel> selectionModel = getSelectionModel(); - final ObservableList> selectedItems = selectionModel.getSelectedItems(); + var selectionModel = getSelectionModel(); + var selectedItems = selectionModel.getSelectedItems(); if (selectedItems.size() == 1) { - final Array fillers = CONTEXT_MENU_FILLER_REGISTRY.getSingleFillers(); - for (final AssetTreeSingleContextMenuFiller filler : fillers) { + for (var filler : CONTEXT_MENU_FILLER_REGISTRY.getSingleFillers()) { filler.fill(element, items, actionTester); } } if (selectedItems.size() >= 1) { - updateSelectedElements(); - final ConcurrentArray selectedElements = getSelectedElements(); + updateSelectedElements(); - final long stamp = selectedElements.readLock(); + var selectedElements = getSelectedElements(); + var stamp = selectedElements.readLock(); try { - final Array fillers = CONTEXT_MENU_FILLER_REGISTRY.getMultiFillers(); - for (final AssetTreeMultiContextMenuFiller filler : fillers) { + for (var filler : CONTEXT_MENU_FILLER_REGISTRY.getMultiFillers()) { filler.fill(selectedElements, items, actionTester); } @@ -453,20 +498,8 @@ private boolean isReadOnly() { * @param rootFolder the root folder. */ @FxThread - public void fill(@NotNull final Path rootFolder) { - - final Consumer onLoadHandler = getOnLoadHandler(); - if (onLoadHandler != null) { - onLoadHandler.accept(Boolean.FALSE); - } - - final TreeItem currentRoot = getRoot(); - if (currentRoot != null) { - setRoot(null); - } - - showLoading(); - + public void fill(@NotNull Path rootFolder) { + prepareToFill(); EXECUTOR_MANAGER.addBackgroundTask(() -> startBackgroundFill(rootFolder)); } @@ -476,24 +509,33 @@ public void fill(@NotNull final Path rootFolder) { * @param rootFolders the list of root folder. */ @FxThread - public void fill(@NotNull final Array rootFolders) { + public void fill(@NotNull Array rootFolders) { + prepareToFill(); + EXECUTOR_MANAGER.addBackgroundTask(() -> startBackgroundFill(rootFolders)); + } + + /** + * Prepare this component to fill again. + */ + @FxThread + protected void prepareToFill() { - final Consumer onLoadHandler = getOnLoadHandler(); + var onLoadHandler = getOnLoadHandler(); if (onLoadHandler != null) { onLoadHandler.accept(Boolean.FALSE); } - final TreeItem currentRoot = getRoot(); + var currentRoot = getRoot(); if (currentRoot != null) { setRoot(null); } showLoading(); - - EXECUTOR_MANAGER.addBackgroundTask(() -> startBackgroundFill(rootFolders)); } /** + * Get the list of expanded elements. + * * @return the list of expanded elements. */ @FromAnyThread @@ -502,6 +544,8 @@ public void fill(@NotNull final Array rootFolders) { } /** + * Get the list of selected elements. + * * @return the list of selected elements. */ @FromAnyThread @@ -515,16 +559,18 @@ public void fill(@NotNull final Array rootFolders) { @FxThread public void refresh() { - final EditorConfig config = EditorConfig.getInstance(); - final Path currentAsset = config.getCurrentAsset(); + var config = EditorConfig.getInstance(); + var currentAsset = config.getCurrentAsset(); if (currentAsset == null) { setRoot(null); return; } - final Consumer onLoadHandler = getOnLoadHandler(); - if (onLoadHandler != null) onLoadHandler.accept(Boolean.FALSE); + var onLoadHandler = getOnLoadHandler(); + if (onLoadHandler != null) { + onLoadHandler.accept(Boolean.FALSE); + } updateSelectedElements(); updateExpandedElements(); @@ -541,20 +587,18 @@ public void refresh() { @FxThread private void updateExpandedElements() { - final ConcurrentArray expandedElements = getExpandedElements(); - final long stamp = expandedElements.writeLock(); + var elements = getExpandedElements(); + var stamp = elements.writeLock(); try { - expandedElements.clear(); + elements.clear(); - final Array> allItems = UiUtils.getAllItems(this); - allItems.forEach(item -> { - if (!item.isExpanded()) return; - expandedElements.add(item.getValue()); - }); + UiUtils.allItems(getRoot()) + .filter(TreeItem::isExpanded) + .forEach(item -> elements.add(item.getValue())); } finally { - expandedElements.writeUnlock(stamp); + elements.writeUnlock(stamp); } } @@ -564,18 +608,18 @@ private void updateExpandedElements() { @FxThread private void updateSelectedElements() { - final ConcurrentArray selectedElements = getSelectedElements(); - final long stamp = selectedElements.writeLock(); + var elements = getSelectedElements(); + var stamp = elements.writeLock(); try { - selectedElements.clear(); + elements.clear(); - final MultipleSelectionModel> selectionModel = getSelectionModel(); - final ObservableList> selectedItems = selectionModel.getSelectedItems(); - selectedItems.forEach(item -> selectedElements.add(item.getValue())); + getSelectionModel() + .getSelectedItems() + .forEach(item -> elements.add(item.getValue())); } finally { - selectedElements.writeUnlock(stamp); + elements.writeUnlock(stamp); } } @@ -591,10 +635,10 @@ private void showLoading() { * Start the background process of filling. */ @BackgroundThread - private void startBackgroundFill(@NotNull final Path path) { + private void startBackgroundFill(@NotNull Path path) { - final ResourceElement rootElement = createFor(path); - final TreeItem newRoot = new TreeItem<>(rootElement); + var rootElement = createFor(path); + var newRoot = new TreeItem(rootElement); newRoot.setExpanded(true); fill(newRoot); @@ -603,24 +647,34 @@ private void startBackgroundFill(@NotNull final Path path) { cleanup(newRoot); } - EXECUTOR_MANAGER.addFxTask(() -> { - setRoot(newRoot); + EXECUTOR_MANAGER.addFxTask(() -> applyNewRoot(newRoot)); + } - final Consumer onLoadHandler = getOnLoadHandler(); - if (onLoadHandler != null) { - onLoadHandler.accept(Boolean.TRUE); - } - }); + /** + * Applies the new root. + * + * @param newRoot the new root, + */ + @FxThread + private void applyNewRoot(@NotNull TreeItem newRoot) { + setRoot(newRoot); + + var onLoadHandler = getOnLoadHandler(); + if (onLoadHandler != null) { + onLoadHandler.accept(Boolean.TRUE); + } + + repaint(); } /** * Start the background process of filling. */ @BackgroundThread - private void startBackgroundFill(@NotNull final Array paths) { + private void startBackgroundFill(@NotNull Array paths) { - final ResourceElement rootElement = new FoldersResourceElement(paths); - final TreeItem newRoot = new TreeItem<>(rootElement); + var rootElement = new FoldersResourceElement(paths); + var newRoot = new TreeItem(rootElement); newRoot.setExpanded(true); fill(newRoot); @@ -629,35 +683,29 @@ private void startBackgroundFill(@NotNull final Array paths) { cleanup(newRoot); } - EXECUTOR_MANAGER.addFxTask(() -> { - setRoot(newRoot); - final Consumer onLoadHandler = getOnLoadHandler(); - if (onLoadHandler != null) { - onLoadHandler.accept(Boolean.TRUE); - } - }); + EXECUTOR_MANAGER.addFxTask(() -> applyNewRoot(newRoot)); } /** * Start the background process of loading. */ @BackgroundThread - private void startBackgroundRefresh(@NotNull final Path assetFolder) { + private void startBackgroundRefresh(@NotNull Path assetFolder) { - final ResourceElement rootElement = createFor(assetFolder); - final TreeItem newRoot = new TreeItem<>(rootElement); + var rootElement = createFor(assetFolder); + var newRoot = new TreeItem(rootElement); newRoot.setExpanded(true); fill(newRoot); - final ConcurrentArray expandedElements = getExpandedElements(); - final long stamp = expandedElements.writeLock(); + var expandedElements = getExpandedElements(); + var stamp = expandedElements.writeLock(); try { expandedElements.sort(COMPARATOR); expandedElements.forEach(element -> { - final TreeItem item = findItemForValue(newRoot, element); + var item = findItemForValue(newRoot, element); if (item == null) { return; } @@ -672,10 +720,11 @@ private void startBackgroundRefresh(@NotNull final Path assetFolder) { } EXECUTOR_MANAGER.addFxTask(() -> { + setRoot(newRoot); restoreSelection(); - final Consumer onLoadHandler = getOnLoadHandler(); + var onLoadHandler = getOnLoadHandler(); if (onLoadHandler != null) { onLoadHandler.accept(Boolean.TRUE); } @@ -689,17 +738,16 @@ private void startBackgroundRefresh(@NotNull final Path assetFolder) { private void restoreSelection() { EXECUTOR_MANAGER.addFxTask(() -> { - final ConcurrentArray selectedElements = getSelectedElements(); - final long stamp = selectedElements.writeLock(); + var selectedElements = getSelectedElements(); + var stamp = selectedElements.writeLock(); try { - final MultipleSelectionModel> selectionModel = getSelectionModel(); + var selectionModel = getSelectionModel(); - selectedElements.forEach(element -> { - final TreeItem item = findItemForValue(getRoot(), element); - if (item == null) return; - selectionModel.select(item); - }); + selectedElements.stream() + .map(resourceElement -> findItemForValue(getRoot(), resourceElement)) + .filter(Objects::nonNull) + .forEach(selectionModel::select); selectedElements.clear(); @@ -713,21 +761,26 @@ private void restoreSelection() { * Fill the node. */ @FxThread - private void fill(@NotNull final TreeItem treeItem) { + private void fill(@NotNull TreeItem treeItem) { + + var element = treeItem.getValue(); + var extensionFilter = getExtensionFilter(); - final ResourceElement element = treeItem.getValue(); - final Array extensionFilter = getExtensionFilter(); if (!element.hasChildren(extensionFilter, isOnlyFolders())) { return; } - final ObservableList> items = treeItem.getChildren(); + var items = treeItem.getChildren(); if (isLazyMode()) { items.add(new TreeItem<>(LoadingResourceElement.getInstance())); } else { - final Array children = element.getChildren(extensionFilter, isOnlyFolders()); + var children = element.getChildren(extensionFilter, isOnlyFolders()); + if (children == null) { + return; + } + children.sort(NAME_COMPARATOR); children.forEach(child -> items.add(new TreeItem<>(child))); @@ -741,24 +794,25 @@ private void fill(@NotNull final TreeItem treeItem) { * @param file the created file. */ @FxThread - public void notifyCreated(@NotNull final Path file) { + public void notifyCreated(@NotNull Path file) { + + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); + var folder = file.getParent(); - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); - final Path folder = file.getParent(); if (!folder.startsWith(currentAsset)) { return; } - final ResourceElement fileElement = createFor(file); - final TreeItem fileItem = findItemForValue(getRoot(), fileElement); + var fileElement = createFor(file); + + var fileItem = findItemForValue(getRoot(), fileElement); if (fileItem != null) { return; } - final ResourceElement element = createFor(folder); - - TreeItem folderItem = findItemForValue(getRoot(), element); + var element = createFor(folder); + var folderItem = findItemForValue(getRoot(), element); if (folderItem == null) { notifyCreated(folder); @@ -769,86 +823,90 @@ public void notifyCreated(@NotNull final Path file) { return; } - final TreeItem newItem = new TreeItem<>(createFor(file)); + var newItem = new TreeItem(createFor(file)); fill(newItem); - final ObservableList> children = folderItem.getChildren(); + var children = folderItem.getChildren(); children.add(newItem); FXCollections.sort(children, ITEM_COMPARATOR); } /** - * Handle a removed file. + * Handle the removed file. * - * @param file the file + * @param file the removed file. */ @FxThread - public void notifyDeleted(@NotNull final Path file) { + public void notifyDeleted(@NotNull Path file) { - final ResourceElement element = createFor(file); - final TreeItem treeItem = findItemForValue(getRoot(), element); + var element = createFor(file); + var treeItem = findItemForValue(getRoot(), element); if (treeItem == null) { return; } - final TreeItem parent = treeItem.getParent(); + var parent = treeItem.getParent(); if (parent == null) { return; } - final ObservableList> children = parent.getChildren(); + var children = parent.getChildren(); children.remove(treeItem); } /** - * Handle a moved file. + * Handle the moved file. * * @param prevFile the prev version. * @param newFile the new version. */ @FxThread - public void notifyMoved(@NotNull final Path prevFile, @NotNull final Path newFile) { + public void notifyMoved(@NotNull Path prevFile, @NotNull Path newFile) { - final ResourceElement prevElement = createFor(prevFile); - final TreeItem prevItem = findItemForValue(getRoot(), prevElement); + var prevElement = createFor(prevFile); + var prevItem = findItemForValue(getRoot(), prevElement); if (prevItem == null) { return; } - final ResourceElement newParentElement = createFor(newFile.getParent()); - final TreeItem newParentItem = findItemForValue(getRoot(), newParentElement); + var newParentElement = createFor(newFile.getParent()); + var newParentItem = findItemForValue(getRoot(), newParentElement); if (newParentItem == null) { return; } - final TreeItem prevParentItem = prevItem.getParent(); - final ObservableList> prevParentChildren = prevParentItem.getChildren(); + var prevParentItem = prevItem.getParent(); + var prevParentChildren = prevParentItem.getChildren(); prevParentChildren.remove(prevItem); prevItem.setValue(createFor(newFile)); - final Array> children = UiUtils.getAllItems(prevItem); + var children = UiUtils.getAllItems(prevItem); children.fastRemove(prevItem); fillChildren(prevFile, newFile, children); - final ObservableList> newParentChildren = newParentItem.getChildren(); + var newParentChildren = newParentItem.getChildren(); newParentChildren.add(prevItem); FXCollections.sort(newParentChildren, ITEM_COMPARATOR); } @FxThread - private void fillChildren(@NotNull final Path prevFile, @NotNull final Path newFile, - @NotNull final Array> children) { - for (final TreeItem child : children) { + private void fillChildren( + @NotNull Path prevFile, + @NotNull Path newFile, + @NotNull Array> children + ) { - final ResourceElement resourceElement = child.getValue(); - final Path file = resourceElement.getFile(); - final Path relativeFile = file.subpath(prevFile.getNameCount(), file.getNameCount()); - final Path resultFile = newFile.resolve(relativeFile); + for (var child : children) { + + var resourceElement = child.getValue(); + var file = resourceElement.getFile(); + var relativeFile = file.subpath(prevFile.getNameCount(), file.getNameCount()); + var resultFile = newFile.resolve(relativeFile); child.setValue(createFor(resultFile)); } @@ -861,17 +919,17 @@ private void fillChildren(@NotNull final Path prevFile, @NotNull final Path newF * @param newFile the new version. */ @FxThread - public void notifyRenamed(@NotNull final Path prevFile, @NotNull final Path newFile) { + public void notifyRenamed(@NotNull Path prevFile, @NotNull Path newFile) { - final ResourceElement prevElement = createFor(prevFile); - final TreeItem prevItem = findItemForValue(getRoot(), prevElement); + var prevElement = createFor(prevFile); + var prevItem = findItemForValue(getRoot(), prevElement); if (prevItem == null) { return; } prevItem.setValue(createFor(newFile)); - final Array> children = UiUtils.getAllItems(prevItem); + var children = UiUtils.getAllItems(prevItem); children.fastRemove(prevItem); fillChildren(prevFile, newFile, children); @@ -881,23 +939,26 @@ public void notifyRenamed(@NotNull final Path prevFile, @NotNull final Path newF * Handle hotkeys. */ @FxThread - private void processKey(@NotNull final KeyEvent event) { + private void processKey(@NotNull KeyEvent event) { + if (isReadOnly()) { return; } - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); if (currentAsset == null) { return; } updateSelectedElements(); - final ConcurrentArray selectedElements = getSelectedElements(); - if (selectedElements.isEmpty()) return; + var selectedElements = getSelectedElements(); + if (selectedElements.isEmpty()) { + return; + } - final ResourceElement firstElement = selectedElements.first(); + var firstElement = selectedElements.first(); if (firstElement instanceof LoadingResourceElement) { return; } @@ -906,7 +967,8 @@ private void processKey(@NotNull final KeyEvent event) { boolean onlyFolders = true; boolean selectedAsset = false; - for (final ResourceElement element : selectedElements.array()) { + for (var element : selectedElements.array()) { + if (element == null) { break; } @@ -922,43 +984,41 @@ private void processKey(@NotNull final KeyEvent event) { } } - final Predicate> actionTester = getActionTester(); - final KeyCode keyCode = event.getCode(); - final boolean controlDown = event.isControlDown(); + var actionTester = getActionTester(); + var keyCode = event.getCode(); + var controlDown = event.isControlDown(); if (!currentAsset.equals(firstElement.getFile())) { - if (controlDown && keyCode == KeyCode.C && actionTester.test(CopyFileAction.class) && !selectedAsset && - (onlyFiles || selectedElements.size() == 1)) { - final CopyFileAction action = new CopyFileAction(selectedElements); - final EventHandler onAction = action.getOnAction(); - onAction.handle(null); + if (controlDown) { - } else if (controlDown && keyCode == KeyCode.X && actionTester.test(CutFileAction.class) && !selectedAsset && - (onlyFiles || selectedElements.size() == 1)) { + if (keyCode == KeyCode.C && actionTester.test(CopyFileAction.class) && + !selectedAsset && (onlyFiles || selectedElements.size() == 1)) { - final CutFileAction action = new CutFileAction(selectedElements); - final EventHandler onAction = action.getOnAction(); - onAction.handle(null); + CopyFileAction.applyFor(selectedElements); - } else if (keyCode == KeyCode.DELETE && actionTester.test(DeleteFileAction.class) && !selectedAsset && - (onlyFiles || selectedElements.size() == 1)) { + } else if (keyCode == KeyCode.X && actionTester.test(CutFileAction.class) && + !selectedAsset && (onlyFiles || selectedElements.size() == 1)) { - final DeleteFileAction action = new DeleteFileAction(selectedElements); - final EventHandler onAction = action.getOnAction(); - onAction.handle(null); + CutFileAction.applyFor(selectedElements); + } + + } else if (keyCode == KeyCode.DELETE && actionTester.test(DeleteFileAction.class) && + !selectedAsset && (onlyFiles || selectedElements.size() == 1)) { + + DeleteFileAction.applyFor(selectedElements); } } - if (controlDown && keyCode == KeyCode.V && hasFileInClipboard() && actionTester.test(PasteFileAction.class)) { - final PasteFileAction action = new PasteFileAction(firstElement); - final EventHandler onAction = action.getOnAction(); - onAction.handle(null); + if (controlDown && keyCode == KeyCode.V && hasFileInClipboard() && + actionTester.test(PasteFileAction.class)) { + + PasteFileAction.applyFor(firstElement); } } /** - * Gets open function. + * Get the open resource function. * * @return the open resource function. */ @@ -971,22 +1031,22 @@ private void processKey(@NotNull final KeyEvent event) { * Cleanup the tree. */ @FxThread - private void cleanup(@NotNull final TreeItem treeItem) { + private void cleanup(@NotNull TreeItem treeItem) { - final ResourceElement element = treeItem.getValue(); + var element = treeItem.getValue(); if (element instanceof FileResourceElement || element instanceof LoadingResourceElement) { return; } - final ObservableList> children = treeItem.getChildren(); + var children = treeItem.getChildren(); for (int i = children.size() - 1; i >= 0; i--) { cleanup(children.get(i)); } if (children.isEmpty() && treeItem.getParent() != null) { - final TreeItem parent = treeItem.getParent(); - final ObservableList> parentChildren = parent.getChildren(); + var parent = treeItem.getParent(); + var parentChildren = parent.getChildren(); parentChildren.remove(treeItem); } } @@ -998,9 +1058,9 @@ private void cleanup(@NotNull final TreeItem treeItem) { * @param needSelect the need select */ @FxThread - public void expandTo(@NotNull final TreeItem treeItem, final boolean needSelect) { + public void expandTo(@NotNull TreeItem treeItem, boolean needSelect) { - TreeItem parent = treeItem; + var parent = treeItem; while (parent != null) { parent.setExpanded(true); @@ -1018,26 +1078,30 @@ public void expandTo(@NotNull final TreeItem treeItem, final bo * @param file the file */ @FxThread - public void markExpand(@NotNull final Path file) { + public void markExpand(@NotNull Path file) { - final ResourceElement element = createFor(file); - final TreeItem treeItem = findItemForValue(getRoot(), element); - if (treeItem == null) return; + var element = createFor(file); + var treeItem = findItemForValue(getRoot(), element); + if (treeItem == null) { + return; + } treeItem.setExpanded(true); } /** - * Sets only folders. + * Set true if need to show only folders. * * @param onlyFolders true if need to show only folders. */ @FromAnyThread - public void setOnlyFolders(final boolean onlyFolders) { + public void setOnlyFolders(boolean onlyFolders) { this.onlyFolders = onlyFolders; } /** + * Return true if need to show only folders. + * * @return true if need to show only folders. */ @FromAnyThread @@ -1046,21 +1110,22 @@ public boolean isOnlyFolders() { } /** - * Expand tree to the file. + * Expand the file in the tree. * - * @param file the file - * @param needSelect the need select + * @param file the file. + * @param needSelect the need select. */ @FxThread - public void expandTo(@NotNull final Path file, final boolean needSelect) { + public void expandTo(@NotNull Path file, boolean needSelect) { if (isLazyMode()) { - final TreeItem targetItem = findItemForValue(getRoot(), file); + var targetItem = findItemForValue(getRoot(), file); if (targetItem == null) { TreeItem parentItem = null; - Path parent = file.getParent(); + + var parent = file.getParent(); while (parent != null) { parentItem = findItemForValue(getRoot(), parent); @@ -1075,23 +1140,25 @@ public void expandTo(@NotNull final Path file, final boolean needSelect) { parentItem = getRoot(); } - final TreeItem toLoad = parentItem; + var toLoad = parentItem; EXECUTOR_MANAGER.addBackgroundTask(() -> lazyLoadChildren(toLoad, item -> expandTo(file, needSelect))); return; } - final ObservableList> children = targetItem.getChildren(); + var children = targetItem.getChildren(); if (children.size() == 1 && children.get(0).getValue() == LoadingResourceElement.getInstance()) { EXECUTOR_MANAGER.addBackgroundTask(() -> lazyLoadChildren(targetItem, item -> expandTo(file, needSelect))); return; } } - final ResourceElement element = createFor(file); - final TreeItem treeItem = findItemForValue(getRoot(), element); - if (treeItem == null) return; + var element = createFor(file); + var treeItem = findItemForValue(getRoot(), element); + if (treeItem == null) { + return; + } - TreeItem parent = treeItem; + var parent = treeItem; while (parent != null) { parent.setExpanded(true); @@ -1104,9 +1171,9 @@ public void expandTo(@NotNull final Path file, final boolean needSelect) { } @FromAnyThread - private void scrollToAndSelect(@NotNull final TreeItem treeItem) { + private void scrollToAndSelect(@NotNull TreeItem treeItem) { EXECUTOR_MANAGER.addFxTask(() -> { - final MultipleSelectionModel> selectionModel = getSelectionModel(); + var selectionModel = getSelectionModel(); selectionModel.clearSelection(); selectionModel.select(treeItem); scrollTo(getRow(treeItem)); diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTreeCell.java b/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTreeCell.java index 211626d4..e0957416 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTreeCell.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/ResourceTreeCell.java @@ -4,22 +4,23 @@ import static java.util.Collections.singletonList; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.FileIconManager; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.component.asset.tree.resource.FolderResourceElement; import com.ss.editor.ui.component.asset.tree.resource.LoadingResourceElement; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.geometry.Side; import javafx.scene.Cursor; -import javafx.scene.control.*; +import javafx.scene.control.ProgressIndicator; +import javafx.scene.control.Tooltip; +import javafx.scene.control.TreeCell; +import javafx.scene.control.TreeView; import javafx.scene.image.ImageView; import javafx.scene.input.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.nio.file.Files; -import java.nio.file.Path; -import java.util.function.Consumer; /** * The implementation of the cell for {@link TreeView} to show resource. @@ -46,9 +47,6 @@ public class ResourceTreeCell extends TreeCell { @Nullable private Tooltip tooltip; - /** - * Instantiates a new Resource tree cell. - */ protected ResourceTreeCell() { setOnMouseClicked(this::handleMouseClickedEvent); setOnDragDetected(this::handleStartDragEvent); @@ -63,7 +61,7 @@ protected ResourceTreeCell() { * @param event the stop drag event. */ @FxThread - private void handleStopDragEvent(@NotNull final DragEvent event) { + private void handleStopDragEvent(@NotNull DragEvent event) { setCursor(Cursor.DEFAULT); event.consume(); } @@ -74,17 +72,21 @@ private void handleStopDragEvent(@NotNull final DragEvent event) { * @param mouseEvent the mouse event. */ @FxThread - private void handleStartDragEvent(@NotNull final MouseEvent mouseEvent) { + private void handleStartDragEvent(@NotNull MouseEvent mouseEvent) { startFullDrag(); - final ResourceElement item = getItem(); - if (item == null) return; + var item = getItem(); + if (item == null) { + return; + } - final Path file = item.getFile(); - if (!Files.exists(file)) return; + var file = item.getFile(); + if (!Files.exists(file)) { + return; + } - final Dragboard dragBoard = startDragAndDrop(TransferMode.COPY); - final ClipboardContent content = new ClipboardContent(); + var dragBoard = startDragAndDrop(TransferMode.COPY); + var content = new ClipboardContent(); content.put(DataFormat.FILES, singletonList(file.toFile())); dragBoard.setContent(content); @@ -99,28 +101,38 @@ private void handleStartDragEvent(@NotNull final MouseEvent mouseEvent) { * @param event the mouse clicked event. */ @FxThread - private void handleMouseClickedEvent(@NotNull final MouseEvent event) { + private void handleMouseClickedEvent(@NotNull MouseEvent event) { - final ResourceElement item = getItem(); - if (item == null) return; + var item = getItem(); + if (item == null) { + return; + } - final boolean isFolder = item instanceof FolderResourceElement; - final ResourceTree treeView = (ResourceTree) getTreeView(); + var isFolder = item instanceof FolderResourceElement; + var treeView = (ResourceTree) getTreeView(); if (event.getButton() == MouseButton.SECONDARY) { - final ContextMenu contextMenu = treeView.getContextMenu(item); - if (contextMenu == null) return; + + var contextMenu = treeView.getContextMenu(item); + if (contextMenu == null) { + return; + } + contextMenu.show(this, Side.BOTTOM, 0, 0); - } else if ((treeView.isOnlyFolders() || !isFolder) && event.getButton() == MouseButton.PRIMARY && - event.getClickCount() > 1) { - final Consumer openFunction = treeView.getOpenFunction(); - if (openFunction != null) openFunction.accept(item); + + } else if ((treeView.isOnlyFolders() || !isFolder) && + event.getButton() == MouseButton.PRIMARY && event.getClickCount() > 1) { + + var openFunction = treeView.getOpenFunction(); + if (openFunction != null) { + openFunction.accept(item); + } } } @Override @FxThread - protected void updateItem(@Nullable final ResourceElement item, boolean empty) { + protected void updateItem(@Nullable ResourceElement item, boolean empty) { super.updateItem(item, empty); removeToolTip(); @@ -135,9 +147,9 @@ protected void updateItem(@Nullable final ResourceElement item, boolean empty) { return; } - final Path file = item.getFile(); - final Path fileName = file.getFileName(); - final boolean folder = item instanceof FolderResourceElement; + var file = item.getFile(); + var fileName = file.getFileName(); + var folder = item instanceof FolderResourceElement; icon.setImage(ICON_MANAGER.getIcon(file, folder, true, DEFAULT_FILE_ICON_SIZE)); @@ -148,9 +160,9 @@ protected void updateItem(@Nullable final ResourceElement item, boolean empty) { @FxThread private @NotNull ProgressIndicator createIndicator() { - final ProgressIndicator indicator = new ProgressIndicator(); - indicator.setMaxHeight(FXConstants.RESOURCE_TREE_CELL_HEIGHT - 2); - indicator.setMaxWidth(FXConstants.RESOURCE_TREE_CELL_HEIGHT - 2); + var indicator = new ProgressIndicator(); + indicator.setMaxHeight(FxConstants.RESOURCE_TREE_CELL_HEIGHT - 2); + indicator.setMaxWidth(FxConstants.RESOURCE_TREE_CELL_HEIGHT - 2); return indicator; } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/ConvertFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/ConvertFileAction.java index 72acd820..4bdc6a35 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/ConvertFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/ConvertFileAction.java @@ -9,7 +9,7 @@ import javafx.scene.control.MenuItem; import javafx.scene.image.ImageView; import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; /** * The action to transformation a file. diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CopyFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CopyFileAction.java index 536b8a41..33bf2425 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CopyFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CopyFileAction.java @@ -1,12 +1,12 @@ package com.ss.editor.ui.component.asset.tree.context.menu.action; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; import javafx.event.ActionEvent; import javafx.scene.image.Image; import javafx.scene.input.Clipboard; @@ -23,36 +23,37 @@ */ public class CopyFileAction extends FileAction { - public CopyFileAction(@NotNull final Array elements) { + @FxThread + public static void applyFor(@NotNull Array elements) { + new CopyFileAction(elements).getOnAction().handle(null); + } + + public CopyFileAction(@NotNull Array elements) { super(elements); } - @FxThread @Override + @FxThread protected @NotNull String getName() { return Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_COPY_FILE; } - @FxThread @Override + @FxThread protected @Nullable Image getIcon() { return Icons.COPY_16; } - @FxThread @Override - protected void execute(@Nullable final ActionEvent event) { + @FxThread + protected void execute(@Nullable ActionEvent event) { super.execute(event); - final Array elements = getElements(); - final Array files = ArrayFactory.newArray(Path.class, elements.size()); - elements.forEach(files, (resource, toStore) -> toStore.add(resource.getFile())); - - final ClipboardContent content = new ClipboardContent(); - - EditorUtil.addCopiedFile(files, content); + var files = getElements().stream() + .map(ResourceElement::getFile) + .collect(toArray(Path.class)); - final Clipboard clipboard = Clipboard.getSystemClipboard(); - clipboard.setContent(content); + var clipboard = Clipboard.getSystemClipboard(); + clipboard.setContent(EditorUtil.addCopiedFile(files, new ClipboardContent())); } } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CutFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CutFileAction.java index ab7efb68..b551b4e7 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CutFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/CutFileAction.java @@ -6,7 +6,7 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.event.ActionEvent; import javafx.scene.image.Image; import javafx.scene.input.Clipboard; @@ -14,9 +14,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.File; import java.nio.file.Path; -import java.util.List; /** * The action to cut a file. @@ -25,37 +23,42 @@ */ public class CutFileAction extends FileAction { - public CutFileAction(@NotNull final Array elements) { + @FxThread + public static void applyFor(@NotNull Array elements) { + new CutFileAction(elements).getOnAction().handle(null); + } + + public CutFileAction(@NotNull Array elements) { super(elements); } - @FxThread @Override + @FxThread protected @Nullable Image getIcon() { return Icons.CUT_16; } - @FxThread @Override + @FxThread protected @NotNull String getName() { return Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_CUT_FILE; } - @FxThread @Override - protected void execute(@Nullable final ActionEvent event) { + @FxThread + protected void execute(@Nullable ActionEvent event) { super.execute(event); - final List files = getElements().stream() + var files = getElements().stream() .map(ResourceElement::getFile) .map(Path::toFile) .collect(toList()); - final ClipboardContent content = new ClipboardContent(); + var content = new ClipboardContent(); content.putFiles(files); content.put(EditorUtil.JAVA_PARAM, "cut"); - final Clipboard clipboard = Clipboard.getSystemClipboard(); + var clipboard = Clipboard.getSystemClipboard(); clipboard.setContent(content); } } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/DeleteFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/DeleteFileAction.java index 63c09d26..29306937 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/DeleteFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/DeleteFileAction.java @@ -8,8 +8,8 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import com.ss.editor.ui.dialog.ConfirmDialog; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; import javafx.event.ActionEvent; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -24,50 +24,57 @@ */ public class DeleteFileAction extends FileAction { - public DeleteFileAction(@NotNull final Array elements) { + @FxThread + public static void applyFor(@NotNull Array elements) { + new DeleteFileAction(elements).getOnAction().handle(null); + } + + public DeleteFileAction(@NotNull Array elements) { super(elements); } - @FxThread @Override + @FxThread protected @NotNull String getName() { return Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE; } - @FxThread @Override + @FxThread protected @Nullable Image getIcon() { return Icons.REMOVE_12; } - @FxThread @Override - protected void execute(@Nullable final ActionEvent event) { + @FxThread + protected void execute(@Nullable ActionEvent event) { super.execute(event); - final Array elements = getElements(); - final ResourceElement first = elements.first(); + var elements = getElements(); + var first = elements.first(); if(elements.size() == 1) { - final Path file = first.getFile(); + var file = first.getFile(); - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); - if (currentAsset == null || currentAsset.equals(file)) return; + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); + if (currentAsset == null || currentAsset.equals(file)) { + return; + } - String question = Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE_QUESTION; + var question = Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE_QUESTION; question = question.replace("%file_name%", file.getFileName().toString()); - final ConfirmDialog confirmDialog = new ConfirmDialog(result -> handle(file, result), question); + var confirmDialog = new ConfirmDialog(result -> handle(file, result), question); confirmDialog.show(); } else { - String question = Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILES_QUESTION; + var question = Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILES_QUESTION; question = question.replace("%file_count%", String.valueOf(elements.size())); - final ConfirmDialog confirmDialog = new ConfirmDialog(result -> handle(elements, result), question); + var confirmDialog = new ConfirmDialog(result -> handle(elements, result), question); confirmDialog.show(); } } @@ -75,13 +82,13 @@ protected void execute(@Nullable final ActionEvent event) { /** * Handle the answer. */ - private void handle(@NotNull final Path file, @Nullable final Boolean result) { + private void handle(@NotNull Path file, @Nullable Boolean result) { if (!Boolean.TRUE.equals(result)) return; deleteFile(file); } - private void deleteFile(@NotNull final Path file) { - final Array handlers = FileDeleteHandlerFactory.findFor(file); + private void deleteFile(@NotNull Path file) { + var handlers = FileDeleteHandlerFactory.findFor(file); handlers.forEach(file, FileDeleteHandler::preDelete); FileUtils.delete(file); handlers.forEach(file, FileDeleteHandler::postDelete); @@ -90,15 +97,17 @@ private void deleteFile(@NotNull final Path file) { /** * Handle the answer. */ - private void handle(@NotNull final Array elements, @Nullable final Boolean result) { + private void handle(@NotNull Array elements, @Nullable Boolean result) { if (!Boolean.TRUE.equals(result)) { return; } - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); - if (currentAsset == null) return; + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); + if (currentAsset == null) { + return; + } elements.stream().map(ResourceElement::getFile) .filter(path -> !currentAsset.equals(path)) diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/FileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/FileAction.java index 0e5a731c..4bae4a02 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/FileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/FileAction.java @@ -1,12 +1,12 @@ package com.ss.editor.ui.component.asset.tree.context.menu.action; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import com.ss.editor.ui.event.FxEventManager; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.array.Array; import javafx.event.ActionEvent; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/NewFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/NewFileAction.java index 685853a5..ceaae590 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/NewFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/NewFileAction.java @@ -11,7 +11,7 @@ import javafx.scene.control.MenuItem; import javafx.scene.image.ImageView; import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; /** * The action to create a new file. diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileAction.java index 07296e75..481714b1 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileAction.java @@ -15,24 +15,20 @@ */ public class OpenFileAction extends FileAction { - public OpenFileAction(@NotNull final ResourceElement element) { + public OpenFileAction(@NotNull ResourceElement element) { super(element); } - @FxThread @Override + @FxThread protected @NotNull String getName() { return Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE; } - @FxThread @Override - protected void execute(@Nullable final ActionEvent event) { + @FxThread + protected void execute(@Nullable ActionEvent event) { super.execute(event); - - final RequestedOpenFileEvent newEvent = new RequestedOpenFileEvent(); - newEvent.setFile(getElement().getFile()); - - FX_EVENT_MANAGER.notify(newEvent); + FX_EVENT_MANAGER.notify(new RequestedOpenFileEvent(getElement().getFile())); } } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileByEditorAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileByEditorAction.java index 175f56c2..614bbaaa 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileByEditorAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenFileByEditorAction.java @@ -24,14 +24,13 @@ class OpenFileByEditorAction extends FileAction { @NotNull private final EditorDescription description; - public OpenFileByEditorAction(@NotNull final ResourceElement element, - @NotNull final EditorDescription description) { + public OpenFileByEditorAction(@NotNull ResourceElement element, @NotNull EditorDescription description) { super(element); this.description = description; setText(description.getEditorName()); - final Image icon = description.getIcon(); + var icon = description.getIcon(); if (icon != null) { setGraphic(new ImageView(icon)); @@ -46,11 +45,10 @@ public OpenFileByEditorAction(@NotNull final ResourceElement element, @FxThread @Override - protected void execute(@Nullable final ActionEvent event) { + protected void execute(@Nullable ActionEvent event) { super.execute(event); - final RequestedOpenFileEvent newEvent = new RequestedOpenFileEvent(); - newEvent.setFile(getElement().getFile()); + var newEvent = new RequestedOpenFileEvent(getElement().getFile()); newEvent.setDescription(description); FX_EVENT_MANAGER.notify(newEvent); diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenWithFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenWithFileAction.java index 9aa7106f..9fd402fc 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenWithFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/OpenWithFileAction.java @@ -10,7 +10,7 @@ import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; /** * The action to choose an editor to open a file. diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/PasteFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/PasteFileAction.java index 72d316d1..1638f246 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/PasteFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/PasteFileAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.component.asset.tree.context.menu.action; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.Icons; @@ -8,9 +8,9 @@ import com.ss.editor.ui.event.impl.MovedFileEvent; import com.ss.editor.ui.event.impl.RequestSelectFileEvent; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.event.ActionEvent; import javafx.scene.image.Image; import javafx.scene.input.Clipboard; @@ -31,35 +31,44 @@ */ public class PasteFileAction extends FileAction { - public PasteFileAction(@NotNull final ResourceElement element) { + @FxThread + public static void applyFor(@NotNull ResourceElement element) { + new PasteFileAction(element).getOnAction().handle(null); + } + + public PasteFileAction(@NotNull ResourceElement element) { super(element); } - @FxThread @Override + @FxThread protected @NotNull String getName() { return Messages.ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_PASTE_FILE; } - @FxThread @Override + @FxThread protected @Nullable Image getIcon() { return Icons.PASTE_16; } - @FxThread @Override - protected void execute(@Nullable final ActionEvent event) { + @FxThread + protected void execute(@Nullable ActionEvent event) { super.execute(event); - final Clipboard clipboard = Clipboard.getSystemClipboard(); - if (clipboard == null) return; + var clipboard = Clipboard.getSystemClipboard(); + if (clipboard == null) { + return; + } - final List files = unsafeCast(clipboard.getContent(DataFormat.FILES)); - if (files == null || files.isEmpty()) return; + List files = unsafeCast(clipboard.getContent(DataFormat.FILES)); + if (files == null || files.isEmpty()) { + return; + } - final Path currentFile = getElement().getFile(); - final boolean isCut = "cut".equals(clipboard.getContent(EditorUtil.JAVA_PARAM)); + var currentFile = getElement().getFile(); + var isCut = "cut".equals(clipboard.getContent(EditorUtil.JAVA_PARAM)); if (isCut) { files.forEach(file -> moveFile(currentFile, file.toPath())); @@ -70,7 +79,7 @@ protected void execute(@Nullable final ActionEvent event) { clipboard.clear(); } - private void copyFile(@NotNull final Path currentFile, @NotNull final Path file) { + private void copyFile(@NotNull Path currentFile, @NotNull Path file) { if (Files.isDirectory(currentFile)) { processCopy(currentFile, file); } else { @@ -78,8 +87,7 @@ private void copyFile(@NotNull final Path currentFile, @NotNull final Path file) } } - private void moveFile(@NotNull final Path currentFile, @NotNull final Path file) { - + private void moveFile(@NotNull Path currentFile, @NotNull Path file) { if (Files.isDirectory(currentFile)) { processMove(currentFile, file); } else { @@ -90,9 +98,9 @@ private void moveFile(@NotNull final Path currentFile, @NotNull final Path file) /** * Process of moving. */ - private void processMove(@NotNull final Path targetFolder, @NotNull final Path file) { + private void processMove(@NotNull Path targetFolder, @NotNull Path file) { - final Path newFile = targetFolder.resolve(file.getFileName()); + var newFile = targetFolder.resolve(file.getFileName()); try { Files.move(file, newFile); @@ -101,7 +109,7 @@ private void processMove(@NotNull final Path targetFolder, @NotNull final Path f return; } - final MovedFileEvent event = new MovedFileEvent(); + var event = new MovedFileEvent(); event.setPrevFile(file); event.setNewFile(newFile); @@ -111,10 +119,10 @@ private void processMove(@NotNull final Path targetFolder, @NotNull final Path f /** * Process of copying. */ - private void processCopy(@NotNull final Path targetFolder, @NotNull final Path file) { + private void processCopy(@NotNull Path targetFolder, @NotNull Path file) { - final Array toCopy = ArrayFactory.newArray(Path.class); - final Array copied = ArrayFactory.newArray(Path.class); + Array toCopy = ArrayFactory.newArray(Path.class); + Array copied = ArrayFactory.newArray(Path.class); if (Files.isDirectory(file)) { toCopy.addAll(FileUtils.getFiles(file, true)); @@ -122,8 +130,8 @@ private void processCopy(@NotNull final Path targetFolder, @NotNull final Path f toCopy.slowRemove(file); } - final String freeName = FileUtils.getFirstFreeName(targetFolder, file); - final Path newFile = targetFolder.resolve(freeName); + var freeName = FileUtils.getFirstFreeName(targetFolder, file); + var newFile = targetFolder.resolve(freeName); try { processCopy(file, toCopy, copied, newFile); @@ -131,7 +139,7 @@ private void processCopy(@NotNull final Path targetFolder, @NotNull final Path f EditorUtil.handleException(LOGGER, this, e); } - final RequestSelectFileEvent event = new RequestSelectFileEvent(); + var event = new RequestSelectFileEvent(); event.setFile(newFile); FX_EVENT_MANAGER.notify(event); @@ -140,16 +148,20 @@ private void processCopy(@NotNull final Path targetFolder, @NotNull final Path f /** * Process of copying. */ - private void processCopy(@NotNull final Path file, @NotNull final Array toCopy, - @NotNull final Array copied, @NotNull final Path newFile) throws IOException { + private void processCopy( + @NotNull Path file, + @NotNull Array toCopy, + @NotNull Array copied, + @NotNull Path newFile + ) throws IOException { Files.copy(file, newFile); copied.add(newFile); toCopy.forEach(path -> { - final Path relativeFile = file.relativize(path); - final Path targetFile = newFile.resolve(relativeFile); + var relativeFile = file.relativize(path); + var targetFile = newFile.resolve(relativeFile); try { Files.copy(path, targetFile); @@ -157,10 +169,13 @@ private void processCopy(@NotNull final Path file, @NotNull final Array to throw new RuntimeException(e); } - boolean needAddToCopied = true; + var needAddToCopied = true; + + for (var copiedFile : copied) { - for (final Path copiedFile : copied) { - if (!Files.isDirectory(copiedFile)) continue; + if (!Files.isDirectory(copiedFile)) { + continue; + } if (targetFile.startsWith(copiedFile)) { needAddToCopied = false; @@ -168,7 +183,9 @@ private void processCopy(@NotNull final Path file, @NotNull final Array to } } - if (needAddToCopied) copied.add(targetFile); + if (needAddToCopied) { + copied.add(targetFile); + } }); } } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/RenameFileAction.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/RenameFileAction.java index 562727f3..8805b2ca 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/RenameFileAction.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/action/RenameFileAction.java @@ -7,8 +7,8 @@ import com.ss.editor.ui.dialog.RenameDialog; import com.ss.editor.ui.event.impl.RenamedFileEvent; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.event.ActionEvent; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeMultiContextMenuFiller.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeMultiContextMenuFiller.java index 72bf20e7..ed07549b 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeMultiContextMenuFiller.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeMultiContextMenuFiller.java @@ -2,7 +2,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.MenuItem; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/FileAssetTreeSingleContextMenuFiller.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/FileAssetTreeSingleContextMenuFiller.java index 22c38832..34046b41 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/FileAssetTreeSingleContextMenuFiller.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/FileAssetTreeSingleContextMenuFiller.java @@ -8,7 +8,7 @@ import com.ss.editor.ui.component.asset.tree.context.menu.filler.AssetTreeSingleContextMenuFiller; import com.ss.editor.ui.component.asset.tree.resource.FileResourceElement; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.MenuItem; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/ResourceAssetTreeSingleContextMenuFiller.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/ResourceAssetTreeSingleContextMenuFiller.java index 0d426cd2..685436c6 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/ResourceAssetTreeSingleContextMenuFiller.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/impl/ResourceAssetTreeSingleContextMenuFiller.java @@ -9,7 +9,7 @@ import com.ss.editor.ui.component.asset.tree.resource.FileResourceElement; import com.ss.editor.ui.component.asset.tree.resource.FolderResourceElement; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.MenuItem; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FolderResourceElement.java b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FolderResourceElement.java index 3af9022f..507bf414 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FolderResourceElement.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FolderResourceElement.java @@ -2,15 +2,14 @@ import static com.ss.editor.ui.component.asset.tree.resource.ResourceElementFactory.createFor; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.nio.file.AccessDeniedException; -import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; @@ -21,39 +20,47 @@ */ public class FolderResourceElement extends ResourceElement { - public FolderResourceElement(@NotNull final Path file) { + public FolderResourceElement(@NotNull Path file) { super(file); } @Override @FromAnyThread - public @Nullable Array getChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { - if (!Files.isDirectory(file)) return null; + public @Nullable Array getChildren( + @NotNull Array extensionFilter, + boolean onlyFolders + ) { + + if (!Files.isDirectory(file)) { + return null; + } final Array elements = ArrayFactory.newArray(ResourceElement.class); - try (final DirectoryStream stream = Files.newDirectoryStream(file)) { - stream.forEach(child -> { + try (var stream = Files.newDirectoryStream(file)) { + for (Path child : stream) { - final String fileName = child.getFileName().toString(); + var fileName = child.getFileName().toString(); if (fileName.startsWith(".")) { - return; + continue; } else if (Files.isDirectory(child)) { elements.add(createFor(child)); - return; + continue; } - if (onlyFolders) return; + if (onlyFolders) { + continue; + } - final String extension = FileUtils.getExtension(child); + var extension = FileUtils.getExtension(child); if (extensionFilter.isEmpty() || extensionFilter.contains(extension)) { elements.add(createFor(child)); } - }); + } - } catch (final IOException e) { + } catch (IOException e) { LOGGER.warning(this, e); } @@ -62,13 +69,16 @@ public FolderResourceElement(@NotNull final Path file) { @Override @FromAnyThread - public boolean hasChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { - if (!Files.isDirectory(file)) return false; + public boolean hasChildren(@NotNull Array extensionFilter, boolean onlyFolders) { + + if (!Files.isDirectory(file)) { + return false; + } - try (final DirectoryStream stream = Files.newDirectoryStream(file)) { - for (final Path path : stream) { + try (var stream = Files.newDirectoryStream(file)) { + for (var path : stream) { - final String fileName = path.getFileName().toString(); + var fileName = path.getFileName().toString(); if (fileName.startsWith(".")) { continue; @@ -76,18 +86,20 @@ public boolean hasChildren(@NotNull final Array extensionFilter, final b return true; } - if (onlyFolders) continue; + if (onlyFolders) { + continue; + } - final String extension = FileUtils.getExtension(path); + var extension = FileUtils.getExtension(path); if (extensionFilter.isEmpty() || extensionFilter.contains(extension)) { return true; } } - } catch (final AccessDeniedException e) { + } catch (AccessDeniedException e) { return false; - } catch (final IOException e) { + } catch (IOException e) { LOGGER.warning(this, e); } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FoldersResourceElement.java b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FoldersResourceElement.java index 35d954e2..6fda9d18 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FoldersResourceElement.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FoldersResourceElement.java @@ -1,10 +1,10 @@ package com.ss.editor.ui.component.asset.tree.resource; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayCollectors; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayCollectors; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,7 +17,7 @@ import java.util.stream.Collectors; import static com.ss.editor.ui.component.asset.tree.resource.ResourceElementFactory.createFor; -import static com.ss.rlib.util.array.ArrayCollectors.toArray; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; /** * The presentation of list of folders. diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElement.java b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElement.java index 49fcfc85..aa9c865e 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElement.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElement.java @@ -1,10 +1,10 @@ package com.ss.editor.ui.component.asset.tree.resource; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.array.Array; +import com.ss.editor.annotation.FxThread; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.Tooltip; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,12 +30,12 @@ public abstract class ResourceElement implements Comparable { @NotNull protected final Path file; - public ResourceElement(@NotNull final Path file) { + public ResourceElement(@NotNull Path file) { this.file = file; } /** - * Create tooltip to preview this element. + * Create a tooltip to preview this element. * * @return the tooltip. */ @@ -45,7 +45,7 @@ public ResourceElement(@NotNull final Path file) { } /** - * Gets file. + * Get the file. * * @return the reference to the file. */ @@ -55,42 +55,42 @@ public ResourceElement(@NotNull final Path file) { } /** - * Gets children. + * Get children of this file. * - * @param extensionFilter the extension filter - * @param onlyFolders the only folders + * @param extensionFilter the extension filter. + * @param onlyFolders true if needs only folders. * @return list of children resource elements. */ @FromAnyThread - public @Nullable Array getChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { + public @Nullable Array getChildren(@NotNull Array extensionFilter, boolean onlyFolders) { return null; } /** - * Has children boolean. + * Return true if this element has children. * - * @param extensionFilter the extension filter - * @param onlyFolders the only folders + * @param extensionFilter the extension filter. + * @param onlyFolders true if needs only folders. * @return true if this element has children. */ @FromAnyThread - public boolean hasChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { + public boolean hasChildren(@NotNull Array extensionFilter, boolean onlyFolders) { return false; } @Override - public int compareTo(@Nullable final ResourceElement other) { + public int compareTo(@Nullable ResourceElement other) { if (other == null) return -1; - final Path file = getFile(); - final Path otherFile = other.getFile(); + var file = getFile(); + var otherFile = other.getFile(); return file.getNameCount() - otherFile.getNameCount(); } @Override - public boolean equals(final Object o) { + public boolean equals(@Nullable Object o) { if (this == o) return true; if (o instanceof Path) return file.equals(o); - final ResourceElement that = (ResourceElement) o; + var that = (ResourceElement) o; return file.equals(that.file); } diff --git a/src/main/java/com/ss/editor/ui/component/bar/EditorMenuBarComponent.java b/src/main/java/com/ss/editor/ui/component/bar/EditorMenuBarComponent.java index 6e4359f4..8cc8eea9 100644 --- a/src/main/java/com/ss/editor/ui/component/bar/EditorMenuBarComponent.java +++ b/src/main/java/com/ss/editor/ui/component/bar/EditorMenuBarComponent.java @@ -4,7 +4,6 @@ import com.ss.editor.ui.component.ScreenComponent; import com.ss.editor.ui.component.bar.action.*; import com.ss.editor.ui.css.CssIds; -import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import org.jetbrains.annotations.NotNull; @@ -16,15 +15,8 @@ */ public class EditorMenuBarComponent extends MenuBar implements ScreenComponent { - /** - * The constant COMPONENT_ID. - */ - @NotNull private static final String COMPONENT_ID = "EditorMenuBarComponent"; - /** - * Instantiates a new Editor bar component. - */ public EditorMenuBarComponent() { super(); setId(CssIds.EDITOR_MENU_BAR_COMPONENT); @@ -32,16 +24,14 @@ public EditorMenuBarComponent() { } private void createComponents() { - final ObservableList menus = getMenus(); - menus.addAll(createFileMenu(), + getMenus().addAll(createFileMenu(), createOtherMenu(), createHelpMenu()); } - @NotNull - private Menu createFileMenu() { + private @NotNull Menu createFileMenu() { - final Menu menu = new Menu(Messages.EDITOR_MENU_FILE); + var menu = new Menu(Messages.EDITOR_MENU_FILE); menu.getItems().addAll(new OpenAssetAction(), new ReopenAssetMenu(), new ExitAction()); @@ -49,10 +39,9 @@ private Menu createFileMenu() { return menu; } - @NotNull - private Menu createOtherMenu() { + private @NotNull Menu createOtherMenu() { - final Menu menu = new Menu(Messages.EDITOR_MENU_OTHER); + var menu = new Menu(Messages.EDITOR_MENU_OTHER); menu.getItems().addAll(new OpenSettingsAction(), new OpenPluginsAction(), new ClearAssetCacheAction(), @@ -61,10 +50,9 @@ private Menu createOtherMenu() { return menu; } - @NotNull - private Menu createHelpMenu() { + private @NotNull Menu createHelpMenu() { - final Menu menu = new Menu(Messages.EDITOR_MENU_HELP); + var menu = new Menu(Messages.EDITOR_MENU_HELP); menu.getItems().addAll(new AboutAction()); return menu; diff --git a/src/main/java/com/ss/editor/ui/component/creator/FileCreatorDescription.java b/src/main/java/com/ss/editor/ui/component/creator/FileCreatorDescription.java index cfd75b54..47dc1000 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/FileCreatorDescription.java +++ b/src/main/java/com/ss/editor/ui/component/creator/FileCreatorDescription.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.component.creator; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/component/creator/FileCreatorRegistry.java b/src/main/java/com/ss/editor/ui/component/creator/FileCreatorRegistry.java index 4afa74f1..4c8f3a9d 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/FileCreatorRegistry.java +++ b/src/main/java/com/ss/editor/ui/component/creator/FileCreatorRegistry.java @@ -5,10 +5,10 @@ import com.ss.editor.ui.component.creator.impl.material.MaterialFileCreator; import com.ss.editor.ui.component.creator.impl.material.definition.MaterialDefinitionFileCreator; import com.ss.editor.ui.component.creator.impl.texture.SingleColorTextureFileCreator; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/AbstractFileCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/AbstractFileCreator.java index 7d022012..97e3dc42 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/AbstractFileCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/AbstractFileCreator.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.component.creator.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.nio.file.StandardCopyOption.ATOMIC_MOVE; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import com.ss.editor.Messages; @@ -18,11 +18,11 @@ import com.ss.editor.ui.event.impl.RequestSelectFileEvent; import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.Utils; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.Utils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.*; diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyFileCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyFileCreator.java index a6994462..fa1f24aa 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyFileCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyFileCreator.java @@ -3,7 +3,7 @@ import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.creator.FileCreatorDescription; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/FolderCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/FolderCreator.java index 72b4ac92..8d4d52ae 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/FolderCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/FolderCreator.java @@ -1,13 +1,13 @@ package com.ss.editor.ui.component.creator.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.creator.FileCreatorDescription; import com.ss.editor.util.EditorUtil; import org.jetbrains.annotations.NotNull; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import java.io.IOException; import java.nio.file.Files; diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/material/MaterialFileCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/material/MaterialFileCreator.java index 335114a0..d828abb0 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/material/MaterialFileCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/material/MaterialFileCreator.java @@ -1,26 +1,25 @@ package com.ss.editor.ui.component.creator.impl.material; import static com.ss.editor.FileExtensions.JME_MATERIAL; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.nio.file.StandardOpenOption.*; -import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.property.EditablePropertyType; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.api.file.creator.GenericFileCreator; import com.ss.editor.plugin.api.property.PropertyDefinition; +import com.ss.editor.ui.component.creator.FileCreatorDescription; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.MaterialSerializer; -import com.ss.editor.ui.component.creator.FileCreatorDescription; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,22 +35,12 @@ */ public class MaterialFileCreator extends GenericFileCreator { - /** - * The constant DESCRIPTION. - */ - @NotNull public static final FileCreatorDescription DESCRIPTION = new FileCreatorDescription(); - @NotNull private static final ResourceManager RESOURCE_MANAGER = ResourceManager.getInstance(); - @NotNull private static final String PBR_MAT_DEF = "Common/MatDefs/Light/PBRLighting.j3md"; - - @NotNull private static final String LIGHTING_MAT_DEF = "Common/MatDefs/Light/Lighting.j3md"; - - @NotNull private static final String PROP_MAT_DEF = "matDef"; static { @@ -83,7 +72,7 @@ public class MaterialFileCreator extends GenericFileCreator { definitions = RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION); - final String def; + String def; if (definitions.contains(PBR_MAT_DEF)) { def = PBR_MAT_DEF; @@ -93,7 +82,7 @@ public class MaterialFileCreator extends GenericFileCreator { def = definitions.first(); } - final Array result = ArrayFactory.newArray(PropertyDefinition.class); + var result = ArrayFactory.newArray(PropertyDefinition.class); result.add(new PropertyDefinition(EditablePropertyType.STRING_FROM_LIST, Messages.MATERIAL_FILE_CREATOR_MATERIAL_TYPE_LABEL, PROP_MAT_DEF, def, definitions)); @@ -101,6 +90,8 @@ public class MaterialFileCreator extends GenericFileCreator { } /** + * Get the list of available definitions. + * * @return the list of available definitions. */ @FromAnyThread @@ -110,9 +101,9 @@ public class MaterialFileCreator extends GenericFileCreator { @Override @FxThread - protected boolean validate(@NotNull final VarTable vars) { + protected boolean validate(@NotNull VarTable vars) { - final String matDef = vars.get(PROP_MAT_DEF, String.class, StringUtils.EMPTY); + var matDef = vars.get(PROP_MAT_DEF, String.class, StringUtils.EMPTY); if (matDef.isEmpty() || !getDefinitions().contains(matDef)) { return false; @@ -123,18 +114,18 @@ protected boolean validate(@NotNull final VarTable vars) { @Override @BackgroundThread - protected void writeData(@NotNull final VarTable vars, @NotNull final Path resultFile) throws IOException { + protected void writeData(@NotNull VarTable vars, @NotNull Path resultFile) throws IOException { super.writeData(vars, resultFile); - final AssetManager assetManager = EditorUtil.getAssetManager(); - final String matDef = vars.get(PROP_MAT_DEF); + var assetManager = EditorUtil.getAssetManager(); + var matDef = vars.get(PROP_MAT_DEF, String.class); - final Material material = new Material(assetManager, matDef); + var material = new Material(assetManager, matDef); material.getAdditionalRenderState(); - final String materialContent = MaterialSerializer.serializeToString(material); + var materialContent = MaterialSerializer.serializeToString(material); - try (final PrintWriter out = new PrintWriter(Files.newOutputStream(resultFile, WRITE, TRUNCATE_EXISTING, CREATE))) { + try (var out = new PrintWriter(Files.newOutputStream(resultFile, WRITE, TRUNCATE_EXISTING, CREATE))) { out.print(materialContent); } } diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/material/definition/MaterialDefinitionFileCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/material/definition/MaterialDefinitionFileCreator.java index 29aa7573..68a3555f 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/material/definition/MaterialDefinitionFileCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/material/definition/MaterialDefinitionFileCreator.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.component.creator.impl.material.definition; import static com.ss.editor.FileExtensions.JME_MATERIAL_DEFINITION; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.lang.Character.toUpperCase; import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; @@ -20,11 +20,11 @@ import com.ss.editor.ui.component.creator.FileCreator; import com.ss.editor.ui.component.creator.FileCreatorDescription; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.io.IOException; diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/texture/SingleColorTextureFileCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/texture/SingleColorTextureFileCreator.java index 3fa76034..5f504e95 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/texture/SingleColorTextureFileCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/texture/SingleColorTextureFileCreator.java @@ -2,7 +2,7 @@ import static com.ss.editor.extension.property.EditablePropertyType.COLOR; import static com.ss.editor.extension.property.EditablePropertyType.INTEGER; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; @@ -13,9 +13,9 @@ import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.component.creator.FileCreatorDescription; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.embed.swing.SwingFXUtils; import javafx.scene.image.ImageView; import javafx.scene.image.PixelWriter; diff --git a/src/main/java/com/ss/editor/ui/component/editor/EditorDescription.java b/src/main/java/com/ss/editor/ui/component/editor/EditorDescription.java index 0822edec..dd5593b7 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/EditorDescription.java +++ b/src/main/java/com/ss/editor/ui/component/editor/EditorDescription.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.component.editor; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/component/editor/EditorRegistry.java b/src/main/java/com/ss/editor/ui/component/editor/EditorRegistry.java index ec97dbbc..17364b74 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/EditorRegistry.java +++ b/src/main/java/com/ss/editor/ui/component/editor/EditorRegistry.java @@ -1,18 +1,18 @@ package com.ss.editor.ui.component.editor; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayFactory.newArray; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayFactory.newArray; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.editor.impl.*; import com.ss.editor.ui.component.editor.impl.material.MaterialFileEditor; import com.ss.editor.ui.component.editor.impl.model.ModelFileEditor; import com.ss.editor.ui.component.editor.impl.scene.SceneFileEditor; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/component/editor/FileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/FileEditor.java index 9572961c..34a45d47 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/FileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/FileEditor.java @@ -3,8 +3,8 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.part3d.editor.Editor3DPart; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.beans.property.BooleanProperty; import javafx.event.Event; import javafx.scene.Parent; diff --git a/src/main/java/com/ss/editor/ui/component/editor/area/EditorAreaComponent.java b/src/main/java/com/ss/editor/ui/component/editor/area/EditorAreaComponent.java index 7c99c8ce..b09b32c4 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/area/EditorAreaComponent.java +++ b/src/main/java/com/ss/editor/ui/component/editor/area/EditorAreaComponent.java @@ -1,9 +1,7 @@ package com.ss.editor.ui.component.editor.area; import static com.ss.editor.manager.FileIconManager.DEFAULT_FILE_ICON_SIZE; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.app.state.AppStateManager; -import com.jme3x.jfx.injfx.processor.FrameTransferSceneProcessor; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.JfxApplication; import com.ss.editor.JmeApplication; import com.ss.editor.Messages; @@ -11,19 +9,12 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.JmeThread; -import com.ss.editor.file.converter.FileConverter; -import com.ss.editor.file.converter.FileConverterDescription; import com.ss.editor.file.converter.FileConverterRegistry; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.manager.FileIconManager; import com.ss.editor.manager.WorkspaceManager; -import com.ss.editor.model.workspace.Workspace; -import com.ss.editor.part3d.editor.Editor3DPart; import com.ss.editor.ui.component.ScreenComponent; -import com.ss.editor.ui.component.creator.FileCreator; -import com.ss.editor.ui.component.creator.FileCreatorDescription; import com.ss.editor.ui.component.creator.FileCreatorRegistry; -import com.ss.editor.ui.component.editor.EditorDescription; import com.ss.editor.ui.component.editor.EditorRegistry; import com.ss.editor.ui.component.editor.FileEditor; import com.ss.editor.ui.css.CssIds; @@ -33,24 +24,21 @@ import com.ss.editor.ui.scene.EditorFxScene; import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.concurrent.util.ThreadUtils; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.ArrayUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.array.ConcurrentArray; -import com.ss.rlib.util.dictionary.ConcurrentObjectDictionary; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.DictionaryUtils; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.concurrent.util.ThreadUtils; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.ArrayUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.ConcurrentArray; +import com.ss.rlib.common.util.dictionary.ConcurrentObjectDictionary; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.DictionaryUtils; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.beans.value.ObservableValue; import javafx.collections.ListChangeListener; -import javafx.collections.ObservableList; -import javafx.collections.ObservableMap; import javafx.event.Event; -import javafx.scene.control.SingleSelectionModel; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.image.ImageView; @@ -60,8 +48,6 @@ import java.nio.file.Files; import java.nio.file.Path; -import java.util.List; -import java.util.Map; /** * The component for containing editors. @@ -70,40 +56,17 @@ */ public class EditorAreaComponent extends TabPane implements ScreenComponent { - @NotNull private static final Logger LOGGER = LoggerManager.getLogger(EditorAreaComponent.class); - /** - * The constant COMPONENT_ID. - */ - @NotNull private static final String COMPONENT_ID = "EditorAreaComponent"; - - /** - * The constant KEY_EDITOR. - */ - @NotNull private static final String KEY_EDITOR = "editor"; - @NotNull private static final FileConverterRegistry FILE_CONVERTER_REGISTRY = FileConverterRegistry.getInstance(); - - @NotNull private static final FileCreatorRegistry CREATOR_REGISTRY = FileCreatorRegistry.getInstance(); - - @NotNull private static final WorkspaceManager WORKSPACE_MANAGER = WorkspaceManager.getInstance(); - - @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); - - @NotNull private static final FxEventManager FX_EVENT_MANAGER = FxEventManager.getInstance(); - - @NotNull private static final EditorRegistry EDITOR_REGISTRY = EditorRegistry.getInstance(); - - @NotNull private static final FileIconManager ICON_MANAGER = FileIconManager.getInstance(); /** @@ -113,13 +76,13 @@ public class EditorAreaComponent extends TabPane implements ScreenComponent { private final ConcurrentObjectDictionary openedEditors; /** - * The list of opening files now. + * The list of opened files. */ @NotNull private final ConcurrentArray openingFiles; /** - * The flag for ignoring changing the list of opened editors. + * True if need to ignore change events. */ private boolean ignoreOpenedFiles; @@ -133,17 +96,26 @@ public EditorAreaComponent() { getSelectionModel().selectedItemProperty() .addListener(this::switchEditor); - FX_EVENT_MANAGER.addEventHandler(RequestedOpenFileEvent.EVENT_TYPE, event -> processOpenFile((RequestedOpenFileEvent) event)); - FX_EVENT_MANAGER.addEventHandler(RequestedCreateFileEvent.EVENT_TYPE, event -> processCreateFile((RequestedCreateFileEvent) event)); - FX_EVENT_MANAGER.addEventHandler(RequestedConvertFileEvent.EVENT_TYPE, event -> processConvertFile((RequestedConvertFileEvent) event)); - FX_EVENT_MANAGER.addEventHandler(RenamedFileEvent.EVENT_TYPE, event -> processEvent((RenamedFileEvent) event)); - FX_EVENT_MANAGER.addEventHandler(MovedFileEvent.EVENT_TYPE, event -> processEvent((MovedFileEvent) event)); - FX_EVENT_MANAGER.addEventHandler(ChangedCurrentAssetFolderEvent.EVENT_TYPE, event -> processEvent((ChangedCurrentAssetFolderEvent) event)); + FX_EVENT_MANAGER.addEventHandler(RequestedOpenFileEvent.EVENT_TYPE, + event -> processOpenFile((RequestedOpenFileEvent) event)); + FX_EVENT_MANAGER.addEventHandler(RequestedCreateFileEvent.EVENT_TYPE, + event -> processCreateFile((RequestedCreateFileEvent) event)); + FX_EVENT_MANAGER.addEventHandler(RequestedConvertFileEvent.EVENT_TYPE, + event -> processConvertFile((RequestedConvertFileEvent) event)); + FX_EVENT_MANAGER.addEventHandler(RenamedFileEvent.EVENT_TYPE, + event -> processEvent((RenamedFileEvent) event)); + FX_EVENT_MANAGER.addEventHandler(MovedFileEvent.EVENT_TYPE, + event -> processEvent((MovedFileEvent) event)); + FX_EVENT_MANAGER.addEventHandler(ChangedCurrentAssetFolderEvent.EVENT_TYPE, + event -> processEvent((ChangedCurrentAssetFolderEvent) event)); } @FxThread - private void switchEditor(@NotNull final ObservableValue observable, @Nullable final Tab oldValue, - @Nullable final Tab newValue) { + private void switchEditor( + @NotNull ObservableValue observable, + @Nullable Tab oldValue, + @Nullable Tab newValue + ) { BorderPane current3DArea = null; BorderPane new3DArea = null; @@ -152,8 +124,8 @@ private void switchEditor(@NotNull final ObservableValue observab if (newValue != null) { - final ObservableMap properties = newValue.getProperties(); - final FileEditor fileEditor = (FileEditor) properties.get(KEY_EDITOR); + var properties = newValue.getProperties(); + var fileEditor = (FileEditor) properties.get(KEY_EDITOR); fileEditor.notifyShowed(); newCurrentFile = fileEditor.getEditFile(); @@ -161,14 +133,16 @@ private void switchEditor(@NotNull final ObservableValue observab } if (oldValue != null) { - final ObservableMap properties = oldValue.getProperties(); - final FileEditor fileEditor = (FileEditor) properties.get(KEY_EDITOR); + + var properties = oldValue.getProperties(); + var fileEditor = (FileEditor) properties.get(KEY_EDITOR); fileEditor.notifyHided(); + current3DArea = fileEditor.get3DArea(); } - final EditorFxScene scene = (EditorFxScene) getScene(); - final ImageView canvas = scene.getCanvas(); + var scene = (EditorFxScene) getScene(); + var canvas = scene.getCanvas(); if (new3DArea != null) { new3DArea.setCenter(canvas); @@ -177,40 +151,40 @@ private void switchEditor(@NotNull final ObservableValue observab scene.hideCanvas(); } - final Workspace workspace = notNull(WORKSPACE_MANAGER.getCurrentWorkspace()); + var workspace = notNull(WORKSPACE_MANAGER.getCurrentWorkspace()); workspace.updateCurrentEditedFile(newCurrentFile); EXECUTOR_MANAGER.addJmeTask(() -> processShowEditor(oldValue, newValue)); } /** - * Handle changing the current asset folder. + * Handle the event of changing a current asset folder. */ @FxThread - private void processEvent(@NotNull final ChangedCurrentAssetFolderEvent event) { + private void processEvent(@NotNull ChangedCurrentAssetFolderEvent event) { setIgnoreOpenedFiles(true); try { - - final ObservableList tabs = getTabs(); - tabs.clear(); - + getTabs().clear(); loadOpenedFiles(); - } finally { setIgnoreOpenedFiles(false); } } /** - * @param ignoreOpenedFiles the flag for ignoring changing the list of opened editors. + * Set true if need to ignore change events. + * + * @param ignoreOpenedFiles true if need to ignore change events. */ @FromAnyThread - private void setIgnoreOpenedFiles(final boolean ignoreOpenedFiles) { + private void setIgnoreOpenedFiles(boolean ignoreOpenedFiles) { this.ignoreOpenedFiles = ignoreOpenedFiles; } /** - * @return the flag for ignoring changing the list of opened editors. + * Return true if need to ignore change events. + * + * @return true if need to ignore change events. */ @FromAnyThread private boolean isIgnoreOpenedFiles() { @@ -218,27 +192,19 @@ private boolean isIgnoreOpenedFiles() { } /** - * Handle a renamed file. + * Handle the event of renamed file. */ @FxThread - private void processEvent(@NotNull final RenamedFileEvent event) { - - final Path prevFile = event.getPrevFile(); - final Path newFile = event.getNewFile(); - - handleMovedFiles(prevFile, newFile); + private void processEvent(@NotNull RenamedFileEvent event) { + handleMovedFiles(event.getPrevFile(), event.getNewFile()); } /** - * Handle a moved file. + * Handle the event of moved file. */ @FxThread private void processEvent(@NotNull final MovedFileEvent event) { - - final Path prevFile = event.getPrevFile(); - final Path newFile = event.getNewFile(); - - handleMovedFiles(prevFile, newFile); + handleMovedFiles(event.getPrevFile(), event.getNewFile()); } /** @@ -248,22 +214,23 @@ private void processEvent(@NotNull final MovedFileEvent event) { * @param newFile the new version of the file. */ @FxThread - private void handleMovedFiles(@NotNull final Path prevFile, @NotNull final Path newFile) { + private void handleMovedFiles(@NotNull Path prevFile, @NotNull Path newFile) { - final ConcurrentObjectDictionary openedEditors = getOpenedEditors(); - final long stamp = openedEditors.writeLock(); + var openedEditors = getOpenedEditors(); + var stamp = openedEditors.writeLock(); try { - final Array files = openedEditors.keyArray(Path.class); - for (final Path file : files) { + var files = openedEditors.keyArray(Path.class); + + for (var file : files) { if (!file.startsWith(prevFile)) { continue; } - final Tab tab = openedEditors.get(file); - final ObservableMap properties = tab.getProperties(); - final FileEditor fileEditor = (FileEditor) properties.get(KEY_EDITOR); + var tab = openedEditors.get(file); + var properties = tab.getProperties(); + var fileEditor = (FileEditor) properties.get(KEY_EDITOR); fileEditor.notifyRenamed(prevFile, newFile); if (fileEditor.isDirty()) { @@ -272,12 +239,12 @@ private void handleMovedFiles(@NotNull final Path prevFile, @NotNull final Path tab.setText(fileEditor.getFileName()); } - final Path editFile = fileEditor.getEditFile(); + var editFile = fileEditor.getEditFile(); openedEditors.remove(file); openedEditors.put(editFile, tab); - final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); + var workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); if (workspace != null) { workspace.removeOpenedFile(file); @@ -294,17 +261,15 @@ private void handleMovedFiles(@NotNull final Path prevFile, @NotNull final Path * Handle the request to convert a file. */ @FxThread - private void processConvertFile(@NotNull final RequestedConvertFileEvent event) { + private void processConvertFile(@NotNull RequestedConvertFileEvent event) { - final Path file = event.getFile(); - final FileConverterDescription description = event.getDescription(); + var file = event.getFile(); + var description = event.getDescription(); + var converter = FILE_CONVERTER_REGISTRY.newCreator(description, file); - final FileConverter converter = FILE_CONVERTER_REGISTRY.newCreator(description, file); - if (converter == null) { - return; + if (converter != null) { + converter.convert(file); } - - converter.convert(file); } /** @@ -318,9 +283,9 @@ private void processConvertFile(@NotNull final RequestedConvertFileEvent event) } /** - * Get the list of opening files now. + * Get the list of opened files. * - * @return the list of opening files now. + * @return the list of opened files. */ @FromAnyThread private @NotNull ConcurrentArray getOpeningFiles() { @@ -331,39 +296,37 @@ private void processConvertFile(@NotNull final RequestedConvertFileEvent event) * Handle the request to create a file. */ @FxThread - private void processCreateFile(@NotNull final RequestedCreateFileEvent event) { + private void processCreateFile(@NotNull RequestedCreateFileEvent event) { - final Path file = event.getFile(); - final FileCreatorDescription description = event.getDescription(); + var file = event.getFile(); + var description = event.getDescription(); + var fileCreator = CREATOR_REGISTRY.newCreator(description, file); - final FileCreator fileCreator = CREATOR_REGISTRY.newCreator(description, file); - if (fileCreator == null) { - return; + if (fileCreator != null) { + fileCreator.start(file); } - - fileCreator.start(file); } /** * Handle the request to close a file editor. */ @FxThread - private void processChangeTabs(@NotNull final ListChangeListener.Change change) { + private void processChangeTabs(@NotNull ListChangeListener.Change change) { if (!change.next()) { return; } - final List removed = change.getRemoved(); + var removed = change.getRemoved(); if (removed == null || removed.isEmpty()) { return; } removed.forEach(tab -> { - final ObservableMap properties = tab.getProperties(); - final FileEditor fileEditor = (FileEditor) properties.get(KEY_EDITOR); - final Path editFile = fileEditor.getEditFile(); + var properties = tab.getProperties(); + var fileEditor = (FileEditor) properties.get(KEY_EDITOR); + var editFile = fileEditor.getEditFile(); DictionaryUtils.runInWriteLock(getOpenedEditors(), editFile, ObjectDictionary::remove); @@ -373,7 +336,7 @@ private void processChangeTabs(@NotNull final ListChangeListener.Change properties = selectedTab.getProperties(); - return (FileEditor) properties.get(KEY_EDITOR); + + var selectedTab = getSelectionModel() + .getSelectedItem(); + + if (selectedTab == null) { + return null; + } + + return (FileEditor) selectedTab.getProperties() + .get(KEY_EDITOR); } /** @@ -400,36 +369,37 @@ private void processChangeTabs(@NotNull final ListChangeListener.Change properties = prevTab.getProperties(); - final FileEditor fileEditor = (FileEditor) properties.get(KEY_EDITOR); + var fileEditor = (FileEditor) prevTab.getProperties() + .get(KEY_EDITOR); - final Array states = fileEditor.get3DStates(); + var states = fileEditor.get3DStates(); states.forEach(stateManager::detach); } if (newTab != null) { - final ObservableMap properties = newTab.getProperties(); - final FileEditor fileEditor = (FileEditor) properties.get(KEY_EDITOR); + var fileEditor = (FileEditor) newTab.getProperties() + .get(KEY_EDITOR); - final Array states = fileEditor.get3DStates(); + var states = fileEditor.get3DStates(); states.forEach(stateManager::attach); enabled = states.size() > 0; } if (sceneProcessor.isEnabled() != enabled) { - final boolean result = enabled; + var result = enabled; EXECUTOR_MANAGER.addFxTask(() -> { ThreadUtils.sleep(100); canvas.setOpacity(result ? 1D : 0D); @@ -442,21 +412,20 @@ private void processShowEditor(@Nullable final Tab prevTab, @Nullable final Tab * Handle the request to open a file. */ @FxThread - private void processOpenFile(@NotNull final RequestedOpenFileEvent event) { + private void processOpenFile(@NotNull RequestedOpenFileEvent event) { - final Path file = event.getFile(); + var file = event.getFile(); - final ConcurrentObjectDictionary openedEditors = getOpenedEditors(); - final Tab tab = DictionaryUtils.getInReadLock(openedEditors, file, ObjectDictionary::get); + var openedEditors = getOpenedEditors(); + var tab = DictionaryUtils.getInReadLock(openedEditors, file, ObjectDictionary::get); if (tab != null) { - final SingleSelectionModel selectionModel = getSelectionModel(); - selectionModel.select(tab); + getSelectionModel().select(tab); return; } - final ConcurrentArray openingFiles = getOpeningFiles(); - final long stamp = openingFiles.writeLock(); + var openingFiles = getOpeningFiles(); + var stamp = openingFiles.writeLock(); try { if (openingFiles.contains(file)) { @@ -475,19 +444,19 @@ private void processOpenFile(@NotNull final RequestedOpenFileEvent event) { } @BackgroundThread - private void processOpenFileImpl(@NotNull final RequestedOpenFileEvent event, @NotNull final Path file) { + private void processOpenFileImpl(@NotNull RequestedOpenFileEvent event, @NotNull Path file) { - final EditorFxScene scene = EditorUtil.getFxScene(); + var scene = EditorUtil.getFxScene(); FileEditor editor; try { - final EditorDescription description = event.getDescription(); + var description = event.getDescription(); editor = description == null ? EDITOR_REGISTRY.createEditorFor(file) : EDITOR_REGISTRY.createEditorFor(description, file); - } catch (final Throwable e) { + } catch (Throwable e) { EditorUtil.handleException(null, this, new Exception(e)); EXECUTOR_MANAGER.addFxTask(scene::decrementLoading); ArrayUtils.runInWriteLock(getOpeningFiles(), file, Array::fastRemove); @@ -500,17 +469,17 @@ private void processOpenFileImpl(@NotNull final RequestedOpenFileEvent event, @N return; } - final FileEditor resultEditor = editor; + var resultEditor = editor; - final JmeApplication jmeApplication = JmeApplication.getInstance(); - final long stamp = jmeApplication.asyncLock(); + var jmeApplication = JmeApplication.getInstance(); + var stamp = jmeApplication.asyncLock(); try { editor.openFile(file); - } catch (final Throwable e) { + } catch (Throwable e) { EditorUtil.handleException(null, this, new Exception(e)); ArrayUtils.runInWriteLock(getOpeningFiles(), file, Array::fastRemove); - final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); + var workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); if (workspace != null) { workspace.removeOpenedFile(file); } @@ -536,28 +505,23 @@ private void processOpenFileImpl(@NotNull final RequestedOpenFileEvent event, @N * @param needShow the need show */ @FxThread - private void addEditor(@NotNull final FileEditor editor, final boolean needShow) { + private void addEditor(@NotNull FileEditor editor, boolean needShow) { - final Path editFile = editor.getEditFile(); + var editFile = editor.getEditFile(); - final Tab tab = new Tab(editor.getFileName()); + var tab = new Tab(editor.getFileName()); tab.setGraphic(new ImageView(ICON_MANAGER.getIcon(editFile, DEFAULT_FILE_ICON_SIZE))); tab.setContent(editor.getPage()); tab.setOnCloseRequest(event -> handleRequestToCloseEditor(editor, tab, event)); + tab.getProperties().put(KEY_EDITOR, editor); - final ObservableMap properties = tab.getProperties(); - properties.put(KEY_EDITOR, editor); - - editor.dirtyProperty().addListener((observable, oldValue, newValue) -> { - tab.setText(newValue == Boolean.TRUE ? "*" + editor.getFileName() : editor.getFileName()); - }); + editor.dirtyProperty().addListener((observable, oldValue, newValue) -> + tab.setText(newValue == Boolean.TRUE ? "*" + editor.getFileName() : editor.getFileName())); - final ObservableList tabs = getTabs(); - tabs.add(tab); + getTabs().add(tab); if (needShow) { - final SingleSelectionModel selectionModel = getSelectionModel(); - selectionModel.select(tab); + getSelectionModel().select(tab); } DictionaryUtils.runInWriteLock(getOpenedEditors(), editFile, tab, ObjectDictionary::put); @@ -569,24 +533,27 @@ private void addEditor(@NotNull final FileEditor editor, final boolean needShow) return; } - final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); - + var workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); if (workspace != null) { workspace.addOpenedFile(editFile, editor); } } @FxThread - private void handleRequestToCloseEditor(@NotNull final FileEditor editor, @NotNull final Tab tab, - @NotNull final Event event) { + private void handleRequestToCloseEditor(@NotNull FileEditor editor, @NotNull Tab tab, @NotNull Event event) { + if (!editor.isDirty()) { return; } - final String question = Messages.EDITOR_AREA_SAVE_FILE_QUESTION.replace("%file_name%", editor.getFileName()); + var question = Messages.EDITOR_AREA_SAVE_FILE_QUESTION + .replace("%file_name%", editor.getFileName()); - final ConfirmDialog dialog = new ConfirmDialog(result -> { - if (result == null) return; + var dialog = new ConfirmDialog(result -> { + + if (result == null) { + return; + } if (result) { editor.save(fileEditor -> getTabs().remove(tab)); @@ -623,29 +590,28 @@ public void notifyFinishBuild() { @FxThread private void loadOpenedFiles() { - final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); + var workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); if (workspace == null) { return; } - final Path assetFolder = workspace.getAssetFolder(); - final String editFile = workspace.getCurrentEditedFile(); + var assetFolder = workspace.getAssetFolder(); + var editFile = workspace.getCurrentEditedFile(); - final Map openedFiles = workspace.getOpenedFiles(); + var openedFiles = workspace.getOpenedFiles(); openedFiles.forEach((assetPath, editorId) -> { - final EditorDescription description = EDITOR_REGISTRY.getDescription(editorId); + var description = EDITOR_REGISTRY.getDescription(editorId); if (description == null) { return; } - final Path file = assetFolder.resolve(assetPath); + var file = assetFolder.resolve(assetPath); if (!Files.exists(file)) { return; } - final RequestedOpenFileEvent event = new RequestedOpenFileEvent(); - event.setFile(file); + var event = new RequestedOpenFileEvent(file); event.setDescription(description); event.setNeedShow(StringUtils.equals(assetPath, editFile)); diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/AbstractFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/AbstractFileEditor.java index d87920b0..e84f28de 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/AbstractFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/AbstractFileEditor.java @@ -1,12 +1,8 @@ package com.ss.editor.ui.component.editor.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; - -import com.jme3.asset.AssetKey; -import com.jme3.asset.ModelKey; import com.jme3.math.Vector3f; -import com.jme3.scene.Spatial; import com.ss.editor.JmeApplication; import com.ss.editor.Messages; import com.ss.editor.analytics.google.GAEvent; @@ -24,17 +20,15 @@ import com.ss.editor.ui.event.impl.FileChangedEvent; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.ui.util.UiUtils; -import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.Utils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.Utils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; -import javafx.event.Event; import javafx.event.EventHandler; import javafx.scene.control.Button; import javafx.scene.control.Tooltip; @@ -93,7 +87,7 @@ public abstract class AbstractFileEditor implements FileEditor { * The file changes listener. */ @NotNull - private final EventHandler fileChangedHandler; + private final EventHandler fileChangedHandler; /** * The dirty property. @@ -152,7 +146,7 @@ protected AbstractFileEditor() { this.showedTime = LocalTime.now(); this.editor3DParts = ArrayFactory.newArray(Editor3DPart.class); this.dirtyProperty = new SimpleBooleanProperty(this, "dirty", false); - this.fileChangedHandler = event -> processChangedFile((FileChangedEvent) event); + this.fileChangedHandler = this::processChangedFile; createContent(); } @@ -614,7 +608,7 @@ protected void handleExternalChanges() { * @return the file changes listener. */ @FxThread - private @NotNull EventHandler getFileChangedHandler() { + private @NotNull EventHandler getFileChangedHandler() { return fileChangedHandler; } diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/AudioViewerEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/AudioViewerEditor.java index ded53a86..a40961da 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/AudioViewerEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/AudioViewerEditor.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.component.editor.impl; import static com.jme3.audio.AudioSource.Status.Playing; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.audio.AudioData; import com.jme3.audio.AudioKey; @@ -17,7 +17,7 @@ import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/CodeAreaFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/CodeAreaFileEditor.java index 206b07ab..a53b0ae3 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/CodeAreaFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/CodeAreaFileEditor.java @@ -1,12 +1,12 @@ package com.ss.editor.ui.component.editor.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.BackgroundThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.code.BaseCodeArea; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.FileUtils; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import org.fxmisc.richtext.CodeArea; diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/ImageViewerEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/ImageViewerEditor.java index f54cb340..45e84c1b 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/ImageViewerEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/ImageViewerEditor.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.component.editor.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.JmeApplication; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; @@ -10,7 +10,7 @@ import com.ss.editor.ui.component.editor.EditorDescription; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.event.impl.FileChangedEvent; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.VBox; diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/TextFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/TextFileEditor.java index 42f3577f..555bf520 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/TextFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/TextFileEditor.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.component.editor.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.BackgroundThread; import com.ss.editor.annotation.FxThread; @@ -8,8 +8,8 @@ import com.ss.editor.ui.component.editor.EditorDescription; import com.ss.editor.ui.component.editor.EditorRegistry; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.FileUtils; import javafx.scene.control.TextArea; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/material/MaterialFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/material/MaterialFileEditor.java index 73d6f423..293a9230 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/material/MaterialFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/material/MaterialFileEditor.java @@ -6,7 +6,7 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; import static com.ss.editor.util.MaterialUtils.updateMaterialIdNeed; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetKey; import com.jme3.asset.AssetManager; @@ -41,7 +41,7 @@ import com.ss.editor.util.EditorUtil; import com.ss.editor.util.MaterialSerializer; import com.ss.editor.util.MaterialUtils; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.collections.ObservableList; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/model/ModelFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/model/ModelFileEditor.java index 884b8a34..5fcf77ce 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/model/ModelFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/model/ModelFileEditor.java @@ -2,7 +2,7 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.asset.TextureKey; @@ -30,9 +30,9 @@ import com.ss.editor.util.EditorUtil; import com.ss.editor.util.MaterialUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.*; import javafx.scene.image.ImageView; @@ -168,18 +168,18 @@ private ModelFileEditor() { @Override @FxThread - protected void doOpenFile(@NotNull final Path file) throws IOException { + protected void doOpenFile(@NotNull Path file) throws IOException { super.doOpenFile(file); - final Path assetFile = notNull(getAssetFile(file), "Asset file for " + file + " can't be null."); - final ModelKey modelKey = new ModelKey(toAssetPath(assetFile)); + var assetFile = notNull(getAssetFile(file), "Asset file for " + file + " can't be null."); + var modelKey = new ModelKey(toAssetPath(assetFile)); - final AssetManager assetManager = EditorUtil.getAssetManager(); - final Spatial model = assetManager.loadAsset(modelKey); + var assetManager = EditorUtil.getAssetManager(); + var model = assetManager.loadAsset(modelKey); MaterialUtils.cleanUpMaterialParams(model); - final ModelEditor3DPart editor3DPart = getEditor3DPart(); + var editor3DPart = getEditor3DPart(); editor3DPart.openModel(model); handleAddedObject(model); @@ -188,8 +188,8 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { setIgnoreListeners(true); try { - final ComboBox fastSkyComboBox = getFastSkyComboBox(); - fastSkyComboBox.getSelectionModel().select(FAST_SKY_LIST.first()); + getFastSkyComboBox().getSelectionModel() + .select(FAST_SKY_LIST.first()); refreshTree(); diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java index f68227e4..03f35805 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java @@ -5,8 +5,8 @@ import static com.ss.editor.util.MaterialUtils.saveIfNeedTextures; import static com.ss.editor.util.MaterialUtils.updateMaterialIdNeed; import static com.ss.editor.util.NodeUtils.findParent; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static javafx.collections.FXCollections.observableArrayList; import com.jme3.asset.AssetManager; import com.jme3.asset.MaterialKey; @@ -70,10 +70,10 @@ import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.ControlUtils; import com.ss.editor.util.*; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.event.Event; import javafx.geometry.Point2D; @@ -1170,11 +1170,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container */ @FxThread protected void refreshTree() { - - final M currentModel = getCurrentModel(); - - final ModelNodeTree modelNodeTree = getModelNodeTree(); - modelNodeTree.fill(currentModel); + getModelNodeTree().fill(notNull(getCurrentModel())); } /** diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/scene/SceneFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/scene/SceneFileEditor.java index 78820c86..d9b659ce 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/scene/SceneFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/scene/SceneFileEditor.java @@ -2,7 +2,7 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.scene.Spatial; @@ -37,8 +37,8 @@ import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.MaterialUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.ToggleButton; import javafx.scene.control.Tooltip; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/ui/component/editor/scripting/EditorScriptingComponent.java b/src/main/java/com/ss/editor/ui/component/editor/scripting/EditorScriptingComponent.java index ccdd4130..b114d9b5 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/scripting/EditorScriptingComponent.java +++ b/src/main/java/com/ss/editor/ui/component/editor/scripting/EditorScriptingComponent.java @@ -4,11 +4,11 @@ import com.ss.editor.ui.component.scripting.GroovyEditorComponent; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import groovy.lang.GroovyShell; import javafx.scene.control.Button; import javafx.scene.control.Label; diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/AbstractEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/AbstractEditorState.java index e92ef4a7..a84bdccb 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/AbstractEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/AbstractEditorState.java @@ -1,10 +1,10 @@ package com.ss.editor.ui.component.editor.state.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.ui.component.editor.state.EditorState; -import com.ss.rlib.util.ArrayUtils; +import com.ss.rlib.common.util.ArrayUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DEditorState.java index f2deeb69..2598e8ef 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DEditorState.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.component.editor.state.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.FastMath; import com.jme3.math.Vector3f; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponent.java b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponent.java index 089ca5da..101f3b3c 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponent.java +++ b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponent.java @@ -3,7 +3,7 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.editor.state.EditorState; -import com.ss.rlib.util.HasName; +import com.ss.rlib.common.util.HasName; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -111,5 +111,6 @@ default void notifyHided() { * @param propertyName the property name */ @FxThread - void notifyChangeProperty(@NotNull Object object, @NotNull String propertyName); + default void notifyChangeProperty(@NotNull Object object, @NotNull String propertyName) { + } } diff --git a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentContainer.java b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentContainer.java index b929f03b..6731be73 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentContainer.java +++ b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentContainer.java @@ -6,13 +6,12 @@ import com.ss.editor.annotation.JmeThread; import com.ss.editor.model.editor.Editor3DProvider; import com.ss.editor.model.undo.editor.ModelChangeConsumer; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.fx.util.FxUtils; import javafx.beans.value.ObservableValue; -import javafx.collections.ObservableList; import javafx.scene.Node; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; @@ -29,13 +28,7 @@ */ public class PaintingComponentContainer extends ScrollPane { - /** - * The constant LABEL_PERCENT. - */ public static final double LABEL_PERCENT = 1D - PropertyControl.CONTROL_WIDTH_PERCENT_2; - /** - * The constant FIELD_PERCENT. - */ public static final double FIELD_PERCENT = PropertyControl.CONTROL_WIDTH_PERCENT_2; /** @@ -85,42 +78,44 @@ public class PaintingComponentContainer extends ScrollPane { */ protected boolean showed; - public PaintingComponentContainer(@NotNull final ModelChangeConsumer changeConsumer, @NotNull final Editor3DProvider provider) { + public PaintingComponentContainer(@NotNull ModelChangeConsumer changeConsumer, @NotNull Editor3DProvider provider) { this.changeConsumer = changeConsumer; this.provider = provider; this.container = new VBox(); this.container.prefWidthProperty() - .bind(widthProperty().subtract(FXConstants.PROPERTY_LIST_OFFSET)); + .bind(widthProperty().subtract(FxConstants.PROPERTY_LIST_OFFSET)); - final HBox horContainer = new HBox(); - horContainer.prefWidthProperty() - .bind(widthProperty().subtract(FXConstants.PROPERTY_LIST_OFFSET)); + var toolTypeContainer = new HBox(); + toolTypeContainer.prefWidthProperty() + .bind(widthProperty().subtract(FxConstants.PROPERTY_LIST_OFFSET)); - final Label label = new Label(Messages.PAINTING_COMPONENT_CONTAINER_TOOL + ":"); - label.maxWidthProperty().bind(horContainer.widthProperty() + var label = new Label(Messages.PAINTING_COMPONENT_CONTAINER_TOOL + ":"); + label.maxWidthProperty().bind(toolTypeContainer.widthProperty() .multiply(LABEL_PERCENT)); componentBox = new ComboBox<>(); componentBox.setCellFactory(PaintingComponentListCell::new); componentBox.setButtonCell(new PaintingComponentListCell(null)); componentBox.setPromptText("No tools"); - componentBox.prefWidthProperty().bind(horContainer.widthProperty() + componentBox.prefWidthProperty().bind(toolTypeContainer.widthProperty() .multiply(FIELD_PERCENT)); componentBox.getSelectionModel() .selectedItemProperty() .addListener(this::activate); - final VBox resultContainer = new VBox(); + var resultContainer = new VBox(); setContent(resultContainer); - FXUtils.addToPane(label, componentBox, horContainer); - FXUtils.addToPane(horContainer, container, resultContainer); - FXUtils.addClassTo(container, CssClasses.DEF_VBOX); - FXUtils.addClassTo(horContainer, CssClasses.DEF_HBOX); - FXUtils.addClassTo(resultContainer, CssClasses.PAINTING_COMPONENT_ROOT); + FxUtils.addClass(container, CssClasses.DEF_VBOX) + .addClass(toolTypeContainer, CssClasses.DEF_HBOX) + .addClass(resultContainer, CssClasses.PAINTING_COMPONENT_ROOT); + + FxUtils.addChild(toolTypeContainer, label, componentBox) + .addChild(resultContainer, toolTypeContainer, container); + + var registry = PaintingComponentRegistry.getInstance(); - final PaintingComponentRegistry registry = PaintingComponentRegistry.getInstance(); this.components = registry.createComponents(this); } @@ -140,7 +135,7 @@ public PaintingComponentContainer(@NotNull final ModelChangeConsumer changeConsu * @param paintedObject the painted object. */ @FxThread - private void setPaintedObject(@Nullable final Object paintedObject) { + private void setPaintedObject(@Nullable Object paintedObject) { this.paintedObject = paintedObject; } @@ -160,7 +155,7 @@ private void setPaintedObject(@Nullable final Object paintedObject) { * @param currentComponent the current painting component. */ @FxThread - private void setCurrentComponent(@Nullable final PaintingComponent currentComponent) { + private void setCurrentComponent(@Nullable PaintingComponent currentComponent) { this.currentComponent = currentComponent; } @@ -172,11 +167,13 @@ private void setCurrentComponent(@Nullable final PaintingComponent currentCompon * @param newValue the new component. */ @FxThread - private void activate(@NotNull final ObservableValue observable, - @Nullable final PaintingComponent oldValue, @Nullable final PaintingComponent newValue) { + private void activate( + @NotNull ObservableValue observable, + @Nullable PaintingComponent oldValue, + @Nullable PaintingComponent newValue + ) { - final ObservableList items = getContainer() - .getChildren(); + var items = getContainer().getChildren(); if (oldValue != null) { oldValue.notifyHided(); @@ -184,15 +181,18 @@ private void activate(@NotNull final ObservableValue componentBox = getComponentBox(); - final ObservableList items = componentBox.getItems(); + var componentBox = getComponentBox(); + var items = componentBox.getItems(); items.clear(); if (element != null) { @@ -258,7 +258,7 @@ public void prepareFor(@Nullable final Object element) { @FxThread public void notifyShowed() { setShowed(true); - final PaintingComponent currentComponent = getCurrentComponent(); + var currentComponent = getCurrentComponent(); if (currentComponent != null) { currentComponent.notifyShowed(); } @@ -270,7 +270,7 @@ public void notifyShowed() { @FxThread public void notifyHided() { setShowed(false); - final PaintingComponent currentComponent = getCurrentComponent(); + var currentComponent = getCurrentComponent(); if (currentComponent != null) { currentComponent.notifyHided(); } @@ -312,7 +312,7 @@ protected boolean isShowed() { * @param showed true if this component is showed. */ @FxThread - protected void setShowed(final boolean showed) { + protected void setShowed(boolean showed) { this.showed = showed; } @@ -323,8 +323,8 @@ protected void setShowed(final boolean showed) { * @param propertyName the property name. */ @FxThread - public void notifyChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { - final PaintingComponent currentComponent = getCurrentComponent(); + public void notifyChangeProperty(@NotNull Object object, @NotNull String propertyName) { + var currentComponent = getCurrentComponent(); if (currentComponent != null) { currentComponent.notifyChangeProperty(object, propertyName); } diff --git a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentListCell.java b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentListCell.java index 42fca06a..d5b06d5d 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentListCell.java +++ b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentListCell.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.component.painting; import com.ss.editor.annotation.FxThread; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.image.ImageView; @@ -21,14 +21,14 @@ public class PaintingComponentListCell extends ListCell { @NotNull private final ImageView imageView; - public PaintingComponentListCell(@Nullable final ListView listView) { + public PaintingComponentListCell(@Nullable ListView listView) { this.imageView = new ImageView(); setGraphic(imageView); } @Override @FxThread - protected void updateItem(@Nullable final PaintingComponent item, final boolean empty) { + protected void updateItem(@Nullable PaintingComponent item, boolean empty) { super.updateItem(item, empty); if (item == null) { diff --git a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentRegistry.java b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentRegistry.java index 4ba5ec32..cbefaa2b 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentRegistry.java +++ b/src/main/java/com/ss/editor/ui/component/painting/PaintingComponentRegistry.java @@ -4,8 +4,8 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.painting.spawn.SpawnPaintingComponent; import com.ss.editor.ui.component.painting.terrain.TerrainPaintingComponent; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.util.function.Function; @@ -42,7 +42,7 @@ private PaintingComponentRegistry() { * @param constructor the new painting component's constructor. */ @FxThread - public void register(@NotNull final Function constructor) { + public void register(@NotNull Function constructor) { this.constructors.add(constructor); } @@ -53,9 +53,13 @@ public void register(@NotNull final Function createComponents(@NotNull final PaintingComponentContainer container) { - final Array result = ArrayFactory.newArray(PaintingComponent.class); - constructors.forEach(result, container, (constructor, components, cont) -> components.add(constructor.apply(cont))); + public @NotNull Array createComponents(@NotNull PaintingComponentContainer container) { + + var result = ArrayFactory.newArray(PaintingComponent.class); + + constructors.forEach(result, container, + (constructor, components, cont) -> components.add(constructor.apply(cont))); + return result; } } diff --git a/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingComponent.java b/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingComponent.java index c010f151..47ec823f 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingComponent.java +++ b/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingComponent.java @@ -1,26 +1,19 @@ package com.ss.editor.ui.component.painting.impl; -import static com.ss.editor.ui.component.painting.PaintingComponentContainer.FIELD_PERCENT; -import static com.ss.editor.ui.component.painting.PaintingComponentContainer.LABEL_PERCENT; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Node; -import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.JmeThread; import com.ss.editor.control.painting.PaintingControl; import com.ss.editor.manager.ExecutorManager; -import com.ss.editor.model.editor.Editor3DProvider; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.component.editor.state.EditorState; import com.ss.editor.ui.component.painting.PaintingComponent; import com.ss.editor.ui.component.painting.PaintingComponentContainer; -import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import javafx.scene.control.Label; -import javafx.scene.layout.GridPane; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,10 +31,8 @@ public abstract class AbstractPaintingComponent extends VBox implements PaintingComponent { - /** - * The executor manager. - */ - @NotNull + protected static final Logger LOGGER = LoggerManager.getLogger(PaintingComponent.class); + protected static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); /** @@ -50,18 +41,6 @@ public abstract class AbstractPaintingComponent changeBrushSize(newValue)); - - final Label brushPowerLabel = new Label(Messages.PAINTING_COMPONENT_BRUSH_POWER + ":"); - brushPowerLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - brushPowerField = new FloatTextField(); - brushPowerField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - brushPowerField.setScrollPower(3F); - brushPowerField.setMinMax(0.0001F, Integer.MAX_VALUE); - brushPowerField.addChangeListener((observable, oldValue, newValue) -> changeBrushPower(newValue)); - - final GridPane settings = new GridPane(); - settings.add(brushSizeLabel, 0, 0); - settings.add(brushSizeField, 1, 0); - settings.add(brushPowerLabel, 0, 1); - settings.add(brushPowerField, 1, 1); - - FXUtils.addClassTo(settings, CssClasses.DEF_GRID_PANE); - FXUtils.addClassTo(brushSizeLabel, brushPowerLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); - FXUtils.addClassTo(brushSizeField, brushPowerField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - - return settings; - } - @Override - public void loadState(@NotNull final EditorState editorState) { - final S state = editorState.getOrCreateAdditionalState(getStateType(), getStateConstructor()); + public void loadState(@NotNull EditorState editorState) { + var state = editorState.getOrCreateAdditionalState(getStateType(), getStateConstructor()); this.state = state; readState(state); } @@ -146,17 +92,6 @@ public void loadState(@NotNull final EditorState editorState) { return notNull(state); } - /** - * Read the saved component's state. - * - * @param state the saved component's state. - */ - @FxThread - protected void readState(@NotNull final S state) { - getBrushSizeField().setValue(state.getBrushSize()); - getBrushPowerField().setValue(state.getBrushPower()); - } - /** * Get the state's constructor. * @@ -174,49 +109,12 @@ protected void readState(@NotNull final S state) { protected abstract @NotNull Class getStateType(); /** - * Change brush sizes. - */ - @FromAnyThread - protected void changeBrushSize(@NotNull final Float size) { - - if (state != null) { - state.setBrushSize(size); - } - - EXECUTOR_MANAGER.addJmeTask(() -> setBrushSize(size)); - } - - /** - * Set the brush size. - * - * @param size the brush size. - */ - @JmeThread - protected void setBrushSize(@NotNull final Float size) { - getToolControl().setBrushSize(size); - } - - /** - * Change brush powers. - */ - @FromAnyThread - protected void changeBrushPower(@NotNull final Float power) { - - if (state != null) { - state.setBrushPower(power); - } - - EXECUTOR_MANAGER.addJmeTask(() -> setBrushPower(power)); - } - - /** - * Set the brush power. + * Read the saved component's state. * - * @param power the brush power. + * @param state the saved component's state. */ - @JmeThread - protected void setBrushPower(@NotNull final Float power) { - getToolControl().setBrushPower(power); + @FxThread + protected void readState(@NotNull S state) { } /** @@ -235,30 +133,10 @@ protected void setBrushPower(@NotNull final Float power) { * @param toolControl the current tool control. */ @FromAnyThread - protected void setToolControl(@Nullable final C toolControl) { + protected void setToolControl(@Nullable C toolControl) { this.toolControl = toolControl; } - /** - * Get the brush power field. - * - * @return the brush power field. - */ - @FxThread - protected @NotNull FloatTextField getBrushPowerField() { - return notNull(brushPowerField); - } - - /** - * Get the brush size field. - * - * @return the brush size field. - */ - @FxThread - protected @NotNull FloatTextField getBrushSizeField() { - return notNull(brushSizeField); - } - @Override @FromAnyThread public @NotNull PaintingComponentContainer getContainer() { @@ -272,8 +150,7 @@ protected void setToolControl(@Nullable final C toolControl) { */ @FromAnyThread public @NotNull ModelChangeConsumer getChangeConsumer() { - final PaintingComponentContainer editingContainer = getContainer(); - return editingContainer.getChangeConsumer(); + return getContainer().getChangeConsumer(); } @Override @@ -284,7 +161,7 @@ protected void setToolControl(@Nullable final C toolControl) { @Override @FxThread - public void startPainting(@NotNull final Object object) { + public void startPainting(@NotNull Object object) { this.paintedObject = unsafeCast(object); } @@ -302,9 +179,8 @@ protected void createComponents() { */ @JmeThread public @NotNull Node getCursorNode() { - final PaintingComponentContainer container = getContainer(); - final Editor3DProvider provider = container.getProvider(); - return provider.getCursorNode(); + return getContainer().getProvider() + .getCursorNode(); } /** @@ -314,27 +190,28 @@ protected void createComponents() { */ @JmeThread public @NotNull Node getMarkersNode() { - final PaintingComponentContainer container = getContainer(); - final Editor3DProvider provider = container.getProvider(); - return provider.getMarkersNode(); + return getContainer().getProvider() + .getMarkersNode(); } @Override @FxThread public void notifyShowed() { setShowed(true); - EXECUTOR_MANAGER.addJmeTask(() -> getCursorNode().addControl(getToolControl())); + EXECUTOR_MANAGER.addJmeTask(() -> + getCursorNode().addControl(getToolControl())); } @Override @FxThread public void notifyHided() { setShowed(false); - EXECUTOR_MANAGER.addJmeTask(() -> getCursorNode().removeControl(getToolControl())); + EXECUTOR_MANAGER.addJmeTask(() -> + getCursorNode().removeControl(getToolControl())); } /** - * Is showed boolean. + * Return true if this component is showed. * * @return true if this component is showed. */ @@ -344,25 +221,29 @@ protected boolean isShowed() { } /** - * Sets showed. + * Set true if this component is showed. * * @param showed true if this component is showed. */ @FxThread - protected void setShowed(final boolean showed) { + protected void setShowed(boolean showed) { this.showed = showed; } /** - * @param ignoreListeners the flag of ignoring listeners. + * Set true of need to ignore listeners + * + * @param ignoreListeners true of need to ignore listeners */ @FxThread - protected void setIgnoreListeners(final boolean ignoreListeners) { + protected void setIgnoreListeners(boolean ignoreListeners) { this.ignoreListeners = ignoreListeners; } /** - * @return the flag of ignoring listeners. + * Return true of need to ignore listeners + * + * @return true of need to ignore listeners */ @FxThread protected boolean isIgnoreListeners() { diff --git a/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingStateWithEditorTool.java b/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingStateWithEditorTool.java index 598b0005..f9102328 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingStateWithEditorTool.java +++ b/src/main/java/com/ss/editor/ui/component/painting/impl/AbstractPaintingStateWithEditorTool.java @@ -59,8 +59,8 @@ public float getBrushSize() { } @FxThread - public void setBrushSize(final float brushSize) { - final boolean changed = abs(getBrushSize() - brushSize) > 0.001f; + public void setBrushSize(float brushSize) { + var changed = abs(getBrushSize() - brushSize) > 0.001f; this.brushSize = brushSize; if (changed) notifyChange(); } @@ -71,8 +71,8 @@ public float getBrushPower() { } @FxThread - public void setBrushPower(final float brushPower) { - final boolean changed = abs(getBrushPower() - brushPower) > 0.001f; + public void setBrushPower(float brushPower) { + var changed = abs(getBrushPower() - brushPower) > 0.001f; this.brushPower = brushPower; if (changed) notifyChange(); } diff --git a/src/main/java/com/ss/editor/ui/component/painting/property/PaintingPropertyDefinition.java b/src/main/java/com/ss/editor/ui/component/painting/property/PaintingPropertyDefinition.java index 4927406c..c00dbe9a 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/property/PaintingPropertyDefinition.java +++ b/src/main/java/com/ss/editor/ui/component/painting/property/PaintingPropertyDefinition.java @@ -16,13 +16,30 @@ public class PaintingPropertyDefinition extends PropertyDefinition { @NotNull private final String category; - public PaintingPropertyDefinition(@NotNull final String category, @NotNull final EditablePropertyType propertyType, - @NotNull final String name, @NotNull final String id, - @Nullable final Object defaultValue) { + public PaintingPropertyDefinition( + @NotNull String category, + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @Nullable Object defaultValue + ) { super(propertyType, name, id, defaultValue); this.category = category; } + public PaintingPropertyDefinition( + @NotNull String category, + @NotNull EditablePropertyType propertyType, + @NotNull String name, + @NotNull String id, + @Nullable Object defaultValue, + float min, + float max + ) { + super(propertyType, name, id, defaultValue, min, max); + this.category = category; + } + /** * Get the category. * diff --git a/src/main/java/com/ss/editor/ui/component/painting/property/PropertiesBasedPaintingComponent.java b/src/main/java/com/ss/editor/ui/component/painting/property/PropertiesBasedPaintingComponent.java index 3c851590..db8207ae 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/property/PropertiesBasedPaintingComponent.java +++ b/src/main/java/com/ss/editor/ui/component/painting/property/PropertiesBasedPaintingComponent.java @@ -1,24 +1,27 @@ package com.ss.editor.ui.component.painting.property; +import static com.ss.editor.extension.property.EditablePropertyType.FLOAT; +import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.control.painting.PaintingControl; +import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.plugin.api.property.control.PropertyEditorControl; import com.ss.editor.plugin.api.property.control.PropertyEditorControlFactory; import com.ss.editor.ui.component.painting.PaintingComponentContainer; import com.ss.editor.ui.component.painting.impl.AbstractPaintingComponent; import com.ss.editor.ui.component.painting.impl.AbstractPaintingStateWithEditorTool; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; -import javafx.collections.ObservableList; -import javafx.scene.Node; -import javafx.scene.layout.GridPane; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; +import java.util.function.Function; + /** * The properties based implementation of painting component. * @@ -27,17 +30,35 @@ * @param the painting control's type. * @author JavaSaBr */ -public abstract class PropertiesBasedPaintingComponent extends - AbstractPaintingComponent { +public abstract class PropertiesBasedPaintingComponent extends AbstractPaintingComponent { - @NotNull - protected static final Array EMPTY_PROPERTIES = ArrayFactory.newArray(PaintingPropertyDefinition.class); + private static final String PROPERTY_BRUSH_SIZE = "brushSize"; + private static final String PROPERTY_BRUSH_POWER = "brushPower"; + + protected static final Array EMPTY_PROPERTIES = + ArrayFactory.newArray(PaintingPropertyDefinition.class); + + protected static class AdditionalPropertyContainer extends VBox { + + private final String category; + + public AdditionalPropertyContainer(@NotNull String category) { + this.category = category; + } + } /** * The map of category to properties container. */ @NotNull - private ObjectDictionary propertyContainers; + private ObjectDictionary propertyContainers; + + /** + * The container of brush settings. + */ + @NotNull + private VBox brushSettings; /** * The property variables. @@ -45,7 +66,7 @@ public abstract class PropertiesBasedPaintingComponent containerFactory = this::createContainer; + Runnable callback = this::syncValues; + + for (var definition : getBrushProperties()) { + var control = PropertyEditorControlFactory.build(vars, definition, callback); + FxUtils.addChild(brushSettings, control); + } - final Runnable callback = this::syncValues; - final GridPane settings = createBrushSettings(); + FxUtils.addChild(this, brushSettings); - for (final PaintingPropertyDefinition definition : getPaintingProperties()) { - final PropertyEditorControl control = PropertyEditorControlFactory.build(vars, definition, callback); - final VBox container = propertyContainers.get(definition.getCategory(), this::createContainer); - FXUtils.addToPane(control, container); + for (var definition : getPaintingProperties()) { + var control = PropertyEditorControlFactory.build(vars, definition, callback); + var container = propertyContainers.get(definition.getCategory(), containerFactory); + FxUtils.addChild(container, control); } - FXUtils.addToPane(settings, this); + propertyContainers.forEach((category, propertyContainer) -> + FxUtils.addChild(this, propertyContainer)); } @Override @FxThread - protected void readState(@NotNull final S state) { + protected void readState(@NotNull S state) { super.readState(state); + readState(state, getVars()); refreshPropertyControls(); syncValues(); } + @FxThread + protected void readState(@NotNull S state, @NotNull VarTable vars) { + vars.set(PROPERTY_BRUSH_POWER, state.getBrushPower()); + vars.set(PROPERTY_BRUSH_SIZE, state.getBrushSize()); + } + /** * Refresh property controls. */ @FxThread protected void refreshPropertyControls() { + + brushSettings.getChildren() + .stream() + .map(node -> (PropertyEditorControl) node) + .forEach(PropertyEditorControl::reload); + propertyContainers.forEach(container -> container.getChildren() - .stream().map(node -> (PropertyEditorControl) node) + .stream() + .map(node -> (PropertyEditorControl) node) .forEach(PropertyEditorControl::reload)); } @@ -93,10 +137,15 @@ protected void refreshPropertyControls() { * @param category the category. */ @FxThread - protected void showCategory(@NotNull final String category) { - final ObservableList children = getChildren(); - children.removeIf(VBox.class::isInstance); - children.add(propertyContainers.get(category)); + protected void showCategory(@NotNull String category) { + getChildren().stream() + .filter(AdditionalPropertyContainer.class::isInstance) + .peek(node -> node.setManaged(false)) + .peek(node -> node.setVisible(false)) + .map(AdditionalPropertyContainer.class::cast) + .filter(container -> container.category.equals(category)) + .peek(container -> container.setManaged(true)) + .forEach(container -> container.setVisible(true)); } /** @@ -114,7 +163,39 @@ protected void showCategory(@NotNull final String category) { */ @FxThread protected void syncValues() { + syncValues(getVars(), getState()); + } + /** + * Synchronize values from properties. + * + * @param vars the variable's table. + * @param state the state. + */ + @FxThread + protected void syncValues(@NotNull VarTable vars, @NotNull S state) { + + var brushSize = vars.getFloat(PROPERTY_BRUSH_SIZE); + var brushPower = vars.getFloat(PROPERTY_BRUSH_POWER); + + state.setBrushPower(brushPower); + state.setBrushSize(brushSize); + + var toolControl = getToolControl(); + + EXECUTOR_MANAGER.addJmeTask(() -> syncValues(state, toolControl)); + } + + /** + * Synchronize values from properties with the current tool control. + * + * @param state the state. + * @param toolControl the tool control. + */ + @JmeThread + protected void syncValues(@NotNull S state, @NotNull C toolControl) { + toolControl.setBrushPower(state.getBrushPower()); + toolControl.setBrushSize(state.getBrushSize()); } /** @@ -123,8 +204,25 @@ protected void syncValues() { * @param category the category. */ @FxThread - private VBox createContainer(@NotNull final String category) { - return new VBox(); + private AdditionalPropertyContainer createContainer(@NotNull String category) { + return new AdditionalPropertyContainer(category); + } + + /** + * Get the list of brush properties. + * + * @return the list of brush properties. + */ + @FxThread + protected @NotNull Array getBrushProperties() { + + var result = ArrayFactory.newArray(PropertyDefinition.class); + result.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_BRUSH_SIZE, + PROPERTY_BRUSH_SIZE, 1F, 0.0001F, Integer.MAX_VALUE)); + result.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_BRUSH_POWER, + PROPERTY_BRUSH_POWER, 1F, 0.0001F, Integer.MAX_VALUE)); + + return result; } /** diff --git a/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingComponent.java b/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingComponent.java index 6cb3cabb..163d1f9b 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingComponent.java +++ b/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingComponent.java @@ -1,13 +1,14 @@ package com.ss.editor.ui.component.painting.spawn; import static com.ss.editor.extension.property.EditablePropertyType.*; -import com.jme3.asset.AssetManager; +import com.jme3.asset.AssetNotFoundException; import com.jme3.math.Vector3f; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.control.painting.spawn.SpawnToolControl; import com.ss.editor.control.painting.spawn.SpawnToolControl.SpawnMethod; import com.ss.editor.ui.Icons; @@ -16,9 +17,9 @@ import com.ss.editor.ui.component.painting.property.PropertiesBasedPaintingComponent; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,17 +31,22 @@ * * @author JavaSaBr */ -public class SpawnPaintingComponent extends PropertiesBasedPaintingComponent { +public class SpawnPaintingComponent extends + PropertiesBasedPaintingComponent { + + private static final SpawnMethod[] SPAWN_METHODS = SpawnMethod.values(); private static final String CATEGORY_DEFAULT = "Default"; private static final String PROPERTY_MODEL = "model"; private static final String PROPERTY_METHOD = "method"; - private static final String PROPERTY_SCALE = "scale"; + private static final String PROPERTY_MIN_SCALE = "minScale"; + private static final String PROPERTY_MAX_SCALE = "maxScale"; + private static final String PROPERTY_PADDING = "padding"; public static final int AVAILABLE_MODELS = 10; - public SpawnPaintingComponent(@NotNull final PaintingComponentContainer container) { + public SpawnPaintingComponent(@NotNull PaintingComponentContainer container) { super(container); setToolControl(new SpawnToolControl(this)); showCategory(CATEGORY_DEFAULT); @@ -50,80 +56,103 @@ public SpawnPaintingComponent(@NotNull final PaintingComponentContainer containe @FxThread protected @NotNull Array getPaintingProperties() { - final Array result = ArrayFactory.newArray(PaintingPropertyDefinition.class); + var result = ArrayFactory.newArray(PaintingPropertyDefinition.class); result.add(new PaintingPropertyDefinition(CATEGORY_DEFAULT, ENUM, - Messages.PAINTING_COMPONENT_METHOD, PROPERTY_METHOD, SpawnMethod.BATCH)); + Messages.MODEL_PROPERTY_METHOD, PROPERTY_METHOD, SpawnMethod.BATCH)); + result.add(new PaintingPropertyDefinition(CATEGORY_DEFAULT, VECTOR_3F, + Messages.MODEL_PROPERTY_MIN_SCALE, PROPERTY_MIN_SCALE, new Vector3f(1F, 1F, 1F))); + result.add(new PaintingPropertyDefinition(CATEGORY_DEFAULT, VECTOR_3F, + Messages.MODEL_PROPERTY_MAX_SCALE, PROPERTY_MAX_SCALE, new Vector3f(1F, 1F, 1F))); result.add(new PaintingPropertyDefinition(CATEGORY_DEFAULT, VECTOR_3F, - Messages.PAINTING_COMPONENT_SCALE, PROPERTY_SCALE, new Vector3f(1F, 1F, 1F))); + Messages.MODEL_PROPERTY_PADDING, PROPERTY_PADDING, new Vector3f(1F, 1F, 1F))); for (int i = 1; i <= AVAILABLE_MODELS; i++) { result.add(new PaintingPropertyDefinition(CATEGORY_DEFAULT, SPATIAL_FROM_ASSET_FOLDER, - Messages.PAINTING_COMPONENT_MODEL + " " + "#" + i, PROPERTY_MODEL + "_" + i, null)); + Messages.MODEL_PROPERTY_MODEL + " " + "#" + i, PROPERTY_MODEL + "_" + i, null)); } return result; } @Override - protected void syncValues() { - super.syncValues(); + @FxThread + protected void syncValues(@NotNull VarTable vars, @NotNull SpawnPaintingStateWithEditorTool state) { - final VarTable vars = getVars(); - final SpawnToolControl toolControl = getToolControl(); + var toolControl = getToolControl(); - final Array examples = ArrayFactory.newArray(Spatial.class); - final String[] selectedModels = new String[AVAILABLE_MODELS]; + var examples = ArrayFactory.newArray(Spatial.class); + var selectedModels = new String[AVAILABLE_MODELS]; - for (int i = 1; i <= AVAILABLE_MODELS; i++) { + for (var i = 1; i <= AVAILABLE_MODELS; i++) { - final String id = PROPERTY_MODEL + "_" + i; + var id = PROPERTY_MODEL + "_" + i; if (!vars.has(id)) { selectedModels[i - 1] = null; continue; } - final Spatial spatial = vars.get(id); + var spatial = vars.get(id, Spatial.class); + examples.add(spatial); - selectedModels[i - 1] = spatial.getKey().getName(); + + selectedModels[i - 1] = spatial.getKey() + .getName(); } - final SpawnMethod method = vars.get(PROPERTY_METHOD); - final Vector3f scale = vars.get(PROPERTY_SCALE); + var method = vars.getEnum(PROPERTY_METHOD, SpawnMethod.class); + var minScale = vars.get(PROPERTY_MIN_SCALE, Vector3f.class); + var maxScale = vars.get(PROPERTY_MAX_SCALE, Vector3f.class); + var padding = vars.get(PROPERTY_PADDING, Vector3f.class); - final SpawnPaintingStateWithEditorTool state = getState(); state.setMethod(method.ordinal()); - state.setScale(scale); + state.setMinScale(minScale); + state.setMaxScale(maxScale); + state.setPadding(padding); state.setSelectedModels(selectedModels); - EXECUTOR_MANAGER.addJmeTask(() -> { - toolControl.setMethod(method); - toolControl.setScale(scale); - toolControl.updateExamples(examples); - }); + super.syncValues(vars, state); + + EXECUTOR_MANAGER.addJmeTask(() -> + toolControl.updateExamples(examples)); } @Override - @FxThread - protected void readState(@NotNull final SpawnPaintingStateWithEditorTool state) { + @JmeThread + protected void syncValues(@NotNull SpawnPaintingStateWithEditorTool state, @NotNull SpawnToolControl toolControl) { + super.syncValues(state, toolControl); + toolControl.setMethod(SpawnMethod.valueOf(state.getMethod())); + toolControl.setMinScale(state.getMinScale()); + toolControl.setMaxScale(state.getMaxScale()); + toolControl.setPadding(state.getPadding()); + } - final int method = state.getMethod(); - final String[] selectedModels = state.getSelectedModels(); + @Override + protected void readState(@NotNull SpawnPaintingStateWithEditorTool state, @NotNull VarTable vars) { + super.readState(state, vars); - final VarTable vars = getVars(); - vars.set(PROPERTY_METHOD, SpawnMethod.values()[method]); - vars.set(PROPERTY_SCALE, state.getScale()); + var method = state.getMethod(); + var selectedModels = state.getSelectedModels(); - final AssetManager assetManager = EditorUtil.getAssetManager(); + vars.set(PROPERTY_METHOD, SPAWN_METHODS[method]); + vars.set(PROPERTY_MIN_SCALE, state.getMinScale()); + vars.set(PROPERTY_MAX_SCALE, state.getMaxScale()); + vars.set(PROPERTY_PADDING, state.getPadding()); + + var assetManager = EditorUtil.getAssetManager(); for (int i = 1; i <= AVAILABLE_MODELS; i++) { - final String selectedModel = selectedModels[i - 1]; + + var selectedModel = selectedModels[i - 1]; if (selectedModel == null) { continue; } - vars.set(PROPERTY_MODEL + "_" + i, assetManager.loadModel(selectedModel)); - } - super.readState(state); + try { + vars.set(PROPERTY_MODEL + "_" + i, assetManager.loadModel(selectedModel)); + } catch (AssetNotFoundException e) { + LOGGER.warning(this, e); + } + } } @Override @@ -140,7 +169,7 @@ protected void readState(@NotNull final SpawnPaintingStateWithEditorTool state) @Override @FxThread - public boolean isSupport(@NotNull final Object object) { + public boolean isSupport(@NotNull Object object) { return object instanceof Node && NodeUtils.findGeometry((Spatial) object) != null; } @@ -156,10 +185,4 @@ public boolean isSupport(@NotNull final Object object) { public @Nullable Image getIcon() { return Icons.FOREST_16; } - - @Override - @FxThread - public void notifyChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { - - } } diff --git a/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingStateWithEditorTool.java b/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingStateWithEditorTool.java index bacb17a3..1bf5340f 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingStateWithEditorTool.java +++ b/src/main/java/com/ss/editor/ui/component/painting/spawn/SpawnPaintingStateWithEditorTool.java @@ -18,7 +18,7 @@ public class SpawnPaintingStateWithEditorTool extends AbstractPaintingStateWithE /** * The constant serialVersionUID. */ - public static final long serialVersionUID = 3; + public static final long serialVersionUID = 4; /** * The selected models. @@ -27,10 +27,22 @@ public class SpawnPaintingStateWithEditorTool extends AbstractPaintingStateWithE private String[] selectedModels; /** - * The models scale. + * The models min scale. */ @NotNull - private Vector3f scale; + private Vector3f minScale; + + /** + * The models max scale. + */ + @NotNull + private Vector3f maxScale; + + /** + * The models padding. + */ + @NotNull + private Vector3f padding; /** * The spawn method. @@ -40,7 +52,9 @@ public class SpawnPaintingStateWithEditorTool extends AbstractPaintingStateWithE public SpawnPaintingStateWithEditorTool() { this.method = SpawnMethod.BATCH.ordinal(); this.selectedModels = new String[SpawnPaintingComponent.AVAILABLE_MODELS]; - this.scale = new Vector3f(Vector3f.UNIT_XYZ); + this.minScale = Vector3f.UNIT_XYZ.clone(); + this.maxScale = Vector3f.UNIT_XYZ.clone(); + this.padding = Vector3f.ZERO.clone(); } /** @@ -49,7 +63,7 @@ public SpawnPaintingStateWithEditorTool() { * @param method the spawn method. */ @FxThread - public void setMethod(final int method) { + public void setMethod(int method) { final boolean changed = getMethod() != method; this.method = method; if (changed) notifyChange(); @@ -66,23 +80,69 @@ public int getMethod() { } /** - * Get the models scale. + * Set the models min scale. + * + * @param minScale the models min scale. + */ + @FxThread + public void setMinScale(@NotNull Vector3f minScale) { + final boolean changed = !minScale.equals(getMinScale()); + this.minScale = minScale; + if (changed) notifyChange(); + } + + /** + * Set the models max scale. + * + * @param maxScale the models max scale. + */ + @FxThread + public void setMaxScale(@NotNull Vector3f maxScale) { + final boolean changed = !maxScale.equals(getMaxScale()); + this.maxScale = maxScale; + if (changed) notifyChange(); + } + + /** + * Set the models padding. + * + * @param padding the models padding. + */ + @FxThread + public void setPadding(@NotNull Vector3f padding) { + final boolean changed = !padding.equals(getPadding()); + this.padding = padding; + if (changed) notifyChange(); + } + + /** + * Get the models min scale. + * + * @return the models min scale. + */ + @FxThread + public @NotNull Vector3f getMinScale() { + return minScale; + } + + /** + * Get the models max scale. * - * @param scale the models scale. + * @return the models max scale. */ @FxThread - public void setScale(@NotNull final Vector3f scale) { - this.scale = scale; + public @NotNull Vector3f getMaxScale() { + return maxScale; } /** - * Set the models scale. + * Get the models padding. * - * @return the models scale. + * @return the models padding. */ @FxThread - public @NotNull Vector3f getScale() { - return scale; + public @NotNull Vector3f getPadding() { + return padding; } /** @@ -91,7 +151,7 @@ public void setScale(@NotNull final Vector3f scale) { * @param selectedModels the selected models. */ @FxThread - public void setSelectedModels(@NotNull final String[] selectedModels) { + public void setSelectedModels(@NotNull String[] selectedModels) { final boolean changed = !Arrays.equals(getSelectedModels(), selectedModels); this.selectedModels = selectedModels; if (changed) notifyChange(); diff --git a/src/main/java/com/ss/editor/ui/component/painting/terrain/TerrainPaintingComponent.java b/src/main/java/com/ss/editor/ui/component/painting/terrain/TerrainPaintingComponent.java index b616dd26..ba6d7057 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/terrain/TerrainPaintingComponent.java +++ b/src/main/java/com/ss/editor/ui/component/painting/terrain/TerrainPaintingComponent.java @@ -1,12 +1,11 @@ package com.ss.editor.ui.component.painting.terrain; +import static com.ss.editor.extension.property.EditablePropertyType.BOOLEAN; +import static com.ss.editor.extension.property.EditablePropertyType.FLOAT; import static com.ss.editor.ui.component.painting.PaintingComponentContainer.FIELD_PERCENT; import static com.ss.editor.ui.component.painting.PaintingComponentContainer.LABEL_PERCENT; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayFactory.toArray; -import com.jme3.material.MatParam; -import com.jme3.material.Material; -import com.jme3.material.MaterialDef; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayFactory.toArray; import com.jme3.scene.Node; import com.jme3.terrain.Terrain; import com.jme3.terrain.geomipmap.TerrainQuad; @@ -16,24 +15,24 @@ import com.ss.editor.annotation.JmeThread; import com.ss.editor.control.painting.terrain.*; import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.Icons; -import com.ss.editor.ui.component.editor.state.EditorState; import com.ss.editor.ui.component.painting.PaintingComponentContainer; -import com.ss.editor.ui.component.painting.impl.AbstractPaintingComponent; +import com.ss.editor.ui.component.painting.property.PaintingPropertyDefinition; +import com.ss.editor.ui.component.painting.property.PropertiesBasedPaintingComponent; import com.ss.editor.ui.component.painting.terrain.paint.TextureLayerSettings; import com.ss.editor.ui.control.property.operation.PropertyOperation; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.MaterialUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; -import javafx.collections.ObservableList; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.CheckBox; @@ -42,8 +41,6 @@ import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane; -import javafx.scene.layout.Pane; -import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,14 +52,29 @@ * * @author JavaSaBr */ -public class TerrainPaintingComponent extends AbstractPaintingComponent { +public class TerrainPaintingComponent extends + PropertiesBasedPaintingComponent { - /** - * The constant TERRAIN_PARAM. - */ - @NotNull public static final String TERRAIN_PARAM = "terrainParam"; + private static final String CATEGORY_RAISE_LOWER = "RaiseLower"; + private static final String CATEGORY_ROUGH = "Rough"; + private static final String CATEGORY_SLOPE = "Slope"; + private static final String CATEGORY_LEVEL = "Level"; + private static final String CATEGORY_SMOOTH = "Smooth"; + private static final String CATEGORY_PAINT = "Paint"; + + private static final String PROPERTY_SLOPE_SMOOTHLY = "slope.smoothly"; + private static final String PROPERTY_SLOPE_LIMITED = "slope.limited"; + private static final String PROPERTY_LEVEL_SMOOTHLY = "level.smoothly"; + private static final String PROPERTY_LEVEL_USE_MARKER = "level.useMarker"; + private static final String PROPERTY_LEVEL_VALUE = "level.level"; + private static final String PROPERTY_ROUGH_ROUGHNESS = "rough.roughness"; + private static final String PROPERTY_ROUGH_FREQUENCY = "rough.frequency"; + private static final String PROPERTY_ROUGH_LACUNARITY = "rough.lacunarity"; + private static final String PROPERTY_ROUGH_OCTAVES = "rough.octaves"; + private static final String PROPERTY_ROUGH_SCALE = "rough.scale"; + @NotNull private static final Function LAYER_TO_SCALE_NAME = layer -> "DiffuseMap_" + layer + "_scale"; @@ -119,10 +131,11 @@ public class TerrainPaintingComponent extends AbstractPaintingComponent buttonToControl; /** - * The map with mapping toggle button to its settings. + * The map with mapping toggle button to properties category. */ @NotNull - private final ObjectDictionary buttonToSettings; + private final ObjectDictionary buttonToCategory; + /** * The control to raise/lowe terrain. @@ -196,90 +209,6 @@ public class TerrainPaintingComponent extends AbstractPaintingComponent getPaintingProperties() { + + var result = ArrayFactory.newArray(PaintingPropertyDefinition.class); + + result.add(new PaintingPropertyDefinition(CATEGORY_SLOPE, BOOLEAN, Messages.MODEL_PROPERTY_SMOOTHLY, + PROPERTY_SLOPE_SMOOTHLY, false)); + result.add(new PaintingPropertyDefinition(CATEGORY_SLOPE, BOOLEAN, Messages.MODEL_PROPERTY_LIMITED, + PROPERTY_SLOPE_LIMITED, false)); + + result.add(new PaintingPropertyDefinition(CATEGORY_ROUGH, FLOAT, Messages.MODEL_PROPERTY_ROUGHNESS, + PROPERTY_ROUGH_ROUGHNESS, 0F, 0F, Integer.MAX_VALUE)); + result.add(new PaintingPropertyDefinition(CATEGORY_ROUGH, FLOAT, Messages.MODEL_PROPERTY_FREQUENCY, + PROPERTY_ROUGH_FREQUENCY, 0F, 0.1F, Integer.MAX_VALUE)); + result.add(new PaintingPropertyDefinition(CATEGORY_ROUGH, FLOAT, Messages.MODEL_PROPERTY_LACUNARITY, + PROPERTY_ROUGH_LACUNARITY, 0F, 1.1F, Integer.MAX_VALUE)); + result.add(new PaintingPropertyDefinition(CATEGORY_ROUGH, FLOAT, Messages.MODEL_PROPERTY_OCTAVES, + PROPERTY_ROUGH_OCTAVES, 0F, 0F, Integer.MAX_VALUE)); + result.add(new PaintingPropertyDefinition(CATEGORY_ROUGH, FLOAT, Messages.MODEL_PROPERTY_MIN_SCALE, + PROPERTY_ROUGH_SCALE, 0F, 0F, Integer.MAX_VALUE)); + + result.add(new PaintingPropertyDefinition(CATEGORY_LEVEL, FLOAT, Messages.MODEL_PROPERTY_LEVEL, + PROPERTY_LEVEL_VALUE, 1F, 0F, Integer.MAX_VALUE)); + result.add(new PaintingPropertyDefinition(CATEGORY_LEVEL, BOOLEAN, Messages.MODEL_PROPERTY_SMOOTHLY, + PROPERTY_LEVEL_SMOOTHLY, false)); + result.add(new PaintingPropertyDefinition(CATEGORY_LEVEL, BOOLEAN, Messages.MODEL_PROPERTY_USE_MARKER, + PROPERTY_LEVEL_USE_MARKER, false)); + + return result; } /** @@ -401,23 +353,13 @@ public void loadState(@NotNull final EditorState editorState) { } /** - * Get the map with mapping toggle button to its settings. + * Get the map with mapping toggle button to properties category. * - * @return the map with mapping toggle button to its settings. + * @return the map with mapping toggle button to properties category. */ @FxThread - private @NotNull ObjectDictionary getButtonToSettings() { - return buttonToSettings; - } - - /** - * Get the container of control settings. - * - * @return the container of control settings. - */ - @FxThread - private @NotNull VBox getControlSettings() { - return notNull(controlSettings); + private @NotNull ObjectDictionary getButtonToCategory() { + return buttonToCategory; } /** @@ -483,7 +425,6 @@ public void loadState(@NotNull final EditorState editorState) { @Override @FxThread protected void createComponents() { - super.createComponents(); raiseLowerButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_UP_32)); raiseLowerButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); @@ -503,7 +444,7 @@ protected void createComponents() { paintButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_PAINT_32)); paintButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); - final GridPane buttonsContainer = new GridPane(); + var buttonsContainer = new GridPane(); buttonsContainer.setAlignment(Pos.CENTER); buttonsContainer.setPadding(new Insets(2, 4, 2, 4)); buttonsContainer.add(raiseLowerButton, 0, 0); @@ -514,172 +455,86 @@ protected void createComponents() { buttonsContainer.add(paintButton, 5, 0); buttonsContainer.prefWidthProperty().bind(widthProperty()); - FXUtils.addClassTo(buttonsContainer, CssClasses.DEF_GRID_PANE); - - controlSettings = new VBox(); - controlSettings.prefWidthProperty().bind(widthProperty()); + FxUtils.addChild(this, buttonsContainer); - FXUtils.addToPane(buttonsContainer, this); - FXUtils.addToPane(createBrushSettings(), this); - FXUtils.addToPane(controlSettings, this); + super.createComponents(); - createLevelControlSettings(); - createSlopeControlSettings(); - createRoughControlSettings(); createPaintControlSettings(); - FXUtils.addClassesTo(raiseLowerButton, smoothButton, roughButton, levelButton, slopeButton, paintButton, - CssClasses.MEDIUM_TOGGLE_BUTTON); - - FXUtils.addClassTo(controlSettings, CssClasses.DEF_VBOX); + FxUtils.addClass(raiseLowerButton, smoothButton, roughButton, CssClasses.MEDIUM_TOGGLE_BUTTON) + .addClass(levelButton, slopeButton, paintButton, CssClasses.MEDIUM_TOGGLE_BUTTON) + .addClass(buttonsContainer, CssClasses.DEF_GRID_PANE); } - /** - * Create settings of slope control. - */ - @FxThread - private void createSlopeControlSettings() { + @Override + protected void readState(@NotNull TerrainPaintingStateWithEditorTool state, @NotNull VarTable vars) { + super.readState(state, vars); + + vars.set(PROPERTY_SLOPE_LIMITED, state.isSlopeLimited()); + vars.set(PROPERTY_SLOPE_SMOOTHLY, state.isSlopeSmoothly()); + vars.set(PROPERTY_LEVEL_VALUE, state.getLevelValue()); + vars.set(PROPERTY_LEVEL_SMOOTHLY, state.isLevelSmoothly()); + vars.set(PROPERTY_LEVEL_USE_MARKER, state.isLevelUseMarker()); + } - final Label smoothlyLabel = new Label(Messages.PAINTING_COMPONENT_SMOOTHLY + ":"); - smoothlyLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); + @Override + protected void syncValues(@NotNull VarTable vars, @NotNull TerrainPaintingStateWithEditorTool state) { + + var slopeLimited = vars.getBoolean(PROPERTY_SLOPE_LIMITED); + var slopeSmoothly = vars.getBoolean(PROPERTY_SLOPE_SMOOTHLY); + var levelUseMarker = vars.getBoolean(PROPERTY_LEVEL_USE_MARKER); + var levelSmoothly = vars.getBoolean(PROPERTY_LEVEL_SMOOTHLY); + var levelValue = vars.getFloat(PROPERTY_LEVEL_VALUE); + var roughFrequency = vars.getFloat(PROPERTY_ROUGH_FREQUENCY); + var roughLacunarity = vars.getFloat(PROPERTY_ROUGH_LACUNARITY); + var roughRoughness = vars.getFloat(PROPERTY_ROUGH_ROUGHNESS); + var roughScale = vars.getFloat(PROPERTY_ROUGH_SCALE); + var roughOctaves = vars.getFloat(PROPERTY_ROUGH_OCTAVES); + + state.setSlopeLimited(slopeLimited); + state.setSlopeSmoothly(slopeSmoothly); + state.setLevelSmoothly(levelSmoothly); + state.setLevelUseMarker(levelUseMarker); + state.setLevelValue(levelValue); + state.setRoughtFrequency(roughFrequency); + state.setRoughtLacunarity(roughLacunarity); + state.setRoughtScale(roughScale); + state.setRoughtOctaves(roughOctaves); + state.setRoughtRoughness(roughRoughness); + + super.syncValues(vars, state); + } - slopeControlSmoothly = new CheckBox(); - slopeControlSmoothly.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - slopeControlSmoothly.selectedProperty() - .addListener((observable, oldValue, newValue) -> changeSlopeControlSmoothly(newValue)); + @Override + @JmeThread + protected void syncValues( + @NotNull TerrainPaintingStateWithEditorTool state, + @NotNull TerrainToolControl toolControl) { - final Label limitedLabel = new Label(Messages.PAINTING_COMPONENT_LIMITED + ":"); - limitedLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); + var brushPower = state.getBrushPower(); + var brushSize = state.getBrushSize(); - slopeControlLimited = new CheckBox(); - slopeControlLimited.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - slopeControlLimited.selectedProperty() - .addListener((observable, oldValue, newValue) -> changeSlopeControlLimited(newValue)); + var toolControls = getToolControls(); + toolControls.forEach(brushSize, TerrainToolControl::setBrushSize); + toolControls.forEach(brushPower, TerrainToolControl::setBrushPower); - slopeControlSettings = new GridPane(); - slopeControlSettings.add(smoothlyLabel, 0, 0); - slopeControlSettings.add(slopeControlSmoothly, 1, 0); - slopeControlSettings.add(limitedLabel, 0, 1); - slopeControlSettings.add(slopeControlLimited, 1, 1); + var slopeToolControl = getSlopeToolControl(); + slopeToolControl.setLock(state.isSlopeLimited()); + slopeToolControl.setPrecision(state.isSlopeSmoothly()); - FXUtils.addClassTo(slopeControlSettings, CssClasses.DEF_GRID_PANE); - FXUtils.addClassTo(smoothlyLabel, limitedLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); - FXUtils.addClassTo(slopeControlSmoothly, slopeControlLimited, CssClasses.ABSTRACT_PARAM_CONTROL_CHECK_BOX); - } + var levelToolControl = getLevelToolControl(); + levelToolControl.setLevel(state.getLevelValue()); + levelToolControl.setPrecision(state.isLevelSmoothly()); + levelToolControl.setUseMarker(state.isLevelUseMarker()); - /** - * Create settings of level control. - */ - @FxThread - private void createLevelControlSettings() { - - final Label smoothlyLabel = new Label(Messages.PAINTING_COMPONENT_SMOOTHLY + ":"); - smoothlyLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - levelControlSmoothly = new CheckBox(); - levelControlSmoothly.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - levelControlSmoothly.selectedProperty() - .addListener((observable, oldValue, newValue) -> changeLevelControlSmoothly(newValue)); - - final Label useMarkerLabel = new Label(Messages.PAINTING_COMPONENT_USE_MARKER + ":"); - useMarkerLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - levelControlUseMarker = new CheckBox(); - levelControlUseMarker.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - levelControlUseMarker.selectedProperty() - .addListener((observable, oldValue, newValue) -> changeLevelControlUseMarker(newValue)); - - final Label levelLabel = new Label(Messages.PAINTING_COMPONENT_LEVEL + ":"); - levelLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - levelControlLevelField = new FloatTextField(); - levelControlLevelField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - levelControlLevelField.setMinMax(0F, Integer.MAX_VALUE); - levelControlLevelField.addChangeListener((observable, oldValue, newValue) -> changeLevelControlLevel(newValue)); - levelControlLevelField.disableProperty() - .bind(levelControlUseMarker.selectedProperty()); - - levelControlSettings = new GridPane(); - levelControlSettings.add(smoothlyLabel, 0, 0); - levelControlSettings.add(levelControlSmoothly, 1, 0); - levelControlSettings.add(useMarkerLabel, 0, 1); - levelControlSettings.add(levelControlUseMarker, 1, 1); - levelControlSettings.add(levelLabel, 0, 2); - levelControlSettings.add(levelControlLevelField, 1, 2); - - FXUtils.addClassTo(smoothlyLabel, useMarkerLabel, levelLabel, - CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); - - FXUtils.addClassesTo(levelControlSettings, CssClasses.DEF_GRID_PANE); - FXUtils.addClassTo(levelControlLevelField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addClassTo(levelControlSmoothly, levelControlUseMarker, CssClasses.ABSTRACT_PARAM_CONTROL_CHECK_BOX); - } + var roughToolControl = getRoughToolControl(); + roughToolControl.setFrequency(state.getRoughtFrequency()); + roughToolControl.setLacunarity(state.getRoughtLacunarity()); + roughToolControl.setOctaves(state.getRoughtOctaves()); + roughToolControl.setScale(state.getRoughtScale()); + roughToolControl.setRoughness(state.getRoughtRoughness()); - /** - * Create settings of rough control. - */ - @FxThread - private void createRoughControlSettings() { - - final Label roughnessLabel = new Label(Messages.PAINTING_COMPONENT_ROUGHNESS + ":"); - roughnessLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - roughControlRoughnessField = new FloatTextField(); - roughControlRoughnessField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - roughControlRoughnessField.setMinMax(0F, Integer.MAX_VALUE); - roughControlRoughnessField.addChangeListener((observable, oldValue, newValue) -> changeRoughControlRoughness(newValue)); - - final Label frequencyLabel = new Label(Messages.PAINTING_COMPONENT_FREQUENCY + ":"); - frequencyLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - roughControlFrequencyField = new FloatTextField(); - roughControlFrequencyField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - roughControlFrequencyField.setMinMax(0.1F, Integer.MAX_VALUE); - roughControlFrequencyField.addChangeListener((observable, oldValue, newValue) -> changeRoughControlFrequency(newValue)); - - final Label lacunarityLabel = new Label(Messages.PAINTING_COMPONENT_LACUNARITY + ":"); - lacunarityLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - roughControlLacunarityField = new FloatTextField(); - roughControlLacunarityField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - roughControlLacunarityField.setMinMax(1.1F, Integer.MAX_VALUE); - roughControlLacunarityField.addChangeListener((observable, oldValue, newValue) -> changeRoughControlLacunarity(newValue)); - - final Label octavesLabel = new Label(Messages.PAINTING_COMPONENT_OCTAVES + ":"); - octavesLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - roughControlOctavesField = new FloatTextField(); - roughControlOctavesField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - roughControlOctavesField.setMinMax(0F, Integer.MAX_VALUE); - roughControlOctavesField.addChangeListener((observable, oldValue, newValue) -> changeRoughControlOctaves(newValue)); - - final Label scaleLabel = new Label(Messages.PAINTING_COMPONENT_SCALE + ":"); - scaleLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); - - roughControlScaleField = new FloatTextField(); - roughControlScaleField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - roughControlScaleField.setMinMax(0F, Integer.MAX_VALUE); - roughControlScaleField.addChangeListener((observable, oldValue, newValue) -> changeRoughControlScale(newValue)); - - roughControlSettings = new GridPane(); - roughControlSettings.add(roughnessLabel, 0, 0); - roughControlSettings.add(roughControlRoughnessField, 1, 0); - roughControlSettings.add(frequencyLabel, 0, 1); - roughControlSettings.add(roughControlFrequencyField, 1, 1); - roughControlSettings.add(lacunarityLabel, 0, 2); - roughControlSettings.add(roughControlLacunarityField, 1, 2); - roughControlSettings.add(octavesLabel, 0, 3); - roughControlSettings.add(roughControlOctavesField, 1, 3); - roughControlSettings.add(scaleLabel, 0, 4); - roughControlSettings.add(roughControlScaleField, 1, 4); - - FXUtils.addClassTo(roughnessLabel, frequencyLabel, lacunarityLabel, octavesLabel, scaleLabel, - CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); - - - FXUtils.addClassesTo(roughControlSettings, CssClasses.DEF_GRID_PANE); - FXUtils.addClassTo(roughControlRoughnessField, roughControlFrequencyField, roughControlLacunarityField, - roughControlOctavesField, roughControlScaleField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); + super.syncValues(state, toolControl); } /** @@ -688,21 +543,24 @@ private void createRoughControlSettings() { @FxThread private void createPaintControlSettings() { - final Label triPlanarLabelLabel = new Label(Messages.PAINTING_COMPONENT_TRI_PLANAR + ":"); - triPlanarLabelLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); + var triPlanarLabelLabel = new Label(Messages.MODEL_PROPERTY_TRI_PLANAR + ":"); + triPlanarLabelLabel.prefWidthProperty() + .bind(widthProperty().multiply(LABEL_PERCENT)); triPlanarCheckBox = new CheckBox(); - triPlanarCheckBox.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); - triPlanarCheckBox.selectedProperty() - .addListener((observable, oldValue, newValue) -> changePaintControlTriPlanar(newValue)); + triPlanarCheckBox.prefWidthProperty() + .bind(widthProperty().multiply(FIELD_PERCENT)); - final Label shininessLabel = new Label(Messages.PAINTING_COMPONENT_SHININESS + ":"); + var shininessLabel = new Label(Messages.MODEL_PROPERTY_SHININESS + ":"); shininessLabel.prefWidthProperty().bind(widthProperty().multiply(LABEL_PERCENT)); shininessField = new FloatTextField(); - shininessField.prefWidthProperty().bind(widthProperty().multiply(FIELD_PERCENT)); shininessField.setMinMax(0F, Integer.MAX_VALUE); - shininessField.addChangeListener((observable, oldValue, newValue) -> changePaintControlShininess(newValue)); + shininessField.prefWidthProperty() + .bind(widthProperty().multiply(FIELD_PERCENT)); + + FxControlUtils.onSelectedChange(triPlanarCheckBox, this::changePaintControlTriPlanar); + FxControlUtils.onValueChange(shininessField, this::changePaintControlShininess); textureLayerSettings = new TextureLayerSettings(this); @@ -713,10 +571,10 @@ private void createPaintControlSettings() { paintControlSettings.add(triPlanarCheckBox, 1, 1); paintControlSettings.add(textureLayerSettings, 0, 2, 2, 1); - FXUtils.addClassesTo(paintControlSettings, CssClasses.DEF_GRID_PANE); - FXUtils.addClassTo(shininessLabel, triPlanarLabelLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); - FXUtils.addClassTo(triPlanarCheckBox, CssClasses.ABSTRACT_PARAM_CONTROL_CHECK_BOX); - FXUtils.addClassTo(shininessField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); + FxUtils.addClass(paintControlSettings, CssClasses.DEF_GRID_PANE) + .addClass(shininessLabel, triPlanarLabelLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW) + .addClass(triPlanarCheckBox, CssClasses.PROPERTY_CONTROL_CHECK_BOX) + .addClass(shininessField, CssClasses.PROPERTY_CONTROL_COMBO_BOX); } /** @@ -763,152 +621,46 @@ private void createPaintControlSettings() { * Change the shininess value. */ @FromAnyThread - private void changePaintControlShininess(@NotNull final Float newValue) { + private void changePaintControlShininess(@NotNull Float newValue) { if (isIgnoreListeners()) { return; } - final Node paintedObject = notNull(getPaintedObject()); - final Material material = NodeUtils.findMateial(paintedObject, mat -> mat.getParam("Shininess") != null); - final MatParam param = material == null ? null : material.getParam("Shininess"); - final float shininess = param == null ? 0F : (float) param.getValue(); + var paintedObject = notNull(getPaintedObject()); + var material = NodeUtils.findMateial(paintedObject, mat -> mat.getParam("Shininess") != null); + var param = material == null ? null : material.getParam("Shininess"); + var shininess = param == null ? 0F : (float) param.getValue(); - final PropertyOperation operation = - new PropertyOperation<>(paintedObject, TERRAIN_PARAM, newValue, shininess); + var operation = new PropertyOperation(paintedObject, TERRAIN_PARAM, + newValue, shininess); operation.setApplyHandler((terrainQuad, value) -> NodeUtils.visitMaterials(terrainQuad, mat -> MaterialUtils.safeSet(mat, "Shininess", value))); - final ModelChangeConsumer changeConsumer = getChangeConsumer(); - changeConsumer.execute(operation); + getChangeConsumer().execute(operation); } /** * Change using tri-planar textures. */ @FromAnyThread - private void changePaintControlTriPlanar(@NotNull final Boolean newValue) { + private void changePaintControlTriPlanar(@NotNull Boolean newValue) { if (isIgnoreListeners()) { return; } - final Node paintedObject = notNull(getPaintedObject()); - final PropertyOperation operation = - new PropertyOperation<>(paintedObject, TERRAIN_PARAM, newValue, !newValue); + var paintedObject = notNull(getPaintedObject()); + var operation = new PropertyOperation(paintedObject, TERRAIN_PARAM, + newValue, !newValue); operation.setApplyHandler((terrainQuad, value) -> NodeUtils.visitMaterials(terrainQuad, mat -> MaterialUtils.safeSet(mat, "useTriPlanarMapping", value))); - final ModelChangeConsumer changeConsumer = getChangeConsumer(); - changeConsumer.execute(operation); - } - - /** - * Change using smoothly editing. - */ - @FromAnyThread - private void changeLevelControlSmoothly(@NotNull final Boolean newValue) { - if (state != null) state.setLevelSmoothly(newValue); - EXECUTOR_MANAGER.addJmeTask(() -> getLevelToolControl().setPrecision(!newValue)); - } - - /** - * Change using marker for level control. - */ - @FromAnyThread - private void changeLevelControlUseMarker(@NotNull final Boolean newValue) { - if (state != null) state.setLevelUseMarker(newValue); - EXECUTOR_MANAGER.addJmeTask(() -> getLevelToolControl().setUseMarker(newValue)); - } - - /** - * Change a level of a level control. - */ - @FromAnyThread - private void changeLevelControlLevel(@NotNull final Float newLevel) { - if (state != null) state.setLevelValue(newLevel); - EXECUTOR_MANAGER.addJmeTask(() -> getLevelToolControl().setLevel(newLevel)); - } - - /** - * Change using smoothly editing. - */ - @FromAnyThread - private void changeSlopeControlSmoothly(@NotNull final Boolean newValue) { - if (state != null) state.setSlopeSmoothly(newValue); - EXECUTOR_MANAGER.addJmeTask(() -> getSlopeToolControl().setPrecision(!newValue)); - } - - /** - * Change using limited editing. - */ - @FromAnyThread - private void changeSlopeControlLimited(@NotNull final Boolean newValue) { - if (state != null) state.setSlopeLimited(newValue); - EXECUTOR_MANAGER.addJmeTask(() -> getSlopeToolControl().setLock(newValue)); - } - - /** - * Change scale of a rough control. - */ - @FromAnyThread - private void changeRoughControlScale(@NotNull final Float newScale) { - if (state != null) state.setRoughtScale(newScale); - EXECUTOR_MANAGER.addJmeTask(() -> getRoughToolControl().setScale(newScale)); - } - - /** - * Change frequency of a rough control. - */ - @FromAnyThread - private void changeRoughControlFrequency(@NotNull final Float newFrequency) { - if (state != null) state.setRoughtFrequency(newFrequency); - EXECUTOR_MANAGER.addJmeTask(() -> getRoughToolControl().setFrequency(newFrequency)); - } - - /** - * Change lacunarity of a rough control. - */ - @FromAnyThread - private void changeRoughControlLacunarity(@NotNull final Float newLacunarity) { - if (state != null) state.setRoughtLacunarity(newLacunarity); - EXECUTOR_MANAGER.addJmeTask(() -> getRoughToolControl().setLacunarity(newLacunarity)); - } - - /** - * Change octaves of a rough control. - */ - @FromAnyThread - private void changeRoughControlOctaves(@NotNull final Float newOctaves) { - if (state != null) state.setRoughtOctaves(newOctaves); - EXECUTOR_MANAGER.addJmeTask(() -> getRoughToolControl().setOctaves(newOctaves)); - } - - /** - * Change roughness of a rough control. - */ - @FromAnyThread - private void changeRoughControlRoughness(@NotNull final Float newRoughness) { - if (state != null) state.setRoughtRoughness(newRoughness); - EXECUTOR_MANAGER.addJmeTask(() -> getRoughToolControl().setRoughness(newRoughness)); - } - - @Override - @JmeThread - protected void setBrushSize(@NotNull final Float size) { - final Array toolControls = getToolControls(); - toolControls.forEach(size, TerrainToolControl::setBrushSize); - } - - @Override - @JmeThread - protected void setBrushPower(@NotNull final Float power) { - final Array toolControls = getToolControls(); - toolControls.forEach(power, TerrainToolControl::setBrushPower); + getChangeConsumer().execute(operation); } /** @@ -932,142 +684,51 @@ protected void setBrushPower(@NotNull final Float power) { } /** - * Get the setting of using smoothly changing of terrain height. - * - * @return the setting of using smoothly changing of terrain height. - */ - @FxThread - private @NotNull CheckBox getLevelControlSmoothly() { - return notNull(levelControlSmoothly); - } - - /** - * Get the setting of using marker to detect a level. - * - * @return the setting of using marker to detect a level. - */ - @FxThread - private @NotNull CheckBox getLevelControlUseMarker() { - return notNull(levelControlUseMarker); - } - - /** - * Get the setting of target level. - * - * @return the setting of target level. - */ - @FxThread - private @NotNull FloatTextField getLevelControlLevelField() { - return notNull(levelControlLevelField); - } - - /** - * Get the setting of using limited between markers. - * - * @return the setting of using limited between markers. - */ - @FxThread - private @NotNull CheckBox getSlopeControlLimited() { - return notNull(slopeControlLimited); - } - - /** - * Get the setting of using smoothly changing of terrain height. - * - * @return the setting of using smoothly changing of terrain height. - */ - @FxThread - private @NotNull CheckBox getSlopeControlSmoothly() { - return notNull(slopeControlSmoothly); - } - - /** - * Get the settings of frequency. - * - * @return the settings of frequency. - */ - @FxThread - private @NotNull FloatTextField getRoughControlFrequencyField() { - return notNull(roughControlFrequencyField); - } - - /** - * Get the settings of lacunarity. - * - * @return the settings of lacunarity. - */ - @FxThread - private @NotNull FloatTextField getRoughControlLacunarityField() { - return notNull(roughControlLacunarityField); - } - - /** - * Get the settings of octaves. - * - * @return the settings of octaves. - */ - @FxThread - private @NotNull FloatTextField getRoughControlOctavesField() { - return notNull(roughControlOctavesField); - } - - /** - * Get the settings of roughness. - * - * @return the settings of roughness. - */ - @FxThread - private @NotNull FloatTextField getRoughControlRoughnessField() { - return notNull(roughControlRoughnessField); - } - - /** - * Get the settings of scale. + * Get the settings of painting control. * - * @return the settings of scale. + * @return the settings of painting control. */ @FxThread - private @NotNull FloatTextField getRoughControlScaleField() { - return notNull(roughControlScaleField); + private @NotNull TextureLayerSettings getTextureLayerSettings() { + return notNull(textureLayerSettings); } /** - * Get the settings of painting control. + * Get the paint control settings. * - * @return the settings of painting control. + * @return the paint control settings. */ @FxThread - private @NotNull TextureLayerSettings getTextureLayerSettings() { - return notNull(textureLayerSettings); + private @NotNull GridPane getPaintControlSettings() { + return notNull(paintControlSettings); } /** * Switch editing mode. */ @FxThread - private void switchMode(@NotNull final ToggleButton source) { + private void switchMode(@NotNull ToggleButton source) { if (!source.isSelected()) { source.setSelected(true); return; } - getToggleButtons().forEach(source, (button, arg) -> button != - arg, (toggleButton, arg) -> toggleButton.setSelected(false)); + getToggleButtons().forEach(source, + (button, arg) -> button != arg, + (toDeselect, arg) -> toDeselect.setSelected(false)); - final ObjectDictionary buttonToSettings = getButtonToSettings(); - final Pane settings = buttonToSettings.get(source); + var category = notNull(getButtonToCategory().get(source)); - final VBox controlSettings = getControlSettings(); - final ObservableList children = controlSettings.getChildren(); - children.clear(); + showCategory(category); - if (settings != null) { - children.add(settings); + if (CATEGORY_PAINT.equals(category)) { + FxUtils.addChild(this, getPaintControlSettings()); + } else { + FxUtils.removeChild(this, getPaintControlSettings()); } - final ObjectDictionary buttonToControl = getButtonToControl(); - final TerrainToolControl toolControl = buttonToControl.get(source); + var toolControl = getButtonToControl().get(source); setToolControl(toolControl); @@ -1076,7 +737,7 @@ private void switchMode(@NotNull final ToggleButton source) { } EXECUTOR_MANAGER.addJmeTask(() -> { - final Node cursorNode = getCursorNode(); + var cursorNode = getCursorNode(); cursorNode.removeControl(TerrainToolControl.class); cursorNode.addControl(toolControl); }); @@ -1084,19 +745,19 @@ private void switchMode(@NotNull final ToggleButton source) { @Override @FxThread - public void startPainting(@NotNull final Object object) { + public void startPainting(@NotNull Object object) { super.startPainting(object); refreshProperties(); - final TextureLayerSettings settings = getTextureLayerSettings(); - final ToggleButton paintButton = getPaintButton(); + var settings = getTextureLayerSettings(); + var paintButton = getPaintButton(); if (object instanceof Terrain) { - final Terrain terrain = (Terrain) object; - final Material material = terrain.getMaterial(); - final MaterialDef materialDef = material.getMaterialDef(); + var terrain = (Terrain) object; + var material = terrain.getMaterial(); + var materialDef = material.getMaterialDef(); if (materialDef.getAssetName().equals("Common/MatDefs/Terrain/TerrainLighting.j3md")) { settings.setLayerToScaleName(LAYER_TO_SCALE_NAME); @@ -1117,7 +778,7 @@ public void startPainting(@NotNull final Object object) { if (paintButton.isSelected()) { - final ToggleButton raiseLowerButton = getRaiseLowerButton(); + var raiseLowerButton = getRaiseLowerButton(); raiseLowerButton.setSelected(true); switchMode(raiseLowerButton); @@ -1133,18 +794,15 @@ private void refreshProperties() { setIgnoreListeners(true); try { - final Node paintedObject = notNull(getPaintedObject()); - final Material material = NodeUtils.findMateial(paintedObject, mat -> mat.getParam("Shininess") != null); - final MatParam shininessParam = material == null ? null : material.getParam("Shininess"); - final MatParam triPlanarMappingParam = material == null ? null : material.getParam("useTriPlanarMapping"); - final float shininess = shininessParam == null ? 0F : (float) shininessParam.getValue(); - final boolean triPlanarMapping = triPlanarMappingParam != null && (boolean) triPlanarMappingParam.getValue(); - - final FloatTextField shininessField = getShininessField(); - shininessField.setValue(shininess); + var paintedObject = notNull(getPaintedObject()); + var material = NodeUtils.findMateial(paintedObject, mat -> mat.getParam("Shininess") != null); + var shininessParam = material == null ? null : material.getParam("Shininess"); + var triPlanarMappingParam = material == null ? null : material.getParam("useTriPlanarMapping"); + var shininess = shininessParam == null ? 0F : (float) shininessParam.getValue(); + var triPlanarMapping = triPlanarMappingParam != null && (boolean) triPlanarMappingParam.getValue(); - final CheckBox triPlanarCheckBox = getTriPlanarCheckBox(); - triPlanarCheckBox.setSelected(triPlanarMapping); + getShininessField().setValue(shininess); + getTriPlanarCheckBox().setSelected(triPlanarMapping); } finally { setIgnoreListeners(false); @@ -1153,7 +811,7 @@ private void refreshProperties() { @Override @FxThread - public void notifyChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { + public void notifyChangeProperty(@NotNull Object object, @NotNull String propertyName) { refreshProperties(); if (getPaintedObject() instanceof Terrain) { @@ -1163,7 +821,7 @@ public void notifyChangeProperty(@NotNull final Object object, @NotNull final St @Override @FxThread - public boolean isSupport(@NotNull final Object object) { + public boolean isSupport(@NotNull Object object) { return object instanceof Node && NodeUtils.findSpatial((Node) object, TerrainQuad.class::isInstance) != null; } diff --git a/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerCell.java b/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerCell.java index f89991f9..1e371a44 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerCell.java +++ b/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerCell.java @@ -6,8 +6,8 @@ import com.ss.editor.ui.control.choose.NamedChooseTextureControl; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FXUtils; import javafx.beans.binding.DoubleBinding; import javafx.scene.control.Label; import javafx.scene.control.ListCell; @@ -81,7 +81,7 @@ public TextureLayerCell(final DoubleBinding prefWidth, normalTextureControl.setChangeHandler(this::updateNormal); normalTextureControl.setControlWidthPercent(PropertyControl.CONTROL_WIDTH_PERCENT_2); - final Label scaleLabel = new Label(Messages.PAINTING_COMPONENT_SCALE + ":"); + final Label scaleLabel = new Label(Messages.MODEL_PROPERTY_SCALE + ":"); scaleLabel.prefWidthProperty().bind(settingContainer.widthProperty().multiply(LABEL_PERCENT)); scaleField = new FloatTextField(); @@ -99,7 +99,7 @@ public TextureLayerCell(final DoubleBinding prefWidth, FXUtils.addClassTo(settingContainer, CssClasses.DEF_GRID_PANE); FXUtils.addClassTo(layerField, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME); FXUtils.addClassTo(scaleLabel, CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW); - FXUtils.addClassTo(scaleField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); + FXUtils.addClassTo(scaleField, CssClasses.PROPERTY_CONTROL_COMBO_BOX); FXUtils.addClassTo(this, CssClasses.PROCESSING_COMPONENT_TERRAIN_EDITOR_TEXTURE_LAYER); } @@ -222,7 +222,7 @@ protected void refresh() { diffuseTextureControl.setTextureFile(item.getDiffuseFile()); final Label layerField = getLayerField(); - layerField.setText(Messages.PAINTING_COMPONENT_LAYER + " #" + (item.getLayer() + 1)); + layerField.setText(Messages.MODEL_PROPERTY_LAYER + " #" + (item.getLayer() + 1)); } finally { setIgnoreListeners(false); diff --git a/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerSettings.java b/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerSettings.java index 186082ca..893a34c2 100644 --- a/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerSettings.java +++ b/src/main/java/com/ss/editor/ui/component/painting/terrain/paint/TextureLayerSettings.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.component.painting.terrain.paint; import static com.ss.editor.ui.component.painting.terrain.TerrainPaintingComponent.TERRAIN_PARAM; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.material.MatParam; import com.jme3.material.Material; import com.jme3.scene.Geometry; @@ -21,9 +21,9 @@ import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.beans.binding.DoubleBinding; import javafx.collections.ObservableList; import javafx.scene.control.*; diff --git a/src/main/java/com/ss/editor/ui/component/scripting/GroovyEditorComponent.java b/src/main/java/com/ss/editor/ui/component/scripting/GroovyEditorComponent.java index f818fdde..454058d8 100644 --- a/src/main/java/com/ss/editor/ui/component/scripting/GroovyEditorComponent.java +++ b/src/main/java/com/ss/editor/ui/component/scripting/GroovyEditorComponent.java @@ -3,7 +3,7 @@ import static java.util.Collections.singleton; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.fxmisc.richtext.CodeArea; import org.fxmisc.richtext.model.StyleSpans; diff --git a/src/main/java/com/ss/editor/ui/component/split/pane/EditorToolSplitPane.java b/src/main/java/com/ss/editor/ui/component/split/pane/EditorToolSplitPane.java index 7690adfa..8099eb2c 100644 --- a/src/main/java/com/ss/editor/ui/component/split/pane/EditorToolSplitPane.java +++ b/src/main/java/com/ss/editor/ui/component/split/pane/EditorToolSplitPane.java @@ -4,7 +4,7 @@ import com.ss.editor.ui.component.editor.state.EditorToolConfig; import com.ss.editor.ui.component.tab.GlobalLeftToolComponent; import com.ss.editor.ui.component.tab.TabToolComponent; -import javafx.application.Platform; +import com.ss.rlib.fx.util.ObservableUtils; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.SplitPane; @@ -24,23 +24,24 @@ public class EditorToolSplitPane extends TabToolSplitPane { @NotNull private final Region root; - public EditorToolSplitPane(@NotNull final Scene scene, @NotNull final Region root) { + public EditorToolSplitPane(@NotNull Scene scene, @NotNull Region root) { super(scene, null); this.root = root; } @Override @FxThread - public void initFor(@NotNull final TabToolComponent toolComponent, @NotNull final Node other) { - super.initFor(toolComponent, other); - root.widthProperty().addListener((observableValue, oldValue, newValue) -> handleSceneChanged(getSceneSize())); + public void initFor(@NotNull TabToolComponent toolComponent, @NotNull Node another) { + super.initFor(toolComponent, another); + ObservableUtils.onChange(root.widthProperty(), + () -> handleSceneChanged(getSceneSize())); } @Override @FxThread - protected void handleSceneChanged(@NotNull final Number newSize) { + protected void handleSceneChanged(@NotNull Number newSize) { super.handleSceneChanged(newSize); - Platform.runLater(this::requestLayout); + EXECUTOR_MANAGER.addFxTask(this::requestLayout); } @Override @@ -50,7 +51,7 @@ protected void bindToScene() { @Override @FxThread - protected void addElements(@NotNull final TabToolComponent toolComponent, @NotNull final Node other) { + protected void addElements(@NotNull TabToolComponent toolComponent, @NotNull Node other) { getItems().setAll(other, toolComponent); } @@ -68,13 +69,13 @@ protected int loadSize() { @Override @FxThread - protected void saveCollapsed(final boolean collapsed) { + protected void storeCollapsed(boolean collapsed) { getConfig().setToolCollapsed(collapsed); } @Override @FxThread - protected void saveSize(final int size) { + protected void storeSize(int size) { getConfig().setToolWidth(size); } @@ -87,13 +88,13 @@ protected double getCollapsedPosition() { @Override @FxThread protected double getSceneSize() { - final double width = root.getWidth(); - return width == 0 ? scene.getWidth() : width; + var width = root.getWidth(); + return Double.compare(width, 0D) == 0 ? scene.getWidth() : width; } @Override @FxThread - protected double getExpandPosition(final double toolSize, final double sceneSize) { + protected double getExpandPosition(double toolSize, double sceneSize) { return 1D - super.getExpandPosition(toolSize, sceneSize); } } diff --git a/src/main/java/com/ss/editor/ui/component/split/pane/GlobalBottomToolSplitPane.java b/src/main/java/com/ss/editor/ui/component/split/pane/GlobalBottomToolSplitPane.java index 79b00187..c565c5bd 100644 --- a/src/main/java/com/ss/editor/ui/component/split/pane/GlobalBottomToolSplitPane.java +++ b/src/main/java/com/ss/editor/ui/component/split/pane/GlobalBottomToolSplitPane.java @@ -1,7 +1,9 @@ package com.ss.editor.ui.component.split.pane; +import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.ui.component.tab.TabToolComponent; +import com.ss.rlib.fx.util.ObservableUtils; import javafx.geometry.Orientation; import javafx.scene.Node; import javafx.scene.Scene; @@ -15,66 +17,70 @@ */ public class GlobalBottomToolSplitPane extends TabToolSplitPane { - /** - * Instantiates a new Global bottom tool split pane. - * - * @param scene the scene - */ - public GlobalBottomToolSplitPane(@NotNull final Scene scene) { + public GlobalBottomToolSplitPane(@NotNull Scene scene) { super(scene, EditorConfig.getInstance()); setOrientation(Orientation.VERTICAL); } @Override - protected void addElements(@NotNull final TabToolComponent toolComponent, @NotNull final Node other) { + @FxThread + protected void addElements(@NotNull TabToolComponent toolComponent, @NotNull Node other) { getItems().setAll(other, toolComponent); } @Override - protected void addListeners(@NotNull final TabToolComponent toolComponent) { - toolComponent.heightProperty() - .addListener((observable, oldValue, newValue) -> handleToolChanged(newValue)); + @FxThread + protected void addListeners(@NotNull TabToolComponent toolComponent) { + ObservableUtils.onChange(toolComponent.heightProperty(), this::handleToolChanged); } @Override + @FxThread protected void bindToScene() { - scene.heightProperty() - .addListener((observableValue, oldValue, newValue) -> handleSceneChanged(getSceneSize())); + ObservableUtils.onChange(scene.heightProperty(), + number -> handleSceneChanged(getSceneSize())); } @Override + @FxThread protected boolean loadCollapsed() { return getConfig().isGlobalBottomToolCollapsed(); } @Override + @FxThread protected int loadSize() { return getConfig().getGlobalBottomToolHeight(); } @Override - protected void saveCollapsed(final boolean collapsed) { + @FxThread + protected void storeCollapsed(boolean collapsed) { getConfig().setGlobalBottomToolCollapsed(collapsed); } @Override - protected void saveSize(final int size) { + @FxThread + protected void storeSize(int size) { getConfig().setGlobalBottomToolHeight(size); } @Override + @FxThread protected double getCollapsedPosition() { return 1; } @Override + @FxThread protected double getSceneSize() { - final double height = scene.getHeight(); - return height == 0 ? scene.getHeight() : height; + var height = scene.getHeight(); + return Double.compare(height, 0D) == 0 ? scene.getHeight() : height; } @Override - protected double getExpandPosition(final double toolSize, final double sceneSize) { + @FxThread + protected double getExpandPosition(double toolSize, double sceneSize) { return 1D - super.getExpandPosition(toolSize, sceneSize); } } diff --git a/src/main/java/com/ss/editor/ui/component/split/pane/GlobalLeftToolSplitPane.java b/src/main/java/com/ss/editor/ui/component/split/pane/GlobalLeftToolSplitPane.java index 778515fb..d7c09dc0 100644 --- a/src/main/java/com/ss/editor/ui/component/split/pane/GlobalLeftToolSplitPane.java +++ b/src/main/java/com/ss/editor/ui/component/split/pane/GlobalLeftToolSplitPane.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.split.pane; +import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.ui.component.tab.GlobalLeftToolComponent; @@ -15,32 +16,31 @@ */ public class GlobalLeftToolSplitPane extends TabToolSplitPane { - /** - * Instantiates a new Global left tool split pane. - * - * @param scene the scene - */ - public GlobalLeftToolSplitPane(@NotNull final Scene scene) { + public GlobalLeftToolSplitPane(@NotNull Scene scene) { super(scene, EditorConfig.getInstance()); } @Override + @FxThread protected boolean loadCollapsed() { return getConfig().isGlobalLeftToolCollapsed(); } @Override + @FxThread protected int loadSize() { return getConfig().getGlobalLeftToolWidth(); } @Override - protected void saveCollapsed(final boolean collapsed) { + @FxThread + protected void storeCollapsed(boolean collapsed) { getConfig().setGlobalLeftToolCollapsed(collapsed); } @Override - protected void saveSize(final int size) { + @FxThread + protected void storeSize(int size) { getConfig().setGlobalLeftToolWidth(size); } } diff --git a/src/main/java/com/ss/editor/ui/component/split/pane/TabToolSplitPane.java b/src/main/java/com/ss/editor/ui/component/split/pane/TabToolSplitPane.java index 26a0e2b2..3cbc332c 100644 --- a/src/main/java/com/ss/editor/ui/component/split/pane/TabToolSplitPane.java +++ b/src/main/java/com/ss/editor/ui/component/split/pane/TabToolSplitPane.java @@ -1,9 +1,12 @@ package com.ss.editor.ui.component.split.pane; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.lang.Math.max; import static java.lang.Math.min; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.manager.ExecutorManager; import com.ss.editor.ui.component.tab.TabToolComponent; +import com.ss.rlib.fx.util.ObservableUtils; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.SplitPane; @@ -13,11 +16,13 @@ /** * The implementation of the {@link SplitPane} for the {@link TabToolComponent}. * - * @param the type parameter + * @param the config's type. * @author JavaSaBr */ public abstract class TabToolSplitPane extends SplitPane { + protected static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); + /** * The scene. */ @@ -46,13 +51,7 @@ public abstract class TabToolSplitPane extends SplitPane { */ private boolean collapsed; - /** - * Instantiates a new Tab tool split pane. - * - * @param scene the scene - * @param config the config - */ - protected TabToolSplitPane(@NotNull final Scene scene, @Nullable C config) { + protected TabToolSplitPane(@NotNull Scene scene, @Nullable C config) { this.scene = scene; this.config = config; if (config != null) { @@ -62,11 +61,12 @@ protected TabToolSplitPane(@NotNull final Scene scene, @Nullable C config) { } /** - * Update this pane for the new config. + * Update this pane to use the new config. * - * @param config the config + * @param config the config. */ - public void updateFor(@NotNull final C config) { + @FxThread + public void updateFor(@NotNull C config) { this.config = config; this.size = loadSize(); this.collapsed = loadCollapsed(); @@ -74,87 +74,97 @@ public void updateFor(@NotNull final C config) { } /** - * Load collapsed boolean. + * Load stored collapsed state of this pane. * - * @return the stored flag of collapsed. + * @return true of this pane was collapsed. */ + @FxThread protected boolean loadCollapsed() { return false; } /** - * Load size int. + * Load stored size of this pane. * - * @return the stored size of the tool component. + * @return the stored size of this pane. */ + @FxThread protected int loadSize() { return 1; } /** - * @return true if the tool collapsed. + * Return true if the tool is collapsed. + * + * @return true if the tool is collapsed. */ + @FxThread private boolean isCollapsed() { return collapsed; } /** + * Get the tool component. + * * @return the tool component. */ - @NotNull - private TabToolComponent getToolComponent() { + @FxThread + private @NotNull TabToolComponent getToolComponent() { return notNull(toolComponent); } /** - * Gets config. + * Get the current config. * - * @return the config. + * @return the current config. */ - @NotNull - public C getConfig() { + @FxThread + public @NotNull C getConfig() { return notNull(config); } /** * Init this split pane for the tool component. * - * @param toolComponent the tool component - * @param other the other + * @param toolComponent the tool component. + * @param another the another node. */ - public void initFor(@NotNull final TabToolComponent toolComponent, @NotNull final Node other) { + @FxThread + public void initFor(@NotNull TabToolComponent toolComponent, @NotNull Node another) { this.toolComponent = toolComponent; - addElements(toolComponent, other); + addElements(toolComponent, another); addListeners(toolComponent); bindToScene(); update(); } /** - * Add with listener to handle size changes. + * Add a width listener to handle changes of the tool component's size. * - * @param toolComponent the tool component + * @param toolComponent the tool component. */ - protected void addListeners(@NotNull final TabToolComponent toolComponent) { - toolComponent.widthProperty() - .addListener((observable, oldValue, newValue) -> handleToolChanged(newValue)); + @FxThread + protected void addListeners(@NotNull TabToolComponent toolComponent) { + ObservableUtils.onChange(toolComponent.widthProperty(), this::handleToolChanged); } /** * Bind to the scene. */ + @FxThread protected void bindToScene() { - scene.widthProperty() - .addListener((observableValue, oldValue, newValue) -> handleSceneChanged(getSceneSize())); + ObservableUtils.onChange(scene.widthProperty(), + () -> handleSceneChanged(getSceneSize())); } /** - * Add an element to the tool component. + * Add the tool component to this pane. * * @param toolComponent the tool component. * @param other the element. */ - protected void addElements(@NotNull final TabToolComponent toolComponent, @NotNull final Node other) { + @FxThread + protected void addElements(@NotNull TabToolComponent toolComponent, @NotNull Node other) { getItems().addAll(toolComponent, other); } @@ -162,7 +172,10 @@ protected void addElements(@NotNull final TabToolComponent toolComponent, @NotNu * Update. */ protected void update() { - if (config == null) return; + + if (config == null) { + return; + } if (isCollapsed()) { getToolComponent().collapse(); @@ -176,24 +189,29 @@ protected void update() { * * @param newValue the new value */ - protected void handleToolChanged(@NotNull final Number newValue) { - if (config == null) return; + protected void handleToolChanged(@NotNull Number newValue) { + + if (config == null) { + return; + } + + var toolComponent = getToolComponent(); this.collapsed = toolComponent.isCollapsed(); - saveCollapsed(collapsed); + + storeCollapsed(isCollapsed()); if (!isCollapsed()) { int abs = Math.abs(size - newValue.intValue()); size = abs > 2 ? newValue.intValue() : size; - saveSize(size); + storeSize(size); } toolComponent.setExpandPosition(getExpandPosition(size, getSceneSize())); - handleSceneChanged(getSceneSize()); } /** - * Gets scene size. + * Get the current scene size. * * @return the scene size. */ @@ -202,19 +220,19 @@ protected double getSceneSize() { } /** - * Save the flag of collapsed. + * Store the current collapsed state. * - * @param collapsed the collapsed + * @param collapsed the current collapsed state. */ - protected void saveCollapsed(final boolean collapsed) { + protected void storeCollapsed(boolean collapsed) { } /** - * Save the size of the tool component. + * Save the current size. * - * @param size the size + * @param size the current size. */ - protected void saveSize(final int size) { + protected void storeSize(int size) { } /** @@ -222,10 +240,11 @@ protected void saveSize(final int size) { * * @param newSize the new size */ - protected void handleSceneChanged(@NotNull final Number newSize) { - if (config == null) return; + protected void handleSceneChanged(@NotNull Number newSize) { - if (isCollapsed()) { + if (config == null) { + return; + } else if (isCollapsed()) { setDividerPosition(getDividerIndex(), getCollapsedPosition()); return; } @@ -234,7 +253,7 @@ protected void handleSceneChanged(@NotNull final Number newSize) { } /** - * Gets collapsed position. + * Get the collapsed position. * * @return the collapsed position. */ @@ -243,6 +262,8 @@ protected double getCollapsedPosition() { } /** + * Get the divider index. + * * @return the divider index. */ private int getDividerIndex() { @@ -256,7 +277,7 @@ private int getDividerIndex() { * @param sceneSize the scene size * @return the expand position */ - protected double getExpandPosition(final double toolSize, final double sceneSize) { + protected double getExpandPosition(double toolSize, double sceneSize) { return min(1, max(0.1, toolSize / sceneSize)); } } diff --git a/src/main/java/com/ss/editor/ui/component/tab/EditorToolComponent.java b/src/main/java/com/ss/editor/ui/component/tab/EditorToolComponent.java index f041898d..5a8fe71d 100644 --- a/src/main/java/com/ss/editor/ui/component/tab/EditorToolComponent.java +++ b/src/main/java/com/ss/editor/ui/component/tab/EditorToolComponent.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.component.tab; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.geometry.Side; import javafx.scene.control.SplitPane; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/component/tab/ScrollableEditorToolComponent.java b/src/main/java/com/ss/editor/ui/component/tab/ScrollableEditorToolComponent.java index e045b917..d88eac4d 100644 --- a/src/main/java/com/ss/editor/ui/component/tab/ScrollableEditorToolComponent.java +++ b/src/main/java/com/ss/editor/ui/component/tab/ScrollableEditorToolComponent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.component.tab; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.ScrollPane; import javafx.scene.control.SplitPane; import javafx.scene.control.Tab; diff --git a/src/main/java/com/ss/editor/ui/component/tab/TabToolComponent.java b/src/main/java/com/ss/editor/ui/component/tab/TabToolComponent.java index 5c75aa6b..33988a67 100644 --- a/src/main/java/com/ss/editor/ui/component/tab/TabToolComponent.java +++ b/src/main/java/com/ss/editor/ui/component/tab/TabToolComponent.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.component.tab; import com.ss.editor.ui.component.ScreenComponent; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanPropertyBase; import javafx.beans.value.ChangeListener; diff --git a/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTree.java b/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTree.java index c415d34a..bbd3edb0 100644 --- a/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTree.java +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTree.java @@ -1,16 +1,16 @@ package com.ss.editor.ui.component.virtual.tree; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.component.virtual.tree.resource.FolderVirtualResourceElement; import com.ss.editor.ui.component.virtual.tree.resource.VirtualResourceElement; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayComparator; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayComparator; import javafx.collections.ObservableList; import javafx.scene.control.SelectionMode; import javafx.scene.control.TreeItem; @@ -75,7 +75,7 @@ public VirtualResourceTree(@NotNull final Class objectsType) { this.objectsType = objectsType; getSelectionModel().setSelectionMode(SelectionMode.SINGLE); - setFixedCellSize(FXConstants.RESOURCE_TREE_CELL_HEIGHT); + setFixedCellSize(FxConstants.RESOURCE_TREE_CELL_HEIGHT); setCellFactory(param -> new VirtualResourceTreeCell()); setShowRoot(false); setFocusTraversable(true); diff --git a/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTreeCell.java b/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTreeCell.java index 8384775a..51b5f321 100644 --- a/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTreeCell.java +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTreeCell.java @@ -4,7 +4,7 @@ import com.ss.editor.manager.FileIconManager; import com.ss.editor.ui.component.virtual.tree.resource.FolderVirtualResourceElement; import com.ss.editor.ui.component.virtual.tree.resource.VirtualResourceElement; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.TreeCell; import javafx.scene.control.TreeView; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/FolderVirtualResourceElement.java b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/FolderVirtualResourceElement.java index ce41fce9..f6fdd224 100644 --- a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/FolderVirtualResourceElement.java +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/FolderVirtualResourceElement.java @@ -2,8 +2,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.virtual.tree.VirtualResourceTree; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElement.java b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElement.java index f3d1a2fd..54eb11cb 100644 --- a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElement.java +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElement.java @@ -1,11 +1,11 @@ package com.ss.editor.ui.component.virtual.tree.resource; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.virtual.tree.VirtualResourceTree; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElementFactory.java b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElementFactory.java index cac89a73..d44dfd6b 100644 --- a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElementFactory.java +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElementFactory.java @@ -2,12 +2,12 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.virtual.tree.VirtualResourceTree; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateList.java b/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateList.java index 3be3c621..92058467 100644 --- a/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateList.java +++ b/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateList.java @@ -1,19 +1,19 @@ package com.ss.editor.ui.control.app.state.list; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.extension.scene.app.state.EditableSceneAppState; import com.ss.editor.extension.scene.app.state.SceneAppState; import com.ss.editor.model.undo.editor.SceneChangeConsumer; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.Icons; import com.ss.editor.ui.dialog.CreateSceneAppStateDialog; import com.ss.editor.model.undo.impl.RemoveAppStateOperation; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.collections.ObservableList; import javafx.scene.control.Button; import javafx.scene.control.ListView; @@ -72,7 +72,7 @@ private void createComponents() { listView.setFocusTraversable(true); listView.prefHeightProperty().bind(heightProperty()); listView.prefWidthProperty().bind(widthProperty()); - listView.setFixedCellSize(FXConstants.LIST_CELL_HEIGHT); + listView.setFixedCellSize(FxConstants.LIST_CELL_HEIGHT); final MultipleSelectionModel selectionModel = listView.getSelectionModel(); selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) -> diff --git a/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateListCell.java b/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateListCell.java index bd17be61..2ff41d0d 100644 --- a/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateListCell.java +++ b/src/main/java/com/ss/editor/ui/control/app/state/list/AppStateListCell.java @@ -7,7 +7,7 @@ import com.ss.editor.model.undo.impl.EnableAppStateOperation; import com.ss.editor.ui.control.list.AbstractListCell; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/choose/ChooseFolderControl.java b/src/main/java/com/ss/editor/ui/control/choose/ChooseFolderControl.java index ed65acaa..88190a6c 100644 --- a/src/main/java/com/ss/editor/ui/control/choose/ChooseFolderControl.java +++ b/src/main/java/com/ss/editor/ui/control/choose/ChooseFolderControl.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.choose; import static com.ss.editor.util.EditorUtil.getAssetFile; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.Icons; @@ -11,8 +11,8 @@ import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/ui/control/choose/ChooseTextureControl.java b/src/main/java/com/ss/editor/ui/control/choose/ChooseTextureControl.java index 4cfebf3e..c0eb701d 100644 --- a/src/main/java/com/ss/editor/ui/control/choose/ChooseTextureControl.java +++ b/src/main/java/com/ss/editor/ui/control/choose/ChooseTextureControl.java @@ -2,7 +2,7 @@ import static com.ss.editor.FileExtensions.TEXTURE_EXTENSIONS; import static com.ss.editor.util.EditorUtil.getAssetFile; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.JavaFxImageManager; @@ -14,7 +14,7 @@ import com.ss.editor.ui.tooltip.ImageChannelPreview; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.Tooltip; diff --git a/src/main/java/com/ss/editor/ui/control/choose/NamedChooseTextureControl.java b/src/main/java/com/ss/editor/ui/control/choose/NamedChooseTextureControl.java index 75dcd01b..7e1a587a 100644 --- a/src/main/java/com/ss/editor/ui/control/choose/NamedChooseTextureControl.java +++ b/src/main/java/com/ss/editor/ui/control/choose/NamedChooseTextureControl.java @@ -1,10 +1,10 @@ package com.ss.editor.ui.control.choose; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.property.PropertyControl; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/control/code/BaseCodeArea.java b/src/main/java/com/ss/editor/ui/control/code/BaseCodeArea.java index 8c291c29..9be7b032 100644 --- a/src/main/java/com/ss/editor/ui/control/code/BaseCodeArea.java +++ b/src/main/java/com/ss/editor/ui/control/code/BaseCodeArea.java @@ -2,7 +2,7 @@ import static java.util.Collections.singleton; import com.ss.editor.annotation.FxThread; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import org.fxmisc.richtext.CodeArea; import org.fxmisc.richtext.model.StyleSpans; import org.fxmisc.richtext.model.StyleSpansBuilder; diff --git a/src/main/java/com/ss/editor/ui/control/filter/list/FilterList.java b/src/main/java/com/ss/editor/ui/control/filter/list/FilterList.java index 94d0440e..49ddd6ce 100644 --- a/src/main/java/com/ss/editor/ui/control/filter/list/FilterList.java +++ b/src/main/java/com/ss/editor/ui/control/filter/list/FilterList.java @@ -5,13 +5,13 @@ import com.ss.editor.extension.scene.filter.EditableSceneFilter; import com.ss.editor.extension.scene.filter.SceneFilter; import com.ss.editor.model.undo.editor.SceneChangeConsumer; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.Icons; import com.ss.editor.ui.dialog.CreateSceneFilterDialog; import com.ss.editor.model.undo.impl.RemoveSceneFilterOperation; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.collections.ObservableList; import javafx.scene.control.Button; import javafx.scene.control.ListView; @@ -70,7 +70,7 @@ private void createComponents() { listView.setFocusTraversable(true); listView.prefHeightProperty().bind(heightProperty()); listView.prefWidthProperty().bind(widthProperty()); - listView.setFixedCellSize(FXConstants.LIST_CELL_HEIGHT); + listView.setFixedCellSize(FxConstants.LIST_CELL_HEIGHT); final MultipleSelectionModel selectionModel = listView.getSelectionModel(); selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) -> diff --git a/src/main/java/com/ss/editor/ui/control/filter/list/FilterListCell.java b/src/main/java/com/ss/editor/ui/control/filter/list/FilterListCell.java index a88cbfd4..eb951fac 100644 --- a/src/main/java/com/ss/editor/ui/control/filter/list/FilterListCell.java +++ b/src/main/java/com/ss/editor/ui/control/filter/list/FilterListCell.java @@ -7,7 +7,7 @@ import com.ss.editor.model.undo.impl.EnableSceneFilterOperation; import com.ss.editor.ui.control.list.AbstractListCell; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/layer/LayerNodeTree.java b/src/main/java/com/ss/editor/ui/control/layer/LayerNodeTree.java index 6673ffc2..ffae22fa 100644 --- a/src/main/java/com/ss/editor/ui/control/layer/LayerNodeTree.java +++ b/src/main/java/com/ss/editor/ui/control/layer/LayerNodeTree.java @@ -8,7 +8,7 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.NodeTreeCell; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.SelectionMode; import javafx.scene.control.TreeItem; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/control/list/AbstractListCell.java b/src/main/java/com/ss/editor/ui/control/list/AbstractListCell.java index 6f71d1a4..420bfd68 100644 --- a/src/main/java/com/ss/editor/ui/control/list/AbstractListCell.java +++ b/src/main/java/com/ss/editor/ui/control/list/AbstractListCell.java @@ -4,8 +4,8 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.Label; import javafx.scene.control.cell.TextFieldListCell; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/ui/control/model/ModelNodeTree.java b/src/main/java/com/ss/editor/ui/control/model/ModelNodeTree.java index 42af6974..98502acd 100644 --- a/src/main/java/com/ss/editor/ui/control/model/ModelNodeTree.java +++ b/src/main/java/com/ss/editor/ui/control/model/ModelNodeTree.java @@ -3,7 +3,7 @@ import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.impl.multi.RemoveElementsAction; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.SelectionMode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,4 +25,9 @@ public ModelNodeTree(@NotNull final Consumer> selectionHandler, @Nullable final ModelChangeConsumer consumer) { super(selectionHandler, consumer, SelectionMode.MULTIPLE); } + + public ModelNodeTree(@NotNull final Consumer> selectionHandler, + @Nullable final ModelChangeConsumer consumer, @NotNull final SelectionMode selectionMode) { + super(selectionHandler, consumer, selectionMode); + } } diff --git a/src/main/java/com/ss/editor/ui/control/model/ModelPropertyEditor.java b/src/main/java/com/ss/editor/ui/control/model/ModelPropertyEditor.java index 3152cc23..8a14fc5d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/ModelPropertyEditor.java +++ b/src/main/java/com/ss/editor/ui/control/model/ModelPropertyEditor.java @@ -8,8 +8,8 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.PropertyEditor; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/property/PropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/PropertyControl.java index d7b61a99..928cd23c 100644 --- a/src/main/java/com/ss/editor/ui/control/property/PropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/PropertyControl.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.property; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; @@ -14,10 +14,10 @@ import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.event.FxEventManager; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.common.function.SixObjectConsumer; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.fx.util.FxUtils; import javafx.geometry.Pos; import javafx.scene.control.Label; import javafx.scene.layout.HBox; @@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Objects; +import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.Predicate; @@ -40,6 +41,15 @@ */ public class PropertyControl extends VBox implements UpdatableControl { + /** + * @param the type of a change consumer. + * @param the type of an editing object. + * @param the type of an editing property. + * @author JavaSaBr + */ + public interface ChangeHandler extends SixObjectConsumer> { + } + /** * The constant LOGGER. */ @@ -139,14 +149,16 @@ public class PropertyControl extends VBox implem */ private boolean ignoreListener; - public PropertyControl(@Nullable final T propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public PropertyControl(@Nullable T propertyValue, @NotNull String propertyName, @NotNull C changeConsumer) { this(propertyValue, propertyName, changeConsumer, null); } - public PropertyControl(@Nullable final T propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, - @Nullable final SixObjectConsumer> changeHandler) { + public PropertyControl( + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @Nullable ChangeHandler changeHandler + ) { this.propertyName = propertyName; this.changeConsumer = changeConsumer; this.changeHandler = changeHandler == null ? newChangeHandler() : changeHandler; @@ -161,8 +173,6 @@ public PropertyControl(@Nullable final T propertyValue, @NotNull final String pr } finally { setIgnoreListener(false); } - - FXUtils.addClassTo(this, CssClasses.ABSTRACT_PARAM_CONTROL); } /** @@ -171,11 +181,10 @@ public PropertyControl(@Nullable final T propertyValue, @NotNull final String pr * @return the six object consumer */ @FromAnyThread - public @NotNull SixObjectConsumer> newChangeHandler() { + protected @NotNull ChangeHandler newChangeHandler() { return (changeConsumer, object, propName, newValue, oldValue, handler) -> { - final PropertyOperation operation = - new PropertyOperation<>(object, propName, newValue, oldValue); + var operation = new PropertyOperation(object, propName, newValue, oldValue); operation.setApplyHandler(handler); changeConsumer.execute(operation); @@ -183,23 +192,23 @@ public PropertyControl(@Nullable final T propertyValue, @NotNull final String pr } /** - * Sets edit object. + * Set the edit object. * * @param editObject the edit object. */ @FxThread - public void setEditObject(@NotNull final D editObject) { + public void setEditObject(@NotNull D editObject) { this.editObject = editObject; } /** - * Sets edit object. + * Set the edit object. * * @param editObject the edit object. * @param needReload the true if need to reload. */ @FxThread - public void setEditObject(@NotNull final D editObject, final boolean needReload) { + public void setEditObject(@NotNull D editObject, boolean needReload) { setEditObject(editObject); if (!needReload) { @@ -215,19 +224,19 @@ public void setEditObject(@NotNull final D editObject, final boolean needReload) } /** - * Sets apply handler. + * Set the apply handler. * - * @param applyHandler the handler for handling new value. + * @param applyHandler the apply handler. */ @FxThread - public void setApplyHandler(@NotNull final BiConsumer applyHandler) { + public void setApplyHandler(@NotNull BiConsumer applyHandler) { this.applyHandler = applyHandler; } /** - * Gets sync handler. + * Get the sync handler. * - * @return the handler for getting actual value. + * @return the sync handler. */ @FromAnyThread protected @Nullable Function getSyncHandler() { @@ -235,17 +244,17 @@ public void setApplyHandler(@NotNull final BiConsumer applyHandler) { } /** - * Sets sync handler. + * Set the sync handler. * - * @param syncHandler the handler for getting actual value. + * @param syncHandler the sync handler. */ @FxThread - public void setSyncHandler(@Nullable final Function syncHandler) { + public void setSyncHandler(@Nullable Function syncHandler) { this.syncHandler = syncHandler; } /** - * Gets edit object. + * Get the edit object. * * @return the edit object. */ @@ -255,7 +264,7 @@ public void setSyncHandler(@Nullable final Function syncHandler) { } /** - * Has edit object boolean. + * Return true if this control has an edit object. * * @return true if this control has an edit object. */ @@ -265,12 +274,40 @@ protected boolean hasEditObject() { } /** - * Initializing control. + * Reloading control. */ @FxThread protected void reload() { } + /** + * Return true if this control has not saved changes. + * + * @return true if this control has not saved changes. + */ + @FxThread + public boolean isDirty() { + return true; + } + + /** + * Apply changes from control to the edited object on lost focus. + * + * @param focused the focused state. + */ + protected void applyOnLostFocus(boolean focused) { + if (!isIgnoreListener() && !focused && isDirty()) { + apply(); + } + } + + /** + * Apply changes from control to the edit object. + */ + @FxThread + protected void apply() { + } + /** * Synchronize value from the edit object. */ @@ -280,8 +317,8 @@ public void sync() { setIgnoreListener(true); try { - final Function syncHandler = getSyncHandler(); - final T currentValue = getPropertyValue(); + var syncHandler = getSyncHandler(); + var currentValue = getPropertyValue(); if (syncHandler != null) { setPropertyValue(syncHandler.apply(getEditObject())); @@ -303,24 +340,30 @@ public void sync() { protected void createComponents() { setAlignment(isSingleRow() ? Pos.CENTER_RIGHT : Pos.CENTER); - final HBox container = new HBox(); + var container = new HBox(); container.setAlignment(isSingleRow() ? Pos.CENTER_RIGHT : Pos.CENTER); propertyNameLabel = new Label(getPropertyName() + ":"); if (isSingleRow()) { - propertyNameLabel.maxWidthProperty().bind(widthProperty().multiply(1F - CONTROL_WIDTH_PERCENT)); + propertyNameLabel.maxWidthProperty() + .bind(widthProperty().multiply(1F - CONTROL_WIDTH_PERCENT)); } - FXUtils.addClassTo(container, CssClasses.DEF_HBOX); - FXUtils.addClassTo(propertyNameLabel, isSingleRow() ? CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW : - CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME); + FxUtils.addClass(container, CssClasses.DEF_HBOX) + .addClass(propertyNameLabel, getLabelCssClass()); - FXUtils.addToPane(propertyNameLabel, isSingleRow() ? container : this); + FxUtils.addChild(isSingleRow() ? container : this, propertyNameLabel); createComponents(container); - FXUtils.addToPane(container, this); + FxUtils.addChild(this, container); + } + + @FromAnyThread + protected @NotNull String getLabelCssClass() { + return isSingleRow() ? CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW : + CssClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME; } /** @@ -339,21 +382,22 @@ protected void createComponents() { * @param controlWidthPercent the control width percent. */ @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { + public void changeControlWidthPercent(double controlWidthPercent) { if (!isSingleRow()) { return; } - final Label propertyNameLabel = getPropertyNameLabel(); + var propertyNameLabel = getPropertyNameLabel(); propertyNameLabel.maxWidthProperty().unbind(); - propertyNameLabel.maxWidthProperty().bind(widthProperty().multiply(1D - controlWidthPercent)); + propertyNameLabel.maxWidthProperty() + .bind(widthProperty().multiply(1D - controlWidthPercent)); } /** - * Is single row boolean. + * Return true if this control is a single row. * - * @return true if this control is single row. + * @return true if this control is a single row. */ @FromAnyThread protected boolean isSingleRow() { @@ -363,14 +407,14 @@ protected boolean isSingleRow() { /** * Create components of this control. * - * @param container the container + * @param container the container. */ @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { } /** - * Gets property name. + * Get the property name. * * @return the name of the property. */ @@ -380,7 +424,7 @@ protected void createComponents(@NotNull final HBox container) { } /** - * Gets change consumer. + * Get the change consumer. * * @return the consumer of changes. */ @@ -396,12 +440,13 @@ protected void createComponents(@NotNull final HBox container) { * @param oldValue the old value */ @FxThread - protected void changed(@Nullable final T newValue, @Nullable final T oldValue) { - changeHandler.accept(getChangeConsumer(), getEditObject(), getPropertyName(), newValue, oldValue, getApplyHandler()); + protected void changed(@Nullable T newValue, @Nullable T oldValue) { + changeHandler.accept(getChangeConsumer(), getEditObject(), getPropertyName(), + newValue, oldValue, getApplyHandler()); } /** - * Gets property value. + * Get the property value. * * @return the value of the property. */ @@ -411,7 +456,17 @@ protected void changed(@Nullable final T newValue, @Nullable final T oldValue) { } /** - * Gets apply handler. + * Get the property value. + * + * @return the value of the property. + */ + @FxThread + public @NotNull Optional getPropertyValueOpt() { + return Optional.ofNullable(getPropertyValue()); + } + + /** + * Get the apply handler. * * @return the handler for handling new value. */ @@ -421,27 +476,27 @@ protected void changed(@Nullable final T newValue, @Nullable final T oldValue) { } /** - * Sets property value. + * Set the property value. * * @param propertyValue the value of the property. */ @FxThread - protected void setPropertyValue(@Nullable final T propertyValue) { + protected void setPropertyValue(@Nullable T propertyValue) { this.propertyValue = propertyValue; } /** - * Sets ignore listener. + * Set the ignore listener. * * @param ignoreListener the flag for ignoring listeners. */ @FxThread - protected void setIgnoreListener(final boolean ignoreListener) { + protected void setIgnoreListener(boolean ignoreListener) { this.ignoreListener = ignoreListener; } /** - * Is ignore listener boolean. + * Return true if need to ignore listeners. * * @return true if need to ignore listeners. */ @@ -449,12 +504,4 @@ protected void setIgnoreListener(final boolean ignoreListener) { protected boolean isIgnoreListener() { return ignoreListener; } - - @Override - public String toString() { - return "PropertyControl{" + - "propertyName='" + propertyName + '\'' + - ", propertyValue=" + propertyValue + - "} " + super.toString(); - } } diff --git a/src/main/java/com/ss/editor/ui/control/property/PropertyEditor.java b/src/main/java/com/ss/editor/ui/control/property/PropertyEditor.java index 818596a9..9045a133 100644 --- a/src/main/java/com/ss/editor/ui/control/property/PropertyEditor.java +++ b/src/main/java/com/ss/editor/ui/control/property/PropertyEditor.java @@ -1,16 +1,14 @@ package com.ss.editor.ui.control.property; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.control.UpdatableControl; import com.ss.editor.ui.control.property.builder.PropertyBuilderRegistry; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import javafx.collections.ObservableList; -import javafx.scene.Node; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.ScrollPane; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; @@ -24,7 +22,6 @@ */ public class PropertyEditor extends ScrollPane { - @NotNull private static final PropertyBuilderRegistry BUILDER_REGISTRY = PropertyBuilderRegistry.getInstance(); /** @@ -51,18 +48,15 @@ public class PropertyEditor extends ScrollPane { @Nullable private Object currentParent; - /** - * Instantiates a new Abstract property editor. - * - * @param changeConsumer the change consumer - */ - public PropertyEditor(@NotNull final C changeConsumer) { + public PropertyEditor(@NotNull C changeConsumer) { this.changeConsumer = changeConsumer; createComponents(); } /** - * @return The container of controls. + * Get the container of controls. + * + * @return the container of controls. */ @FxThread private @NotNull VBox getContainer() { @@ -76,31 +70,33 @@ public PropertyEditor(@NotNull final C changeConsumer) { private void createComponents() { this.container = new VBox(); this.container.prefWidthProperty() - .bind(widthProperty().subtract(FXConstants.PROPERTY_LIST_OFFSET)); + .bind(widthProperty().subtract(FxConstants.PROPERTY_LIST_OFFSET)); - final VBox wrapper = new VBox(container); + var wrapper = new VBox(container); - FXUtils.addClassTo(this, CssClasses.ABSTRACT_PARAM_CONTROL_CONTAINER); - FXUtils.addClassTo(container, CssClasses.DEF_VBOX); - FXUtils.addClassTo(wrapper, CssClasses.DEF_VBOX); + FxUtils.addClass(this, + CssClasses.PROPERTY_EDITOR) + .addClass(wrapper, container, + CssClasses.DEF_VBOX, CssClasses.PROPERTY_EDITOR_CONTAINER); setContent(wrapper); } /** - * Sync all properties with controls. + * Sync all property controls. * - * @param object the object + * @param object the object. */ @FxThread - public void syncFor(@Nullable final Object object) { - if (!isNeedUpdate(object)) return; + public void syncFor(@Nullable Object object) { - final VBox container = getContainer(); - container.setDisable(object == null || !canEdit(object, getCurrentParent())); + if (!isNeedUpdate(object)) { + return; + } - final ObservableList children = container.getChildren(); - children.forEach(node -> { + var container = getContainer(); + container.setDisable(object == null || !canEdit(object, getCurrentParent())); + container.getChildren().forEach(node -> { if (node instanceof UpdatableControl) { ((UpdatableControl) node).sync(); } @@ -108,19 +104,19 @@ public void syncFor(@Nullable final Object object) { } /** - * Sync all properties with controls. + * Sync all property controls. */ @FxThread public void refresh() { - final Object object = getCurrentObject(); - if (object == null) return; + var object = getCurrentObject(); + if (object == null) { + return; + } - final VBox container = getContainer(); + var container = getContainer(); container.setDisable(!canEdit(object, getCurrentParent())); - - final ObservableList children = container.getChildren(); - children.forEach(node -> { + container.getChildren().forEach(node -> { if (node instanceof UpdatableControl) { ((UpdatableControl) node).sync(); } @@ -134,14 +130,14 @@ public void refresh() { * @param parent the parent */ @FxThread - public void buildFor(@Nullable final Object object, @Nullable final Object parent) { + public void buildFor(@Nullable Object object, @Nullable Object parent) { if (getCurrentObject() == object) { return; } - final VBox container = getContainer(); - final ObservableList children = container.getChildren(); + var container = getContainer(); + var children = container.getChildren(); children.clear(); if (object != null) { @@ -155,29 +151,32 @@ public void buildFor(@Nullable final Object object, @Nullable final Object paren } /** - * Can edit boolean. + * Return true if we can edit properties of the object. * * @param object the object to edit. * @param parent the parent. * @return true if we can edit properties of the object. */ @FxThread - protected boolean canEdit(@NotNull final Object object, @Nullable final Object parent) { + protected boolean canEdit(@NotNull Object object, @Nullable Object parent) { return true; } /** * Re-build property controls for the object. * - * @param object the object - * @param parent the parent + * @param object the object. + * @param parent the parent. */ @FxThread - public void rebuildFor(@Nullable final Object object, @Nullable final Object parent) { - if (getCurrentObject() != object) return; + public void rebuildFor(@Nullable Object object, @Nullable Object parent) { - final VBox container = getContainer(); - final ObservableList children = container.getChildren(); + if (getCurrentObject() != object) { + return; + } + + var container = getContainer(); + var children = container.getChildren(); children.clear(); if (object != null) { @@ -186,7 +185,7 @@ public void rebuildFor(@Nullable final Object object, @Nullable final Object par } /** - * Rebuild this editor. + * Rebuild all property controls. */ @FxThread public void rebuild() { @@ -194,30 +193,34 @@ public void rebuild() { } /** - * Is need update boolean. + * Return true if need to update property controls. * - * @param object the object - * @return the boolean + * @param object the object. + * @return true if need to update property controls. */ @FxThread - protected boolean isNeedUpdate(@Nullable final Object object) { - final Object currentObject = getCurrentObject(); + protected boolean isNeedUpdate(@Nullable Object object) { + + var currentObject = getCurrentObject(); if (object instanceof EditableProperty) { return currentObject == ((EditableProperty) object).getObject(); } + return currentObject == object; } /** + * Set the current editable object. + * * @param currentObject the current editable object. */ @FxThread - private void setCurrentObject(@Nullable final Object currentObject) { + private void setCurrentObject(@Nullable Object currentObject) { this.currentObject = currentObject; } /** - * Gets current object. + * Get the current object. * * @return the current editable object. */ @@ -227,17 +230,17 @@ private void setCurrentObject(@Nullable final Object currentObject) { } /** - * Sets the current parent. + * Set the current parent. * * @param currentParent the current parent. */ @FxThread - protected void setCurrentParent(@Nullable final Object currentParent) { + protected void setCurrentParent(@Nullable Object currentParent) { this.currentParent = currentParent; } /** - * Gets the current parent. + * Get the current parent. * * @return the current parent. */ diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilder.java index 86d5146e..0e72627e 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilder.java @@ -2,12 +2,10 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; - +import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.layout.VBox; - /** * The interface to implement property builder to create property controls for some objects. * @@ -24,8 +22,12 @@ public interface PropertyBuilder extends Comparable { * @param changeConsumer the consumer for working between controls and editor. */ @FxThread - void buildFor(@NotNull Object object, @Nullable Object parent, @NotNull VBox container, - @NotNull ChangeConsumer changeConsumer); + void buildFor( + @NotNull Object object, + @Nullable Object parent, + @NotNull VBox container, + @NotNull ChangeConsumer changeConsumer + ); /** * Get the priority of this builder. @@ -37,7 +39,7 @@ default int getPriority() { } @Override - default int compareTo(@NotNull final PropertyBuilder o) { + default int compareTo(@NotNull PropertyBuilder o) { return o.getPriority() - getPriority(); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderFilter.java b/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderFilter.java index 629865cb..7c7d2cb0 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderFilter.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderFilter.java @@ -19,5 +19,5 @@ public interface PropertyBuilderFilter { * @param parent the parent. * @return true of we should skip the builder for the object. */ - boolean skip(@NotNull final PropertyBuilder builder, @NotNull final Object object, @Nullable final Object parent); + boolean skip(@NotNull PropertyBuilder builder, @NotNull Object object, @Nullable Object parent); } diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderRegistry.java b/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderRegistry.java index 61b9198c..39bb600f 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderRegistry.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderRegistry.java @@ -4,8 +4,8 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.builder.impl.*; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,7 +64,7 @@ private PropertyBuilderRegistry() { * @param builder the property builder. */ @FromAnyThread - public void register(@NotNull final PropertyBuilder builder) { + public void register(@NotNull PropertyBuilder builder) { builders.add(builder); builders.sort(PropertyBuilder::compareTo); } @@ -75,7 +75,7 @@ public void register(@NotNull final PropertyBuilder builder) { * @param filter the property builder filter. */ @FromAnyThread - public void register(@NotNull final PropertyBuilderFilter filter) { + public void register(@NotNull PropertyBuilderFilter filter) { filters.add(filter); } @@ -88,14 +88,18 @@ public void register(@NotNull final PropertyBuilderFilter filter) { * @param changeConsumer the consumer to work between controls and editor. */ @FxThread - public void buildFor(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container, - @NotNull final ChangeConsumer changeConsumer) { + public void buildFor( + @NotNull Object object, + @Nullable Object parent, + @NotNull VBox container, + @NotNull ChangeConsumer changeConsumer + ) { - for (final PropertyBuilder builder : builders) { + for (var builder : builders) { boolean needSkip = false; - for (final PropertyBuilderFilter filter : filters) { + for (var filter : filters) { if (filter.skip(builder, object, parent)) { needSkip = true; break; diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/AbstractPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/AbstractPropertyBuilder.java index 66ab2f3e..abe83444 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/AbstractPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/AbstractPropertyBuilder.java @@ -4,7 +4,7 @@ import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; @@ -25,15 +25,18 @@ public abstract class AbstractPropertyBuilder implemen @NotNull private final Class type; - protected AbstractPropertyBuilder(@NotNull final Class type) { + protected AbstractPropertyBuilder(@NotNull Class type) { this.type = type; } @Override @FxThread - public void buildFor(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container, - @NotNull final ChangeConsumer changeConsumer) { - + public void buildFor( + @NotNull Object object, + @Nullable Object parent, + @NotNull VBox container, + @NotNull ChangeConsumer changeConsumer + ) { if (type.isInstance(changeConsumer)) { buildForImpl(object, parent, container, type.cast(changeConsumer)); } @@ -48,8 +51,12 @@ public void buildFor(@NotNull final Object object, @Nullable final Object parent * @param changeConsumer the change consumer. */ @FxThread - protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, - @NotNull final VBox container, @NotNull final C changeConsumer) { + protected void buildForImpl( + @NotNull Object object, + @Nullable Object parent, + @NotNull VBox container, + @NotNull C changeConsumer + ) { } /** @@ -58,11 +65,15 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object * @param pane the container of the line. */ @FxThread - protected void buildSplitLine(@NotNull final Pane pane) { - final HBox line = new HBox(); - final VBox container = new VBox(line); - FXUtils.addClassTo(line, CssClasses.DEF_HBOX); - FXUtils.addClassTo(container, CssClasses.ABSTRACT_PARAM_CONTROL_CONTAINER_SPLIT_LINE); - FXUtils.addToPane(container, pane); + protected void buildSplitLine(@NotNull Pane pane) { + + var line = new HBox(); + var container = new VBox(line); + + FxUtils.addClass(line, CssClasses.DEF_HBOX) + .addClass(container, + CssClasses.PROPERTY_EDITOR_CONTAINER_SPLIT_LINE); + + FxUtils.addChild(pane, container); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/AudioNodePropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/AudioNodePropertyBuilder.java index 169b230b..a87b0c7a 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/AudioNodePropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/AudioNodePropertyBuilder.java @@ -1,22 +1,20 @@ package com.ss.editor.ui.control.property.builder.impl; -import com.jme3.asset.AssetManager; -import com.jme3.audio.AudioData; import com.jme3.audio.AudioKey; import com.jme3.audio.AudioNode; import com.jme3.math.Vector3f; import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.impl.AudioKeyPropertyControl; import com.ss.editor.ui.control.property.impl.BooleanPropertyControl; import com.ss.editor.ui.control.property.impl.FloatPropertyControl; -import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl; +import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl; import com.ss.editor.util.AudioNodeUtils; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,12 +31,12 @@ public class AudioNodePropertyBuilder extends AbstractPropertyBuilder AUDIO_APPLY_HANDLER = (audioNode, audioKey) -> { - final AssetManager assetManager = EditorUtil.getAssetManager(); + var assetManager = EditorUtil.getAssetManager(); if (audioKey == null) { audioNode.setAudioData(null, null); } else { - final AudioData audioData = assetManager.loadAudio(audioKey); + var audioData = assetManager.loadAudio(audioKey); AudioNodeUtils.updateData(audioNode, audioData, audioKey); } }; @@ -62,8 +60,12 @@ private AudioNodePropertyBuilder() { @Override @FxThread - protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, - @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) { + protected void buildForImpl( + @NotNull Object object, + @Nullable Object parent, + @NotNull VBox container, + @NotNull ModelChangeConsumer changeConsumer + ) { if (!(object instanceof AudioNode)) return; @@ -189,14 +191,14 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object audioKeyControl.setSyncHandler(AudioNodeUtils::getAudioKey); audioKeyControl.setEditObject(audioNode); - final Vector3FPropertyControl velocityControl = new Vector3FPropertyControl<>(velocity, + final Vector3fPropertyControl velocityControl = new Vector3fPropertyControl<>(velocity, Messages.MODEL_PROPERTY_VELOCITY, changeConsumer); velocityControl.setApplyHandler(AudioNode::setVelocity); velocityControl.setSyncHandler(AudioNode::getVelocity); velocityControl.setEditObject(audioNode); - final Vector3FPropertyControl directionControl = new Vector3FPropertyControl<>(direction, + final Vector3fPropertyControl directionControl = new Vector3fPropertyControl<>(direction, Messages.MODEL_PROPERTY_DIRECTION, changeConsumer); directionControl.setApplyHandler(AudioNode::setDirection); diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/CollisionShapePropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/CollisionShapePropertyBuilder.java index c3ae4278..72a63bce 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/CollisionShapePropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/CollisionShapePropertyBuilder.java @@ -11,7 +11,7 @@ import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.impl.DefaultSinglePropertyControl; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/DefaultControlPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/DefaultControlPropertyBuilder.java index 57386295..a487bea3 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/DefaultControlPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/DefaultControlPropertyBuilder.java @@ -48,9 +48,9 @@ private DefaultControlPropertyBuilder() { } @FxThread - protected @NotNull List> getProperties(@NotNull final AbstractControl control) { + protected @NotNull List> getProperties(@NotNull AbstractControl control) { - final List> result = new ArrayList<>(); + var result = new ArrayList>(); result.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_ENABLED, control, AbstractControl::isEnabled, AbstractControl::setEnabled)); @@ -58,9 +58,9 @@ private DefaultControlPropertyBuilder() { } @FxThread - protected @NotNull List> getProperties(@NotNull final PhysicsControl control) { + protected @NotNull List> getProperties(@NotNull PhysicsControl control) { - final List> result = new ArrayList<>(); + var result = new ArrayList>(); result.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_ENABLED, control, PhysicsControl::isEnabled, PhysicsControl::setEnabled)); @@ -69,13 +69,13 @@ private DefaultControlPropertyBuilder() { @Override @FxThread - protected @Nullable List> getProperties(@NotNull final Object object) { + protected @Nullable List> getProperties(@NotNull Object object) { - final List> properties = new ArrayList<>(); + var properties = new ArrayList>(); if (object instanceof VehicleWheel) { - final VehicleWheel control = (VehicleWheel) object; + var control = (VehicleWheel) object; properties.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_FRONT, control, VehicleWheel::isFrontWheel, VehicleWheel::setFrontWheel)); @@ -116,7 +116,7 @@ private DefaultControlPropertyBuilder() { } else if (object instanceof AbstractCinematicEvent) { - final AbstractCinematicEvent control = (AbstractCinematicEvent) object; + var control = (AbstractCinematicEvent) object; properties.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_LOOP_MODE, control, AbstractCinematicEvent::getLoopMode, AbstractCinematicEvent::setLoopMode)); @@ -129,7 +129,7 @@ private DefaultControlPropertyBuilder() { } else if (object instanceof Animation) { - final Animation animation = (Animation) object; + var animation = (Animation) object; properties.add(new SimpleProperty<>(FLOAT, Messages.MODEL_PROPERTY_LENGTH, animation, Animation::getLength)); @@ -137,7 +137,7 @@ private DefaultControlPropertyBuilder() { if (object instanceof MotionEvent) { - final MotionEvent control = (MotionEvent) object; + var control = (MotionEvent) object; properties.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_DIRECTION_TYPE, control, MotionEvent::getDirectionType, MotionEvent::setDirectionType)); @@ -161,7 +161,7 @@ private DefaultControlPropertyBuilder() { if (object instanceof LightControl) { - final LightControl control = (LightControl) object; + var control = (LightControl) object; properties.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_DIRECTION_TYPE, control, LightControl::getControlDir, LightControl::setControlDir)); @@ -170,7 +170,7 @@ private DefaultControlPropertyBuilder() { } else if (object instanceof BetterCharacterControl) { - final BetterCharacterControl control = (BetterCharacterControl) object; + var control = (BetterCharacterControl) object; properties.add(new SimpleProperty<>(VECTOR_3F, Messages.MODEL_PROPERTY_GRAVITY, control, BetterCharacterControl::getGravity, BetterCharacterControl::setGravity)); @@ -189,21 +189,21 @@ private DefaultControlPropertyBuilder() { } else if (object instanceof RigidBodyControl) { - final RigidBodyControl control = (RigidBodyControl) object; + var control = (RigidBodyControl) object; properties.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_KINEMATIC_SPATIAL, control, RigidBodyControl::isKinematicSpatial, RigidBodyControl::setKinematicSpatial)); } else if (object instanceof SkeletonControl) { - final SkeletonControl control = (SkeletonControl) object; + var control = (SkeletonControl) object; properties.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_HARDWARE_SKINNING_PREFERRED, control, SkeletonControl::isHardwareSkinningPreferred, SkeletonControl::setHardwareSkinningPreferred)); } else if (object instanceof VehicleControl) { - final VehicleControl control = (VehicleControl) object; + var control = (VehicleControl) object; properties.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_APPLY_PHYSICS_LOCAL, control, VehicleControl::isApplyPhysicsLocal, VehicleControl::setApplyPhysicsLocal)); @@ -212,7 +212,7 @@ private DefaultControlPropertyBuilder() { if (object instanceof PhysicsRigidBody) { - final PhysicsRigidBody control = (PhysicsRigidBody) object; + var control = (PhysicsRigidBody) object; properties.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_KINEMATIC, control, PhysicsRigidBody::isKinematic, PhysicsRigidBody::setKinematic)); diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableModelObjectPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableModelObjectPropertyBuilder.java index 1bbc8ce1..5eb2d1ef 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableModelObjectPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableModelObjectPropertyBuilder.java @@ -4,17 +4,16 @@ import com.jme3.light.DirectionalLight; import com.jme3.light.Light; import com.jme3.light.PointLight; +import com.jme3.math.Vector2f; import com.jme3.post.Filter; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.property.EditableProperty; -import com.ss.editor.extension.property.EditablePropertyType; +import com.ss.editor.extension.scene.SceneLayer; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.model.undo.editor.SceneChangeConsumer; -import com.ss.editor.ui.control.property.impl.FilterElementModelPropertyControl; -import com.ss.editor.ui.control.property.impl.LightElementModelPropertyControl; -import com.ss.editor.ui.control.property.impl.SpatialElementModelPropertyControl; +import com.ss.editor.ui.control.property.impl.*; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; @@ -25,81 +24,85 @@ */ public class EditableModelObjectPropertyBuilder extends EditableObjectPropertyBuilder { - protected EditableModelObjectPropertyBuilder(@NotNull final Class type) { + protected EditableModelObjectPropertyBuilder(@NotNull Class type) { super(type); } @Override @FxThread - protected void buildFor(@NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer, - @NotNull final EditableProperty description) { + protected void buildFor( + @NotNull VBox container, + @NotNull ModelChangeConsumer changeConsumer, + @NotNull EditableProperty description + ) { + super.buildFor(container, changeConsumer, description); - final EditablePropertyType type = description.getType(); + var type = description.getType(); switch (type) { case DIRECTION_LIGHT_FROM_SCENE: { - final EditableProperty property = cast(description); - final DirectionalLight value = property.getValue(); + EditableProperty property = cast(description); - final LightElementModelPropertyControl> propertyControl = - new LightElementModelPropertyControl<>(DirectionalLight.class, value, property.getName(), changeConsumer); + var value = property.getValue(); + var propertyControl = new LightElementModelPropertyControl>( + DirectionalLight.class, value, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case AMBIENT_LIGHT_FROM_SCENE: { - final EditableProperty property = cast(description); - final AmbientLight value = property.getValue(); + EditableProperty property = cast(description); - final LightElementModelPropertyControl> propertyControl = - new LightElementModelPropertyControl<>(AmbientLight.class, value, property.getName(), changeConsumer); + var value = property.getValue(); + var propertyControl = new LightElementModelPropertyControl>( + AmbientLight.class, value, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case POINT_LIGHT_FROM_SCENE: { - final EditableProperty property = cast(description); - final PointLight value = property.getValue(); + EditableProperty property = cast(description); - final LightElementModelPropertyControl> propertyControl = - new LightElementModelPropertyControl<>(PointLight.class, value, property.getName(), changeConsumer); + var value = property.getValue(); + var propertyControl = new LightElementModelPropertyControl>( + PointLight.class, value, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case LIGHT_FROM_SCENE: { - final EditableProperty property = cast(description); - final Light value = property.getValue(); + EditableProperty property = cast(description); - final LightElementModelPropertyControl> propertyControl = - new LightElementModelPropertyControl<>(Light.class, value, property.getName(), changeConsumer); + var value = property.getValue(); + var propertyControl = new LightElementModelPropertyControl>( + Light.class, value, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case SPATIAL_FROM_SCENE: { - final EditableProperty property = cast(description); - final Spatial value = property.getValue(); + EditableProperty property = cast(description); - final SpatialElementModelPropertyControl> propertyControl = - new SpatialElementModelPropertyControl<>(Spatial.class, value, property.getName(), changeConsumer); + var value = property.getValue(); + var propertyControl = new SpatialElementModelPropertyControl>( + Spatial.class, value, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case NODE_FROM_SCENE: { - final EditableProperty property = cast(description); - final Node value = property.getValue(); + EditableProperty property = cast(description); - final SpatialElementModelPropertyControl> propertyControl = - new SpatialElementModelPropertyControl<>(Node.class, value, property.getName(), changeConsumer); + var value = property.getValue(); + var propertyControl = new SpatialElementModelPropertyControl>( + Node.class, value, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; @@ -110,16 +113,27 @@ protected void buildFor(@NotNull final VBox container, @NotNull final ModelChang return; } - final SceneChangeConsumer consumer = (SceneChangeConsumer) changeConsumer; + var consumer = (SceneChangeConsumer) changeConsumer; switch (type) { case FILTER_FROM_SCENE: { - final EditableProperty property = cast(description); - final Filter value = property.getValue(); + EditableProperty property = cast(description); + + var value = property.getValue(); + var propertyControl = new FilterElementModelPropertyControl>( + value, property.getName(), consumer); + + addControl(container, property, propertyControl); + break; + } + case SCENE_LAYER: { + + EditableProperty property = cast(description); - final FilterElementModelPropertyControl> propertyControl = - new FilterElementModelPropertyControl<>(value, property.getName(), consumer); + var value = property.getValue(); + var propertyControl = new LayerModelPropertyControl>(value, + property.getName(), consumer); addControl(container, property, propertyControl); break; diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableObjectPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableObjectPropertyBuilder.java index 1e5ab24e..b2fe1993 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableObjectPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableObjectPropertyBuilder.java @@ -1,20 +1,17 @@ package com.ss.editor.ui.control.property.builder.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.math.Vector4f; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import com.jme3.math.*; import com.jme3.texture.Texture2D; import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.property.EditableProperty; -import com.ss.editor.extension.property.EditablePropertyType; import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.control.property.impl.*; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ClassUtils; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,53 +26,60 @@ */ public class EditableObjectPropertyBuilder extends AbstractPropertyBuilder { - protected EditableObjectPropertyBuilder(@NotNull final Class type) { + protected EditableObjectPropertyBuilder(@NotNull Class type) { super(type); } @Override @FxThread - protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, - @NotNull final VBox container, @NotNull final C changeConsumer) { - - final List> properties = getProperties(object, parent, changeConsumer); + protected void buildForImpl( + @NotNull Object object, + @Nullable Object parent, + @NotNull VBox container, + @NotNull C changeConsumer + ) { + + var properties = getProperties(object, parent, changeConsumer); if (properties == null || properties.isEmpty()) { return; } - for (final EditableProperty description : properties) { + for (var description : properties) { buildFor(container, changeConsumer, description); } } @FxThread - protected void buildFor(@NotNull final VBox container, @NotNull final C changeConsumer, - @NotNull final EditableProperty description) { + protected void buildFor( + @NotNull VBox container, + @NotNull C changeConsumer, + @NotNull EditableProperty description + ) { - final EditablePropertyType type = description.getType(); + var type = description.getType(); switch (type) { case BOOLEAN: { - final EditableProperty property = cast(description); - final Boolean currentValue = property.getValue(); + EditableProperty property = cast(description); + var currentValue = property.getValue(); - final BooleanPropertyControl> propertyControl = - new BooleanPropertyControl<>(currentValue, property.getName(), changeConsumer); + var propertyControl = new BooleanPropertyControl>(currentValue, + property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case FLOAT: { - final EditableProperty property = cast(description); - final Float currentValue = property.getValue(); + EditableProperty property = cast(description); + var currentValue = property.getValue(); - final FloatPropertyControl> propertyControl = - new FloatPropertyControl<>(currentValue, property.getName(), changeConsumer); + var propertyControl = new FloatPropertyControl>(currentValue, + property.getName(), changeConsumer); - final float scrollPower = propertyControl.getScrollPower(); - final float mod = property.getScrollPower(); + var scrollPower = propertyControl.getScrollPower(); + var mod = property.getScrollPower(); propertyControl.setScrollPower(scrollPower * mod); propertyControl.setMinMax(property.getMinValue(), property.getMaxValue()); @@ -85,8 +89,9 @@ protected void buildFor(@NotNull final VBox container, @NotNull final C changeCo } case COLOR: { - final EditableProperty property = cast(description); - final Object undefine = description.getValue(); + EditableProperty property = cast(description); + var undefine = description.getValue(); + final ColorRGBA color; // for some cases with materials @@ -97,86 +102,120 @@ protected void buildFor(@NotNull final VBox container, @NotNull final C changeCo color = (ColorRGBA) undefine; } - final ColorPropertyControl> propertyControl = - new ColorPropertyControl<>(color, property.getName(), changeConsumer); + var propertyControl = new ColorPropertyControl>(color, + property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case INTEGER: { - final EditableProperty property = cast(description); - final Integer currentValue = property.getValue(); + EditableProperty property = cast(description); + var currentValue = property.getValue(); - final IntegerPropertyControl> propertyControl = - new IntegerPropertyControl<>(currentValue, property.getName(), changeConsumer); + var propertyControl = new IntegerPropertyControl>(currentValue, + property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case STRING: { - final EditableProperty property = cast(description); - final String currentValue = property.getValue(); + EditableProperty property = cast(description); + var currentValue = property.getValue(); - final StringPropertyControl> propertyControl = - new StringPropertyControl<>(currentValue, property.getName(), changeConsumer); + var propertyControl = new StringPropertyControl>(currentValue, + property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case READ_ONLY_STRING: { - final EditableProperty property = cast(description); - final Object currentValue = property.getValue(); + EditableProperty property = cast(description); + var currentValue = property.getValue(); - final DefaultSinglePropertyControl, Object> propertyControl = - new DefaultSinglePropertyControl<>(currentValue, property.getName(), changeConsumer); + var propertyControl = new DefaultSinglePropertyControl, Object>( + currentValue, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case VECTOR_2F: { - final EditableProperty property = cast(description); - final Vector2f currentValue = property.getValue(); + EditableProperty property = cast(description); + var currentValue = property.getValue(); + var propertyControl = new Vector2fPropertyControl>(currentValue, + property.getName(), changeConsumer); + + var scrollPower = propertyControl.getScrollPower(); + var mod = property.getScrollPower(); + + propertyControl.setMinMax(property.getMinValue(), property.getMaxValue()); + propertyControl.setScrollPower(scrollPower * mod); + + addControl(container, property, propertyControl); + break; + } + case MIN_MAX_2F: { + + EditableProperty property = cast(description); - final Vector2FPropertyControl> propertyControl = - new Vector2FPropertyControl<>(currentValue, property.getName(), changeConsumer); + var value = property.getValue(); + var propertyControl = new MinMaxPropertyControl>( + value, property.getName(), changeConsumer); + + + var scrollPower = propertyControl.getScrollPower(); + var mod = property.getScrollPower(); + + propertyControl.setMinMax(property.getMinValue(), property.getMaxValue()); + propertyControl.setScrollPower(scrollPower * mod); addControl(container, property, propertyControl); break; } case VECTOR_3F: { - final EditableProperty property = cast(description); - final Vector3f currentValue = property.getValue(); + EditableProperty property = cast(description); + var currentValue = property.getValue(); + + var propertyControl = new Vector3fPropertyControl>(currentValue, + property.getName(), changeConsumer); + + addControl(container, property, propertyControl); + break; + } + case QUATERNION: { + + EditableProperty property = cast(description); + var currentValue = property.getValue(); - final Vector3FPropertyControl> propertyControl = - new Vector3FPropertyControl<>(currentValue, property.getName(), changeConsumer); + var propertyControl = new QuaternionPropertyControl>( + currentValue, property.getName(), changeConsumer); addControl(container, property, propertyControl); break; } case ENUM: { - final EditableProperty, ?> property = cast(description); - final Enum value = notNull(property.getValue(), "Enum value can't be null."); - final Enum[] availableValues = EditorUtil.getAvailableValues(value); + EditableProperty, ?> property = cast(description); + var value = notNull(property.getValue(), "Enum value can't be null."); + var availableValues = EditorUtil.getAvailableValues(value); - final EnumPropertyControl, ?>, Enum> propertyControl = - new EnumPropertyControl<>(value, property.getName(), changeConsumer, availableValues); + var propertyControl = new EnumPropertyControl, ?>, Enum>(value, + property.getName(), changeConsumer, availableValues); addControl(container, property, propertyControl); break; } case TEXTURE_2D: { - final EditableProperty property = cast(description); - final Texture2D value = property.getValue(); + EditableProperty property = cast(description); + var value = property.getValue(); - final Texture2DPropertyControl> propertyControl = - new Texture2DPropertyControl<>(value, property.getName(), changeConsumer); + var propertyControl = new Texture2dPropertyControl>(value, + property.getName(), changeConsumer); addControl(container, property, propertyControl); break; @@ -200,15 +239,18 @@ protected void buildFor(@NotNull final VBox container, @NotNull final C changeCo * @param propertyControl the property control. */ @FxThread - protected void addControl(@NotNull final VBox container, @NotNull final EditableProperty property, - @NotNull final PropertyControl, T> propertyControl) { + protected void addControl( + @NotNull VBox container, + @NotNull EditableProperty property, + @NotNull PropertyControl, T> propertyControl + ) { propertyControl.setApplyHandler(EditableProperty::setValue); propertyControl.setSyncHandler(EditableProperty::getValue); propertyControl.setEditObject(property); propertyControl.setDisable(property.isReadOnly()); - FXUtils.addToPane(propertyControl, container); + FxUtils.addChild(container, propertyControl); } /** @@ -220,9 +262,11 @@ protected void addControl(@NotNull final VBox container, @NotNull final Edit * @return the list of properties or null. */ @FxThread - protected @Nullable List> getProperties(@NotNull final Object object, - @Nullable final Object parent, - @NotNull final C changeConsumer) { + protected @Nullable List> getProperties( + @NotNull Object object, + @Nullable Object parent, + @NotNull C changeConsumer + ) { return getProperties(object); } @@ -233,12 +277,12 @@ protected void addControl(@NotNull final VBox container, @NotNull final Edit * @return the list of properties or null. */ @FxThread - protected @Nullable List> getProperties(@NotNull final Object object) { + protected @Nullable List> getProperties(@NotNull Object object) { return null; } @FxThread - protected @NotNull EditableProperty cast(@NotNull final EditableProperty property) { + protected @NotNull EditableProperty cast(@NotNull EditableProperty property) { return ClassUtils.unsafeCast(property); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/EmitterShapePropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/EmitterShapePropertyBuilder.java index b0614fa9..21ddf608 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/EmitterShapePropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/EmitterShapePropertyBuilder.java @@ -11,8 +11,8 @@ import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.impl.FloatPropertyControl; -import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -72,8 +72,8 @@ private void createControls(@NotNull final VBox container, @NotNull final ModelC final Vector3f point = shape.getPoint(); - final Vector3FPropertyControl pointControl = - new Vector3FPropertyControl<>(point, Messages.MODEL_PROPERTY_POINT, changeConsumer); + final Vector3fPropertyControl pointControl = + new Vector3fPropertyControl<>(point, Messages.MODEL_PROPERTY_POINT, changeConsumer); pointControl.setSyncHandler(EmitterPointShape::getPoint); pointControl.setApplyHandler(EmitterPointShape::setPoint); @@ -96,15 +96,15 @@ private void createControls(@NotNull final VBox container, @NotNull final ModelC final Vector3f length = shape.getLen(); final Vector3f min = shape.getMin(); - final Vector3FPropertyControl lengthControl = - new Vector3FPropertyControl<>(length, Messages.MODEL_PROPERTY_LENGTH, changeConsumer); + final Vector3fPropertyControl lengthControl = + new Vector3fPropertyControl<>(length, Messages.MODEL_PROPERTY_LENGTH, changeConsumer); lengthControl.setSyncHandler(EmitterBoxShape::getLen); lengthControl.setApplyHandler(EmitterBoxShape::setLen); lengthControl.setEditObject(shape); - final Vector3FPropertyControl minControl = - new Vector3FPropertyControl<>(min, Messages.MODEL_PROPERTY_MIN, changeConsumer); + final Vector3fPropertyControl minControl = + new Vector3fPropertyControl<>(min, Messages.MODEL_PROPERTY_MIN, changeConsumer); minControl.setSyncHandler(EmitterBoxShape::getMin); minControl.setApplyHandler(EmitterBoxShape::setMin); @@ -135,8 +135,8 @@ private void createControls(@NotNull final VBox container, @NotNull final ModelC radiusControl.setApplyHandler(EmitterSphereShape::setRadius); radiusControl.setEditObject(shape); - final Vector3FPropertyControl centerControl = - new Vector3FPropertyControl<>(center, Messages.MODEL_PROPERTY_CENTER, changeConsumer); + final Vector3fPropertyControl centerControl = + new Vector3fPropertyControl<>(center, Messages.MODEL_PROPERTY_CENTER, changeConsumer); centerControl.setSyncHandler(EmitterSphereShape::getCenter); centerControl.setApplyHandler(EmitterSphereShape::setCenter); diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/GeometryPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/GeometryPropertyBuilder.java index 3c3f30bf..652fb86b 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/GeometryPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/GeometryPropertyBuilder.java @@ -18,10 +18,10 @@ import com.ss.editor.ui.control.property.impl.LodLevelPropertyControl; import com.ss.editor.ui.control.property.impl.MaterialKeyPropertyControl; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/LightPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/LightPropertyBuilder.java index 30753d02..27a85a81 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/LightPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/LightPropertyBuilder.java @@ -15,8 +15,8 @@ import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.impl.ColorPropertyControl; import com.ss.editor.ui.control.property.impl.FloatPropertyControl; -import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,8 +87,8 @@ private void buildForPointLight(@NotNull final PointLight light, @NotNull final final Vector3f position = light.getPosition().clone(); final float radius = light.getRadius(); - final Vector3FPropertyControl positionControl = - new Vector3FPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer); + final Vector3fPropertyControl positionControl = + new Vector3fPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer); positionControl.setApplyHandler(PointLight::setPosition); positionControl.setSyncHandler(PointLight::getPosition); positionControl.setEditObject(light); @@ -122,8 +122,8 @@ private void buildForSpotLight(@NotNull final SpotLight light, @NotNull final VB directionControl.setSyncHandler(SpotLight::getDirection); directionControl.setEditObject(light); - final Vector3FPropertyControl positionControl = - new Vector3FPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer); + final Vector3fPropertyControl positionControl = + new Vector3fPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer); positionControl.setApplyHandler(SpotLight::setPosition); positionControl.setSyncHandler(SpotLight::getPosition); positionControl.setEditObject(light); diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialPropertyBuilder.java index 50eee8c0..8749d25d 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialPropertyBuilder.java @@ -12,8 +12,8 @@ import com.ss.editor.extension.property.SimpleProperty; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,11 +36,6 @@ public class MaterialPropertyBuilder extends EditableObjectPropertyBuilder { private static final ObjectDictionary SIZE_MAP = DictionaryFactory.newObjectDictionary(); static { - - for (final VarType varType : VarType.values()) { - SIZE_MAP.put(varType, 0); - } - SIZE_MAP.put(VarType.Texture2D, -1); SIZE_MAP.put(VarType.Vector3, -2); SIZE_MAP.put(VarType.Boolean, 3); @@ -50,9 +45,9 @@ public class MaterialPropertyBuilder extends EditableObjectPropertyBuilder { @NotNull protected static final Comparator MAT_PARAM_COMPARATOR = (first, second) -> { - final VarType firstType = first.getVarType(); - final VarType secondType = second.getVarType(); - return SIZE_MAP.get(secondType) - SIZE_MAP.get(firstType); + var firstType = first.getVarType(); + var secondType = second.getVarType(); + return SIZE_MAP.get(secondType, () -> 0) - SIZE_MAP.get(firstType, () -> 0); }; /** @@ -71,17 +66,16 @@ protected MaterialPropertyBuilder() { @Override @FxThread - protected @Nullable List> getProperties(@NotNull final Object object) { + protected @Nullable List> getProperties(@NotNull Object object) { if(!(object instanceof Material)) { return null; } - final Material material = (Material) object; - final MaterialDef definition = material.getMaterialDef(); + var material = (Material) object; + var definition = material.getMaterialDef(); - final Collection materialParams = definition.getMaterialParams(); - return materialParams.stream() + return definition.getMaterialParams().stream() .sorted(MAT_PARAM_COMPARATOR) .map(param -> convert(param, material)) .filter(Objects::nonNull) @@ -96,17 +90,15 @@ protected MaterialPropertyBuilder() { * @return the editable property or null. */ @FxThread - private @Nullable EditableProperty convert(@NotNull final MatParam param, - @NotNull final Material material) { + private @Nullable EditableProperty convert(@NotNull MatParam param, @NotNull Material material) { - final EditablePropertyType propertyType = convert(param.getVarType()); + var propertyType = convert(param.getVarType()); if (propertyType == null) { return null; } return new SimpleProperty<>(propertyType, param.getName(), 0.1F, material, - object -> getParamValue(param, object), - (object, newValue) -> applyParam(param, object, newValue)); + object -> getParamValue(param, object), (object, newValue) -> applyParam(param, object, newValue)); } /** @@ -117,8 +109,7 @@ protected MaterialPropertyBuilder() { * @param newValue the new value. */ @FxThread - protected void applyParam(@NotNull final MatParam param, @NotNull final Material material, - @Nullable final Object newValue) { + protected void applyParam(@NotNull MatParam param, @NotNull Material material, @Nullable Object newValue) { if (newValue == null) { material.clearParam(param.getName()); @@ -135,8 +126,8 @@ protected void applyParam(@NotNull final MatParam param, @NotNull final Material * @return the relevant value. */ @FxThread - protected @Nullable Object getParamValue(@NotNull final MatParam param, @NotNull final Material material) { - final MatParam currentParam = material.getParam(param.getName()); + protected @Nullable Object getParamValue(@NotNull MatParam param, @NotNull Material material) { + var currentParam = material.getParam(param.getName()); return currentParam == null ? null : currentParam.getValue(); } @@ -147,7 +138,7 @@ protected void applyParam(@NotNull final MatParam param, @NotNull final Material * @return the editable property type or null. */ @FxThread - protected @Nullable EditablePropertyType convert(@NotNull final VarType varType) { + protected @Nullable EditablePropertyType convert(@NotNull VarType varType) { switch (varType) { case Boolean: diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialSettingsPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialSettingsPropertyBuilder.java index 1775898f..24d5e442 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialSettingsPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/MaterialSettingsPropertyBuilder.java @@ -14,7 +14,7 @@ import com.ss.editor.extension.property.SimpleProperty; import com.ss.editor.model.node.material.*; import com.ss.editor.ui.control.property.builder.PropertyBuilder; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/MeshPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/MeshPropertyBuilder.java index c1d6f2dc..580941fd 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/MeshPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/MeshPropertyBuilder.java @@ -8,7 +8,7 @@ import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.impl.DefaultSinglePropertyControl; import com.ss.editor.ui.control.property.impl.EnumPropertyControl; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleEmitterPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleEmitterPropertyBuilder.java index cb00393a..aac50438 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleEmitterPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleEmitterPropertyBuilder.java @@ -1,75 +1,61 @@ package com.ss.editor.ui.control.property.builder.impl; +import static com.ss.editor.extension.property.EditablePropertyType.*; +import static com.ss.rlib.common.util.ObjectUtils.ifNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.effect.ParticleEmitter; -import com.jme3.effect.ParticleMesh; -import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.FxThread; +import com.ss.editor.extension.property.*; import com.ss.editor.model.undo.editor.ModelChangeConsumer; -import com.ss.editor.ui.control.property.impl.particle.ParticleEmitterImagesModelPropertyControl; import com.ss.editor.ui.control.property.builder.PropertyBuilder; -import com.ss.editor.ui.control.property.impl.*; -import com.ss.rlib.ui.util.FXUtils; -import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; -import java.util.function.Function; +import java.util.ArrayList; +import java.util.List; /** * The implementation of the {@link PropertyBuilder} to build property controls for {@link ParticleEmitter} objects. * * @author JavaSaBr */ -public class ParticleEmitterPropertyBuilder extends AbstractPropertyBuilder { +public class ParticleEmitterPropertyBuilder extends EditableModelObjectPropertyBuilder { - @NotNull - private static final ParticleMesh.Type[] MESH_TYPES = ParticleMesh.Type.values(); + @FunctionalInterface + private interface ChangeHandler extends Setter { - @NotNull - private static final BiConsumer APPLY_SIZE_HANDLER = (emitter, result) -> { - emitter.setStartSize(result.getX()); - emitter.setEndSize(result.getY()); - emitter.killAllParticles(); - }; - - @NotNull - private static final BiConsumer APPLY_LIFE_HANDLER = (emitter, result) -> { - emitter.setLowLife(result.getX()); - emitter.setHighLife(result.getY()); - emitter.killAllParticles(); - }; - - @NotNull - private static final BiConsumer APPLY_IMAGES_HANDLER = (emitter, result) -> { - emitter.setImagesX((int) result.getX()); - emitter.setImagesY((int) result.getY()); - emitter.killAllParticles(); - }; - - @NotNull - private static final Function SYNC_SIZE_HANDLER = emitter -> - new Vector2f(emitter.getStartSize(), emitter.getEndSize()); + @Override + default void set(@NotNull ParticleEmitter emitter, @Nullable T value) { + setImpl(emitter, notNull(value)); + emitter.killAllParticles(); + } - @NotNull - private static final Function SYNC_LIFE_HANDLER = emitter -> - new Vector2f(emitter.getLowLife(), emitter.getHighLife()); + void setImpl(@NotNull ParticleEmitter emitter, @NotNull T value); + } - @NotNull - private static final Function SYNC_IMAGES_HANDLER = emitter -> - new Vector2f(emitter.getImagesX(), emitter.getImagesY()); + private static final Getter SIZE_GETTER = + emitter -> new Vector2f(emitter.getStartSize(), emitter.getEndSize()); + private static final Getter LIFE_GETTER = + emitter -> new Vector2f(emitter.getLowLife(), emitter.getHighLife()); + private static final Getter SPRITES_GETTER = + emitter -> new Vector2f(emitter.getImagesX(), emitter.getImagesY()); - @NotNull - private static final Function SYNC_FACE_NORMAL_HANDLER = emitter -> { - final Vector3f faceNormal = emitter.getFaceNormal(); - return faceNormal == null ? new Vector3f() : faceNormal; + private static final ChangeHandler SIZE_SETTER = (emitter, size) -> { + emitter.setStartSize(size.getX()); + emitter.setEndSize(size.getY()); + }; + private static final ChangeHandler LIFE_SETTER = (emitter, size) -> { + emitter.setLowLife(size.getX()); + emitter.setHighLife(size.getY()); + }; + private static final ChangeHandler SPRITES_SETTER = (emitter, size) -> { + emitter.setImagesX((int) size.getX()); + emitter.setImagesY((int) size.getY()); }; - @NotNull private static final PropertyBuilder INSTANCE = new ParticleEmitterPropertyBuilder(); @FromAnyThread @@ -82,155 +68,57 @@ private ParticleEmitterPropertyBuilder() { } @Override - @FxThread - protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, - @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) { + protected @Nullable List> getProperties(@NotNull Object object) { if (!(object instanceof ParticleEmitter)) { - return; + return null; } - buildFor(container, changeConsumer, (ParticleEmitter) object); - buildSplitLine(container); + var emitter = (ParticleEmitter) object; + + var result = new ArrayList>(); + result.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_ENABLED, emitter, + ParticleEmitter::isEnabled, ParticleEmitter::setEnabled)); + result.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_FACING_VELOCITY, emitter, + ParticleEmitter::isFacingVelocity, ParticleEmitter::setFacingVelocity)); + result.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_IN_WORLD_SPACE, emitter, + ParticleEmitter::isInWorldSpace, ParticleEmitter::setInWorldSpace)); + result.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_RANDOM_ANGLE, emitter, + ParticleEmitter::isRandomAngle, ParticleEmitter::setRandomAngle)); + result.add(new SimpleProperty<>(BOOLEAN, Messages.MODEL_PROPERTY_IS_SELECT_RANDOM_IMAGE, emitter, + ParticleEmitter::isSelectRandomImage, ParticleEmitter::setSelectRandomImage)); + + result.add(new SimpleProperty<>(INTEGER, Messages.MODEL_PROPERTY_MAX_PARTICLES, 1F, 0, Integer.MAX_VALUE, emitter, + ParticleEmitter::getMaxNumParticles, ParticleEmitter::setNumParticles)); + result.add(new SimpleProperty<>(FLOAT, Messages.MODEL_PROPERTY_ROTATE_SPEED, emitter, + ParticleEmitter::getRotateSpeed, ParticleEmitter::setRotateSpeed)); + result.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_MESH_TYPE, emitter, + ParticleEmitter::getMeshType, ParticleEmitter::setMeshType)); + + result.add(new SimpleProperty<>(COLOR, Messages.MODEL_PROPERTY_START_COLOR, emitter, + ParticleEmitter::getStartColor, ParticleEmitter::setStartColor)); + result.add(new SimpleProperty<>(COLOR, Messages.MODEL_PROPERTY_END_COLOR, emitter, + ParticleEmitter::getEndColor, ParticleEmitter::setEndColor)); + + result.add(new SimpleProperty<>(VECTOR_2F, Messages.MODEL_PROPERTY_SIZE, 1F, 0F, 100F, emitter, + SIZE_GETTER, SIZE_SETTER)); + result.add(new SimpleProperty<>(MIN_MAX_2F, Messages.MODEL_PROPERTY_LIFE, 1F, 0F, 100F, emitter, + LIFE_GETTER, LIFE_SETTER)); + result.add(new SimpleProperty<>(VECTOR_2F, Messages.MODEL_PROPERTY_SPRITE_COUNT, 1F, 1, 100F, emitter, + SPRITES_GETTER, SPRITES_SETTER)); + + result.add(new SimpleProperty<>(VECTOR_3F, Messages.MODEL_PROPERTY_GRAVITY, emitter, + ParticleEmitter::getGravity, ParticleEmitter::setGravity)); + result.add(new SimpleProperty<>(VECTOR_3F, Messages.MODEL_PROPERTY_FACE_NORMAL, emitter, + em -> ifNull(em.getFaceNormal(), Vector3f::new), ParticleEmitter::setFaceNormal)); + + result.add(SeparatorProperty.getInstance()); + + return result; } - @FxThread - private void buildFor(@NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer, - @NotNull final ParticleEmitter emitter) { - - final boolean facingVelocity = emitter.isFacingVelocity(); - final boolean enabled = emitter.isEnabled(); - final boolean inWorldSpace = emitter.isInWorldSpace(); - final boolean randomAngle = emitter.isRandomAngle(); - final boolean selectRandomImage = emitter.isSelectRandomImage(); - - final float startSize = emitter.getStartSize(); - final float endSize = emitter.getEndSize(); - - final float lowLife = emitter.getLowLife(); - final float highLife = emitter.getHighLife(); - - final int imagesX = emitter.getImagesX(); - final int imagesY = emitter.getImagesY(); - - final int maxNumParticles = emitter.getMaxNumParticles(); - final float rotateSpeed = emitter.getRotateSpeed(); - - final ColorRGBA startColor = emitter.getStartColor(); - final ColorRGBA endColor = emitter.getEndColor(); - - final ParticleMesh.Type meshType = emitter.getMeshType(); - - final Vector3f gravity = emitter.getGravity(); - final Vector3f faceNormal = emitter.getFaceNormal() == null? new Vector3f() : emitter.getFaceNormal(); - - final BooleanPropertyControl enabledControl = - new BooleanPropertyControl<>(enabled, Messages.MODEL_PROPERTY_IS_ENABLED, changeConsumer); - enabledControl.setApplyHandler(ParticleEmitter::setEnabled); - enabledControl.setSyncHandler(ParticleEmitter::isEnabled); - enabledControl.setEditObject(emitter); - - final BooleanPropertyControl facingVelocityControl = - new BooleanPropertyControl<>(facingVelocity, Messages.MODEL_PROPERTY_IS_FACING_VELOCITY, changeConsumer); - facingVelocityControl.setApplyHandler(ParticleEmitter::setFacingVelocity); - facingVelocityControl.setSyncHandler(ParticleEmitter::isFacingVelocity); - facingVelocityControl.setEditObject(emitter); - - final BooleanPropertyControl inWorldSpaceControl = - new BooleanPropertyControl<>(inWorldSpace, Messages.MODEL_PROPERTY_IS_IN_WORLD_SPACE, changeConsumer); - inWorldSpaceControl.setApplyHandler(ParticleEmitter::setInWorldSpace); - inWorldSpaceControl.setSyncHandler(ParticleEmitter::isInWorldSpace); - inWorldSpaceControl.setEditObject(emitter); - - final BooleanPropertyControl randomAngleControl = - new BooleanPropertyControl<>(randomAngle, Messages.MODEL_PROPERTY_IS_RANDOM_ANGLE, changeConsumer); - randomAngleControl.setApplyHandler(ParticleEmitter::setRandomAngle); - randomAngleControl.setSyncHandler(ParticleEmitter::isRandomAngle); - randomAngleControl.setEditObject(emitter); - - final BooleanPropertyControl selectRandomImageControl = - new BooleanPropertyControl<>(selectRandomImage, Messages.MODEL_PROPERTY_IS_SELECT_RANDOM_IMAGE, changeConsumer); - selectRandomImageControl.setApplyHandler(ParticleEmitter::setSelectRandomImage); - selectRandomImageControl.setSyncHandler(ParticleEmitter::isSelectRandomImage); - selectRandomImageControl.setEditObject(emitter); - - final IntegerPropertyControl maxNumParticlesControl = - new IntegerPropertyControl<>(maxNumParticles, Messages.MODEL_PROPERTY_MAX_PARTICLES, changeConsumer); - maxNumParticlesControl.setApplyHandler(ParticleEmitter::setNumParticles); - maxNumParticlesControl.setSyncHandler(ParticleEmitter::getMaxNumParticles); - maxNumParticlesControl.setEditObject(emitter); - - final FloatPropertyControl rotateSpeedControl = - new FloatPropertyControl<>(rotateSpeed, Messages.MODEL_PROPERTY_ROTATE_SPEED, changeConsumer); - rotateSpeedControl.setApplyHandler(ParticleEmitter::setRotateSpeed); - rotateSpeedControl.setSyncHandler(ParticleEmitter::getRotateSpeed); - rotateSpeedControl.setEditObject(emitter); - - final EnumPropertyControl meshTypeControl = - new EnumPropertyControl<>(meshType, Messages.MODEL_PROPERTY_MESH_TYPE, changeConsumer, MESH_TYPES); - meshTypeControl.setApplyHandler(ParticleEmitter::setMeshType); - meshTypeControl.setSyncHandler(ParticleEmitter::getMeshType); - meshTypeControl.setEditObject(emitter); - - final ColorPropertyControl startColorControl = - new ColorPropertyControl<>(startColor, Messages.MODEL_PROPERTY_START_COLOR, changeConsumer); - startColorControl.setApplyHandler(ParticleEmitter::setStartColor); - startColorControl.setSyncHandler(ParticleEmitter::getStartColor); - startColorControl.setEditObject(emitter); - - final ColorPropertyControl endColorControl = - new ColorPropertyControl<>(endColor, Messages.MODEL_PROPERTY_END_COLOR, changeConsumer); - endColorControl.setApplyHandler(ParticleEmitter::setEndColor); - endColorControl.setSyncHandler(ParticleEmitter::getEndColor); - endColorControl.setEditObject(emitter); - - final MinMaxPropertyControl sizeControl = - new MinMaxPropertyControl<>(new Vector2f(startSize, endSize), Messages.MODEL_PROPERTY_SIZE, changeConsumer); - sizeControl.setApplyHandler(APPLY_SIZE_HANDLER); - sizeControl.setSyncHandler(SYNC_SIZE_HANDLER); - sizeControl.setEditObject(emitter); - - final MinMaxPropertyControl lifeControl = - new MinMaxPropertyControl<>(new Vector2f(lowLife, highLife), Messages.MODEL_PROPERTY_LIFE, changeConsumer); - lifeControl.setApplyHandler(APPLY_LIFE_HANDLER); - lifeControl.setSyncHandler(SYNC_LIFE_HANDLER); - lifeControl.setEditObject(emitter); - - final ParticleEmitterImagesModelPropertyControl imagesControl = - new ParticleEmitterImagesModelPropertyControl(new Vector2f(imagesX, imagesY), Messages.MODEL_PROPERTY_SPRITE_COUNT, changeConsumer); - imagesControl.setApplyHandler(APPLY_IMAGES_HANDLER); - imagesControl.setSyncHandler(SYNC_IMAGES_HANDLER); - imagesControl.setEditObject(emitter); - - final Vector3FPropertyControl gravityControl = - new Vector3FPropertyControl<>(gravity, Messages.MODEL_PROPERTY_GRAVITY, changeConsumer); - gravityControl.setApplyHandler(ParticleEmitter::setGravity); - gravityControl.setSyncHandler(ParticleEmitter::getGravity); - gravityControl.setEditObject(emitter); - - final Vector3FPropertyControl faceNormalControl = - new Vector3FPropertyControl<>(faceNormal, Messages.MODEL_PROPERTY_FACE_NORMAL, changeConsumer); - faceNormalControl.setApplyHandler(ParticleEmitter::setFaceNormal); - faceNormalControl.setSyncHandler(SYNC_FACE_NORMAL_HANDLER); - faceNormalControl.setEditObject(emitter); - - FXUtils.addToPane(enabledControl, container); - FXUtils.addToPane(facingVelocityControl, container); - FXUtils.addToPane(inWorldSpaceControl, container); - FXUtils.addToPane(randomAngleControl, container); - FXUtils.addToPane(selectRandomImageControl, container); - FXUtils.addToPane(maxNumParticlesControl, container); - FXUtils.addToPane(rotateSpeedControl, container); - FXUtils.addToPane(meshTypeControl, container); - FXUtils.addToPane(startColorControl, container); - FXUtils.addToPane(endColorControl, container); - FXUtils.addToPane(sizeControl, container); - FXUtils.addToPane(lifeControl, container); - FXUtils.addToPane(imagesControl, container); - - buildSplitLine(container); - - FXUtils.addToPane(gravityControl, container); - FXUtils.addToPane(faceNormalControl, container); + @Override + public int getPriority() { + return SpatialPropertyBuilder.PRIORITY + 1; } } diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleInfluencerPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleInfluencerPropertyBuilder.java index 5810a6c8..11dad8cd 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleInfluencerPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleInfluencerPropertyBuilder.java @@ -11,8 +11,8 @@ import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.impl.BooleanPropertyControl; import com.ss.editor.ui.control.property.impl.FloatPropertyControl; -import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,8 +48,8 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object final float velocityVariation = influencer.getVelocityVariation(); - final Vector3FPropertyControl initialVelocityControl = - new Vector3FPropertyControl<>(initialVelocity, Messages.MODEL_PROPERTY_INITIAL_VELOCITY, changeConsumer); + final Vector3fPropertyControl initialVelocityControl = + new Vector3fPropertyControl<>(initialVelocity, Messages.MODEL_PROPERTY_INITIAL_VELOCITY, changeConsumer); initialVelocityControl.setSyncHandler(ParticleInfluencer::getInitialVelocity); initialVelocityControl.setApplyHandler(ParticleInfluencer::setInitialVelocity); @@ -106,8 +106,8 @@ private void createControls(@NotNull final VBox container, final @NotNull ModelC horizontalControl.setApplyHandler(RadialParticleInfluencer::setHorizontal); horizontalControl.setEditObject(influencer); - final Vector3FPropertyControl originControl = - new Vector3FPropertyControl<>(origin, Messages.MODEL_PROPERTY_ORIGIN, changeConsumer); + final Vector3fPropertyControl originControl = + new Vector3fPropertyControl<>(origin, Messages.MODEL_PROPERTY_ORIGIN, changeConsumer); originControl.setSyncHandler(RadialParticleInfluencer::getOrigin); originControl.setApplyHandler(RadialParticleInfluencer::setOrigin); diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/PrimitivePropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/PrimitivePropertyBuilder.java index 3b7d6860..b2273a5f 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/PrimitivePropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/PrimitivePropertyBuilder.java @@ -7,8 +7,8 @@ import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.impl.DefaultSinglePropertyControl; -import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,8 +48,8 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object final Vector3f position = (Vector3f) object; final Vector3f value = position.clone(); - final Vector3FPropertyControl control = - new Vector3FPropertyControl<>(value, Messages.MODEL_PROPERTY_VALUE, changeConsumer); + final Vector3fPropertyControl control = + new Vector3fPropertyControl<>(value, Messages.MODEL_PROPERTY_VALUE, changeConsumer); control.setApplyHandler(Vector3f::set); control.setSyncHandler(Vector3f::clone); control.setEditObject(position); diff --git a/src/main/java/com/ss/editor/ui/control/property/builder/impl/SpatialPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/property/builder/impl/SpatialPropertyBuilder.java index b0ab06ac..d34547ea 100644 --- a/src/main/java/com/ss/editor/ui/control/property/builder/impl/SpatialPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/property/builder/impl/SpatialPropertyBuilder.java @@ -1,53 +1,44 @@ package com.ss.editor.ui.control.property.builder.impl; +import static com.ss.editor.extension.property.EditablePropertyType.*; import static com.ss.editor.part3d.editor.impl.scene.AbstractSceneEditor3DPart.KEY_LOADED_MODEL; +import static com.ss.rlib.common.util.ObjectUtils.ifNull; import com.jme3.math.ColorRGBA; -import com.jme3.math.Quaternion; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Spatial; -import com.jme3.scene.Spatial.CullHint; import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.extension.property.*; import com.ss.editor.extension.scene.SceneLayer; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.model.undo.editor.ModelChangeConsumer; -import com.ss.editor.model.undo.editor.SceneChangeConsumer; -import com.ss.editor.ui.control.property.impl.LayerModelPropertyControl; import com.ss.editor.ui.control.property.builder.PropertyBuilder; -import com.ss.editor.ui.control.property.impl.*; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import javafx.scene.layout.VBox; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; +import java.util.ArrayList; +import java.util.List; /** * The implementation of the {@link PropertyBuilder} to build property controls for {@link Spatial} objects. * * @author JavaSaBr */ -public class SpatialPropertyBuilder extends AbstractPropertyBuilder { +public class SpatialPropertyBuilder extends EditableModelObjectPropertyBuilder { public static final int PRIORITY = 1; - @NotNull - private static final CullHint[] CULL_HINTS = CullHint.values(); - - @NotNull - private static final ShadowMode[] SHADOW_MODES = ShadowMode.values(); + private static final PropertyBuilder INSTANCE = new SpatialPropertyBuilder(); - @NotNull - private static final Bucket[] BUCKETS = Bucket.values(); + private static final Getter LAYER_GETTER = + spatial -> ifNull(SceneLayer.getLayer(spatial), SceneLayer.NO_LAYER); - @NotNull - private static final PropertyBuilder INSTANCE = new SpatialPropertyBuilder(); + private static final Setter LAYER_SETTER = + (spatial, layer) -> SceneLayer.setLayer(layer, spatial); @FromAnyThread public static @NotNull PropertyBuilder getInstance() { @@ -59,210 +50,101 @@ private SpatialPropertyBuilder() { } @Override - @FxThread - protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container, - @NotNull final ModelChangeConsumer changeConsumer) { + protected @Nullable List> getProperties( + @NotNull Object object, + @Nullable Object parent, + @NotNull ModelChangeConsumer changeConsumer + ) { if (!(object instanceof Spatial)) { - return; + return null; } - final Spatial spatial = (Spatial) object; - final CullHint cullHint = spatial.getLocalCullHint(); - final ShadowMode shadowMode = spatial.getLocalShadowMode(); - final Bucket queueBucket = spatial.getLocalQueueBucket(); + var properties = new ArrayList>(); + var spatial = (Spatial) object; - if (changeConsumer instanceof SceneChangeConsumer) { + properties.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_CULL_HINT, spatial, + Spatial::getCullHint, Spatial::setCullHint)); + properties.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_SHADOW_MODE, spatial, + Spatial::getShadowMode, Spatial::setShadowMode)); + properties.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_QUEUE_BUCKET, spatial, + Spatial::getLocalQueueBucket, Spatial::setQueueBucket)); + properties.add(new SimpleProperty<>(SCENE_LAYER, Messages.MODEL_PROPERTY_LAYER, spatial, LAYER_GETTER, LAYER_SETTER)); - final SceneLayer layer = SceneLayer.getLayer(spatial); - final LayerModelPropertyControl propertyControl = new LayerModelPropertyControl(layer, (SceneChangeConsumer) changeConsumer); - propertyControl.setEditObject(spatial); - - FXUtils.addToPane(propertyControl, container); - } - - final EnumPropertyControl cullHintControl = - new EnumPropertyControl<>(cullHint, Messages.MODEL_PROPERTY_CULL_HINT, changeConsumer, CULL_HINTS); - cullHintControl.setApplyHandler(Spatial::setCullHint); - cullHintControl.setSyncHandler(Spatial::getLocalCullHint); - cullHintControl.setEditObject(spatial); - - final EnumPropertyControl shadowModeControl = - new EnumPropertyControl<>(shadowMode, Messages.MODEL_PROPERTY_SHADOW_MODE, changeConsumer, SHADOW_MODES); - shadowModeControl.setApplyHandler(Spatial::setShadowMode); - shadowModeControl.setSyncHandler(Spatial::getLocalShadowMode); - shadowModeControl.setEditObject(spatial); - - final EnumPropertyControl queueBucketControl = - new EnumPropertyControl<>(queueBucket, Messages.MODEL_PROPERTY_QUEUE_BUCKET, changeConsumer, BUCKETS); - queueBucketControl.setApplyHandler(Spatial::setQueueBucket); - queueBucketControl.setSyncHandler(Spatial::getLocalQueueBucket); - queueBucketControl.setEditObject(spatial); + if (canEditTransformation(spatial)) { - FXUtils.addToPane(cullHintControl, container); - FXUtils.addToPane(shadowModeControl, container); - FXUtils.addToPane(queueBucketControl, container); + properties.add(SeparatorProperty.getInstance()); - if (canEditTransformation(spatial)) { + properties.add(new SimpleProperty<>(VECTOR_3F, Messages.MODEL_PROPERTY_LOCATION, spatial, + Spatial::getLocalTranslation, Spatial::setLocalTranslation)); + properties.add(new SimpleProperty<>(VECTOR_3F, Messages.MODEL_PROPERTY_SCALE, spatial, + Spatial::getLocalScale, Spatial::setLocalScale)); + properties.add(new SimpleProperty<>(QUATERNION, Messages.MODEL_PROPERTY_ROTATION, spatial, + Spatial::getLocalRotation, Spatial::setLocalRotation)); - buildSplitLine(container); - - final Vector3f location = spatial.getLocalTranslation().clone(); - final Vector3f scale = spatial.getLocalScale().clone(); - final Quaternion rotation = spatial.getLocalRotation().clone(); - - final Vector3FPropertyControl locationControl = - new Vector3FPropertyControl<>(location, Messages.MODEL_PROPERTY_LOCATION, changeConsumer); - locationControl.setApplyHandler(Spatial::setLocalTranslation); - locationControl.setSyncHandler(Spatial::getLocalTranslation); - locationControl.setEditObject(spatial); - - final Vector3FPropertyControl scaleControl = - new Vector3FPropertyControl<>(scale, Messages.MODEL_PROPERTY_SCALE, changeConsumer); - scaleControl.setApplyHandler(Spatial::setLocalScale); - scaleControl.setSyncHandler(Spatial::getLocalScale); - scaleControl.setEditObject(spatial); - - final QuaternionPropertyControl rotationControl = - new QuaternionPropertyControl<>(rotation, Messages.MODEL_PROPERTY_ROTATION, changeConsumer); - rotationControl.setApplyHandler(Spatial::setLocalRotation); - rotationControl.setSyncHandler(Spatial::getLocalRotation); - rotationControl.setEditObject(spatial); - - FXUtils.addToPane(locationControl, container); - FXUtils.addToPane(scaleControl, container); - FXUtils.addToPane(rotationControl, container); } - final Collection userDataKeys = spatial.getUserDataKeys(); + var userDataKeys = spatial.getUserDataKeys(); if (userDataKeys.isEmpty()) { - return; + return properties; } - int count = 0; - - for (final String key : userDataKeys) { - if (isNeedSkip(key)) continue; - count++; - } + var count = userDataKeys.stream() + .filter(s -> !isNeedSkip(s)) + .count(); - if(count < 1) { - return; + if (count < 1) { + return properties; } - buildSplitLine(container); + properties.add(SeparatorProperty.getInstance()); final Array sortedKeys = ArrayFactory.newSortedArray(String.class); sortedKeys.addAll(userDataKeys); - for (final String key : sortedKeys) { - if (isNeedSkip(key)) continue; - - final Object data = spatial.getUserData(key); - - if (data instanceof Float) { - - final Float value = (Float) data; - - final FloatPropertyControl control = - new FloatPropertyControl<>(value, key, changeConsumer); - control.setApplyHandler((sp, newValue) -> sp.setUserData(key, newValue)); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); - - FXUtils.addToPane(control, container); - - } else if (data instanceof Integer) { - - final Integer value = (Integer) data; - - final IntegerPropertyControl control = - new IntegerPropertyControl<>(value, key, changeConsumer); - control.setApplyHandler((sp, newValue) -> sp.setUserData(key, newValue)); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); - - FXUtils.addToPane(control, container); + for (var key : sortedKeys) { - } else if (data instanceof Boolean) { - - final Boolean value = (Boolean) data; - - final BooleanPropertyControl control = - new BooleanPropertyControl<>(value, key, changeConsumer); - control.setApplyHandler((sp, newValue) -> sp.setUserData(key, newValue)); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); - - FXUtils.addToPane(control, container); - - } else if (data instanceof Vector3f) { - - final Vector3f value = (Vector3f) data; - - final Vector3FPropertyControl control = - new Vector3FPropertyControl<>(value, key, changeConsumer); - control.setApplyHandler((sp, newValue) -> sp.setUserData(key, newValue)); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); - - FXUtils.addToPane(control, container); - - } else if (data instanceof Vector2f) { - - final Vector2f value = (Vector2f) data; - - final Vector2FPropertyControl control = - new Vector2FPropertyControl<>(value, key, changeConsumer); - control.setApplyHandler((sp, newValue) -> sp.setUserData(key, newValue)); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); - - FXUtils.addToPane(control, container); - - } else if (data instanceof ColorRGBA) { - - final ColorRGBA value = (ColorRGBA) data; - - final ColorPropertyControl control = - new ColorPropertyControl<>(value, key, changeConsumer); - control.setApplyHandler((sp, newValue) -> sp.setUserData(key, newValue)); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); - - FXUtils.addToPane(control, container); - - } else if (data instanceof String) { - - final String value = (String) data; - - final StringPropertyControl control = - new StringPropertyControl<>(value, key, changeConsumer); - control.setApplyHandler((sp, newValue) -> sp.setUserData(key, newValue)); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); + if (isNeedSkip(key)) { + continue; + } - FXUtils.addToPane(control, container); + var data = spatial.getUserData(key); - } else { + properties.add(new SimpleProperty<>(getUserDataType(data), key, spatial, + sp -> sp.getUserData(key), (sp, val) -> sp.setUserData(key, val))); + } - final DefaultSinglePropertyControl control = - new DefaultSinglePropertyControl<>(data, key, changeConsumer); - control.setSyncHandler(sp -> sp.getUserData(key)); - control.setEditObject(spatial); + return properties; + } - FXUtils.addToPane(control, container); - } + private @NotNull EditablePropertyType getUserDataType(@NotNull Object value) { + + if (value instanceof Float) { + return EditablePropertyType.FLOAT; + } else if (value instanceof Integer) { + return EditablePropertyType.INTEGER; + } else if (value instanceof Boolean) { + return EditablePropertyType.BOOLEAN; + } else if (value instanceof Vector3f) { + return EditablePropertyType.VECTOR_3F; + } else if (value instanceof Vector2f) { + return EditablePropertyType.VECTOR_2F; + } else if (value instanceof ColorRGBA) { + return EditablePropertyType.COLOR; + } else if (value instanceof String) { + return EditablePropertyType.STRING; } + + return EditablePropertyType.READ_ONLY_STRING; } @FxThread - private boolean isNeedSkip(@NotNull final String key) { + private boolean isNeedSkip(@NotNull String key) { return SceneLayer.KEY.equals(key) || KEY_LOADED_MODEL.equals(key); } @FxThread - private boolean canEditTransformation(@NotNull final Spatial spatial) { + private boolean canEditTransformation(@NotNull Spatial spatial) { return !(spatial instanceof SceneNode || spatial instanceof SceneLayer); } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/AudioKeyPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/AudioKeyPropertyControl.java index d50094b8..87c141c6 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/AudioKeyPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/AudioKeyPropertyControl.java @@ -2,7 +2,7 @@ import static com.ss.editor.FileExtensions.AUDIO_EXTENSIONS; import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.audio.AudioData; import com.jme3.audio.AudioKey; import com.jme3.audio.AudioNode; @@ -15,8 +15,10 @@ import com.ss.editor.ui.event.impl.RequestedOpenFileEvent; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.fx.util.FxUtils; +import com.ss.rlib.common.util.StringUtils; +import javafx.event.ActionEvent; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.image.ImageView; @@ -32,7 +34,7 @@ /** * The implementation of the {@link PropertyControl} to edit the {@link AudioData}. * - * @param the change consumer's type. + * @param the type of a change consumer. * @author JavaSaBr */ public class AudioKeyPropertyControl extends PropertyControl { @@ -46,8 +48,11 @@ public class AudioKeyPropertyControl extends PropertyC @Nullable private Label audioKeyLabel; - public AudioKeyPropertyControl(@Nullable final AudioKey element, @NotNull final String paramName, - @NotNull final C changeConsumer) { + public AudioKeyPropertyControl( + @Nullable AudioKey element, + @NotNull String paramName, + @NotNull C changeConsumer + ) { super(element, paramName, changeConsumer); setOnDragOver(this::handleDragOverEvent); setOnDragDropped(this::handleDragDroppedEvent); @@ -55,20 +60,19 @@ public AudioKeyPropertyControl(@Nullable final AudioKey element, @NotNull final } /** - * Handle grad exited events. + * Handle drag exited events. * * @param dragEvent the drag exited event. */ - private void handleDragExitedEvent(@NotNull final DragEvent dragEvent) { - + private void handleDragExitedEvent(@NotNull DragEvent dragEvent) { } /** - * Handle dropped event. + * Handle dropped events. * * @param dragEvent the dropped event. */ - private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { + private void handleDragDroppedEvent(@NotNull DragEvent dragEvent) { UiUtils.handleDroppedFile(dragEvent, AUDIO_EXTENSIONS, this, AudioKeyPropertyControl::addAudioData); } @@ -77,48 +81,54 @@ private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { * * @param dragEvent the drag over events. */ - private void handleDragOverEvent(@NotNull final DragEvent dragEvent) { + private void handleDragOverEvent(@NotNull DragEvent dragEvent) { UiUtils.acceptIfHasFile(dragEvent, AUDIO_EXTENSIONS); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); audioKeyLabel = new Label(NO_AUDIO); - final Button changeButton = new Button(); + var changeButton = new Button(); changeButton.setGraphic(new ImageView(Icons.ADD_16)); - changeButton.setOnAction(event -> processChange()); + changeButton.setOnAction(this::processChange); - final Button openButton = new Button(); + var openButton = new Button(); openButton.setGraphic(new ImageView(Icons.EDIT_16)); - openButton.disableProperty().bind(audioKeyLabel.textProperty().isEqualTo(NO_AUDIO)); - openButton.setOnAction(event -> processOpen()); + openButton.setOnAction(this::openAudio); + openButton.disableProperty() + .bind(audioKeyLabel.textProperty().isEqualTo(NO_AUDIO)); - audioKeyLabel.prefWidthProperty().bind(widthProperty() + audioKeyLabel.prefWidthProperty() + .bind(widthProperty() .subtract(changeButton.widthProperty()) .subtract(openButton.widthProperty())); - FXUtils.addToPane(audioKeyLabel, container); - FXUtils.addToPane(changeButton, container); - FXUtils.addToPane(openButton, container); + FxUtils.addClass(container, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER) + .addClass(audioKeyLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL) + .addClass(changeButton, openButton, + CssClasses.FLAT_BUTTON, + CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); - FXUtils.addClassesTo(container, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); - FXUtils.addClassTo(audioKeyLabel, CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL); - FXUtils.addClassesTo(changeButton, openButton, CssClasses.FLAT_BUTTON, - CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); + FxUtils.addChild(container, + audioKeyLabel, changeButton, openButton); DynamicIconSupport.addSupport(changeButton, openButton); } /** * Show dialog for choosing another audio key. + * + * @param event the action event. */ @FxThread - protected void processChange() { + protected void processChange(@Nullable ActionEvent event) { UiUtils.openFileAssetDialog(this::addAudioData, AUDIO_EXTENSIONS, DEFAULT_ACTION_TESTER); } @@ -128,10 +138,10 @@ protected void processChange() { * @param file the audio file. */ @FxThread - private void addAudioData(@NotNull final Path file) { + private void addAudioData(@NotNull Path file) { - final Path assetFile = notNull(getAssetFile(file)); - final AudioKey audioKey = new AudioKey(toAssetPath(assetFile)); + var assetFile = notNull(getAssetFile(file)); + var audioKey = new AudioKey(toAssetPath(assetFile)); changed(audioKey, getPropertyValue()); setIgnoreListener(true); @@ -144,34 +154,35 @@ private void addAudioData(@NotNull final Path file) { /** * Open this audio data in the audio viewer. + * + * @param event the action event. */ @FxThread - protected void processOpen() { + protected void openAudio(@Nullable ActionEvent event) { - final AudioKey element = getPropertyValue(); + var element = getPropertyValue(); if (element == null) { return; } - final String assetPath = element.getName(); - if (StringUtils.isEmpty(assetPath)) return; + var assetPath = element.getName(); + if (StringUtils.isEmpty(assetPath)) { + return; + } - final Path assetFile = Paths.get(assetPath); - final Path realFile = notNull(getRealFile(assetFile)); + var assetFile = Paths.get(assetPath); + var realFile = notNull(getRealFile(assetFile)); if (!Files.exists(realFile)) { return; } - final RequestedOpenFileEvent event = new RequestedOpenFileEvent(); - event.setFile(realFile); - - FX_EVENT_MANAGER.notify(event); + FX_EVENT_MANAGER.notify(new RequestedOpenFileEvent(realFile)); } /** - * Gets audio key label. + * Get the audio key label. * - * @return the label with name of the audio key. + * @return the audio key label. */ @FxThread private @NotNull Label getAudioKeyLabel() { @@ -181,8 +192,10 @@ protected void processOpen() { @Override @FxThread protected void reload() { - final AudioKey element = getPropertyValue(); - final Label audioKeyLabel = getAudioKeyLabel(); - audioKeyLabel.setText(element == null || StringUtils.isEmpty(element.getName()) ? NO_AUDIO : element.getName()); + getAudioKeyLabel().setText(getKeyLabel(getPropertyValue())); + } + + private @NotNull String getKeyLabel(@Nullable AudioKey assetKey) { + return EditorUtil.isEmpty(assetKey) ? NO_AUDIO : assetKey.getName(); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/BooleanPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/BooleanPropertyControl.java index 610ddfc0..ae72f986 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/BooleanPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/BooleanPropertyControl.java @@ -1,74 +1,77 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static java.lang.Boolean.TRUE; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.ui.util.FXUtils; -import javafx.beans.property.DoubleProperty; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.CheckBox; -import javafx.scene.control.Label; import javafx.scene.layout.HBox; -import javafx.scene.layout.Region; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; +import java.util.Objects; /** * The implementation of the {@link PropertyControl} to change boolean values. * - * @param the type of a {@link ChangeConsumer}. - * @param the type of an editing object. + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr */ -public class BooleanPropertyControl extends PropertyControl { +public class BooleanPropertyControl extends PropertyControl { /** - * The {@link CheckBox} with current value. + * The field with current value. */ @Nullable private CheckBox checkBox; - public BooleanPropertyControl(@Nullable final Boolean propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public BooleanPropertyControl( + @Nullable Boolean propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } - public BooleanPropertyControl(@Nullable final Boolean propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, - @Nullable final SixObjectConsumer> changeHandler) { + public BooleanPropertyControl( + @Nullable Boolean propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @Nullable ChangeHandler changeHandler + ) { super(propertyValue, propertyName, changeConsumer, changeHandler); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); checkBox = new CheckBox(); - checkBox.selectedProperty().addListener((observable, oldValue, newValue) -> updateValue()); - checkBox.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + checkBox.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxControlUtils.onSelectedChange(checkBox, this::updateValue); + + FxUtils.addClass(checkBox, + CssClasses.PROPERTY_CONTROL_CHECK_BOX); - FXUtils.addToPane(checkBox, container); - FXUtils.addClassTo(checkBox, CssClasses.ABSTRACT_PARAM_CONTROL_CHECK_BOX); + FxUtils.addChild(container, checkBox); } @Override @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { + public void changeControlWidthPercent(double controlWidthPercent) { + super.changeControlWidthPercent(controlWidthPercent); - final CheckBox checkBox = getCheckBox(); - final DoubleProperty widthProperty = checkBox.prefWidthProperty(); - - if (widthProperty.isBound()) { - super.changeControlWidthPercent(controlWidthPercent); - widthProperty.unbind(); - widthProperty.bind(widthProperty().multiply(controlWidthPercent)); - } + FxUtils.rebindPrefWidth(getCheckBox(), + widthProperty().multiply(controlWidthPercent)); } /** @@ -76,16 +79,9 @@ public void changeControlWidthPercent(final double controlWidthPercent) { */ @FxThread public void disableCheckboxOffset() { - - final CheckBox checkBox = getCheckBox(); - checkBox.prefWidthProperty().unbind(); - - final Label propertyNameLabel = getPropertyNameLabel(); - propertyNameLabel.maxWidthProperty().unbind(); - propertyNameLabel.setMaxWidth(Region.USE_COMPUTED_SIZE); - propertyNameLabel.prefWidthProperty().bind(widthProperty()); - propertyNameLabel.minWidthProperty().unbind(); - propertyNameLabel.setMinWidth(Region.USE_COMPUTED_SIZE); + FxUtils.resetPrefWidth(getCheckBox()); + FxUtils.resetMinMaxWidth(getPropertyNameLabel()) + .prefWidthProperty().bind(widthProperty()); } @Override @@ -95,7 +91,9 @@ protected boolean isSingleRow() { } /** - * @return the {@link CheckBox} with current value. + * Get the field with current value. + * + * @return the field with current value. */ @FxThread private @NotNull CheckBox getCheckBox() { @@ -105,9 +103,13 @@ protected boolean isSingleRow() { @Override @FxThread protected void reload() { - final Boolean value = getPropertyValue(); - final CheckBox checkBox = getCheckBox(); - checkBox.setSelected(Boolean.TRUE.equals(value)); + getCheckBox().setSelected(TRUE.equals(getPropertyValue())); + } + + @FxThread + @Override + public boolean isDirty() { + return !Objects.equals(getPropertyValue(), getCheckBox().isSelected()); } /** @@ -115,8 +117,14 @@ protected void reload() { */ @FxThread private void updateValue() { - if (isIgnoreListener()) return; - final CheckBox checkBox = getCheckBox(); - changed(checkBox.isSelected(), getPropertyValue()); + if (!isIgnoreListener()) { + apply(); + } + } + + @Override + protected void apply() { + super.apply(); + changed(getCheckBox().isSelected(), getPropertyValue()); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/ColorPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/ColorPropertyControl.java index e9af5a9f..0389b066 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/ColorPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/ColorPropertyControl.java @@ -1,14 +1,15 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.ColorPicker; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; @@ -29,37 +30,43 @@ public class ColorPropertyControl extends PropertyC @Nullable private ColorPicker colorPicker; - public ColorPropertyControl(@Nullable final ColorRGBA propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public ColorPropertyControl( + @Nullable ColorRGBA propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); colorPicker = new ColorPicker(); - colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> updateValue()); - colorPicker.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + colorPicker.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxControlUtils.onColorChange(colorPicker, this::updateValue); + + FxUtils.addClass(colorPicker, + CssClasses.PROPERTY_CONTROL_COLOR_PICKER); - FXUtils.addToPane(colorPicker, container); - FXUtils.addClassTo(colorPicker, CssClasses.ABSTRACT_PARAM_CONTROL_COLOR_PICKER); + FxUtils.addChild(container, colorPicker); } @Override @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { + public void changeControlWidthPercent(double controlWidthPercent) { super.changeControlWidthPercent(controlWidthPercent); - final ColorPicker colorPicker = getColorPicker(); - colorPicker.prefWidthProperty().unbind(); - colorPicker.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); + FxUtils.rebindPrefWidth(getColorPicker(), + widthProperty().multiply(controlWidthPercent)); } @Override @FxThread - protected void setPropertyValue(@Nullable final ColorRGBA color) { + protected void setPropertyValue(@Nullable ColorRGBA color) { super.setPropertyValue(color == null ? null : color.clone()); } @@ -70,6 +77,8 @@ protected boolean isSingleRow() { } /** + * Get the color picker. + * * @return the color picker. */ @FxThread @@ -80,8 +89,7 @@ protected boolean isSingleRow() { @Override @FxThread protected void reload() { - final ColorPicker colorPicker = getColorPicker(); - colorPicker.setValue(UiUtils.from(getPropertyValue())); + getColorPicker().setValue(UiUtils.from(getPropertyValue())); } /** @@ -94,9 +102,9 @@ private void updateValue() { return; } - final ColorPicker colorPicker = getColorPicker(); - final ColorRGBA newColor = UiUtils.from(colorPicker.getValue()); - final ColorRGBA oldValue = getPropertyValue(); + var colorPicker = getColorPicker(); + var newColor = UiUtils.from(colorPicker.getValue()); + var oldValue = getPropertyValue(); changed(newColor, oldValue == null ? null : oldValue.clone()); } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/DefaultPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/DefaultPropertyControl.java index b520ec12..b919d17a 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/DefaultPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/DefaultPropertyControl.java @@ -1,12 +1,12 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; @@ -36,22 +36,27 @@ public class DefaultPropertyControl extends Prop @Nullable private Function toStringFunction; - public DefaultPropertyControl(@Nullable final T propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public DefaultPropertyControl( + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } /** - * Sets to string function. + * Set the string function. * * @param toStringFunction the string function. */ @FromAnyThread - public void setToStringFunction(@Nullable final Function toStringFunction) { + public void setToStringFunction(@Nullable Function toStringFunction) { this.toStringFunction = toStringFunction; } /** + * Get the string function. + * * @return the string function. */ @FromAnyThread @@ -60,6 +65,8 @@ public void setToStringFunction(@Nullable final Function toStringFunc } /** + * Get the label with value of the property. + * * @return the label with value of the property. */ protected @NotNull Label getPropertyValueLabel() { @@ -68,15 +75,18 @@ public void setToStringFunction(@Nullable final Function toStringFunc @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); propertyValueLabel = new Label(); - propertyValueLabel.prefWidthProperty().bind(container.widthProperty()); + propertyValueLabel.prefWidthProperty() + .bind(container.widthProperty()); - FXUtils.addClassesTo(propertyValueLabel, CssClasses.ABSTRACT_PARAM_CONTROL_LABEL_VALUE, + FxUtils.addClass(propertyValueLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_LABEL_VALUE, CssClasses.TEXT_INPUT_CONTAINER); - FXUtils.addToPane(propertyValueLabel, container); + + FxUtils.addChild(container, propertyValueLabel); } @Override @@ -84,9 +94,8 @@ protected void createComponents(@NotNull final HBox container) { public void reload() { super.reload(); - final Function function = getToStringFunction(); - - final Label propertyValueLabel = getPropertyValueLabel(); + var function = getToStringFunction(); + var propertyValueLabel = getPropertyValueLabel(); propertyValueLabel.setText(function == null ? String.valueOf(getPropertyValue()) : function.apply(getPropertyValue())); } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/DefaultSinglePropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/DefaultSinglePropertyControl.java index d9dd6c88..9cf091b9 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/DefaultSinglePropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/DefaultSinglePropertyControl.java @@ -17,14 +17,17 @@ */ public class DefaultSinglePropertyControl extends DefaultPropertyControl { - public DefaultSinglePropertyControl(@Nullable final T propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public DefaultSinglePropertyControl( + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); getPropertyValueLabel().prefWidthProperty() .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/DirectionLightPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/DirectionLightPropertyControl.java index bdf9af67..f9e626a5 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/DirectionLightPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/DirectionLightPropertyControl.java @@ -6,15 +6,18 @@ import org.jetbrains.annotations.NotNull; /** - * The implementation of the {@link Vector3FPropertyControl} to edit direction's vector of the {@link Light}. + * The implementation of the {@link Vector3fPropertyControl} to edit direction's vector of the {@link Light}. * * @param the light's type. * @author JavaSaBr */ -public class DirectionLightPropertyControl extends Vector3FPropertyControl { +public class DirectionLightPropertyControl extends Vector3fPropertyControl { - public DirectionLightPropertyControl(@NotNull final Vector3f element, @NotNull final String paramName, - @NotNull final ModelChangeConsumer modelChangeConsumer) { + public DirectionLightPropertyControl( + @NotNull Vector3f element, + @NotNull String paramName, + @NotNull ModelChangeConsumer modelChangeConsumer + ) { super(element, paramName, modelChangeConsumer); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/ElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/ElementModelPropertyControl.java index 7b1ebfa5..69dc98ba 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/ElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/ElementModelPropertyControl.java @@ -9,33 +9,35 @@ /** * The implementation of the {@link ElementPropertyControl} to edit elements from models. * - * @param the edited object's type. + * @param the type of an editing object. + * @param the type of an editing property. * @author JavaSaBr */ public abstract class ElementModelPropertyControl extends ElementPropertyControl { - public ElementModelPropertyControl(@NotNull final Class type, @Nullable final T propertyValue, - @NotNull final String propertyName, - @NotNull final ModelChangeConsumer changeConsumer) { + public ElementModelPropertyControl( + @NotNull Class type, + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull ModelChangeConsumer changeConsumer + ) { super(type, propertyValue, propertyName, changeConsumer); } @Override @FxThread - protected void processAdd() { - final NodeSelectorDialog dialog = createNodeSelectorDialog(); - dialog.show(this); + protected void addElement() { + createNodeSelectorDialog().show(this); } /** * Create node selector dialog node selector dialog. * - * @return the node selector dialog + * @return the node selector dialog. */ @FxThread protected @NotNull NodeSelectorDialog createNodeSelectorDialog() { - final ModelChangeConsumer changeConsumer = getChangeConsumer(); - return new NodeSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); + return new NodeSelectorDialog<>(getChangeConsumer().getCurrentModel(), type, this::addElement); } /** @@ -44,7 +46,7 @@ protected void processAdd() { * @param newElement the new element. */ @FxThread - protected void processAdd(@NotNull final T newElement) { + protected void addElement(@NotNull T newElement) { changed(newElement, getPropertyValue()); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/ElementPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/ElementPropertyControl.java index 3ba4bacc..de622f0b 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/ElementPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/ElementPropertyControl.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -8,7 +8,7 @@ import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.image.ImageView; @@ -19,9 +19,9 @@ /** * The implementation of the {@link PropertyControl} to edit an elements from scene. * - * @param the change consumer's type. - * @param the edited object's type. - * @param the element's type. + * @param the type of a change consumer. + * @param the type of an editing object. + * @param the type of an editing property. * @author JavaSaBr */ public class ElementPropertyControl extends PropertyControl { @@ -44,61 +44,68 @@ public class ElementPropertyControl extends Prop @Nullable private Label elementLabel; - public ElementPropertyControl(@NotNull final Class type, @Nullable final T propertyValue, - @NotNull final String propertyName, @NotNull final C changeConsumer) { + public ElementPropertyControl( + @NotNull Class type, + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); this.type = type; } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); elementLabel = new Label(NO_ELEMENT); - elementLabel.prefWidthProperty().bind(container.widthProperty()); + elementLabel.prefWidthProperty() + .bind(container.widthProperty()); - final Button changeButton = new Button(); + var changeButton = new Button(); changeButton.setGraphic(new ImageView(Icons.ADD_16)); - changeButton.setOnAction(event -> processAdd()); + changeButton.setOnAction(event -> addElement()); - final Button editButton = new Button(); + var editButton = new Button(); editButton.setGraphic(new ImageView(Icons.REMOVE_12)); - editButton.disableProperty().bind(elementLabel.textProperty().isEqualTo(NO_ELEMENT)); - editButton.setOnAction(event -> processRemove()); + editButton.setOnAction(event -> removeElement()); + editButton.disableProperty() + .bind(elementLabel.textProperty().isEqualTo(NO_ELEMENT)); - FXUtils.addToPane(elementLabel, container); - FXUtils.addToPane(changeButton, container); - FXUtils.addToPane(editButton, container); + FxUtils.addClass(container, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER) + .addClass(elementLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL) + .addClass(changeButton, editButton, + CssClasses.FLAT_BUTTON, + CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); - FXUtils.addClassesTo(container, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); - FXUtils.addClassTo(elementLabel, CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL); - FXUtils.addClassesTo(changeButton, editButton, CssClasses.FLAT_BUTTON, - CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); + FxUtils.addChild(container, elementLabel, changeButton, editButton); DynamicIconSupport.addSupport(changeButton, editButton); } /** - * Show dialog to choose an element. + * Show a dialog to choose an element. */ @FxThread - protected void processAdd() { + protected void addElement() { } /** - * Open this material in the material editor. + * Remove the current element. */ @FxThread - protected void processRemove() { + protected void removeElement() { changed(null, getPropertyValue()); } /** - * Gets element label. + * Get the element label. * - * @return the label with name of the material. + * @return the element label. */ @FxThread protected @NotNull Label getElementLabel() { diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/EnumPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/EnumPropertyControl.java index c8f5ac45..85088ccb 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/EnumPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/EnumPropertyControl.java @@ -1,32 +1,28 @@ package com.ss.editor.ui.control.property.impl; import static com.ss.editor.util.EditorUtil.getAvailableValues; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.ui.util.FXUtils; -import javafx.collections.ObservableList; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.ComboBox; -import javafx.scene.control.SingleSelectionModel; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; - /** * The implementation of the {@link PropertyControl} to edit {@link Enum} values. * * @param the type of a {@link ChangeConsumer} - * @param the type of an editing object. + * @param the type of an editing object. * @param the type of editing enum. * @author JavaSaBr */ -public class EnumPropertyControl> extends PropertyControl { +public class EnumPropertyControl> extends PropertyControl { /** * The list of available options of the {@link Enum} value. @@ -34,43 +30,57 @@ public class EnumPropertyControl> @Nullable private ComboBox enumComboBox; - public EnumPropertyControl(@Nullable final E propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, @NotNull final E[] availableValues) { + public EnumPropertyControl( + @Nullable E propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @NotNull E[] availableValues + ) { super(propertyValue, propertyName, changeConsumer); - final ObservableList items = getEnumComboBox().getItems(); - items.addAll(availableValues); + getEnumComboBox().getItems() + .addAll(availableValues); } - public EnumPropertyControl(@NotNull final E propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public EnumPropertyControl( + @NotNull E propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { this(propertyValue, propertyName, changeConsumer, getAvailableValues(propertyValue)); } - public EnumPropertyControl(@Nullable final E propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, @NotNull final E[] availableValues, - @Nullable final SixObjectConsumer> changeHandler) { + public EnumPropertyControl( + @Nullable E propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @NotNull E[] availableValues, + @Nullable ChangeHandler changeHandler + ) { super(propertyValue, propertyName, changeConsumer, changeHandler); - final ObservableList items = getEnumComboBox().getItems(); - items.addAll(availableValues); + getEnumComboBox().getItems() + .addAll(availableValues); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); enumComboBox = new ComboBox<>(); - enumComboBox.getSelectionModel() - .selectedItemProperty() - .addListener((observable, oldValue, newValue) -> change()); enumComboBox.prefWidthProperty() .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); - FXUtils.addToPane(enumComboBox, container); - FXUtils.addClassTo(enumComboBox, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); + FxControlUtils.onSelectedItemChange(enumComboBox, this::change); + + FxUtils.addClass(enumComboBox, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); + + FxUtils.addChild(container, enumComboBox); } /** + * Get the list of available options of the {@link Enum} value. + * * @return the list of available options of the {@link Enum} value. */ @FxThread @@ -88,9 +98,9 @@ private void change() { return; } - final ComboBox enumComboBox = getEnumComboBox(); - final SingleSelectionModel selectionModel = enumComboBox.getSelectionModel(); - final E newValue = selectionModel.getSelectedItem(); + var enumComboBox = getEnumComboBox(); + var selectionModel = enumComboBox.getSelectionModel(); + var newValue = selectionModel.getSelectedItem(); changed(newValue, getPropertyValue()); } @@ -98,10 +108,8 @@ private void change() { @Override @FxThread protected void reload() { - final E element = getPropertyValue(); - final ComboBox enumComboBox = getEnumComboBox(); - final SingleSelectionModel selectionModel = enumComboBox.getSelectionModel(); - selectionModel.select(element); + getEnumComboBox().getSelectionModel() + .select(getPropertyValue()); } @Override diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/FilterElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/FilterElementModelPropertyControl.java index 4bacf770..812e22b5 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/FilterElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/FilterElementModelPropertyControl.java @@ -5,7 +5,7 @@ import com.ss.editor.model.undo.editor.SceneChangeConsumer; import com.ss.editor.ui.dialog.scene.selector.FilterSceneSelectorDialog; import com.ss.editor.ui.dialog.scene.selector.SceneSelectorDialog; -import javafx.scene.control.Label; +import com.ss.rlib.common.util.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,25 +17,29 @@ */ public class FilterElementModelPropertyControl extends SceneElementPropertyControl { - public FilterElementModelPropertyControl(@Nullable final Filter propertyValue, @NotNull final String propertyName, - @NotNull final SceneChangeConsumer changeConsumer) { + public FilterElementModelPropertyControl( + @Nullable Filter propertyValue, + @NotNull String propertyName, + @NotNull SceneChangeConsumer changeConsumer + ) { super(Filter.class, propertyValue, propertyName, changeConsumer); } @Override @FxThread protected @NotNull SceneSelectorDialog createSceneSelectorDialog() { - final SceneChangeConsumer changeConsumer = getChangeConsumer(); - return new FilterSceneSelectorDialog(changeConsumer.getCurrentModel(), this::processAdd); + return new FilterSceneSelectorDialog(getChangeConsumer().getCurrentModel(), this::addElement); } @Override @FxThread protected void reload() { - final Filter filter = getPropertyValue(); - final Label elementLabel = getElementLabel(); + + var filter = getPropertyValue(); + String name = filter == null ? null : filter.getName(); - name = name == null && filter != null ? filter.getClass().getSimpleName() : name; - elementLabel.setText(name == null ? NO_ELEMENT : name); + name = StringUtils.isEmpty(name) && filter != null ? filter.getClass().getSimpleName() : name; + + getElementLabel().setText(StringUtils.ifEmpty(name, NO_ELEMENT)); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/FloatArrayPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/FloatArrayPropertyControl.java index cc48b5ec..c40b9d3e 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/FloatArrayPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/FloatArrayPropertyControl.java @@ -1,96 +1,49 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; -import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; -import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ArrayUtils; -import com.ss.rlib.util.StringUtils; -import javafx.scene.control.TextField; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.HBox; +import com.ss.rlib.common.util.ArrayUtils; +import com.ss.rlib.common.util.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; +import java.util.Arrays; /** * The implementation of the {@link PropertyControl} to edit float array values. * * @param the change consumer's type. - * @param the edited object's type. + * @param the type of an editing object. * @author JavaSaBr */ -public class FloatArrayPropertyControl extends PropertyControl { - - /** - * The filed with current value. - */ - @Nullable - private TextField valueField; - - public FloatArrayPropertyControl(@Nullable final float[] propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { +public class FloatArrayPropertyControl + extends StringBasedArrayPropertyControl { + + public FloatArrayPropertyControl( + @Nullable float[] propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } - public FloatArrayPropertyControl(@Nullable final float[] propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, - @Nullable final SixObjectConsumer> changeHandler) { + public FloatArrayPropertyControl( + @Nullable float[] propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @Nullable ChangeHandler changeHandler + ) { super(propertyValue, propertyName, changeConsumer, changeHandler); } - @Override - @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { - super.changeControlWidthPercent(controlWidthPercent); - - final TextField valueField = getValueField(); - valueField.prefWidthProperty().unbind(); - valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); - } - - @Override - @FxThread - protected void createComponents(@NotNull final HBox container) { - super.createComponents(container); - - valueField = new TextField(); - valueField.setOnKeyReleased(this::updateValue); - valueField.prefWidthProperty() - .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); - - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, container); - } - - @Override - @FromAnyThread - protected boolean isSingleRow() { - return true; - } - - /** - * @return the filed with current value. - */ - @FxThread - private @NotNull TextField getValueField() { - return notNull(valueField); - } - @Override @FxThread protected void reload() { - final float[] element = getPropertyValue(); - - final TextField valueField = getValueField(); - final int caretPosition = valueField.getCaretPosition(); + var element = getPropertyValue(); + var valueField = getValueField(); + var caretPosition = valueField.getCaretPosition(); if (element == null) { valueField.setText(StringUtils.EMPTY); @@ -101,30 +54,31 @@ protected void reload() { valueField.positionCaret(caretPosition); } - /** - * Update the value. - */ + @Override @FxThread - private void updateValue(@Nullable final KeyEvent event) { + public boolean isDirty() { + return !Arrays.equals(getCurrentValue(), getPropertyValue()); + } - if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) { - return; - } + @Override + @FxThread + protected @Nullable float[] getCurrentValue() { + + var textValue = getValueField().getText(); - final String textValue = getValueField().getText(); float[] newValue = null; if (!StringUtils.isEmpty(textValue)) { - final String splitter = textValue.contains(" ") ? " " : ","; - final String[] splited = textValue.split(splitter); + var splitter = textValue.contains(" ") ? " " : ","; + var split = textValue.split(splitter); - newValue = new float[splited.length]; + newValue = new float[split.length]; - for (int i = 0; i < splited.length; i++) { + for (var i = 0; i < split.length; i++) { try { - newValue[i] = Float.parseFloat(splited[i]); - } catch (final NumberFormatException e) { + newValue[i] = Float.parseFloat(split[i]); + } catch (NumberFormatException e) { LOGGER.warning(this, e); newValue = getPropertyValue(); break; @@ -132,6 +86,6 @@ private void updateValue(@Nullable final KeyEvent event) { } } - changed(newValue, getPropertyValue()); + return newValue; } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/FloatPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/FloatPropertyControl.java index d3d0f30f..4c1cae91 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/FloatPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/FloatPropertyControl.java @@ -1,28 +1,29 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.NumberUtils.zeroIfNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; +import java.util.Objects; /** * The implementation of the {@link PropertyControl} to edit float values. * - * @param the change consumer's type. - * @param the edited object's type. + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr */ -public class FloatPropertyControl extends PropertyControl { +public class FloatPropertyControl extends PropertyControl { /** * The filed with current value. @@ -30,53 +31,62 @@ public class FloatPropertyControl extends PropertyC @Nullable private FloatTextField valueField; - public FloatPropertyControl(@Nullable final Float propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public FloatPropertyControl( + @Nullable Float propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } - public FloatPropertyControl(@Nullable final Float propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, - @Nullable final SixObjectConsumer> changeHandler) { + public FloatPropertyControl( + @Nullable Float propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @Nullable ChangeHandler changeHandler + ) { super(propertyValue, propertyName, changeConsumer, changeHandler); } @Override @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { + public void changeControlWidthPercent(double controlWidthPercent) { super.changeControlWidthPercent(controlWidthPercent); - final FloatTextField valueField = getValueField(); - valueField.prefWidthProperty().unbind(); - valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); + FxUtils.rebindPrefWidth(getValueField(), + widthProperty().multiply(controlWidthPercent)); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); valueField = new FloatTextField(); - valueField.addChangeListener((observable, oldValue, newValue) -> updateValue()); valueField.prefWidthProperty() - .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxControlUtils.onValueChange(valueField, this::updateValue); + FxControlUtils.onFocusChange(valueField, this::applyOnLostFocus); + + FxUtils.addClass(valueField, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, container); + FxUtils.addChild(container, valueField); } /** - * Sets scroll power. + * Set the scroll power. * * @param scrollPower the scroll power. */ @FxThread - public void setScrollPower(final float scrollPower) { + public void setScrollPower(float scrollPower) { getValueField().setScrollPower(scrollPower); } /** - * Gets scroll power. + * Get the scroll power. * * @return the scroll power. */ @@ -86,13 +96,13 @@ public float getScrollPower() { } /** - * Set value limits for this field. + * Set the value limits for this field. * * @param min the min value. * @param max the max value. */ @FxThread - public void setMinMax(final float min, final float max) { + public void setMinMax(float min, float max) { getValueField().setMinMax(min, max); } @@ -103,6 +113,8 @@ protected boolean isSingleRow() { } /** + * Get the filed with current value. + * * @return the filed with current value. */ @FxThread @@ -113,27 +125,32 @@ protected boolean isSingleRow() { @Override @FxThread protected void reload() { - final Float value = getPropertyValue(); - final FloatTextField valueField = getValueField(); - final int caretPosition = valueField.getCaretPosition(); - valueField.setValue(value == null ? 0F : value); + var valueField = getValueField(); + var caretPosition = valueField.getCaretPosition(); + valueField.setValue(zeroIfNull(getPropertyValue())); valueField.positionCaret(caretPosition); } + @Override + @FxThread + public boolean isDirty() { + return !Objects.equals(getValueField().getValue(), getPropertyValue()); + } + /** * Update the value. */ @FxThread private void updateValue() { - - if (isIgnoreListener()) { - return; + if (!isIgnoreListener()) { + apply(); } + } - final FloatTextField valueField = getValueField(); - final float value = valueField.getValue(); - - final Float oldValue = getPropertyValue(); - changed(value, oldValue); + @Override + @FxThread + protected void apply() { + super.apply(); + changed(getValueField().getValue(), getPropertyValue()); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/IntArrayPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/IntArrayPropertyControl.java index b5c6c46b..5e2ea535 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/IntArrayPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/IntArrayPropertyControl.java @@ -1,32 +1,24 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; -import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; -import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ArrayUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.ArrayUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.TextField; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; +import java.util.Arrays; /** * The implementation of the {@link PropertyControl} to edit int array values. * * @param the change consumer's type. - * @param the edited object's type. + * @param the type of an editing object. * @author JavaSaBr */ -public class IntArrayPropertyControl extends PropertyControl { +public class IntArrayPropertyControl extends StringBasedArrayPropertyControl { /** * The filed with current value. @@ -34,63 +26,31 @@ public class IntArrayPropertyControl extends Proper @Nullable private TextField valueField; - public IntArrayPropertyControl(@Nullable final int[] propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public IntArrayPropertyControl( + @Nullable int[] propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } - public IntArrayPropertyControl(@Nullable final int[] propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, - @Nullable final SixObjectConsumer> changeHandler) { + public IntArrayPropertyControl( + @Nullable int[] propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @Nullable ChangeHandler changeHandler + ) { super(propertyValue, propertyName, changeConsumer, changeHandler); } - @Override - @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { - super.changeControlWidthPercent(controlWidthPercent); - - final TextField valueField = getValueField(); - valueField.prefWidthProperty().unbind(); - valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); - } - - @Override - @FxThread - protected void createComponents(@NotNull final HBox container) { - super.createComponents(container); - - valueField = new TextField(); - valueField.setOnKeyReleased(this::updateValue); - valueField.prefWidthProperty() - .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); - - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, container); - } - - @Override - @FromAnyThread - protected boolean isSingleRow() { - return true; - } - - /** - * @return the filed with current value. - */ - @FxThread - private @NotNull TextField getValueField() { - return notNull(valueField); - } - @Override @FxThread protected void reload() { - final int[] element = getPropertyValue(); + var element = getPropertyValue(); - final TextField valueField = getValueField(); - final int caretPosition = valueField.getCaretPosition(); + var valueField = getValueField(); + var caretPosition = valueField.getCaretPosition(); if (element == null) { valueField.setText(StringUtils.EMPTY); @@ -101,30 +61,31 @@ protected void reload() { valueField.positionCaret(caretPosition); } - /** - * Update the value. - */ + @Override @FxThread - private void updateValue(@Nullable final KeyEvent event) { + public boolean isDirty() { + return !Arrays.equals(getCurrentValue(), getPropertyValue()); + } - if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) { - return; - } + @Override + @FxThread + protected @Nullable int[] getCurrentValue() { + + var textValue = getValueField().getText(); - final String textValue = getValueField().getText(); int[] newValue = null; if (!StringUtils.isEmpty(textValue)) { - final String splitter = textValue.contains(" ") ? " " : ","; - final String[] splited = textValue.split(splitter); + var splitter = textValue.contains(" ") ? " " : ","; + var split = textValue.split(splitter); - newValue = new int[splited.length]; + newValue = new int[split.length]; - for (int i = 0; i < splited.length; i++) { + for (var i = 0; i < split.length; i++) { try { - newValue[i] = Integer.parseInt(splited[i]); - } catch (final NumberFormatException e) { + newValue[i] = Integer.parseInt(split[i]); + } catch (NumberFormatException e) { LOGGER.warning(this, e); newValue = getPropertyValue(); break; @@ -132,6 +93,6 @@ private void updateValue(@Nullable final KeyEvent event) { } } - changed(newValue, getPropertyValue()); + return newValue; } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/IntegerPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/IntegerPropertyControl.java index 064aac06..8d17065b 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/IntegerPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/IntegerPropertyControl.java @@ -1,25 +1,29 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.NumberUtils.zeroIfNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.control.input.IntegerTextField; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.control.input.IntegerTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + /** * The implementation of the {@link PropertyControl} to edit integer values. * - * @param the type of {@link ChangeConsumer}. - * @param the type of edited object. + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr */ -public class IntegerPropertyControl extends PropertyControl { +public class IntegerPropertyControl extends PropertyControl { /** * The filed with current value. @@ -27,32 +31,39 @@ public class IntegerPropertyControl extends Propert @Nullable private IntegerTextField valueField; - public IntegerPropertyControl(@Nullable final Integer propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public IntegerPropertyControl( + @Nullable Integer propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } @Override @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { + public void changeControlWidthPercent(double controlWidthPercent) { super.changeControlWidthPercent(controlWidthPercent); - final IntegerTextField valueField = getValueField(); - valueField.prefWidthProperty().unbind(); - valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); + FxUtils.rebindPrefWidth(getValueField(), + widthProperty().multiply(controlWidthPercent)); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); valueField = new IntegerTextField(); - valueField.addChangeListener((observable, oldValue, newValue) -> updateValue()); - valueField.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + valueField.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxControlUtils.onValueChange(valueField, this::updateValue); + FxControlUtils.onFocusChange(valueField, this::applyOnLostFocus); - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, container); + FxUtils.addClass(valueField, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); + + FxUtils.addChild(container, valueField); } @Override @@ -62,6 +73,8 @@ protected boolean isSingleRow() { } /** + * Get the filed with current value. + * * @return the filed with current value. */ @FxThread @@ -76,54 +89,59 @@ protected boolean isSingleRow() { * @param max the max value. */ @FxThread - public void setMinMax(final int min, final int max) { + public void setMinMax(int min, int max) { getValueField().setMinMax(min, max); } /** - * Sets scroll power. + * Set the scroll power. * * @param scrollPower the scroll power. */ @FxThread - public void setScrollPower(final int scrollPower) { + public void setScrollPower(int scrollPower) { getValueField().setScrollPower(scrollPower); } /** - * Gets scroll power. + * Get the scroll power. * * @return the scroll power. */ @FxThread public int getScrollPower() { - return getValueField().getScrollPower(); + return (int) getValueField().getScrollPower(); } @Override @FxThread protected void reload() { - final Integer element = getPropertyValue(); - final IntegerTextField valueField = getValueField(); - final int caretPosition = valueField.getCaretPosition(); - valueField.setText(String.valueOf(element)); + var valueField = getValueField(); + var caretPosition = valueField.getCaretPosition(); + valueField.setValue(zeroIfNull(getPropertyValue())); valueField.positionCaret(caretPosition); } + @Override + @FxThread + public boolean isDirty() { + return !Objects.equals(getValueField().getValue(), getPropertyValue()); + } + /** * Update the value. */ @FxThread private void updateValue() { - - if (isIgnoreListener()) { - return; + if (!isIgnoreListener()) { + apply(); } + } - final IntegerTextField valueField = getValueField(); - final int value = valueField.getValue(); - final Integer oldValue = getPropertyValue(); - - changed(value, oldValue); + @Override + @FxThread + protected void apply() { + super.apply(); + changed(getValueField().getValue(), getPropertyValue()); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/LayerModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/LayerModelPropertyControl.java index 6d69982f..478f8c5a 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/LayerModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/LayerModelPropertyControl.java @@ -1,42 +1,36 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.scene.Spatial; +import static com.ss.rlib.common.util.ObjectUtils.ifNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JmeThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.scene.SceneLayer; -import com.ss.editor.extension.scene.SceneNode; -import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.model.undo.editor.SceneChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; -import com.ss.editor.ui.control.property.operation.PropertyOperation; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.ui.util.FXUtils; -import javafx.collections.ObservableList; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.ComboBox; import javafx.scene.control.ListCell; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; - /** * The implementation of the {@link PropertyControl} to edit layers. * + * @param the type of an editing object. * @author JavaSaBr */ -public class LayerModelPropertyControl extends PropertyControl { +public class LayerModelPropertyControl extends PropertyControl { @NotNull private class LayerCell extends ListCell { @Override - protected void updateItem(@Nullable final SceneLayer layer, final boolean empty) { + protected void updateItem(@Nullable SceneLayer layer, boolean empty) { super.updateItem(layer, empty); if (layer == null || layer == SceneLayer.NO_LAYER) { @@ -54,34 +48,12 @@ protected void updateItem(@Nullable final SceneLayer layer, final boolean empty) @Nullable private ComboBox layerComboBox; - public LayerModelPropertyControl(@Nullable final SceneLayer layer, @NotNull final SceneChangeConsumer changeConsumer) { - super(layer == null ? SceneLayer.NO_LAYER : layer, Messages.MODEL_PROPERTY_LAYER, changeConsumer); - setApplyHandler(this::setLayer); - setSyncHandler(this::getLayer); - } - - @Override - @FromAnyThread - public @NotNull SixObjectConsumer> newChangeHandler() { - return (changeConsumer, object, propName, newValue, oldValue, handler) -> { - - final PropertyOperation operation = - new PropertyOperation<>(object, SceneLayer.KEY, newValue, oldValue); - operation.setApplyHandler(handler); - - changeConsumer.execute(operation); - }; - } - - @JmeThread - private void setLayer(@NotNull final Spatial spatial, @NotNull final SceneLayer newLayer) { - SceneLayer.setLayer(newLayer, spatial); - } - - @JmeThread - private SceneLayer getLayer(@NotNull final Spatial spatial) { - final SceneLayer sceneLayer = SceneLayer.getLayer(spatial); - return sceneLayer == null ? SceneLayer.NO_LAYER : sceneLayer; + public LayerModelPropertyControl( + @Nullable SceneLayer layer, + @NotNull String propertyName, + @NotNull SceneChangeConsumer changeConsumer + ) { + super(ifNull(layer, SceneLayer.NO_LAYER), propertyName, changeConsumer); } @Override @@ -92,29 +64,32 @@ protected boolean isSingleRow() { @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); layerComboBox = new ComboBox<>(); layerComboBox.setCellFactory(param -> new LayerCell()); layerComboBox.setButtonCell(new LayerCell()); layerComboBox.setEditable(false); - layerComboBox.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); - layerComboBox.getSelectionModel().selectedItemProperty() - .addListener((observable, oldValue, newValue) -> updateLevel(newValue)); + layerComboBox.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxControlUtils.onSelectedItemChange(layerComboBox, this::updateLevel); + + FxUtils.addClass(layerComboBox, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); - FXUtils.addToPane(layerComboBox, container); - FXUtils.addClassTo(layerComboBox, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); + FxUtils.addChild(container, layerComboBox); } @FxThread - private void updateLevel(@Nullable final SceneLayer layer) { + private void updateLevel(@Nullable SceneLayer layer) { if (isIgnoreListener()) return; changed(layer, getPropertyValue()); } /** - * Gets layer combo box. + * Get the layers combo box. * * @return the layers combo box. */ @@ -127,16 +102,17 @@ private void updateLevel(@Nullable final SceneLayer layer) { @FxThread protected void reload() { - final SceneChangeConsumer changeConsumer = (SceneChangeConsumer) getChangeConsumer(); - final SceneNode currentModel = changeConsumer.getCurrentModel(); - final SceneLayer sceneLayer = getPropertyValue(); + var changeConsumer = (SceneChangeConsumer) getChangeConsumer(); + var currentModel = changeConsumer.getCurrentModel(); + var sceneLayer = getPropertyValue(); - final ComboBox levelComboBox = getLayerComboBox(); - final ObservableList items = levelComboBox.getItems(); + var levelComboBox = getLayerComboBox(); + var items = levelComboBox.getItems(); items.clear(); items.add(SceneLayer.NO_LAYER); items.addAll(currentModel.getLayers()); - levelComboBox.getSelectionModel().select(sceneLayer == null ? SceneLayer.NO_LAYER : sceneLayer); + levelComboBox.getSelectionModel() + .select(sceneLayer == null ? SceneLayer.NO_LAYER : sceneLayer); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/LightElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/LightElementModelPropertyControl.java index c35c999c..4068fe5d 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/LightElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/LightElementModelPropertyControl.java @@ -5,7 +5,7 @@ import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.dialog.node.selector.LightSelectorDialog; import com.ss.editor.ui.dialog.node.selector.NodeSelectorDialog; -import javafx.scene.control.Label; +import com.ss.rlib.common.util.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,29 +17,31 @@ */ public class LightElementModelPropertyControl extends ElementModelPropertyControl { - public LightElementModelPropertyControl(@NotNull final Class type, @Nullable final L propertyValue, - @NotNull final String propertyName, - @NotNull final ModelChangeConsumer changeConsumer) { + public LightElementModelPropertyControl( + @NotNull Class type, + @Nullable L propertyValue, + @NotNull String propertyName, + @NotNull ModelChangeConsumer changeConsumer + ) { super(type, propertyValue, propertyName, changeConsumer); } @Override @FxThread protected @NotNull NodeSelectorDialog createNodeSelectorDialog() { - final ModelChangeConsumer changeConsumer = getChangeConsumer(); - return new LightSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); + return new LightSelectorDialog<>(getChangeConsumer().getCurrentModel(), type, this::addElement); } @Override @FxThread protected void reload() { - final L light = getPropertyValue(); - final Label elementLabel = getElementLabel(); + var light = getPropertyValue(); + var elementLabel = getElementLabel(); String name = light == null ? null : light.getName(); name = name == null && light != null ? light.getClass().getSimpleName() : name; - elementLabel.setText(name == null ? NO_ELEMENT : name); + elementLabel.setText(StringUtils.ifEmpty(name, NO_ELEMENT)); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/LodLevelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/LodLevelPropertyControl.java index 9d3e34e3..57afb78c 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/LodLevelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/LodLevelPropertyControl.java @@ -1,17 +1,15 @@ package com.ss.editor.ui.control.property.impl; import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; -import com.jme3.scene.VertexBuffer; import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ObjectUtils; -import javafx.collections.ObservableList; +import com.ss.rlib.common.util.ObjectUtils; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.control.ComboBox; import javafx.scene.control.ListCell; import javafx.scene.layout.HBox; @@ -28,11 +26,11 @@ public class LodLevelPropertyControl extends PropertyC private class LodLevelCell extends ListCell { @Override - protected void updateItem(@Nullable final Integer level, final boolean empty) { + protected void updateItem(@Nullable Integer level, boolean empty) { super.updateItem(level, empty); - final Geometry geometry = getEditObject(); - final Mesh mesh = geometry.getMesh(); + var geometry = getEditObject(); + var mesh = geometry.getMesh(); if (level == null || mesh == null) { setText("None"); @@ -42,7 +40,7 @@ protected void updateItem(@Nullable final Integer level, final boolean empty) { int elements; if (level < mesh.getNumLodLevels()) { - final VertexBuffer lodLevel = mesh.getLodLevel(level); + var lodLevel = mesh.getLodLevel(level); elements = lodLevel.getNumElements(); } else { elements = mesh.getTriangleCount(); @@ -59,8 +57,11 @@ protected void updateItem(@Nullable final Integer level, final boolean empty) { @Nullable private ComboBox levelComboBox; - public LodLevelPropertyControl(@Nullable final Integer element, @NotNull final String paramName, - @NotNull final C changeConsumer) { + public LodLevelPropertyControl( + @Nullable Integer element, + @NotNull String paramName, + @NotNull C changeConsumer + ) { super(element, paramName, changeConsumer); } @@ -72,19 +73,22 @@ protected boolean isSingleRow() { @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); levelComboBox = new ComboBox<>(); levelComboBox.setCellFactory(param -> new LodLevelCell()); levelComboBox.setButtonCell(new LodLevelCell()); levelComboBox.setEditable(false); - levelComboBox.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); - levelComboBox.getSelectionModel().selectedItemProperty() - .addListener((observable, oldValue, newValue) -> updateLevel(newValue)); + levelComboBox.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxControlUtils.onSelectedItemChange(levelComboBox, this::updateLevel); - FXUtils.addToPane(levelComboBox, container); - FXUtils.addClassTo(levelComboBox, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); + FxUtils.addClass(levelComboBox, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); + + FxUtils.addChild(container, levelComboBox); } /** @@ -93,22 +97,21 @@ protected void createComponents(@NotNull final HBox container) { * @param newValue the new level. */ @FxThread - private void updateLevel(@Nullable final Integer newValue) { + private void updateLevel(@Nullable Integer newValue) { if (isIgnoreListener()) return; - changed(newValue == null ? 0 : newValue, getPropertyValue()); + changed(ObjectUtils.ifNull(newValue, 0), getPropertyValue()); } @Override @FxThread public @NotNull Integer getPropertyValue() { - final Integer value = super.getPropertyValue(); - return value == null ? 0 : value; + return ObjectUtils.ifNull(super.getPropertyValue(), 0); } /** - * Gets level combo box. + * Get the level combo box. * - * @return The lod level combobox. + * @return The lod level combo box. */ @FxThread protected @NotNull ComboBox getLevelComboBox() { @@ -123,18 +126,20 @@ protected void reload() { return; } - final Geometry geometry = getEditObject(); - final Mesh mesh = geometry.getMesh(); - if (mesh == null) return; + var geometry = getEditObject(); + var mesh = geometry.getMesh(); + if (mesh == null) { + return; + } - final Integer element = getPropertyValue(); - final ComboBox levelComboBox = getLevelComboBox(); - final ObservableList items = levelComboBox.getItems(); + var element = getPropertyValue(); + var levelComboBox = getLevelComboBox(); + var items = levelComboBox.getItems(); items.clear(); - final int numLodLevels = mesh.getNumLodLevels(); + var numLodLevels = mesh.getNumLodLevels(); - for (int i = 0; i < numLodLevels; i++) { + for (var i = 0; i < numLodLevels; i++) { items.add(i); } @@ -142,6 +147,7 @@ protected void reload() { items.add(0); } - levelComboBox.getSelectionModel().select(element); + levelComboBox.getSelectionModel() + .select(element); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/MaterialKeyPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/MaterialKeyPropertyControl.java index 4e4d933c..ba1332a9 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/MaterialKeyPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/MaterialKeyPropertyControl.java @@ -1,20 +1,19 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.editor.util.EditorUtil.getAssetFile; +import static com.ss.editor.util.EditorUtil.toAssetPath; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.MaterialKey; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.ui.event.impl.RequestedOpenFileEvent; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.util.StringUtils; -import javafx.scene.control.Label; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.common.util.StringUtils; +import javafx.event.ActionEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; /** * The implementation of the {@link MaterialPropertyControl} to edit the {@link MaterialKey}. @@ -24,23 +23,26 @@ */ public class MaterialKeyPropertyControl extends MaterialPropertyControl { - public MaterialKeyPropertyControl(@Nullable final MaterialKey element, @NotNull final String paramName, - @NotNull final C changeConsumer) { + public MaterialKeyPropertyControl( + @Nullable MaterialKey element, + @NotNull String paramName, + @NotNull C changeConsumer + ) { super(element, paramName, changeConsumer); } - @FxThread @Override - protected void processChange() { + @FxThread + protected void change(@Nullable ActionEvent event) { UiUtils.openFileAssetDialog(this::addMaterial, MATERIAL_EXTENSIONS, DEFAULT_ACTION_TESTER); } - @FxThread @Override - protected void addMaterial(@NotNull final Path file) { + @FxThread + protected void addMaterial(@NotNull Path file) { - final Path assetFile = notNull(getAssetFile(file)); - final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile)); + var assetFile = notNull(getAssetFile(file)); + var materialKey = new MaterialKey(toAssetPath(assetFile)); changed(materialKey, getPropertyValue()); setIgnoreListener(true); @@ -51,37 +53,17 @@ protected void addMaterial(@NotNull final Path file) { } } - @FxThread @Override - protected void processEdit() { - - final MaterialKey element = getPropertyValue(); - if (element == null) { - return; - } - - final String assetPath = element.getName(); - if (StringUtils.isEmpty(assetPath)) { - return; - } - - final Path assetFile = Paths.get(assetPath); - final Path realFile = notNull(getRealFile(assetFile)); - if (!Files.exists(realFile)) { - return; - } - - final RequestedOpenFileEvent event = new RequestedOpenFileEvent(); - event.setFile(realFile); - - FX_EVENT_MANAGER.notify(event); + @FxThread + protected void openToEdit(@Nullable ActionEvent event) { + EditorUtil.openInEditor(getPropertyValue()); } - @FxThread @Override + @FxThread protected void reload() { - final MaterialKey element = getPropertyValue(); - final Label materialLabel = getMaterialLabel(); - materialLabel.setText(element == null || StringUtils.isEmpty(element.getName()) ? NO_MATERIAL : element.getName()); + var element = getPropertyValue(); + getMaterialLabel().setText(element == null || StringUtils.isEmpty(element.getName()) ? + NO_MATERIAL : element.getName()); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/MaterialPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/MaterialPropertyControl.java index 721cee8e..28bb3fa3 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/MaterialPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/MaterialPropertyControl.java @@ -1,7 +1,6 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.material.Material; import com.jme3.scene.Spatial; import com.ss.editor.FileExtensions; @@ -12,24 +11,21 @@ import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FxUtils; +import javafx.event.ActionEvent; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.image.ImageView; -import javafx.scene.input.DataFormat; import javafx.scene.input.DragEvent; -import javafx.scene.input.Dragboard; import javafx.scene.input.TransferMode; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.File; import java.nio.file.Path; -import java.util.List; -import java.util.Set; /** * The implementation of the {@link PropertyControl} to edit the {@link Material}. @@ -53,13 +49,16 @@ public class MaterialPropertyControl extends Pro protected static final Array MATERIAL_EXTENSIONS = ArrayFactory.asArray(FileExtensions.JME_MATERIAL); /** - * The label with name of the material. + * The material name label. */ @Nullable private Label materialLabel; - public MaterialPropertyControl(@Nullable final V element, @NotNull final String paramName, - @NotNull final C changeConsumer) { + public MaterialPropertyControl( + @Nullable V element, + @NotNull String paramName, + @NotNull C changeConsumer + ) { super(element, paramName, changeConsumer); setOnDragOver(this::handleDragOverEvent); setOnDragDropped(this::handleDragDroppedEvent); @@ -67,12 +66,12 @@ public MaterialPropertyControl(@Nullable final V element, @NotNull final String } /** - * Handle grad exited events. + * Handle drag exited events. * * @param dragEvent the drag exited event. */ @FxThread - private void handleDragExitedEvent(@NotNull final DragEvent dragEvent) { + private void handleDragExitedEvent(@NotNull DragEvent dragEvent) { } @@ -82,16 +81,14 @@ private void handleDragExitedEvent(@NotNull final DragEvent dragEvent) { * @param dragEvent the dropped event. */ @FxThread - private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { + private void handleDragDroppedEvent(@NotNull DragEvent dragEvent) { - final Dragboard dragboard = dragEvent.getDragboard(); - final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); - - if (files == null || files.size() != 1) { + var files = EditorUtil.getFiles(dragEvent.getDragboard()); + if (files.size() != 1) { return; } - final File file = files.get(0); + var file = files.get(0); if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) { return; @@ -106,23 +103,22 @@ private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { * @param dragEvent the drag over event. */ @FxThread - private void handleDragOverEvent(@NotNull final DragEvent dragEvent) { - - final Dragboard dragboard = dragEvent.getDragboard(); - final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); + private void handleDragOverEvent(@NotNull DragEvent dragEvent) { - if (files == null || files.size() != 1) { + var dragboard = dragEvent.getDragboard(); + var files = EditorUtil.getFiles(dragboard); + if (files.size() != 1) { return; } - final File file = files.get(0); + var file = files.get(0); if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) { return; } - final Set transferModes = dragboard.getTransferModes(); - final boolean isCopy = transferModes.contains(TransferMode.COPY); + var transferModes = dragboard.getTransferModes(); + var isCopy = transferModes.contains(TransferMode.COPY); dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE); dragEvent.consume(); @@ -134,60 +130,66 @@ private void handleDragOverEvent(@NotNull final DragEvent dragEvent) { * @param file the file */ @FxThread - protected void addMaterial(@NotNull final Path file) { + protected void addMaterial(@NotNull Path file) { } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); materialLabel = new Label(NO_MATERIAL); - final Button changeButton = new Button(); + var changeButton = new Button(); changeButton.setGraphic(new ImageView(Icons.ADD_16)); - changeButton.setOnAction(event -> processChange()); + changeButton.setOnAction(this::change); - final Button editButton = new Button(); + var editButton = new Button(); editButton.setGraphic(new ImageView(Icons.EDIT_16)); editButton.disableProperty().bind(materialLabel.textProperty().isEqualTo(NO_MATERIAL)); - editButton.setOnAction(event -> processEdit()); + editButton.setOnAction(this::openToEdit); materialLabel.prefWidthProperty().bind(widthProperty() .subtract(changeButton.widthProperty()) .subtract(editButton.widthProperty())); - FXUtils.addToPane(materialLabel, container); - FXUtils.addToPane(changeButton, container); - FXUtils.addToPane(editButton, container); + FxUtils.addClass(container, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER) + .addClass(materialLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL) + .addClass(changeButton, editButton, + CssClasses.FLAT_BUTTON, + CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); - FXUtils.addClassesTo(container, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); - FXUtils.addClassTo(materialLabel, CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL); - FXUtils.addClassesTo(changeButton, editButton, CssClasses.FLAT_BUTTON, - CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); + FxUtils.addChild(container, + materialLabel, changeButton, editButton); DynamicIconSupport.addSupport(changeButton, editButton); } /** - * Show dialog for choosing another material. + * Show dialog to choose another material. + * + * @param event the action event. */ @FxThread - protected void processChange() { + protected void change(@Nullable ActionEvent event) { } /** * Open this material in the material editor. + * + * @param event the action event. */ @FxThread - protected void processEdit() { + protected void openToEdit(@Nullable ActionEvent event) { } /** - * Gets material label. + * Get the material name label. * - * @return the label with name of the material. + * @return the material name label. */ @FxThread protected @NotNull Label getMaterialLabel() { diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/MinMaxPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/MinMaxPropertyControl.java index 59668649..187cad10 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/MinMaxPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/MinMaxPropertyControl.java @@ -3,23 +3,25 @@ import static java.lang.Math.max; import static java.lang.Math.min; import com.jme3.math.Vector2f; -import com.jme3.scene.Spatial; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * The implementation of the {@link Vector2FPropertyControl} to edit min-max value range. + * The implementation of the {@link Vector2fPropertyControl} to edit min-max value range. * - * @param the change consumer's type. - * @param the edited object's type. + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr */ -public class MinMaxPropertyControl extends Vector2FPropertyControl { +public class MinMaxPropertyControl extends Vector2fPropertyControl { - public MinMaxPropertyControl(@Nullable final Vector2f propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public MinMaxPropertyControl( + @Nullable Vector2f propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); getXField().setMinMax(0, Integer.MAX_VALUE); getYField().setMinMax(0, Integer.MAX_VALUE); @@ -27,13 +29,13 @@ public MinMaxPropertyControl(@Nullable final Vector2f propertyValue, @NotNull fi @Override @FxThread - protected float checkResultXValue(final float x, final float y) { + protected float checkResultXValue(float x, float y) { return min(x, y); } @Override @FxThread - protected float checkResultYValue(final float x, final float y) { + protected float checkResultYValue(float x, float y) { return max(x, y); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/QuaternionPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/QuaternionPropertyControl.java index 085c46b7..188d1c77 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/QuaternionPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/QuaternionPropertyControl.java @@ -1,17 +1,19 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.geom.util.AngleUtils.degreeToRadians; -import static com.ss.rlib.geom.util.AngleUtils.radiansToDegree; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.geom.util.AngleUtils.degreeToRadians; +import static com.ss.rlib.common.geom.util.AngleUtils.radiansToDegree; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.Quaternion; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; +import com.ss.rlib.fx.util.ObservableUtils; import javafx.scene.control.Label; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; @@ -22,11 +24,11 @@ /** * The implementation of the {@link PropertyControl} to edit {@link Quaternion} values. * - * @param the change consumer's type. - * @param the edited object's type. + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr */ -public class QuaternionPropertyControl extends PropertyControl { +public class QuaternionPropertyControl extends PropertyControl { /** * The field Y. @@ -46,60 +48,72 @@ public class QuaternionPropertyControl extends Prop @Nullable private FloatTextField zField; - public QuaternionPropertyControl(@Nullable final Quaternion propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public QuaternionPropertyControl( + @Nullable Quaternion propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); - final Label xLabel = new Label("x:"); + var xLabel = new Label("x:"); xField = new FloatTextField(); - xField.setOnKeyReleased(this::updateRotation); - xField.addChangeListener((observable, oldValue, newValue) -> updateRotation(null)); - xField.prefWidthProperty().bind(widthProperty().divide(3)); + xField.setOnKeyReleased(this::keyReleased); + xField.prefWidthProperty() + .bind(widthProperty().divide(3)); - final Label yLabel = new Label("y:"); + var yLabel = new Label("y:"); yField = new FloatTextField(); - yField.setOnKeyReleased(this::updateRotation); - yField.addChangeListener((observable, oldValue, newValue) -> updateRotation(null)); - yField.prefWidthProperty().bind(widthProperty().divide(3)); + yField.setOnKeyReleased(this::keyReleased); + yField.prefWidthProperty() + .bind(widthProperty().divide(3)); - final Label zLabel = new Label("z:"); + var zLabel = new Label("z:"); zField = new FloatTextField(); - zField.setOnKeyReleased(this::updateRotation); - zField.addChangeListener((observable, oldValue, newValue) -> updateRotation(null)); - zField.prefWidthProperty().bind(widthProperty().divide(3)); - - FXUtils.addToPane(xLabel, container); - FXUtils.addToPane(xField, container); - FXUtils.addToPane(yLabel, container); - FXUtils.addToPane(yField, container); - FXUtils.addToPane(zLabel, container); - FXUtils.addToPane(zField, container); - - FXUtils.addClassTo(xLabel, yLabel, zLabel, CssClasses.ABSTRACT_PARAM_CONTROL_NUMBER_LABEL); - FXUtils.addClassesTo(container, CssClasses.DEF_HBOX, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); - FXUtils.addClassesTo(xField, yField, zField, CssClasses.ABSTRACT_PARAM_CONTROL_VECTOR3F_FIELD, - CssClasses.TRANSPARENT_TEXT_FIELD); - - UiUtils.addFocusBinding(container, xField, yField, zField); + zField.setOnKeyReleased(this::keyReleased); + zField.prefWidthProperty() + .bind(widthProperty().divide(3)); + + FxControlUtils.onValueChange(xField, this::changeValue); + FxControlUtils.onValueChange(yField, this::changeValue); + FxControlUtils.onValueChange(zField, this::changeValue); + + FxUtils.addClass(xLabel, yLabel, zLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_NUMBER_LABEL) + .addClass(container, + CssClasses.DEF_HBOX, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER) + .addClass(xField, yField, zField, + CssClasses.PROPERTY_CONTROL_VECTOR_3F_FIELD, + CssClasses.TRANSPARENT_TEXT_FIELD); + + FxUtils.addChild(container, + xLabel, xField, + yLabel, yField, + zLabel, zField); + + ObservableUtils.onChange(UiUtils.addFocusBinding(container, xField, yField, zField), + this::applyOnLostFocus); } @Override @FxThread - protected void setPropertyValue(@Nullable final Quaternion quaternion) { + protected void setPropertyValue(@Nullable Quaternion quaternion) { super.setPropertyValue(quaternion == null ? null : quaternion.clone()); } /** + * Get the field X. + * * @return the field X. */ @FxThread @@ -108,6 +122,8 @@ protected void setPropertyValue(@Nullable final Quaternion quaternion) { } /** + * Get the field Y. + * * @return the field Y. */ @FxThread @@ -116,6 +132,8 @@ protected void setPropertyValue(@Nullable final Quaternion quaternion) { } /** + * Get the field Z. + * * @return the field Z. */ @FxThread @@ -127,50 +145,80 @@ protected void setPropertyValue(@Nullable final Quaternion quaternion) { @FxThread protected void reload() { - final float[] angles = new float[3]; + var angles = new float[3]; + var value = getPropertyValue(); - final Quaternion element = getPropertyValue(); - notNull(element, "The property value can't be null."); - - element.toAngles(angles); + if(value != null) { + value.toAngles(angles); + } - final FloatTextField xField = getXField(); + var xField = getXField(); xField.setValue(radiansToDegree(angles[0])); xField.positionCaret(xField.getText().length()); - final FloatTextField yFiled = getYFiled(); + var yFiled = getYFiled(); yFiled.setValue(radiansToDegree(angles[1])); yFiled.positionCaret(yFiled.getText().length()); - final FloatTextField zField = getZField(); + var zField = getZField(); zField.setValue(radiansToDegree(angles[2])); zField.positionCaret(zField.getText().length()); } + @Override + public boolean isDirty() { + + var angles = new float[3]; + var value = getPropertyValue(); + + if(value != null) { + value.toAngles(angles); + } + + float xValue = getXField().getValue(); + float yValue = getYFiled().getValue(); + float zValue = getZField().getValue(); + + return angles[0] != xValue || angles[1] != yValue || angles[2] != zValue; + } + /** - * Updating rotation. + * Handle of input the enter key. */ @FxThread - private void updateRotation(@Nullable final KeyEvent event) { - - if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) { - return; + private void keyReleased(@NotNull KeyEvent event) { + if (event.getCode() == KeyCode.ENTER) { + changeValue(); } + } - final Quaternion oldValue = notNull(getPropertyValue()); + /** + * Change value of rotation. + */ + @FxThread + private void changeValue() { + if (!isIgnoreListener()) { + apply(); + } + } - final FloatTextField xField = getXField(); - final float x = degreeToRadians(xField.getValue()); + @Override + @FxThread + protected void apply() { + super.apply(); - final FloatTextField yFiled = getYFiled(); - final float y = degreeToRadians(yFiled.getValue()); + var oldValue = getPropertyValue(); + if (oldValue != null) { + oldValue = oldValue.clone(); + } - final FloatTextField zField = getZField(); - final float z = degreeToRadians(zField.getValue()); + var x = degreeToRadians(getXField().getValue()); + var y = degreeToRadians(getYFiled().getValue()); + var z = degreeToRadians(getZField().getValue()); - final Quaternion newValue = new Quaternion(); - newValue.fromAngles(ArrayFactory.toFloatArray(x, y, z)); + var newValue = new Quaternion() + .fromAngles(ArrayFactory.toFloatArray(x, y, z)); - changed(newValue, oldValue.clone()); + changed(newValue, oldValue); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/SceneElementPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/SceneElementPropertyControl.java index c0dbfb1d..e352a8c7 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/SceneElementPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/SceneElementPropertyControl.java @@ -9,42 +9,44 @@ /** * The implementation of the {@link ElementPropertyControl} to edit elements from scenes. * - * @param the edited object's type. + * @param the type of an editing object. + * @param the type of an editing property. * @author JavaSaBr */ public abstract class SceneElementPropertyControl extends ElementPropertyControl { - public SceneElementPropertyControl(@NotNull final Class type, @Nullable final T propertyValue, - @NotNull final String propertyName, - @NotNull final SceneChangeConsumer changeConsumer) { + public SceneElementPropertyControl( + @NotNull Class type, + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull SceneChangeConsumer changeConsumer + ) { super(type, propertyValue, propertyName, changeConsumer); } @Override @FxThread - protected void processAdd() { - final SceneSelectorDialog dialog = createSceneSelectorDialog(); - dialog.show(this); + protected void addElement() { + createSceneSelectorDialog().show(this); } /** - * Create scene selector dialog node selector dialog. + * Create a scene selector dialog. * * @return the scene selector dialog. */ @FxThread protected @NotNull SceneSelectorDialog createSceneSelectorDialog() { - final SceneChangeConsumer changeConsumer = getChangeConsumer(); - return new SceneSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); + return new SceneSelectorDialog<>(getChangeConsumer().getCurrentModel(), type, this::addElement); } /** - * Process adding the new element. + * Add the chosen element. * * @param newElement the new element. */ @FxThread - protected void processAdd(@NotNull final T newElement) { + protected void addElement(@NotNull T newElement) { changed(newElement, getPropertyValue()); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/SpatialElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/SpatialElementModelPropertyControl.java index 54a821dc..a6ab371f 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/SpatialElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/SpatialElementModelPropertyControl.java @@ -5,41 +5,42 @@ import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.dialog.node.selector.NodeSelectorDialog; import com.ss.editor.ui.dialog.node.selector.SpatialSelectorDialog; -import javafx.scene.control.Label; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * The implementation of the {@link ElementModelPropertyControl} to edit a spatial from a scene. * - * @param the type parameter + * @param the type of an editing object. + * @param the type of an editing property. * @author JavaSaBr */ -public class SpatialElementModelPropertyControl extends ElementModelPropertyControl { - - public SpatialElementModelPropertyControl(@NotNull Class type, @Nullable final S propertyValue, - @NotNull final String propertyName, - @NotNull final ModelChangeConsumer changeConsumer) { +public class SpatialElementModelPropertyControl extends ElementModelPropertyControl { + + public SpatialElementModelPropertyControl( + @NotNull Class type, + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull ModelChangeConsumer changeConsumer + ) { super(type, propertyValue, propertyName, changeConsumer); } @Override @FxThread - protected @NotNull NodeSelectorDialog createNodeSelectorDialog() { - final ModelChangeConsumer changeConsumer = getChangeConsumer(); - return new SpatialSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); + protected @NotNull NodeSelectorDialog createNodeSelectorDialog() { + return new SpatialSelectorDialog<>(getChangeConsumer().getCurrentModel(), type, this::addElement); } @Override @FxThread protected void reload() { - final Spatial spatial = getPropertyValue(); - final Label elementLabel = getElementLabel(); + var spatial = getPropertyValue(); String name = spatial == null ? null : spatial.getName(); name = name == null && spatial != null ? spatial.getClass().getSimpleName() : name; - elementLabel.setText(name == null ? NO_ELEMENT : name); + getElementLabel().setText(name == null ? NO_ELEMENT : name); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/StringBasedArrayPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/StringBasedArrayPropertyControl.java new file mode 100644 index 00000000..bb8e8512 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/impl/StringBasedArrayPropertyControl.java @@ -0,0 +1,112 @@ +package com.ss.editor.ui.control.property.impl; + +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.ui.control.property.PropertyControl; +import com.ss.editor.ui.css.CssClasses; +import com.ss.rlib.fx.util.FxUtils; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.HBox; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The implementation of the {@link PropertyControl} to edit array values. + * + * @param the change consumer's type. + * @param the type of an editing object. + * @param the type of an editing property. + * @author JavaSaBr + */ +public class StringBasedArrayPropertyControl extends PropertyControl { + + /** + * The filed with current value. + */ + @Nullable + private TextField valueField; + + public StringBasedArrayPropertyControl( + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { + super(propertyValue, propertyName, changeConsumer); + } + + public StringBasedArrayPropertyControl( + @Nullable T propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @Nullable ChangeHandler changeHandler + ) { + super(propertyValue, propertyName, changeConsumer, changeHandler); + } + + @Override + @FxThread + public void changeControlWidthPercent(double controlWidthPercent) { + super.changeControlWidthPercent(controlWidthPercent); + + FxUtils.rebindPrefWidth(getValueField(), + widthProperty().multiply(controlWidthPercent)); + } + + @Override + @FxThread + protected void createComponents(@NotNull HBox container) { + super.createComponents(container); + + valueField = new TextField(); + valueField.setOnKeyReleased(this::updateValue); + valueField.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxUtils.addClass(valueField, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); + + FxUtils.addChild(container, valueField); + } + + @Override + @FromAnyThread + protected boolean isSingleRow() { + return true; + } + + /** + * Get the filed with current value. + * + * @return the filed with current value. + */ + @FxThread + protected @NotNull TextField getValueField() { + return notNull(valueField); + } + + /** + * Update the value. + */ + @FxThread + protected void updateValue(@Nullable KeyEvent event) { + if (!isIgnoreListener() && (event == null || event.getCode() == KeyCode.ENTER)) { + apply(); + } + } + + @Override + @FxThread + protected void apply() { + super.apply(); + changed(getCurrentValue(), getPropertyValue()); + } + + @FxThread + protected @Nullable T getCurrentValue() { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/StringPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/StringPropertyControl.java index fd5e05ea..b39c20f6 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/StringPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/StringPropertyControl.java @@ -1,12 +1,15 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.StringUtils.emptyIfNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; @@ -17,11 +20,11 @@ /** * The implementation of the {@link PropertyControl} to edit string values. * - * @param the type parameter - * @param the type parameter + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr */ -public class StringPropertyControl extends PropertyControl { +public class StringPropertyControl extends PropertyControl { /** * The filed with current value. @@ -29,22 +32,29 @@ public class StringPropertyControl extends Property @Nullable private TextField valueField; - public StringPropertyControl(@Nullable final String propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public StringPropertyControl( + @Nullable String propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); valueField = new TextField(); valueField.setOnKeyReleased(this::updateValue); - valueField.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + valueField.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + FxControlUtils.onFocusChange(valueField, this::applyOnLostFocus); + FxUtils.addClass(valueField, + CssClasses.PROPERTY_CONTROL_COMBO_BOX); - FXUtils.addClassTo(valueField, CssClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); - FXUtils.addToPane(valueField, container); + FxUtils.addChild(container, valueField); } @Override @@ -54,6 +64,8 @@ protected boolean isSingleRow() { } /** + * Get the filed with current value. + * * @return the filed with current value. */ @FxThread @@ -64,10 +76,9 @@ protected boolean isSingleRow() { @Override @FxThread protected void reload() { - final String value = getPropertyValue(); - final TextField valueField = getValueField(); - final int caretPosition = valueField.getCaretPosition(); - valueField.setText(value == null ? "" : value); + var valueField = getValueField(); + var caretPosition = valueField.getCaretPosition(); + valueField.setText(emptyIfNull(getPropertyValue())); valueField.positionCaret(caretPosition); } @@ -75,17 +86,22 @@ protected void reload() { * Update the value. */ @FxThread - private void updateValue(@NotNull final KeyEvent event) { - - if (isIgnoreListener() || event.getCode() != KeyCode.ENTER) { - return; + private void updateValue(@NotNull KeyEvent event) { + if (!isIgnoreListener() && event.getCode() == KeyCode.ENTER) { + apply(); } + } - final TextField valueField = getValueField(); - - final String oldValue = getPropertyValue(); - final String newValue = valueField.getText(); + @FxThread + @Override + public boolean isDirty() { + return !StringUtils.equals(getPropertyValue(), getValueField().getText()); + } - changed(newValue, oldValue); + @Override + @FxThread + protected void apply() { + super.apply(); + changed(getValueField().getText(), getPropertyValue()); } } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Texture2DPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Texture2DPropertyControl.java deleted file mode 100644 index cbd9ff5d..00000000 --- a/src/main/java/com/ss/editor/ui/control/property/impl/Texture2DPropertyControl.java +++ /dev/null @@ -1,390 +0,0 @@ -package com.ss.editor.ui.control.property.impl; - -import static com.ss.editor.FileExtensions.TEXTURE_EXTENSIONS; -import static com.ss.editor.config.DefaultSettingsProvider.Defaults.PREF_DEFAULT_FLIPPED_TEXTURES; -import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_FLIPPED_TEXTURES; -import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.asset.AssetKey; -import com.jme3.asset.AssetManager; -import com.jme3.asset.TextureKey; -import com.jme3.texture.Texture; -import com.jme3.texture.Texture2D; -import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; -import com.ss.editor.config.EditorConfig; -import com.ss.editor.extension.property.EditablePropertyType; -import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; -import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.editor.ui.Icons; -import com.ss.editor.ui.control.property.PropertyControl; -import com.ss.editor.ui.css.CssClasses; -import com.ss.editor.ui.tooltip.ImageChannelPreview; -import com.ss.editor.ui.util.UiUtils; -import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import javafx.beans.binding.BooleanBinding; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.Tooltip; -import javafx.scene.image.ImageView; -import javafx.scene.input.DragEvent; -import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.nio.file.Files; -import java.nio.file.Path; - -/** - * The implementation of the {@link PropertyControl} to edit {@link com.jme3.texture.Texture2D} values. - * - * @param the type of a {@link ChangeConsumer} - * @param the type of an editing object. - * @author JavaSaBr - */ -public class Texture2DPropertyControl extends PropertyControl { - - /** - * The constant NO_TEXTURE. - */ - @NotNull - protected static final String NO_TEXTURE = Messages.MATERIAL_MODEL_PROPERTY_CONTROL_NO_TEXTURE; - - @NotNull - protected static final Point DIALOG_SIZE = new Point(600, -1); - - @NotNull - protected static final String PROP_FLIP = "flip"; - - @NotNull - protected static final String PROP_WRAP_MODE_S = "wrapModeS"; - - @NotNull - protected static final String PROP_WRAP_MODE_T = "wrapModeT"; - - @NotNull - protected static final String PROP_MAG_FILTER = "magFilter"; - - @NotNull - protected static final String PROP_MIN_FILTER = "minFilter"; - - /** - * The image channels preview. - */ - @Nullable - private ImageChannelPreview textureTooltip; - - /** - * The image preview. - */ - @Nullable - private ImageView texturePreview; - - /** - * The label for of path to a texture. - */ - @Nullable - private Label textureLabel; - - /** - * The field container. - */ - @Nullable - private HBox fieldContainer; - - public Texture2DPropertyControl(@Nullable final Texture2D propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { - super(propertyValue, propertyName, changeConsumer); - setOnDragOver(this::handleDragOverEvent); - setOnDragDropped(this::handleDragDroppedEvent); - } - - @Override - @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { - } - - /** - * Handle drag dropped events. - * - * @param dragEvent the drag dropped event. - */ - @FxThread - protected void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { - UiUtils.handleDroppedFile(dragEvent, TEXTURE_EXTENSIONS, this, Texture2DPropertyControl::setTexture); - } - - /** - * Handle drag over events. - * - * @param dragEvent the drag over event. - */ - @FxThread - protected void handleDragOverEvent(@NotNull final DragEvent dragEvent) { - UiUtils.acceptIfHasFile(dragEvent, TEXTURE_EXTENSIONS); - } - - @Override - @FxThread - protected void createComponents(@NotNull final HBox container) { - super.createComponents(container); - - fieldContainer = new HBox(); - - if (!isSingleRow()) { - fieldContainer.prefWidthProperty().bind(container.widthProperty()); - } - - textureTooltip = new ImageChannelPreview(); - - final VBox previewContainer = new VBox(); - - texturePreview = new ImageView(); - texturePreview.fitHeightProperty().bind(previewContainer.heightProperty()); - texturePreview.fitWidthProperty().bind(previewContainer.widthProperty()); - - Tooltip.install(texturePreview, textureTooltip); - - final Button settingsButton = new Button(); - settingsButton.setGraphic(new ImageView(Icons.SETTINGS_16)); - settingsButton.setOnAction(event -> openSettings()); - settingsButton.disableProperty().bind(buildDisableRemoveCondition()); - - final Button addButton = new Button(); - addButton.setGraphic(new ImageView(Icons.ADD_12)); - addButton.setOnAction(event -> processAdd()); - - final Button removeButton = new Button(); - removeButton.setGraphic(new ImageView(Icons.REMOVE_12)); - removeButton.setOnAction(event -> processRemove()); - removeButton.disableProperty().bind(buildDisableRemoveCondition()); - - if (!isSingleRow()) { - - textureLabel = new Label(NO_TEXTURE); - textureLabel.prefWidthProperty().bind(widthProperty() - .subtract(removeButton.widthProperty()) - .subtract(previewContainer.widthProperty()) - .subtract(settingsButton.widthProperty()) - .subtract(addButton.widthProperty())); - - FXUtils.addToPane(textureLabel, fieldContainer); - FXUtils.addClassTo(textureLabel, CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL); - FXUtils.addClassesTo(fieldContainer, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); - - } else { - FXUtils.addClassesTo(fieldContainer, CssClasses.TEXT_INPUT_CONTAINER_WITHOUT_PADDING); - } - - FXUtils.addToPane(previewContainer, fieldContainer); - FXUtils.addToPane(addButton, fieldContainer); - FXUtils.addToPane(settingsButton, fieldContainer); - FXUtils.addToPane(removeButton, fieldContainer); - FXUtils.addToPane(fieldContainer, container); - FXUtils.addToPane(texturePreview, previewContainer); - - FXUtils.addClassTo(previewContainer, CssClasses.ABSTRACT_PARAM_CONTROL_PREVIEW_CONTAINER); - FXUtils.addClassesTo(settingsButton, addButton, removeButton, CssClasses.FLAT_BUTTON, - CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); - } - - /** - * @return the disable|remove condition. - */ - @FxThread - protected @NotNull BooleanBinding buildDisableRemoveCondition() { - return getTexturePreview().imageProperty().isNull(); - } - - /** - * @return the texture label. - */ - @FxThread - private @NotNull Label getTextureLabel() { - return notNull(textureLabel); - } - - /** - * Get the field container. - * - * @return the field container. - */ - @FxThread - protected @NotNull HBox getFieldContainer() { - return notNull(fieldContainer); - } - - /** - * @return the texture preview. - */ - @FxThread - private @NotNull ImageView getTexturePreview() { - return notNull(texturePreview); - } - - /** - * @return the image channels preview. - */ - @FxThread - private @NotNull ImageChannelPreview getTextureTooltip() { - return notNull(textureTooltip); - } - - /** - * Process to remove the current texture. - */ - @FxThread - protected void processRemove() { - setTexture(null); - } - - /** - * Process to add a new texture. - */ - @FxThread - protected void processAdd() { - UiUtils.openFileAssetDialog(this::setTexture, TEXTURE_EXTENSIONS, DEFAULT_ACTION_TESTER); - } - - /** - * Process to open texture's settings. - */ - @FxThread - protected void openSettings() { - - final Texture2D texture = notNull(getPropertyValue()); - final TextureKey key = (TextureKey) texture.getKey(); - final boolean flipY = key.isFlipY(); - final Texture.WrapMode wrapS = texture.getWrap(Texture.WrapAxis.S); - final Texture.WrapMode wrapT = texture.getWrap(Texture.WrapAxis.T); - final Texture.MagFilter magFilter = texture.getMagFilter(); - final Texture.MinFilter minFilter = texture.getMinFilter(); - - final Array properties = ArrayFactory.newArray(PropertyDefinition.class); - properties.add(new PropertyDefinition(EditablePropertyType.BOOLEAN, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_FLIP_Y, PROP_FLIP, flipY)); - properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_S, PROP_WRAP_MODE_S, wrapS)); - properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_T, PROP_WRAP_MODE_T, wrapT)); - properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_MAG_FILTER, PROP_MAG_FILTER, magFilter)); - properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_MIN_FILTER, PROP_MIN_FILTER, minFilter)); - - final GenericFactoryDialog dialog = new GenericFactoryDialog(properties, this::applyChanges); - dialog.setTitle(Messages.MATERIAL_MODEL_PROPERTY_CONTROL_TEXTURE_SETTINGS); - dialog.setButtonOkText(Messages.SIMPLE_DIALOG_BUTTON_APPLY); - dialog.setButtonCloseText(Messages.SIMPLE_DIALOG_BUTTON_CANCEL); - dialog.configureSize(DIALOG_SIZE); - dialog.show(); - } - - /** - * Apple new changes if need. - * - * @param varTable the var table. - */ - @FxThread - private void applyChanges(@NotNull final VarTable varTable) { - - final Texture2D texture = notNull(getPropertyValue()); - final TextureKey key = (TextureKey) texture.getKey(); - final boolean flipY = key.isFlipY(); - final Texture.WrapMode wrapS = texture.getWrap(Texture.WrapAxis.S); - final Texture.WrapMode wrapT = texture.getWrap(Texture.WrapAxis.T); - final Texture.MagFilter magFilter = texture.getMagFilter(); - final Texture.MinFilter minFilter = texture.getMinFilter(); - - final boolean needFlipY = varTable.getBoolean(PROP_FLIP); - final Texture.WrapMode needWrapS = varTable.getEnum(PROP_WRAP_MODE_S, Texture.WrapMode.class); - final Texture.WrapMode needWrapT = varTable.getEnum(PROP_WRAP_MODE_T, Texture.WrapMode.class); - final Texture.MagFilter needMagFilter = varTable.getEnum(PROP_MAG_FILTER, Texture.MagFilter.class); - final Texture.MinFilter needMinFilter = varTable.getEnum(PROP_MIN_FILTER, Texture.MinFilter.class); - - if (flipY == needFlipY && wrapS == needWrapS && wrapT == needWrapT && magFilter == needMagFilter && - minFilter == needMinFilter) { - return; - } - - final TextureKey newKey = new TextureKey(key.getName()); - newKey.setFlipY(needFlipY); - - final AssetManager assetManager = EditorUtil.getAssetManager(); - assetManager.deleteFromCache(key); - - final Texture2D loadedTexture = (Texture2D) assetManager.loadTexture(newKey); - loadedTexture.setWrap(Texture.WrapAxis.S, needWrapS); - loadedTexture.setWrap(Texture.WrapAxis.T, needWrapT); - loadedTexture.setMagFilter(needMagFilter); - loadedTexture.setMinFilter(needMinFilter); - - changed(loadedTexture, texture); - } - - - /** - * Sets new texture to this property. - * - * @param file the file to new texture. - */ - @FxThread - protected void setTexture(@Nullable final Path file) { - - if (file == null) { - changed(null, getPropertyValue()); - } else { - - final EditorConfig config = EditorConfig.getInstance(); - final Path assetFile = notNull(getAssetFile(file)); - final TextureKey textureKey = new TextureKey(toAssetPath(assetFile)); - textureKey.setFlipY(config.getBoolean(PREF_FLIPPED_TEXTURES, PREF_DEFAULT_FLIPPED_TEXTURES)); - - final AssetManager assetManager = EditorUtil.getAssetManager(); - final Texture2D texture = (Texture2D) assetManager.loadTexture(textureKey); - texture.setWrap(Texture.WrapMode.Repeat); - - changed(texture, getPropertyValue()); - } - } - - @Override - @FxThread - protected void reload() { - - final Texture2D texture2D = getPropertyValue(); - final AssetKey key = texture2D == null ? null : texture2D.getKey(); - - if (!isSingleRow()) { - final Label textureLabel = getTextureLabel(); - textureLabel.setText(key == null ? NO_TEXTURE : key.getName()); - } - - final ImageChannelPreview textureTooltip = getTextureTooltip(); - final ImageView preview = getTexturePreview(); - - if (key == null) { - preview.setImage(null); - textureTooltip.clean(); - preview.setDisable(true); - preview.setMouseTransparent(true); - } else { - - preview.setDisable(false); - preview.setMouseTransparent(false); - - final Path realFile = notNull(getRealFile(key.getName())); - - if (Files.exists(realFile)) { - preview.setImage(IMAGE_MANAGER.getImagePreview(realFile, 24, 24)); - textureTooltip.showImage(realFile); - } else { - preview.setImage(IMAGE_MANAGER.getImagePreview(key.getName(), 24, 24)); - textureTooltip.showImage(key.getName()); - } - } - } -} diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Texture2dPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Texture2dPropertyControl.java new file mode 100644 index 00000000..e4f38a6c --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/impl/Texture2dPropertyControl.java @@ -0,0 +1,407 @@ +package com.ss.editor.ui.control.property.impl; + +import static com.ss.editor.FileExtensions.TEXTURE_EXTENSIONS; +import static com.ss.editor.config.DefaultSettingsProvider.Defaults.PREF_DEFAULT_FLIPPED_TEXTURES; +import static com.ss.editor.config.DefaultSettingsProvider.Preferences.PREF_FLIPPED_TEXTURES; +import static com.ss.editor.extension.property.EditablePropertyType.BOOLEAN; +import static com.ss.editor.extension.property.EditablePropertyType.ENUM; +import static com.ss.editor.util.EditorUtil.*; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import com.jme3.asset.TextureKey; +import com.jme3.texture.Texture; +import com.jme3.texture.Texture2D; +import com.ss.editor.Messages; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.config.EditorConfig; +import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; +import com.ss.editor.plugin.api.property.PropertyDefinition; +import com.ss.editor.ui.Icons; +import com.ss.editor.ui.control.property.PropertyControl; +import com.ss.editor.ui.css.CssClasses; +import com.ss.editor.ui.tooltip.ImageChannelPreview; +import com.ss.editor.ui.util.UiUtils; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FxUtils; +import javafx.beans.binding.BooleanBinding; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.Tooltip; +import javafx.scene.image.ImageView; +import javafx.scene.input.DragEvent; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.nio.file.Files; +import java.nio.file.Path; + +/** + * The implementation of the {@link PropertyControl} to edit {@link com.jme3.texture.Texture2D} values. + * + * @param the type of a change consumer. + * @param the type of an editing object. + * @author JavaSaBr + */ +public class Texture2dPropertyControl extends PropertyControl { + + /** + * The constant NO_TEXTURE. + */ + @NotNull + protected static final String NO_TEXTURE = Messages.MATERIAL_MODEL_PROPERTY_CONTROL_NO_TEXTURE; + + @NotNull + protected static final Point DIALOG_SIZE = new Point(600, -1); + + @NotNull + protected static final String PROP_FLIP = "flip"; + + @NotNull + protected static final String PROP_WRAP_MODE_S = "wrapModeS"; + + @NotNull + protected static final String PROP_WRAP_MODE_T = "wrapModeT"; + + @NotNull + protected static final String PROP_MAG_FILTER = "magFilter"; + + @NotNull + protected static final String PROP_MIN_FILTER = "minFilter"; + + /** + * The image channels preview. + */ + @Nullable + private ImageChannelPreview textureTooltip; + + /** + * The image preview. + */ + @Nullable + private ImageView texturePreview; + + /** + * The label for of path to a texture. + */ + @Nullable + private Label textureLabel; + + /** + * The field container. + */ + @Nullable + private HBox fieldContainer; + + public Texture2dPropertyControl( + @Nullable Texture2D propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { + super(propertyValue, propertyName, changeConsumer); + setOnDragOver(this::handleDragOverEvent); + setOnDragDropped(this::handleDragDroppedEvent); + } + + @Override + @FxThread + public void changeControlWidthPercent(double controlWidthPercent) { + } + + /** + * Handle drag dropped events. + * + * @param dragEvent the drag dropped event. + */ + @FxThread + protected void handleDragDroppedEvent(@NotNull DragEvent dragEvent) { + UiUtils.handleDroppedFile(dragEvent, TEXTURE_EXTENSIONS, this, Texture2dPropertyControl::changeTexture); + } + + /** + * Handle drag over events. + * + * @param dragEvent the drag over event. + */ + @FxThread + protected void handleDragOverEvent(@NotNull DragEvent dragEvent) { + UiUtils.acceptIfHasFile(dragEvent, TEXTURE_EXTENSIONS); + } + + @Override + @FxThread + protected void createComponents(@NotNull HBox container) { + super.createComponents(container); + + fieldContainer = new HBox(); + + if (!isSingleRow()) { + fieldContainer.prefWidthProperty() + .bind(container.widthProperty()); + } + + textureTooltip = new ImageChannelPreview(); + + var previewContainer = new VBox(); + + texturePreview = new ImageView(); + texturePreview.fitHeightProperty() + .bind(previewContainer.heightProperty()); + texturePreview.fitWidthProperty() + .bind(previewContainer.widthProperty()); + + Tooltip.install(texturePreview, textureTooltip); + + var settingsButton = new Button(); + settingsButton.setGraphic(new ImageView(Icons.SETTINGS_16)); + settingsButton.setOnAction(event -> openSettings()); + settingsButton.disableProperty().bind(buildDisableRemoveCondition()); + + var addButton = new Button(); + addButton.setGraphic(new ImageView(Icons.ADD_12)); + addButton.setOnAction(event -> addNewTexture()); + + var removeButton = new Button(); + removeButton.setGraphic(new ImageView(Icons.REMOVE_12)); + removeButton.setOnAction(event -> removeTexture()); + removeButton.disableProperty().bind(buildDisableRemoveCondition()); + + if (!isSingleRow()) { + + textureLabel = new Label(NO_TEXTURE); + textureLabel.prefWidthProperty() + .bind(widthProperty() + .subtract(removeButton.widthProperty()) + .subtract(previewContainer.widthProperty()) + .subtract(settingsButton.widthProperty()) + .subtract(addButton.widthProperty())); + + FxUtils.addClass(textureLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL) + .addClass(fieldContainer, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); + + FxUtils.addChild(fieldContainer, textureLabel); + + } else { + FxUtils.addClass(fieldContainer, + CssClasses.TEXT_INPUT_CONTAINER_WITHOUT_PADDING); + } + + FxUtils.addClass(previewContainer, + CssClasses.ABSTRACT_PARAM_CONTROL_PREVIEW_CONTAINER) + .addClass(settingsButton, addButton, removeButton, + CssClasses.FLAT_BUTTON, + CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON); + + FxUtils.addChild(fieldContainer, previewContainer, addButton, settingsButton, removeButton) + .addChild(container, fieldContainer) + .addChild(previewContainer, texturePreview); + } + + /** + * Get the disable|remove condition. + * + * @return the disable|remove condition. + */ + @FxThread + protected @NotNull BooleanBinding buildDisableRemoveCondition() { + return getTexturePreview().imageProperty().isNull(); + } + + /** + * Get the texture label. + * + * @return the texture label. + */ + @FxThread + private @NotNull Label getTextureLabel() { + return notNull(textureLabel); + } + + /** + * Get the field container. + * + * @return the field container. + */ + @FxThread + protected @NotNull HBox getFieldContainer() { + return notNull(fieldContainer); + } + + /** + * Get the texture preview. + * + * @return the texture preview. + */ + @FxThread + private @NotNull ImageView getTexturePreview() { + return notNull(texturePreview); + } + + /** + * Get the image channels preview. + * + * @return the image channels preview. + */ + @FxThread + private @NotNull ImageChannelPreview getTextureTooltip() { + return notNull(textureTooltip); + } + + /** + * Remove the current texture. + */ + @FxThread + protected void removeTexture() { + changeTexture(null); + } + + /** + * Open the dialog to choose a new texture. + */ + @FxThread + protected void addNewTexture() { + UiUtils.openFileAssetDialog(this::changeTexture, TEXTURE_EXTENSIONS, DEFAULT_ACTION_TESTER); + } + + /** + * Open a dialog with texture's settings. + */ + @FxThread + protected void openSettings() { + + var texture = notNull(getPropertyValue()); + var key = (TextureKey) texture.getKey(); + var flipY = key.isFlipY(); + var wrapS = texture.getWrap(Texture.WrapAxis.S); + var wrapT = texture.getWrap(Texture.WrapAxis.T); + var magFilter = texture.getMagFilter(); + var minFilter = texture.getMinFilter(); + + var properties = ArrayFactory.newArray(PropertyDefinition.class); + properties.add(new PropertyDefinition(BOOLEAN, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_FLIP_Y, PROP_FLIP, flipY)); + properties.add(new PropertyDefinition(ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_S, PROP_WRAP_MODE_S, wrapS)); + properties.add(new PropertyDefinition(ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_T, PROP_WRAP_MODE_T, wrapT)); + properties.add(new PropertyDefinition(ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_MAG_FILTER, PROP_MAG_FILTER, magFilter)); + properties.add(new PropertyDefinition(ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_MIN_FILTER, PROP_MIN_FILTER, minFilter)); + + var dialog = new GenericFactoryDialog(properties, this::applyChanges); + dialog.setTitle(Messages.MATERIAL_MODEL_PROPERTY_CONTROL_TEXTURE_SETTINGS); + dialog.setButtonOkText(Messages.SIMPLE_DIALOG_BUTTON_APPLY); + dialog.setButtonCloseText(Messages.SIMPLE_DIALOG_BUTTON_CANCEL); + dialog.configureSize(DIALOG_SIZE); + dialog.show(); + } + + /** + * Apply new changes if need. + * + * @param vars the vars table. + */ + @FxThread + private void applyChanges(@NotNull VarTable vars) { + + var texture = notNull(getPropertyValue()); + var key = (TextureKey) texture.getKey(); + var flipY = key.isFlipY(); + var wrapS = texture.getWrap(Texture.WrapAxis.S); + var wrapT = texture.getWrap(Texture.WrapAxis.T); + var magFilter = texture.getMagFilter(); + var minFilter = texture.getMinFilter(); + + var needFlipY = vars.getBoolean(PROP_FLIP); + var needWrapS = vars.getEnum(PROP_WRAP_MODE_S, Texture.WrapMode.class); + var needWrapT = vars.getEnum(PROP_WRAP_MODE_T, Texture.WrapMode.class); + var needMagFilter = vars.getEnum(PROP_MAG_FILTER, Texture.MagFilter.class); + var needMinFilter = vars.getEnum(PROP_MIN_FILTER, Texture.MinFilter.class); + + if (flipY == needFlipY && + wrapS == needWrapS && + wrapT == needWrapT && + magFilter == needMagFilter && + minFilter == needMinFilter) { + return; + } + + var newKey = new TextureKey(key.getName()); + newKey.setFlipY(needFlipY); + + var assetManager = EditorUtil.getAssetManager(); + assetManager.deleteFromCache(key); + + var loadedTexture = (Texture2D) assetManager.loadTexture(newKey); + loadedTexture.setWrap(Texture.WrapAxis.S, needWrapS); + loadedTexture.setWrap(Texture.WrapAxis.T, needWrapT); + loadedTexture.setMagFilter(needMagFilter); + loadedTexture.setMinFilter(needMinFilter); + + changed(loadedTexture, texture); + } + + /** + * Change a texture to the file. + * + * @param file the file of a new texture. + */ + @FxThread + protected void changeTexture(@Nullable Path file) { + + if (file == null) { + changed(null, getPropertyValue()); + } else { + + var config = EditorConfig.getInstance(); + var assetFile = notNull(getAssetFile(file)); + var textureKey = new TextureKey(toAssetPath(assetFile)); + textureKey.setFlipY(config.getBoolean(PREF_FLIPPED_TEXTURES, PREF_DEFAULT_FLIPPED_TEXTURES)); + + var texture = (Texture2D) EditorUtil.getAssetManager() + .loadTexture(textureKey); + texture.setWrap(Texture.WrapMode.Repeat); + + changed(texture, getPropertyValue()); + } + } + + @Override + @FxThread + protected void reload() { + + var texture2D = getPropertyValue(); + var key = texture2D == null ? null : texture2D.getKey(); + + if (!isSingleRow()) { + getTextureLabel().setText(key == null ? NO_TEXTURE : key.getName()); + } + + var textureTooltip = getTextureTooltip(); + var preview = getTexturePreview(); + + if (key == null) { + preview.setImage(null); + textureTooltip.clean(); + preview.setDisable(true); + preview.setMouseTransparent(true); + } else { + + preview.setDisable(false); + preview.setMouseTransparent(false); + + var realFile = notNull(getRealFile(key.getName())); + + if (Files.exists(realFile)) { + preview.setImage(IMAGE_MANAGER.getImagePreview(realFile, 24, 24)); + textureTooltip.showImage(realFile); + } else { + preview.setImage(IMAGE_MANAGER.getImagePreview(key.getName(), 24, 24)); + textureTooltip.showImage(key.getName()); + } + } + } +} diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Texture2DSingleRowPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Texture2dSingleRowPropertyControl.java similarity index 56% rename from src/main/java/com/ss/editor/ui/control/property/impl/Texture2DSingleRowPropertyControl.java rename to src/main/java/com/ss/editor/ui/control/property/impl/Texture2dSingleRowPropertyControl.java index 97ce2c58..4242ca02 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/Texture2DSingleRowPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/Texture2dSingleRowPropertyControl.java @@ -9,14 +9,17 @@ /** * The single row implementation of the control to edit textures. * - * @param the type of a {@link ChangeConsumer} - * @param the type of an editing object. + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr */ -public class Texture2DSingleRowPropertyControl extends Texture2DPropertyControl { +public class Texture2dSingleRowPropertyControl extends Texture2dPropertyControl { - public Texture2DSingleRowPropertyControl(@Nullable final Texture2D propertyValue, - @NotNull final String propertyName, @NotNull final C changeConsumer) { + public Texture2dSingleRowPropertyControl( + @Nullable Texture2D propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { super(propertyValue, propertyName, changeConsumer); } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Vector2FPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Vector2FPropertyControl.java deleted file mode 100644 index 4f4e7228..00000000 --- a/src/main/java/com/ss/editor/ui/control/property/impl/Vector2FPropertyControl.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.ss.editor.ui.control.property.impl; - -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FxThread; -import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.ui.control.property.PropertyControl; -import com.ss.editor.ui.css.CssClasses; -import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.HBox; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The implementation of the {@link PropertyControl} to edit {@link Vector2f} values. - * - * @param the type parameter - * @param the type parameter - * @author JavaSaBr. - */ -public class Vector2FPropertyControl extends PropertyControl { - - /** - * The field X. - */ - @Nullable - private FloatTextField xField; - - /** - * The field Y. - */ - @Nullable - private FloatTextField yField; - - /** - * The field container. - */ - @Nullable - private HBox fieldContainer; - - public Vector2FPropertyControl(@Nullable final Vector2f propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { - super(propertyValue, propertyName, changeConsumer); - } - - @Override - @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { - super.changeControlWidthPercent(controlWidthPercent); - - final HBox valueField = getFieldContainer(); - valueField.prefWidthProperty().unbind(); - valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); - } - - @Override - @FxThread - protected void createComponents(@NotNull final HBox container) { - super.createComponents(container); - - fieldContainer = new HBox(); - fieldContainer.prefWidthProperty() - .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); - - xField = new FloatTextField(); - xField.setOnKeyReleased(this::updateVector); - xField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - xField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.5)); - xField.setScrollPower(10F); - - yField = new FloatTextField(); - yField.setOnKeyReleased(this::updateVector); - yField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - yField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.5)); - yField.setScrollPower(10F); - - FXUtils.addToPane(xField, fieldContainer); - FXUtils.addToPane(yField, fieldContainer); - FXUtils.addToPane(fieldContainer, container); - - FXUtils.addClassesTo(fieldContainer, CssClasses.DEF_HBOX, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER); - - FXUtils.addClassesTo(xField, yField, CssClasses.TRANSPARENT_TEXT_FIELD); - - UiUtils.addFocusBinding(fieldContainer, xField, yField); - } - - /** - * @return the field container. - */ - @FxThread - private @NotNull HBox getFieldContainer() { - return notNull(fieldContainer); - } - - @Override - @FxThread - protected void setPropertyValue(@Nullable final Vector2f vector) { - super.setPropertyValue(vector == null ? null : vector.clone()); - } - - @Override - @FromAnyThread - protected boolean isSingleRow() { - return true; - } - - /** - * Check result x value float. - * - * @param x the x - * @param y the y - * @return the float - */ - @FxThread - protected float checkResultXValue(final float x, final float y) { - return x; - } - - /** - * Check result y value float. - * - * @param x the x - * @param y the y - * @return the float - */ - @FxThread - protected float checkResultYValue(final float x, final float y) { - return y; - } - - /** - * Gets x field. - * - * @return the field X. - */ - @FxThread - protected @NotNull FloatTextField getXField() { - return notNull(xField); - } - - /** - * Gets y field. - * - * @return the field Y. - */ - @FxThread - protected @NotNull FloatTextField getYField() { - return notNull(yField); - } - - @Override - @FxThread - protected void reload() { - - final Vector2f vector = getPropertyValue() == null ? Vector2f.ZERO : getPropertyValue(); - - final FloatTextField xField = getXField(); - xField.setValue(vector.getX()); - xField.positionCaret(xField.getText().length()); - - final FloatTextField yField = getYField(); - yField.setValue(vector.getY()); - yField.positionCaret(yField.getText().length()); - } - - /** - * Update the vector. - * - * @param event the event - */ - @FxThread - private void updateVector(@Nullable final KeyEvent event) { - - if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) { - return; - } - - final FloatTextField xField = getXField(); - final float x = xField.getValue(); - - final FloatTextField yField = getYField(); - final float y = yField.getValue(); - - final Vector2f oldValue = getPropertyValue() == null ? Vector2f.ZERO : getPropertyValue(); - final Vector2f newValue = new Vector2f(); - newValue.set(checkResultXValue(x, y), checkResultYValue(x, y)); - - changed(newValue, oldValue.clone()); - } -} diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Vector2fPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Vector2fPropertyControl.java new file mode 100644 index 00000000..a973eb09 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/impl/Vector2fPropertyControl.java @@ -0,0 +1,249 @@ +package com.ss.editor.ui.control.property.impl; + +import static com.ss.editor.util.GeomUtils.zeroIfNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import com.jme3.math.Vector2f; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.ui.control.property.PropertyControl; +import com.ss.editor.ui.css.CssClasses; +import com.ss.editor.ui.util.UiUtils; +import com.ss.editor.util.GeomUtils; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FxUtils; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.HBox; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The implementation of the {@link PropertyControl} to edit {@link Vector2f} values. + * + * @param the type of a change consumer. + * @param the type of an editing object. + * @author JavaSaBr + */ +public class Vector2fPropertyControl extends PropertyControl { + + /** + * The field X. + */ + @Nullable + private FloatTextField xField; + + /** + * The field Y. + */ + @Nullable + private FloatTextField yField; + + /** + * The field container. + */ + @Nullable + private HBox fieldContainer; + + public Vector2fPropertyControl( + @Nullable Vector2f propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { + super(propertyValue, propertyName, changeConsumer); + } + + @Override + @FxThread + public void changeControlWidthPercent(double controlWidthPercent) { + super.changeControlWidthPercent(controlWidthPercent); + + FxUtils.rebindPrefWidth(getFieldContainer(), + widthProperty().multiply(controlWidthPercent)); + } + + /** + * Set value limits for this field. + * + * @param min the min value. + * @param max the max value. + */ + @FxThread + public void setMinMax(float min, float max) { + getXField().setMinMax(min, max); + getYField().setMinMax(min, max); + } + + /** + * Sets the scroll power. + * + * @param scrollPower the scroll power. + */ + @FxThread + public void setScrollPower(float scrollPower) { + getXField().setScrollPower(scrollPower); + getYField().setScrollPower(scrollPower); + } + + /** + * Get the scroll power. + * + * @return the scroll power. + */ + @FxThread + public float getScrollPower() { + return getXField().getScrollPower(); + } + + @Override + @FxThread + protected void createComponents(@NotNull HBox container) { + super.createComponents(container); + + fieldContainer = new HBox(); + fieldContainer.prefWidthProperty() + .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); + + xField = new FloatTextField(); + xField.setOnKeyReleased(this::updateVector); + xField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); + xField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.5)); + xField.setScrollPower(10F); + + yField = new FloatTextField(); + yField.setOnKeyReleased(this::updateVector); + yField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); + yField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.5)); + yField.setScrollPower(10F); + + FxUtils.addClass(fieldContainer, + CssClasses.DEF_HBOX, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER) + .addClass(xField, yField, + CssClasses.TRANSPARENT_TEXT_FIELD); + + FxUtils.addChild(fieldContainer, xField, yField) + .addChild(container, fieldContainer); + + UiUtils.addFocusBinding(fieldContainer, xField, yField) + .addListener((observable, oldValue, newValue) -> applyOnLostFocus(newValue)); + } + + /** + * Get the field container. + * + * @return the field container. + */ + @FxThread + private @NotNull HBox getFieldContainer() { + return notNull(fieldContainer); + } + + @Override + @FxThread + protected void setPropertyValue(@Nullable Vector2f vector) { + super.setPropertyValue(zeroIfNull(vector).clone()); + } + + @Override + @FromAnyThread + protected boolean isSingleRow() { + return true; + } + + /** + * Check the result x value. + * + * @param x the x. + * @param y the y. + * @return the result x value. + */ + @FxThread + protected float checkResultXValue(float x, float y) { + return x; + } + + /** + * Check result y value. + * + * @param x the x. + * @param y the y. + * @return the result y value. + */ + @FxThread + protected float checkResultYValue(float x, float y) { + return y; + } + + /** + * Get the X field. + * + * @return the X field. + */ + @FxThread + protected @NotNull FloatTextField getXField() { + return notNull(xField); + } + + /** + * Get the Y field. + * + * @return the Y field. + */ + @FxThread + protected @NotNull FloatTextField getYField() { + return notNull(yField); + } + + @Override + @FxThread + protected void reload() { + + var vector = zeroIfNull(getPropertyValue()); + + var xField = getXField(); + xField.setValue(vector.getX()); + xField.positionCaret(xField.getText().length()); + + var yField = getYField(); + yField.setValue(vector.getY()); + yField.positionCaret(yField.getText().length()); + } + + @Override + @FxThread + public boolean isDirty() { + + var x = getXField().getValue(); + var y = getYField().getValue(); + + return !GeomUtils.equals(getPropertyValue(), x, y); + } + + /** + * Update the vector. + * + * @param event the event + */ + @FxThread + private void updateVector(@Nullable KeyEvent event) { + if (!isIgnoreListener() && (event == null || event.getCode() == KeyCode.ENTER)) { + apply(); + } + } + + @Override + @FxThread + protected void apply() { + super.apply(); + + var x = getXField().getValue(); + var y = getYField().getValue(); + + var oldValue = zeroIfNull(getPropertyValue()); + var newValue = new Vector2f(checkResultXValue(x, y), checkResultYValue(x, y)); + + changed(newValue, oldValue.clone()); + } +} diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Vector3FPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Vector3FPropertyControl.java deleted file mode 100644 index 914d2abf..00000000 --- a/src/main/java/com/ss/editor/ui/control/property/impl/Vector3FPropertyControl.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.ss.editor.ui.control.property.impl; - -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.math.Vector3f; -import com.ss.editor.annotation.FxThread; -import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.ui.control.property.PropertyControl; -import com.ss.editor.ui.css.CssClasses; -import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.function.SixObjectConsumer; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import javafx.scene.control.Label; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.HBox; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.function.BiConsumer; - -/** - * The implementation of the {@link PropertyControl} to edit {@link Vector3f} values. - * - * @param the type of a {@link ChangeConsumer} - * @param the type of an editing object. - * @author JavaSaBr - */ -public class Vector3FPropertyControl extends PropertyControl { - - /** - * The field X. - */ - @Nullable - private FloatTextField xField; - - /** - * The field Y. - */ - @Nullable - private FloatTextField yField; - - /** - * The field Z. - */ - @Nullable - private FloatTextField zField; - - public Vector3FPropertyControl(@Nullable final Vector3f propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { - super(propertyValue, propertyName, changeConsumer); - } - - public Vector3FPropertyControl(@Nullable final Vector3f propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer, - @Nullable final SixObjectConsumer> changeHandler) { - super(propertyValue, propertyName, changeConsumer, changeHandler); - } - - @Override - @FxThread - protected void createComponents(@NotNull final HBox container) { - super.createComponents(container); - - final Label xLabel = new Label("x:"); - - xField = new FloatTextField(); - xField.setOnKeyReleased(this::updateVector); - xField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - xField.prefWidthProperty().bind(widthProperty().divide(3)); - xField.setScrollPower(getScrollPower()); - - final Label yLabel = new Label("y:"); - - yField = new FloatTextField(); - yField.setOnKeyReleased(this::updateVector); - yField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - yField.prefWidthProperty().bind(widthProperty().divide(3)); - yField.setScrollPower(getScrollPower()); - - final Label zLabel = new Label("z:"); - - zField = new FloatTextField(); - zField.setOnKeyReleased(this::updateVector); - zField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - zField.prefWidthProperty().bind(widthProperty().divide(3)); - zField.setScrollPower(getScrollPower()); - - FXUtils.addToPane(xLabel, container); - FXUtils.addToPane(xField, container); - FXUtils.addToPane(yLabel, container); - FXUtils.addToPane(yField, container); - FXUtils.addToPane(zLabel, container); - FXUtils.addToPane(zField, container); - - FXUtils.addClassTo(xLabel, yLabel, zLabel, CssClasses.ABSTRACT_PARAM_CONTROL_NUMBER_LABEL); - FXUtils.addClassesTo(container, CssClasses.DEF_HBOX, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); - FXUtils.addClassesTo(xField, yField, zField, CssClasses.ABSTRACT_PARAM_CONTROL_VECTOR3F_FIELD, - CssClasses.TRANSPARENT_TEXT_FIELD); - - UiUtils.addFocusBinding(container, xField, yField, zField); - } - - @Override - @FxThread - protected void setPropertyValue(@Nullable final Vector3f vector) { - super.setPropertyValue(vector == null ? null : vector.clone()); - } - - /** - * Gets scroll power. - * - * @return the scroll power. - */ - @FxThread - protected float getScrollPower() { - return 10F; - } - - /** - * Gets x field. - * - * @return the field X. - */ - @FxThread - protected @NotNull FloatTextField getXField() { - return notNull(xField); - } - - /** - * Gets y filed. - * - * @return the field Y. - */ - @FxThread - protected @NotNull FloatTextField getYFiled() { - return notNull(yField); - } - - /** - * Gets z field. - * - * @return the field Z. - */ - @FxThread - protected @NotNull FloatTextField getZField() { - return notNull(zField); - } - - @Override - @FxThread - protected void reload() { - - final Vector3f vector = getPropertyValue() == null ? Vector3f.ZERO : getPropertyValue(); - - final FloatTextField xField = getXField(); - xField.setValue(vector.getX()); - xField.positionCaret(xField.getText().length()); - - final FloatTextField yFiled = getYFiled(); - yFiled.setValue(vector.getY()); - yFiled.positionCaret(xField.getText().length()); - - final FloatTextField zField = getZField(); - zField.setValue(vector.getZ()); - zField.positionCaret(xField.getText().length()); - } - - /** - * Update the vector. - * - * @param event the event - */ - @FxThread - protected void updateVector(@Nullable final KeyEvent event) { - - if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) { - return; - } - - final FloatTextField xField = getXField(); - final float x = xField.getValue(); - - final FloatTextField yFiled = getYFiled(); - final float y = yFiled.getValue(); - - final FloatTextField zField = getZField(); - final float z = zField.getValue(); - - final Vector3f oldValue = getPropertyValue() == null ? Vector3f.ZERO : getPropertyValue(); - final Vector3f newValue = new Vector3f(); - newValue.set(x, y, z); - - changed(newValue, oldValue.clone()); - } -} diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Vector3fPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Vector3fPropertyControl.java new file mode 100644 index 00000000..8f3a7544 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/impl/Vector3fPropertyControl.java @@ -0,0 +1,227 @@ +package com.ss.editor.ui.control.property.impl; + +import static com.ss.editor.util.GeomUtils.zeroIfNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import com.jme3.math.Vector3f; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.ui.control.property.PropertyControl; +import com.ss.editor.ui.css.CssClasses; +import com.ss.editor.ui.util.UiUtils; +import com.ss.editor.util.GeomUtils; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; +import javafx.scene.control.Label; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.HBox; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The implementation of the {@link PropertyControl} to edit {@link Vector3f} values. + * + * @param the type of a change consumer. + * @param the type of an editing object. + * @author JavaSaBr + */ +public class Vector3fPropertyControl extends PropertyControl { + + /** + * The field X. + */ + @Nullable + private FloatTextField xField; + + /** + * The field Y. + */ + @Nullable + private FloatTextField yField; + + /** + * The field Z. + */ + @Nullable + private FloatTextField zField; + + public Vector3fPropertyControl( + @Nullable Vector3f propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { + super(propertyValue, propertyName, changeConsumer); + } + + public Vector3fPropertyControl( + @Nullable Vector3f propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer, + @Nullable ChangeHandler changeHandler + ) { + super(propertyValue, propertyName, changeConsumer, changeHandler); + } + + @Override + @FxThread + protected void createComponents(@NotNull HBox container) { + super.createComponents(container); + + var xLabel = new Label("x:"); + + xField = new FloatTextField(); + xField.setOnKeyReleased(this::keyReleased); + xField.setScrollPower(getScrollPower()); + xField.prefWidthProperty(). + bind(widthProperty().divide(3)); + + var yLabel = new Label("y:"); + + yField = new FloatTextField(); + yField.setOnKeyReleased(this::keyReleased); + yField.setScrollPower(getScrollPower()); + yField.prefWidthProperty() + .bind(widthProperty().divide(3)); + + var zLabel = new Label("z:"); + + zField = new FloatTextField(); + zField.setOnKeyReleased(this::keyReleased); + zField.setScrollPower(getScrollPower()); + zField.prefWidthProperty() + .bind(widthProperty().divide(3)); + + FxControlUtils.onValueChange(xField, this::changeValue); + FxControlUtils.onValueChange(yField, this::changeValue); + FxControlUtils.onValueChange(zField, this::changeValue); + + FxUtils.addClass(xLabel, yLabel, zLabel, + CssClasses.ABSTRACT_PARAM_CONTROL_NUMBER_LABEL) + .addClass(container, + CssClasses.DEF_HBOX, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER) + .addClass(xField, yField, zField, + CssClasses.PROPERTY_CONTROL_VECTOR_3F_FIELD, + CssClasses.TRANSPARENT_TEXT_FIELD); + + FxUtils.addChild(container, + xLabel, xField, + yLabel, yField, + zLabel, zField); + + UiUtils.addFocusBinding(container, xField, yField, zField) + .addListener((observable, oldValue, newValue) -> applyOnLostFocus(newValue)); + } + + @Override + @FxThread + protected void setPropertyValue(@Nullable Vector3f vector) { + super.setPropertyValue(zeroIfNull(vector).clone()); + } + + /** + * Get the scroll power. + * + * @return the scroll power. + */ + @FxThread + protected float getScrollPower() { + return 10F; + } + + /** + * Get the field X. + * + * @return the field X. + */ + @FxThread + protected @NotNull FloatTextField getXField() { + return notNull(xField); + } + + /** + * Get the filed Y. + * + * @return the field Y. + */ + @FxThread + protected @NotNull FloatTextField getYField() { + return notNull(yField); + } + + /** + * Get the field Z. + * + * @return the field Z. + */ + @FxThread + protected @NotNull FloatTextField getZField() { + return notNull(zField); + } + + @Override + @FxThread + protected void reload() { + + var vector = zeroIfNull(getPropertyValue()); + + var xField = getXField(); + xField.setValue(vector.getX()); + xField.positionCaret(xField.getText().length()); + + var yFiled = getYField(); + yFiled.setValue(vector.getY()); + yFiled.positionCaret(xField.getText().length()); + + var zField = getZField(); + zField.setValue(vector.getZ()); + zField.positionCaret(xField.getText().length()); + } + + @Override + @FxThread + public boolean isDirty() { + + var x = getXField().getValue(); + var y = getYField().getValue(); + var z = getZField().getValue(); + + return !GeomUtils.equals(getPropertyValue(), x, y, z); + } + + /** + * Handle of input the enter key. + */ + @FxThread + private void keyReleased(@NotNull KeyEvent event) { + if (event.getCode() == KeyCode.ENTER) { + changeValue(); + } + } + + /** + * Change value of vector. + */ + @FxThread + private void changeValue() { + if (!isIgnoreListener()) { + apply(); + } + } + + @Override + @FxThread + protected void apply() { + super.apply(); + + var x = getXField().getValue(); + var y = getYField().getValue(); + var z = getZField().getValue(); + + var storedValue = zeroIfNull(getPropertyValue()); + + changed(new Vector3f(x, y, z), storedValue.clone()); + } +} diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/Vector3FSingleRowPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/Vector3fSingleRowPropertyControl.java similarity index 51% rename from src/main/java/com/ss/editor/ui/control/property/impl/Vector3FSingleRowPropertyControl.java rename to src/main/java/com/ss/editor/ui/control/property/impl/Vector3fSingleRowPropertyControl.java index 9df5a1b9..786d6704 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/Vector3FSingleRowPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/Vector3fSingleRowPropertyControl.java @@ -1,15 +1,18 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.editor.util.GeomUtils.zeroIfNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.Vector3f; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.editor.util.GeomUtils; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FxControlUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.HBox; @@ -19,11 +22,11 @@ /** * The implementation of the {@link PropertyControl} to edit {@link com.jme3.math.Vector3f} values. * - * @param the change consumer's type. - * @param the edited object's type. + * @param the type of a change consumer. + * @param the type of an editing object. * @author JavaSaBr. */ -public class Vector3FSingleRowPropertyControl extends PropertyControl { +public class Vector3fSingleRowPropertyControl extends PropertyControl { /** * The field X. @@ -49,60 +52,71 @@ public class Vector3FSingleRowPropertyControl exten @Nullable private HBox fieldContainer; - public Vector3FSingleRowPropertyControl(@Nullable final Vector3f propertyValue, @NotNull final String propertyName, - @NotNull final C changeConsumer) { + public Vector3fSingleRowPropertyControl( + @Nullable Vector3f propertyValue, + @NotNull String propertyName, + @NotNull C changeConsumer + ) { + super(propertyValue, propertyName, changeConsumer); } @Override @FxThread - public void changeControlWidthPercent(final double controlWidthPercent) { + public void changeControlWidthPercent(double controlWidthPercent) { super.changeControlWidthPercent(controlWidthPercent); - final HBox valueField = getFieldContainer(); - valueField.prefWidthProperty().unbind(); - valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); + FxUtils.rebindPrefWidth(getFieldContainer(), + widthProperty().multiply(controlWidthPercent)); } @Override @FxThread - protected void createComponents(@NotNull final HBox container) { + protected void createComponents(@NotNull HBox container) { super.createComponents(container); fieldContainer = new HBox(); fieldContainer.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); xField = new FloatTextField(); - xField.setOnKeyReleased(this::updateVector); - xField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - xField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.33)); + xField.setOnKeyReleased(this::keyReleased); xField.setScrollPower(10F); + xField.prefWidthProperty(). + bind(fieldContainer.widthProperty().multiply(0.33)); yField = new FloatTextField(); - yField.setOnKeyReleased(this::updateVector); - yField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - yField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.33)); + yField.setOnKeyReleased(this::keyReleased); yField.setScrollPower(10F); + yField.prefWidthProperty() + .bind(fieldContainer.widthProperty().multiply(0.33)); zField = new FloatTextField(); - zField.setOnKeyReleased(this::updateVector); - zField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); - zField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.33)); + zField.setOnKeyReleased(this::keyReleased); zField.setScrollPower(10F); + zField.prefWidthProperty() + .bind(fieldContainer.widthProperty().multiply(0.33)); - FXUtils.addToPane(xField, fieldContainer); - FXUtils.addToPane(yField, fieldContainer); - FXUtils.addToPane(zField, fieldContainer); - FXUtils.addToPane(fieldContainer, container); + FxControlUtils.onValueChange(xField, this::changeValue); + FxControlUtils.onValueChange(yField, this::changeValue); + FxControlUtils.onValueChange(zField, this::changeValue); - FXUtils.addClassesTo(fieldContainer, CssClasses.DEF_HBOX, CssClasses.TEXT_INPUT_CONTAINER, - CssClasses.ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER); - FXUtils.addClassesTo(xField, yField, zField, CssClasses.TRANSPARENT_TEXT_FIELD); + FxUtils.addClass(fieldContainer, + CssClasses.DEF_HBOX, + CssClasses.TEXT_INPUT_CONTAINER, + CssClasses.ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER) + .addClass(xField, yField, zField, + CssClasses.TRANSPARENT_TEXT_FIELD); - UiUtils.addFocusBinding(fieldContainer, xField, yField, zField); + FxUtils.addChild(fieldContainer, xField, yField, zField) + .addChild(container, fieldContainer); + + UiUtils.addFocusBinding(fieldContainer, xField, yField, zField) + .addListener((observable, oldValue, newValue) -> applyOnLostFocus(newValue)); } /** + * Get the field container. + * * @return the field container. */ @FxThread @@ -112,8 +126,8 @@ protected void createComponents(@NotNull final HBox container) { @Override @FxThread - protected void setPropertyValue(@Nullable final Vector3f vector) { - super.setPropertyValue(vector == null ? null : vector.clone()); + protected void setPropertyValue(@Nullable Vector3f vector) { + super.setPropertyValue(zeroIfNull(vector).clone()); } @Override @@ -131,7 +145,7 @@ protected boolean isSingleRow() { * @return the result x value. */ @FxThread - protected float checkResultXValue(final float x, final float y, final float z) { + protected float checkResultXValue(float x, float y, float z) { return x; } @@ -144,7 +158,7 @@ protected float checkResultXValue(final float x, final float y, final float z) { * @return the result y value. */ @FxThread - protected float checkResultYValue(final float x, final float y, final float z) { + protected float checkResultYValue(float x, float y, float z) { return y; } @@ -157,7 +171,7 @@ protected float checkResultYValue(final float x, final float y, final float z) { * @return the result z value. */ @FxThread - protected float checkResultZValue(final float x, final float y, final float z) { + protected float checkResultZValue(float x, float y, float z) { return z; } @@ -195,44 +209,63 @@ protected float checkResultZValue(final float x, final float y, final float z) { @FxThread protected void reload() { - final Vector3f vector = getPropertyValue() == null ? Vector3f.ZERO : getPropertyValue(); + var vector = zeroIfNull(getPropertyValue()); - final FloatTextField xField = getXField(); + var xField = getXField(); xField.setValue(vector.getX()); xField.positionCaret(xField.getText().length()); - final FloatTextField yField = getYField(); + var yField = getYField(); yField.setValue(vector.getY()); yField.positionCaret(yField.getText().length()); - final FloatTextField zField = getZField(); + var zField = getZField(); zField.setValue(vector.getZ()); zField.positionCaret(zField.getText().length()); } + @Override + @FxThread + public boolean isDirty() { + + var x = getXField().getValue(); + var y = getYField().getValue(); + var z = getZField().getValue(); + + return !GeomUtils.equals(getPropertyValue(), x, y, z); + } + /** - * Update the current value. - * - * @param event the change event. + * Handle of input the enter key. */ @FxThread - private void updateVector(@Nullable final KeyEvent event) { - - if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) { - return; + private void keyReleased(@NotNull KeyEvent event) { + if (event.getCode() == KeyCode.ENTER) { + changeValue(); } + } - final FloatTextField xField = getXField(); - final float x = xField.getValue(); + /** + * Change value of vector. + */ + @FxThread + private void changeValue() { + if (!isIgnoreListener()) { + apply(); + } + } - final FloatTextField yField = getYField(); - final float y = yField.getValue(); + @Override + @FxThread + protected void apply() { + super.apply(); - final FloatTextField zField = getZField(); - final float z = zField.getValue(); + var x = getXField().getValue(); + var y = getYField().getValue(); + var z = getZField().getValue(); - final Vector3f oldValue = getPropertyValue() == null ? Vector3f.ZERO : getPropertyValue(); - final Vector3f newValue = new Vector3f(); + var oldValue = zeroIfNull(getPropertyValue()); + var newValue = new Vector3f(); newValue.set(checkResultXValue(x, y, z), checkResultYValue(x, y, z), checkResultZValue(x, y, z)); changed(newValue, oldValue.clone()); diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/WheelElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/WheelElementModelPropertyControl.java index bda07a2c..ca29a3a6 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/WheelElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/WheelElementModelPropertyControl.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.property.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.control.VehicleControl; import com.jme3.bullet.objects.VehicleWheel; import com.jme3.scene.Spatial; @@ -18,18 +18,22 @@ */ public class WheelElementModelPropertyControl extends SpatialElementModelPropertyControl { - public WheelElementModelPropertyControl(@Nullable final Spatial propertyValue, @NotNull final String propertyName, - @NotNull final ModelChangeConsumer changeConsumer) { + public WheelElementModelPropertyControl( + @Nullable Spatial propertyValue, + @NotNull String propertyName, + @NotNull ModelChangeConsumer changeConsumer + ) { + super(Spatial.class, propertyValue, propertyName, changeConsumer); } @Override @FxThread protected @NotNull NodeSelectorDialog createNodeSelectorDialog() { - final ModelChangeConsumer changeConsumer = getChangeConsumer(); - final Spatial currentModel = changeConsumer.getCurrentModel(); - final Spatial root = NodeUtils.findSpatial(currentModel, this::checkSpatial); - return new NodeSelectorDialog<>(notNull(root), type, this::processAdd); + var changeConsumer = getChangeConsumer(); + var currentModel = changeConsumer.getCurrentModel(); + var root = NodeUtils.findSpatial(currentModel, this::checkSpatial); + return new NodeSelectorDialog<>(notNull(root), type, this::addElement); } /** @@ -38,17 +42,17 @@ public WheelElementModelPropertyControl(@Nullable final Spatial propertyValue, @ * @param spatial the spatial. * @return true if the spatial has this wheel. */ - private boolean checkSpatial(@NotNull final Spatial spatial) { + private boolean checkSpatial(@NotNull Spatial spatial) { - final VehicleControl control = spatial.getControl(VehicleControl.class); + var control = spatial.getControl(VehicleControl.class); if (control == null) { return false; } - final int numWheels = control.getNumWheels(); + var numWheels = control.getNumWheels(); - for (int i = 0; i < numWheels; i++) { - final VehicleWheel wheel = control.getWheel(i); + for (var i = 0; i < numWheels; i++) { + var wheel = control.getWheel(i); if (wheel == getEditObject()) { return true; } diff --git a/src/main/java/com/ss/editor/ui/control/property/impl/particle/ParticleEmitterImagesModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/property/impl/particle/ParticleEmitterImagesModelPropertyControl.java index 3143e705..9d9d2a9e 100644 --- a/src/main/java/com/ss/editor/ui/control/property/impl/particle/ParticleEmitterImagesModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/property/impl/particle/ParticleEmitterImagesModelPropertyControl.java @@ -3,22 +3,23 @@ import com.jme3.effect.ParticleEmitter; import com.jme3.math.Vector2f; import com.ss.editor.model.undo.editor.ModelChangeConsumer; -import com.ss.editor.ui.control.property.impl.Vector2FPropertyControl; +import com.ss.editor.ui.control.property.impl.Vector2fPropertyControl; import org.jetbrains.annotations.NotNull; /** - * The implementation of the {@link Vector2FPropertyControl} to edit images count of the {@link + * The implementation of the {@link Vector2fPropertyControl} to edit images count of the {@link * ParticleEmitter}*. * * @author JavaSaBr. */ -public class ParticleEmitterImagesModelPropertyControl extends - Vector2FPropertyControl { +public class ParticleEmitterImagesModelPropertyControl extends Vector2fPropertyControl { - public ParticleEmitterImagesModelPropertyControl(@NotNull final Vector2f element, - @NotNull final String paramName, - @NotNull final ModelChangeConsumer modelChangeConsumer) { - super(element, paramName, modelChangeConsumer); + public ParticleEmitterImagesModelPropertyControl( + @NotNull Vector2f element, + @NotNull String paramName, + @NotNull ModelChangeConsumer changeConsumer + ) { + super(element, paramName, changeConsumer); getXField().setMinMax(1, Integer.MAX_VALUE); getYField().setMinMax(1, Integer.MAX_VALUE); } diff --git a/src/main/java/com/ss/editor/ui/control/scene/SceneNodeTree.java b/src/main/java/com/ss/editor/ui/control/scene/SceneNodeTree.java index 170aaffa..b5f0634b 100644 --- a/src/main/java/com/ss/editor/ui/control/scene/SceneNodeTree.java +++ b/src/main/java/com/ss/editor/ui/control/scene/SceneNodeTree.java @@ -2,7 +2,7 @@ import com.ss.editor.model.undo.editor.SceneChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.SelectionMode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/NodeTree.java b/src/main/java/com/ss/editor/ui/control/tree/NodeTree.java index 6c474f60..fc6d54be 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/NodeTree.java +++ b/src/main/java/com/ss/editor/ui/control/tree/NodeTree.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree; import static com.ss.editor.ui.util.UiUtils.findItemForValue; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -9,11 +9,11 @@ import com.ss.editor.ui.control.tree.node.factory.TreeNodeFactoryRegistry; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.LocalObjects; -import com.ss.rlib.function.TripleConsumer; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayCollectors; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.function.TripleConsumer; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayCollectors; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; import javafx.scene.control.*; @@ -169,17 +169,17 @@ private void updateSelection(@NotNull final ObservableValue> treeView = getTreeView(); - final TreeItem> currentRoot = treeView.getRoot(); + var treeView = getTreeView(); + var currentRoot = treeView.getRoot(); if (currentRoot != null) { treeView.setRoot(null); } - final TreeNode rootElement = FACTORY_REGISTRY.createFor(object); - final TreeItem> newRoot = new TreeItem<>(rootElement); + var rootElement = FACTORY_REGISTRY.createFor(object); + var newRoot = new TreeItem>(rootElement); newRoot.setExpanded(true); fill(newRoot, false, 1); @@ -191,16 +191,16 @@ public void fill(@NotNull final Object object) { * Fill the item. */ @FxThread - private void fill(@NotNull final TreeItem> treeItem, final boolean expanded, final int level) { + private void fill(@NotNull TreeItem> treeItem, boolean expanded, int level) { treeItem.setExpanded(expanded || level == 1); - final TreeNode element = treeItem.getValue(); + var element = treeItem.getValue(); if (!element.hasChildren(this)) { return; } - final ObservableList>> items = treeItem.getChildren(); - final Array> children = element.getChildren(this); + var items = treeItem.getChildren(); + var children = element.getChildren(this); children.forEach(child -> { element.notifyChildPreAdd(child); items.add(new TreeItem<>(child)); diff --git a/src/main/java/com/ss/editor/ui/control/tree/NodeTreeCell.java b/src/main/java/com/ss/editor/ui/control/tree/NodeTreeCell.java index 0bb3a203..8f92d8cf 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/NodeTreeCell.java +++ b/src/main/java/com/ss/editor/ui/control/tree/NodeTreeCell.java @@ -2,8 +2,8 @@ import static com.ss.editor.ui.util.UiUtils.findItem; import static com.ss.editor.ui.util.UiUtils.findItemForValue; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -13,8 +13,8 @@ import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanPropertyBase; import javafx.css.PseudoClass; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/AbstractNodeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/AbstractNodeAction.java index cd9cb88d..ce54e05a 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/AbstractNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/AbstractNodeAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.analytics.google.GAEvent; import com.ss.editor.analytics.google.GAnalytics; import com.ss.editor.annotation.FxThread; @@ -9,10 +9,10 @@ import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/AddUserDataAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/AddUserDataAction.java index c44f453e..45c7cb23 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/AddUserDataAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/AddUserDataAction.java @@ -2,7 +2,7 @@ import static com.ss.editor.extension.property.EditablePropertyType.ENUM; import static com.ss.editor.extension.property.EditablePropertyType.STRING; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; @@ -18,10 +18,10 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/CreateNodeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/CreateNodeAction.java index aa4d023e..c6cad750 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/CreateNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/CreateNodeAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action.impl; import static com.ss.editor.util.EditorUtil.getDefaultLayer; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Node; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/DisableAllControlsAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/DisableAllControlsAction.java index e2ab3da9..fc09fce6 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/DisableAllControlsAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/DisableAllControlsAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayCollectors.toArray; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; @@ -14,7 +14,7 @@ import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.util.ControlUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/EnableAllControlsAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/EnableAllControlsAction.java index 6d8ee425..a24d0936 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/EnableAllControlsAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/EnableAllControlsAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayCollectors.toArray; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; @@ -14,7 +14,7 @@ import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.util.ControlUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/LinkModelAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/LinkModelAction.java index f48fb56e..065bf0dd 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/LinkModelAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/LinkModelAction.java @@ -3,7 +3,7 @@ import static com.ss.editor.part3d.editor.impl.scene.AbstractSceneEditor3DPart.KEY_LOADED_MODEL; import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.scene.AssetLinkNode; @@ -25,8 +25,8 @@ import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/LoadModelAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/LoadModelAction.java index c227b869..2f27d980 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/LoadModelAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/LoadModelAction.java @@ -2,7 +2,7 @@ import static com.ss.editor.part3d.editor.impl.scene.AbstractSceneEditor3DPart.KEY_LOADED_MODEL; import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.scene.Node; @@ -23,8 +23,8 @@ import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/MakeAsEmbeddedMaterialAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/MakeAsEmbeddedMaterialAction.java index 586cc6bc..839b90f4 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/MakeAsEmbeddedMaterialAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/MakeAsEmbeddedMaterialAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetKey; import com.jme3.material.Material; import com.ss.editor.Messages; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/OptimizeGeometryAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/OptimizeGeometryAction.java index 37847e12..8fe4747d 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/OptimizeGeometryAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/OptimizeGeometryAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Node; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/PasteNodeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/PasteNodeAction.java index e51cb7f9..b13a4c52 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/PasteNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/PasteNodeAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveControlAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveControlAction.java index 503ebb6e..42f94151 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveControlAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveLightAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveLightAction.java index 27d4006f..17a07391 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveLightAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.light.Light; import com.jme3.scene.Node; import com.ss.editor.Messages; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveNodeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveNodeAction.java index 0644769e..c0ef1371 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/RemoveNodeAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/SaveAsMaterialAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/SaveAsMaterialAction.java index ee69b8fc..4d588e15 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/SaveAsMaterialAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/SaveAsMaterialAction.java @@ -2,7 +2,7 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.nio.file.StandardOpenOption.*; import com.jme3.asset.AssetKey; import com.jme3.asset.AssetManager; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlayAnimationAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlayAnimationAction.java index d9eb1d3a..92d2bcb5 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlayAnimationAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlayAnimationAction.java @@ -11,7 +11,7 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlaySettingsAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlaySettingsAction.java index 948a1692..6ca266c3 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlaySettingsAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/PlaySettingsAction.java @@ -12,8 +12,8 @@ import com.ss.editor.ui.control.tree.node.impl.control.anim.AnimationControlTreeNode; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.NodeTree; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/RemoveAnimationAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/RemoveAnimationAction.java index 6e1dbe5c..6760d9fa 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/RemoveAnimationAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/animation/RemoveAnimationAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.animation; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.animation.AnimControl; import com.jme3.animation.Animation; import com.ss.editor.Messages; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/audio/CreateAudioNodeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/audio/CreateAudioNodeAction.java index dc7b23d8..a27293fc 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/audio/CreateAudioNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/audio/CreateAudioNodeAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.audio; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.audio.AudioNode; import com.jme3.scene.Node; import com.ss.editor.Messages; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/AbstractCreateControlAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/AbstractCreateControlAction.java index fe47c72b..84da4962 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/AbstractCreateControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/AbstractCreateControlAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/CreateCustomControlAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/CreateCustomControlAction.java index 9461bbe6..03d93ed7 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/CreateCustomControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/CreateCustomControlAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.control; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/CreateCharacterControlAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/CreateCharacterControlAction.java index 0dad78cc..69a6a549 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/CreateCharacterControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/CreateCharacterControlAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action.impl.control.physics; import static com.ss.editor.extension.property.EditablePropertyType.FLOAT; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.control.BetterCharacterControl; import com.jme3.bullet.control.CharacterControl; import com.jme3.scene.Spatial; @@ -15,8 +15,8 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.impl.control.AbstractCreateControlAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/CreateVehicleWheelAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/CreateVehicleWheelAction.java index 69c49c2b..b83e8673 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/CreateVehicleWheelAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/CreateVehicleWheelAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action.impl.control.physics.vehicle; import static com.ss.editor.extension.property.EditablePropertyType.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.control.VehicleControl; import com.jme3.bullet.objects.VehicleWheel; import com.jme3.math.Vector3f; @@ -16,9 +16,9 @@ import com.ss.editor.model.undo.impl.AddVehicleWheelOperation; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/RemoveVehicleWheelAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/RemoveVehicleWheelAction.java index ce9ce8c6..b89e6e04 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/RemoveVehicleWheelAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/control/physics/vehicle/RemoveVehicleWheelAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.control.physics.vehicle; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.control.VehicleControl; import com.jme3.bullet.objects.VehicleWheel; import com.ss.editor.Messages; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/AbstractCreateGeometryAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/AbstractCreateGeometryAction.java index 84a00b7a..8a553fd0 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/AbstractCreateGeometryAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/AbstractCreateGeometryAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action.impl.geometry; import static com.ss.editor.util.EditorUtil.getDefaultLayer; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.scene.Geometry; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/GenerateLoDAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/GenerateLoDAction.java index 57274a9e..6a7d4643 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/GenerateLoDAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/geometry/GenerateLoDAction.java @@ -10,7 +10,7 @@ import com.ss.editor.ui.dialog.geometry.lod.GenerateLodLevelsDialog; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.ClassUtils; +import com.ss.rlib.common.util.ClassUtils; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/light/AbstractCreateLightAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/light/AbstractCreateLightAction.java index a59c33c8..f61368a0 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/light/AbstractCreateLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/light/AbstractCreateLightAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.light; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.light.Light; import com.jme3.scene.Node; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/multi/RemoveElementsAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/multi/RemoveElementsAction.java index aedecfc5..b67c89b4 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/multi/RemoveElementsAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/multi/RemoveElementsAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.multi; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -15,10 +15,10 @@ import com.ss.editor.ui.control.tree.node.impl.control.anim.AnimationTreeNode; import com.ss.editor.ui.control.tree.node.impl.light.LightTreeNode; import com.ss.editor.ui.control.tree.node.impl.spatial.SpatialTreeNode; -import com.ss.rlib.function.TripleConsumer; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayCollectors; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.function.TripleConsumer; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayCollectors; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/CreateParticleEmitterAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/CreateParticleEmitterAction.java index 9914118e..00006d1a 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/CreateParticleEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/CreateParticleEmitterAction.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.action.impl.particle.emitter; import static com.ss.editor.util.EditorUtil.getDefaultLayer; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.effect.ParticleEmitter; import com.jme3.effect.ParticleMesh; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/ResetParticleEmittersAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/ResetParticleEmittersAction.java index f377e47b..55593102 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/ResetParticleEmittersAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/ResetParticleEmittersAction.java @@ -10,8 +10,8 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java index 75e3e1e9..4be166b5 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.particle.emitter.influencer; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.effect.ParticleEmitter; import com.jme3.effect.influencers.ParticleInfluencer; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/AbstractCreateShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/AbstractCreateShapeEmitterAction.java index ae06bbcf..321ed491 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/AbstractCreateShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/AbstractCreateShapeEmitterAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.particle.emitter.shape; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.effect.ParticleEmitter; import com.jme3.effect.shapes.EmitterShape; import com.ss.editor.annotation.FxThread; @@ -13,8 +13,8 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateBoxShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateBoxShapeEmitterAction.java index 5f1ef153..10579d71 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateBoxShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateBoxShapeEmitterAction.java @@ -11,9 +11,9 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java index 2762f774..90db14d5 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java @@ -13,9 +13,9 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreatePointShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreatePointShapeEmitterAction.java index 5509b99e..e647b481 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreatePointShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreatePointShapeEmitterAction.java @@ -11,9 +11,9 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateSphereShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateSphereShapeEmitterAction.java index d475a5ce..aba170d1 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateSphereShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/particle/emitter/shape/CreateSphereShapeEmitterAction.java @@ -12,9 +12,9 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/AbstractCreateShapeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/AbstractCreateShapeAction.java index 4dbd0978..da69e460 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/AbstractCreateShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/AbstractCreateShapeAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.physics.shape; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.collision.PhysicsCollisionObject; import com.jme3.bullet.collision.shapes.CollisionShape; import com.ss.editor.annotation.FxThread; @@ -13,8 +13,8 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateBoxCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateBoxCollisionShapeAction.java index babfea5c..947b99af 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateBoxCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateBoxCollisionShapeAction.java @@ -9,9 +9,9 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCapsuleCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCapsuleCollisionShapeAction.java index 4da72ab7..671f2d1d 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCapsuleCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCapsuleCollisionShapeAction.java @@ -9,9 +9,9 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.plugin.api.property.PropertyDefinition; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateConeCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateConeCollisionShapeAction.java index 75c15c0f..34a60478 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateConeCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateConeCollisionShapeAction.java @@ -10,9 +10,9 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCylinderCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCylinderCollisionShapeAction.java index d6da6ae7..034c0518 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCylinderCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateCylinderCollisionShapeAction.java @@ -12,9 +12,9 @@ import com.ss.editor.ui.control.tree.action.impl.physics.shape.CreateConeCollisionShapeAction.Axis; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateSphereCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateSphereCollisionShapeAction.java index dc9a3a35..316607d8 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateSphereCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/CreateSphereCollisionShapeAction.java @@ -9,9 +9,9 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/GenerateCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/GenerateCollisionShapeAction.java index abf7b77b..9f19a382 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/GenerateCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/physics/shape/GenerateCollisionShapeAction.java @@ -2,7 +2,7 @@ import static com.jme3.bullet.util.CollisionShapeFactory.createDynamicMeshShape; import static com.jme3.bullet.util.CollisionShapeFactory.createMeshShape; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.collision.PhysicsCollisionObject; import com.jme3.bullet.collision.shapes.BoxCollisionShape; import com.jme3.bullet.collision.shapes.CollisionShape; @@ -22,9 +22,9 @@ import com.ss.editor.model.undo.impl.ChangeCollisionShapeOperation; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/action/impl/scene/RemoveSceneLayerAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/impl/scene/RemoveSceneLayerAction.java index bd93f13e..c339d43a 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/action/impl/scene/RemoveSceneLayerAction.java +++ b/src/main/java/com/ss/editor/ui/control/tree/action/impl/scene/RemoveSceneLayerAction.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.action.impl.scene; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.scene.SceneLayer; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/TreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/TreeNode.java index f301515f..e2a86af7 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/TreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/TreeNode.java @@ -12,8 +12,8 @@ import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.factory.TreeNodeFactoryRegistry; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/TreeNodeFactoryRegistry.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/TreeNodeFactoryRegistry.java index 846de224..0fe06f9f 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/TreeNodeFactoryRegistry.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/TreeNodeFactoryRegistry.java @@ -1,12 +1,12 @@ package com.ss.editor.ui.control.tree.node.factory; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.tree.node.factory.impl.MaterialSettingsTreeNodeFactory; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.control.tree.node.factory.impl.*; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/AnimationTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/AnimationTreeNodeFactory.java index 76e735e4..c4cd9ee8 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/AnimationTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/AnimationTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.animation.*; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.tree.node.impl.control.anim.*; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/CollisionTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/CollisionTreeNodeFactory.java index 0ba756a8..830c6db5 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/CollisionTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/CollisionTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.bullet.collision.shapes.*; import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; import com.ss.editor.annotation.FxThread; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/ControlTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/ControlTreeNodeFactory.java index c68571b9..94e14f32 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/ControlTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/ControlTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.animation.SkeletonControl; import com.jme3.bullet.control.*; import com.jme3.cinematic.events.MotionEvent; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultParticlesTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultParticlesTreeNodeFactory.java index 25acbc44..2a1658bc 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultParticlesTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultParticlesTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.effect.ParticleEmitter; import com.jme3.effect.influencers.DefaultParticleInfluencer; import com.jme3.effect.influencers.EmptyParticleInfluencer; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultTreeNodeFactory.java index 77976fb8..1718bb8e 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/DefaultTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.audio.AudioNode; import com.jme3.material.Material; import com.jme3.post.Filter; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/LightTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/LightTreeNodeFactory.java index 038357bb..d5c846cf 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/LightTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/LightTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.light.*; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.tree.node.impl.light.*; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/MaterialSettingsTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/MaterialSettingsTreeNodeFactory.java index dc6bad9c..410e7780 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/MaterialSettingsTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/MaterialSettingsTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.node.material.*; import com.ss.editor.ui.control.tree.node.TreeNode; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/PrimitiveTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/PrimitiveTreeNodeFactory.java index f7ce1586..1ba1e698 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/PrimitiveTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/factory/impl/PrimitiveTreeNodeFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.factory.impl; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.bullet.objects.VehicleWheel; import com.jme3.cinematic.MotionPath; import com.jme3.math.Vector3f; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/VertexBufferTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/VertexBufferTreeNode.java index 4b17fee8..cc2c162a 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/VertexBufferTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/VertexBufferTreeNode.java @@ -8,8 +8,8 @@ import com.ss.editor.ui.control.model.ModelNodeTree; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationBoneTrackTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationBoneTrackTreeNode.java index 2aeb2d0d..46c3a426 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationBoneTrackTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationBoneTrackTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.impl.control.anim; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.animation.AnimControl; import com.jme3.animation.Bone; import com.jme3.animation.BoneTrack; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationControlTreeNode.java index c3f7c77d..eeb7d5c4 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationControlTreeNode.java @@ -16,8 +16,8 @@ import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import java.util.Collection; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationTreeNode.java index fc05907a..556b4da3 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/anim/AnimationTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.impl.control.anim; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.animation.AnimControl; import com.jme3.animation.Animation; import com.jme3.animation.Track; @@ -15,10 +15,10 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.util.AnimationUtils; -import com.ss.rlib.util.ArrayUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.ArrayUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionEventTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionEventTreeNode.java index 37f1dc96..57754868 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionEventTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionEventTreeNode.java @@ -9,8 +9,8 @@ import com.ss.editor.ui.control.tree.node.impl.control.ControlTreeNode; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionPathTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionPathTreeNode.java index 10969614..0b7cbed8 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionPathTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/motion/MotionPathTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.impl.control.motion; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.cinematic.MotionPath; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; @@ -13,8 +13,8 @@ import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of the {@link TreeNode} to show a {@link MotionPath} in the tree. diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/physics/PhysicsControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/physics/PhysicsControlTreeNode.java index 2aecac7f..4db20175 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/physics/PhysicsControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/control/physics/PhysicsControlTreeNode.java @@ -10,8 +10,8 @@ import com.ss.editor.ui.control.tree.action.impl.physics.shape.*; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.control.tree.node.impl.control.ControlTreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/LayersRootTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/LayersRootTreeNode.java index 073e4688..1273e2ec 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/LayersRootTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/LayersRootTreeNode.java @@ -11,8 +11,8 @@ import com.ss.editor.ui.control.tree.action.impl.scene.CreateSceneLayerAction; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/SceneLayerTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/SceneLayerTreeNode.java index 7ba46a84..f4ed0ea2 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/SceneLayerTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/layer/SceneLayerTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.impl.layer; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; @@ -18,8 +18,8 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.HideableNode; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/AmbientLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/AmbientLightTreeNode.java index 67a59a79..60678152 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/AmbientLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/AmbientLightTreeNode.java @@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable; import javafx.scene.image.Image; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; /** * The implementation of {@link LightTreeNode} to present ambient lights. diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/DirectionalLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/DirectionalLightTreeNode.java index c8e62076..91991fe0 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/DirectionalLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/DirectionalLightTreeNode.java @@ -5,7 +5,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/LightTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/LightTreeNode.java index 7adb8241..57b403bb 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/LightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/LightTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.impl.light; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.light.Light; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; @@ -10,7 +10,7 @@ import com.ss.editor.ui.control.tree.action.impl.RemoveLightAction; import com.ss.editor.model.undo.impl.RenameLightOperation; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.collections.ObservableList; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/PointLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/PointLightTreeNode.java index f52ad9e9..dbcd6b42 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/PointLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/PointLightTreeNode.java @@ -5,7 +5,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/SpotLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/SpotLightTreeNode.java index 8c5c8099..6dcbdbc6 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/SpotLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/light/SpotLightTreeNode.java @@ -5,7 +5,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/material/settings/RootMaterialSettingsTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/material/settings/RootMaterialSettingsTreeNode.java index 182c0fff..a571b627 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/material/settings/RootMaterialSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/material/settings/RootMaterialSettingsTreeNode.java @@ -6,8 +6,8 @@ import com.ss.editor.model.node.material.*; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ChildCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ChildCollisionShapeTreeNode.java index bbedbfb7..e9afbe1e 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ChildCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ChildCollisionShapeTreeNode.java @@ -8,8 +8,8 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ComputedCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ComputedCollisionShapeTreeNode.java index b1db873e..09a8b862 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ComputedCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/physics/shape/ComputedCollisionShapeTreeNode.java @@ -11,8 +11,8 @@ import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import java.util.List; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneAppStatesTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneAppStatesTreeNode.java index 103cefab..39272db9 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneAppStatesTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneAppStatesTreeNode.java @@ -10,8 +10,8 @@ import com.ss.editor.ui.control.scene.SceneNodeTree; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneFiltersTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneFiltersTreeNode.java index 724fad90..fc50d5ca 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneFiltersTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneFiltersTreeNode.java @@ -10,8 +10,8 @@ import com.ss.editor.ui.control.scene.SceneNodeTree; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneNodeTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneNodeTreeNode.java index 61d6ec29..9e57bd78 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneNodeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/scene/SceneNodeTreeNode.java @@ -10,8 +10,8 @@ import com.ss.editor.ui.control.tree.action.impl.RenameNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.control.tree.node.impl.spatial.NodeTreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/GeometryTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/GeometryTreeNode.java index 002c0670..16fec3f5 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/GeometryTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/GeometryTreeNode.java @@ -12,8 +12,8 @@ import com.ss.editor.ui.control.property.operation.PropertyOperation; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.control.Menu; import javafx.scene.image.Image; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MaterialTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MaterialTreeNode.java index ed81c9f4..3338bcab 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MaterialTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MaterialTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.control.tree.node.impl.spatial; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.material.Material; import com.jme3.scene.AssetLinkNode; import com.jme3.scene.Spatial; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MeshTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MeshTreeNode.java index ada66da9..327b5b2a 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MeshTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/MeshTreeNode.java @@ -12,8 +12,8 @@ import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; /** * The implementation of the {@link TreeNode} to represent the {@link Mesh} in the editor. diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/NodeTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/NodeTreeNode.java index d5dad40e..94aafe5d 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/NodeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/NodeTreeNode.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.control.tree.node.impl.spatial; import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.effect.ParticleEmitter; @@ -35,8 +35,8 @@ import com.ss.editor.util.EditorUtil; import com.ss.editor.util.GeomUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/SpatialTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/SpatialTreeNode.java index a698856e..046b0f6e 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/SpatialTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/SpatialTreeNode.java @@ -4,7 +4,7 @@ import static com.ss.editor.Messages.MODEL_NODE_TREE_ACTION_CREATE; import static com.ss.editor.part3d.editor.impl.scene.AbstractSceneEditor3DPart.KEY_MODEL_NODE; import static com.ss.editor.util.NodeUtils.findParent; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.bullet.control.CharacterControl; import com.jme3.bullet.control.RigidBodyControl; import com.jme3.bullet.control.VehicleControl; @@ -42,9 +42,9 @@ import com.ss.editor.ui.control.tree.node.impl.light.LightTreeNode; import com.ss.editor.util.ControlUtils; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/particle/emitter/ParticleEmitterTreeNode.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/particle/emitter/ParticleEmitterTreeNode.java index 5f52f76a..105b0e43 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/particle/emitter/ParticleEmitterTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/spatial/particle/emitter/ParticleEmitterTreeNode.java @@ -15,8 +15,8 @@ import com.ss.editor.ui.control.tree.action.impl.particle.emitter.shape.*; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.collections.ObservableList; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; diff --git a/src/main/java/com/ss/editor/ui/css/CssClasses.java b/src/main/java/com/ss/editor/ui/css/CssClasses.java index f198abd1..89a65657 100644 --- a/src/main/java/com/ss/editor/ui/css/CssClasses.java +++ b/src/main/java/com/ss/editor/ui/css/CssClasses.java @@ -87,26 +87,27 @@ public interface CssClasses { @NotNull String ABSTRACT_NODE_TREE_CONTAINER = "abstract-node-tree-container"; @NotNull String ABSTRACT_NODE_TREE_CELL = "abstract-node-tree-cell"; - @NotNull String ABSTRACT_PARAM_CONTROL_CONTAINER = "abstract-param-control-container"; - @NotNull String ABSTRACT_PARAM_CONTROL_CONTAINER_SPLIT_LINE = "abstract-param-control-container-split-line"; - @NotNull String ABSTRACT_PARAM_CONTROL = "abstract-param-control"; - @NotNull String ABSTRACT_PARAM_EDITOR_CONTROL = "abstract-param-editor-control"; + @NotNull String PROPERTY_EDITOR_CONTROL = "property-editor-control"; + + @NotNull String PROPERTY_CONTROL_VECTOR_3F_FIELD = "property-control-vector-3f-field"; + @NotNull String PROPERTY_CONTROL_RESOURCE = "property-control-resource"; + @NotNull String PROPERTY_CONTROL_COMBO_BOX = "property-control-combo-box"; + @NotNull String PROPERTY_CONTROL_CHECK_BOX = "property-control-check-box"; + @NotNull String PROPERTY_CONTROL_COLOR_PICKER = "property-control-check-box-color-picker"; + @NotNull String ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW = "abstract-param-control-param-name-single-row"; @NotNull String ABSTRACT_PARAM_CONTROL_PARAM_NAME = "abstract-param-control-param-name"; @NotNull String ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL = "abstract-param-control-element-label"; @NotNull String ABSTRACT_PARAM_CONTROL_PREVIEW_CONTAINER = "abstract-param-control-preview-container"; @NotNull String ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER = "abstract-param-control-input-container"; @NotNull String ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER = "abstract-param-control-short-input-container"; - @NotNull String ABSTRACT_PARAM_CONTROL_CHECK_BOX = "abstract-param-control-checkbox"; - @NotNull String ABSTRACT_PARAM_CONTROL_COLOR_PICKER = "abstract-param-control-param-color-picker"; - @NotNull String ABSTRACT_PARAM_CONTROL_COMBO_BOX = "abstract-param-control-combobox"; @NotNull String ABSTRACT_PARAM_CONTROL_VECTOR2F_FIELD = "abstract-param-control-vector2f-field"; - @NotNull String ABSTRACT_PARAM_CONTROL_VECTOR3F_FIELD = "abstract-param-control-vector3f-field"; @NotNull String ABSTRACT_PARAM_CONTROL_LABEL_VALUE = "abstract-param-control-label-value"; @NotNull String ABSTRACT_PARAM_CONTROL_NUMBER_LABEL = "abstract-param-control-number-label"; - @NotNull String ABSTRACT_PARAM_CONTROL_INFLUENCER = "abstract-param-control-influencer"; - @NotNull String ABSTRACT_PARAM_CONTROL_INFLUENCER_ELEMENT = "abstract-param-control-influencer-element"; - @NotNull String ABSTRACT_RESOURCE_PROPERTY_CONTROL = "abstract-resource-property-control"; + + @NotNull String PROPERTY_EDITOR = "property-editor"; + @NotNull String PROPERTY_EDITOR_CONTAINER = "property-editor-container"; + @NotNull String PROPERTY_EDITOR_CONTAINER_SPLIT_LINE = "property-editor-container-split-line"; @NotNull String EDITOR_SCRIPTING_COMPONENT = "editor-scripting-component"; @NotNull String GROOVY_EDITOR_COMPONENT = "groovy-editor-component"; @@ -165,4 +166,13 @@ public interface CssClasses { @NotNull String STATS_3D_STATE = "stats-3dstate"; @NotNull String WEBVIEW_TEXT_AREA = "webview-text-area"; + + @NotNull String TEXT_PLAIN_CODE = "plain-code"; + @NotNull String TEXT_KEYWORD = "keyword"; + @NotNull String TEXT_VALUE_TYPE = "value-type"; + @NotNull String TEXT_VALUE_VALUE = "value-value"; + @NotNull String TEXT_SEMICOLON = "semicolon"; + @NotNull String TEXT_PAREN = "paren"; + @NotNull String TEXT_STRING = "string"; + @NotNull String TEXT_COMMENT = "comment"; } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/ui/css/CssRegistry.java b/src/main/java/com/ss/editor/ui/css/CssRegistry.java index 98f0ab93..d6cffb83 100644 --- a/src/main/java/com/ss/editor/ui/css/CssRegistry.java +++ b/src/main/java/com/ss/editor/ui/css/CssRegistry.java @@ -1,9 +1,9 @@ package com.ss.editor.ui.css; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.net.URL; diff --git a/src/main/java/com/ss/editor/ui/dialog/AbstractSimpleEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/AbstractSimpleEditorDialog.java index 8ba2fc8d..37359dcf 100644 --- a/src/main/java/com/ss/editor/ui/dialog/AbstractSimpleEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/AbstractSimpleEditorDialog.java @@ -6,7 +6,7 @@ import com.ss.editor.manager.ExecutorManager; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Button; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; diff --git a/src/main/java/com/ss/editor/ui/dialog/ConfirmDialog.java b/src/main/java/com/ss/editor/ui/dialog/ConfirmDialog.java index 489f140d..fef03522 100644 --- a/src/main/java/com/ss/editor/ui/dialog/ConfirmDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/ConfirmDialog.java @@ -1,11 +1,11 @@ package com.ss.editor.ui.dialog; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.input.KeyCode; diff --git a/src/main/java/com/ss/editor/ui/dialog/CreateCustomControlDialog.java b/src/main/java/com/ss/editor/ui/dialog/CreateCustomControlDialog.java index 1b7db3f1..5e993f7b 100644 --- a/src/main/java/com/ss/editor/ui/dialog/CreateCustomControlDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/CreateCustomControlDialog.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.dialog; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.dictionary.DictionaryFactory.newObjectDictionary; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.dictionary.DictionaryFactory.newObjectDictionary; import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; @@ -14,12 +14,12 @@ import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.model.undo.impl.AddControlOperation; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ClassUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.collections.ObservableList; import javafx.scene.control.*; import javafx.scene.control.Label; diff --git a/src/main/java/com/ss/editor/ui/dialog/CreateSceneAppStateDialog.java b/src/main/java/com/ss/editor/ui/dialog/CreateSceneAppStateDialog.java index 6da4c05e..a9085bcb 100644 --- a/src/main/java/com/ss/editor/ui/dialog/CreateSceneAppStateDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/CreateSceneAppStateDialog.java @@ -1,8 +1,8 @@ package com.ss.editor.ui.dialog; import static com.ss.editor.util.EditorUtil.tryToCreateUserObject; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.dictionary.DictionaryFactory.newObjectDictionary; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.dictionary.DictionaryFactory.newObjectDictionary; import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; @@ -15,11 +15,11 @@ import com.ss.editor.model.undo.editor.SceneChangeConsumer; import com.ss.editor.model.undo.impl.AddAppStateOperation; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ClassUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.scene.control.*; import javafx.scene.control.Label; import javafx.scene.control.TextField; diff --git a/src/main/java/com/ss/editor/ui/dialog/CreateSceneFilterDialog.java b/src/main/java/com/ss/editor/ui/dialog/CreateSceneFilterDialog.java index 57b77d3d..c05b0d26 100644 --- a/src/main/java/com/ss/editor/ui/dialog/CreateSceneFilterDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/CreateSceneFilterDialog.java @@ -1,8 +1,8 @@ package com.ss.editor.ui.dialog; import static com.ss.editor.util.EditorUtil.tryToCreateUserObject; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.dictionary.DictionaryFactory.newObjectDictionary; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.dictionary.DictionaryFactory.newObjectDictionary; import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; @@ -14,11 +14,11 @@ import com.ss.editor.model.undo.editor.SceneChangeConsumer; import com.ss.editor.model.undo.impl.AddSceneFilterOperation; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.ClassUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.scene.control.*; import javafx.scene.control.Label; import javafx.scene.control.TextField; diff --git a/src/main/java/com/ss/editor/ui/dialog/EditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/EditorDialog.java index 8da00307..a7f19009 100644 --- a/src/main/java/com/ss/editor/ui/dialog/EditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/EditorDialog.java @@ -10,25 +10,22 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.ui.css.CssClasses; -import com.ss.editor.ui.css.CssColorTheme; import com.ss.editor.ui.css.CssRegistry; import com.ss.editor.ui.event.FxEventManager; import com.ss.editor.ui.scene.EditorFxScene; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.ui.window.popup.dialog.AbstractPopupDialog; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.fx.util.FxUtils; +import com.ss.rlib.fx.window.popup.dialog.AbstractPopupDialog; import javafx.application.Platform; import javafx.beans.property.ReadOnlyDoubleProperty; -import javafx.collections.ObservableList; import javafx.scene.Node; import javafx.scene.Scene; -import javafx.scene.image.Image; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.GridPane; -import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Modality; import javafx.stage.Stage; @@ -48,28 +45,14 @@ */ public class EditorDialog { - /** - * The constant LOGGER. - */ - @NotNull protected static final Logger LOGGER = LoggerManager.getLogger(EditorDialog.class); - /** - * The constant FX_EVENT_MANAGER. - */ - @NotNull protected static final FxEventManager FX_EVENT_MANAGER = FxEventManager.getInstance(); - - /** - * The CSS registry. - */ - @NotNull - private static final CssRegistry CSS_REGISTRY = CssRegistry.getInstance(); + protected static final CssRegistry CSS_REGISTRY = CssRegistry.getInstance(); /** * The default dialog size. */ - @NotNull private static final Point DEFAULT_SIZE = new Point(0, 0); /** @@ -102,11 +85,11 @@ public EditorDialog() { container = new VBox(); container.setAlignment(CENTER); - final EditorConfig editorConfig = EditorConfig.getInstance(); - final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME); + var editorConfig = EditorConfig.getInstance(); + var theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME); - final Scene scene = new Scene(container); - final ObservableList stylesheets = scene.getStylesheets(); + var scene = new Scene(container); + var stylesheets = scene.getStylesheets(); stylesheets.addAll(CSS_REGISTRY.getAvailableCssFiles()); stylesheets.add(theme.getCssFile()); @@ -119,14 +102,16 @@ public EditorDialog() { dialog.setResizable(isResizable()); dialog.setScene(scene); - final Stage fxStage = EditorUtil.getFxStage(); - final ObservableList icons = dialog.getIcons(); + var fxStage = EditorUtil.getFxStage(); + var icons = dialog.getIcons(); icons.addAll(fxStage.getIcons()); configureSize(container); } /** + * Returns true if this dialog should be resizable. + * * @return true if this dialog should be resizable. */ @FromAnyThread @@ -140,28 +125,28 @@ protected boolean isResizable() { * @param root the root container. */ @FxThread - protected void createControls(@NotNull final VBox root) { - - final VBox actionsContainer = new VBox(); + protected void createControls(@NotNull VBox root) { - FXUtils.addClassTo(actionsContainer, CssClasses.DIALOG_ACTIONS_ROOT); + var actionsContainer = new VBox(); if (isGridStructure()) { - final GridPane container = new GridPane(); - FXUtils.addClassesTo(container, CssClasses.DEF_GRID_PANE, CssClasses.DIALOG_CONTENT_ROOT); + var container = new GridPane(); + FxUtils.addClass(container, CssClasses.DEF_GRID_PANE, CssClasses.DIALOG_CONTENT_ROOT); createContent(container); - FXUtils.addToPane(container, root); + FxUtils.addChild(root, container); } else { - final VBox container = new VBox(); - FXUtils.addClassesTo(container, CssClasses.DEF_VBOX, CssClasses.DIALOG_CONTENT_ROOT); + var container = new VBox(); + FxUtils.addClass(container, CssClasses.DEF_VBOX, CssClasses.DIALOG_CONTENT_ROOT); createContent(container); - FXUtils.addToPane(container, root); + FxUtils.addChild(root, container); } createActions(actionsContainer); - FXUtils.addToPane(actionsContainer, root); - FXUtils.addClassTo(root, CssClasses.DIALOG_ROOT); + FxUtils.addClass(actionsContainer, CssClasses.DIALOG_ACTIONS_ROOT) + .addClass(root, CssClasses.DIALOG_ROOT); + + FxUtils.addChild(root, actionsContainer); root.addEventHandler(KeyEvent.KEY_RELEASED, this::processKey); } @@ -202,7 +187,7 @@ protected void createControls(@NotNull final VBox root) { * @param container the root container. */ @FxThread - protected void configureSize(@NotNull final VBox container) { + protected void configureSize(@NotNull VBox container) { configureSize(container, getSize()); } @@ -212,7 +197,7 @@ protected void configureSize(@NotNull final VBox container) { * @param size the size. */ @FxThread - public void configureSize(@NotNull final Point size) { + public void configureSize(@NotNull Point size) { configureSize(container, size); } @@ -223,12 +208,12 @@ public void configureSize(@NotNull final Point size) { * @param size the size. */ @FxThread - private void configureSize(@NotNull final VBox container, @NotNull final Point size) { + private void configureSize(@NotNull VBox container, @NotNull Point size) { - final Stage dialog = getDialog(); + var dialog = getDialog(); - final double width = size.getX(); - final double height = size.getY(); + var width = size.getX(); + var height = size.getY(); if (width >= 1D) { FXUtils.setFixedWidth(container, width); @@ -244,9 +229,9 @@ private void configureSize(@NotNull final VBox container, @NotNull final Point s } /** - * Gets container. + * Get the content container. * - * @return The content container. + * @return the content container. */ @FromAnyThread protected @NotNull VBox getContainer() { @@ -259,7 +244,7 @@ private void configureSize(@NotNull final VBox container, @NotNull final Point s * @param size the size of the dialog. */ @FxThread - public void updateSize(@NotNull final Point size) { + public void updateSize(@NotNull Point size) { configureSize(getContainer(), size); } @@ -274,7 +259,7 @@ public void updateSize(@NotNull final Point size) { * @param event the event */ @FxThread - protected void processKey(@NotNull final KeyEvent event) { + protected void processKey(@NotNull KeyEvent event) { event.consume(); if (event.getCode() == KeyCode.ESCAPE) { hide(); @@ -287,7 +272,7 @@ protected void processKey(@NotNull final KeyEvent event) { * @param owner the owner. */ @FxThread - public void show(@NotNull final Node owner) { + public void show(@NotNull Node owner) { show(owner.getScene().getWindow()); } @@ -305,13 +290,13 @@ public void show() { * @param owner the owner. */ @FxThread - public void show(@NotNull final Window owner) { + public void show(@NotNull Window owner) { - final Scene scene = owner.getScene(); + var scene = owner.getScene(); if (scene instanceof EditorFxScene) { - final EditorFxScene editorFxScene = (EditorFxScene) scene; - final StackPane container = editorFxScene.getContainer(); + var editorFxScene = (EditorFxScene) scene; + var container = editorFxScene.getContainer(); container.setFocusTraversable(false); } @@ -344,15 +329,15 @@ public void show(@NotNull final Window owner) { @FxThread public void hide() { - final Duration duration = Duration.between(showedTime, LocalTime.now()); - final int seconds = (int) duration.getSeconds(); + var duration = Duration.between(showedTime, LocalTime.now()); + var seconds = (int) duration.getSeconds(); - final Window window = dialog.getOwner(); - final Scene scene = window.getScene(); + var window = dialog.getOwner(); + var scene = window.getScene(); if (scene instanceof EditorFxScene) { - final EditorFxScene editorFxScene = (EditorFxScene) scene; - final StackPane container = editorFxScene.getContainer(); + var editorFxScene = (EditorFxScene) scene; + var container = editorFxScene.getContainer(); container.setFocusTraversable(true); } @@ -374,7 +359,7 @@ public void hide() { * @param root the root */ @FxThread - protected void createContent(@NotNull final VBox root) { + protected void createContent(@NotNull VBox root) { } /** @@ -383,7 +368,7 @@ protected void createContent(@NotNull final VBox root) { * @param root the root */ @FxThread - protected void createContent(@NotNull final GridPane root) { + protected void createContent(@NotNull GridPane root) { } /** @@ -402,7 +387,7 @@ protected boolean isGridStructure() { * @param root the root */ @FxThread - protected void createActions(@NotNull final VBox root) { + protected void createActions(@NotNull VBox root) { } /** @@ -421,7 +406,7 @@ protected void createActions(@NotNull final VBox root) { * @param title the new title. */ @FxThread - public void setTitleText(@NotNull final String title) { + public void setTitleText(@NotNull String title) { dialog.setTitle(title); } } diff --git a/src/main/java/com/ss/editor/ui/dialog/GenerateTangentsDialog.java b/src/main/java/com/ss/editor/ui/dialog/GenerateTangentsDialog.java index ffa628c1..08b67ffc 100644 --- a/src/main/java/com/ss/editor/ui/dialog/GenerateTangentsDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/GenerateTangentsDialog.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.dialog; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static javafx.collections.FXCollections.observableArrayList; import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; @@ -13,7 +13,7 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.collections.ObservableList; import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; diff --git a/src/main/java/com/ss/editor/ui/dialog/RenameDialog.java b/src/main/java/com/ss/editor/ui/dialog/RenameDialog.java index 3de47aeb..3a34ff3e 100644 --- a/src/main/java/com/ss/editor/ui/dialog/RenameDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/RenameDialog.java @@ -1,11 +1,11 @@ package com.ss.editor.ui.dialog; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; diff --git a/src/main/java/com/ss/editor/ui/dialog/SettingsDialog.java b/src/main/java/com/ss/editor/ui/dialog/SettingsDialog.java index abc9408f..2c943fe1 100644 --- a/src/main/java/com/ss/editor/ui/dialog/SettingsDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/SettingsDialog.java @@ -3,13 +3,9 @@ import static com.ss.editor.config.DefaultSettingsProvider.Defaults.*; import static com.ss.editor.config.DefaultSettingsProvider.Preferences.*; import static com.ss.editor.plugin.api.property.control.PropertyEditorControlFactory.build; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayCollectors.toArray; -import com.jme3.asset.AssetManager; -import com.jme3.post.filters.FXAAFilter; -import com.jme3.post.filters.ToneMapFilter; -import com.jme3x.jfx.injfx.processor.FrameTransferSceneProcessor; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayCollectors.toArray; import com.ss.editor.JfxApplication; import com.ss.editor.JmeApplication; import com.ss.editor.Messages; @@ -26,13 +22,13 @@ import com.ss.editor.plugin.api.settings.SettingsProviderRegistry; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.application.Platform; import javafx.scene.control.Button; import javafx.scene.control.Label; @@ -52,13 +48,9 @@ */ public class SettingsDialog extends EditorDialog { - @NotNull private static final Point DIALOG_SIZE = new Point(-1, -1); - @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); - - @NotNull private static final SettingsProviderRegistry SETTINGS_REGISTRY = SettingsProviderRegistry.getInstance(); /** @@ -86,7 +78,7 @@ public SettingsDialog() { @Override @FxThread - protected void createContent(@NotNull final VBox root) { + protected void createContent(@NotNull VBox root) { super.createContent(root); vars = VarTable.newInstance(); @@ -94,49 +86,59 @@ protected void createContent(@NotNull final VBox root) { messageLabel = new Label(); - final ObjectDictionary> categoryToSettings = DictionaryFactory.newObjectDictionary(); - final Array definitions = SETTINGS_REGISTRY.getDefinitions(); - final Array categories = definitions.stream() + var categoryToSettings = DictionaryFactory.>newObjectDictionary(); + + var definitions = SETTINGS_REGISTRY.getDefinitions(); + var categories = definitions.stream() .map(SettingsPropertyDefinition::getCategory) - .distinct().sorted() + .distinct() + .sorted() .collect(toArray(SettingsCategory.class)); - for (final SettingsPropertyDefinition definition : definitions) { - categoryToSettings.get(definition.getCategory(), cat -> ArrayFactory.newArray(SettingsPropertyDefinition.class)) + for (var definition : definitions) { + categoryToSettings.get(definition.getCategory(), cat -> newCategoryArray()) .add(definition); } - final TabPane tabPane = new TabPane(); + var tabPane = new TabPane(); tabPane.prefWidthProperty().bind(root.widthProperty()); tabPane.prefHeightProperty().bind(heightProperty()); - messageLabel.prefWidthProperty().bind(tabPane.widthProperty()); + messageLabel.prefWidthProperty() + .bind(tabPane.widthProperty()); - for (final SettingsCategory category : categories) { + for (var category : categories) { - final Array properties = notNull(categoryToSettings.get(category)); - final Array> tabControls = properties.stream() + var properties = notNull(categoryToSettings.get(category)); + + Array> tabControls = properties.stream() .map(definition -> build(vars, definition, this::validate)) .collect(unsafeCast(toArray(PropertyEditorControl.class))); controls.addAll(tabControls); - final VBox container = new VBox(); - container.prefWidthProperty().bind(tabPane.widthProperty()); + var container = new VBox(); + container.prefWidthProperty() + .bind(tabPane.widthProperty()); - final Tab tab = new Tab(category.getLabel()); + var tab = new Tab(category.getLabel()); tab.setClosable(false); tab.setContent(container); - tabControls.forEach(container.getChildren(), (control, nodes) -> nodes.add(control)); + tabControls.forEach(container.getChildren(), + (control, nodes) -> nodes.add(control)); - FXUtils.addClassesTo(container, CssClasses.SETTINGS_DIALOG_CONTAINER); + FxUtils.addClass(container, CssClasses.SETTINGS_DIALOG_CONTAINER); tabPane.getTabs().add(tab); } - FXUtils.addClassTo(messageLabel, CssClasses.SETTINGS_DIALOG_MESSAGE_LABEL); - FXUtils.addToPane(tabPane, messageLabel, root); + FxUtils.addClass(messageLabel, CssClasses.SETTINGS_DIALOG_MESSAGE_LABEL); + FxUtils.addChild(root, tabPane, messageLabel); + } + + private @NotNull Array newCategoryArray() { + return ArrayFactory.newArray(SettingsPropertyDefinition.class); } /** @@ -175,18 +177,18 @@ protected void createContent(@NotNull final VBox root) { @FxThread private void validate() { - final Array> controls = getControls(); + var controls = getControls(); if (controls != null) { controls.forEach(PropertyEditorControl::checkDependency); } - final PropertyEditorControl requiredRestart = controls == null ? null : controls.search(control -> { - final String propertyId = control.getPropertyId(); - final SettingsProviderRegistry registry = SettingsProviderRegistry.getInstance(); + var requiredRestart = controls == null ? null : controls.search(control -> { + var propertyId = control.getPropertyId(); + var registry = SettingsProviderRegistry.getInstance(); return registry.isRequiredRestart(propertyId) && control.isNotDefault(); }); - final Label messageLabel = getMessageLabel(); + var messageLabel = getMessageLabel(); if (requiredRestart != null) { messageLabel.setText(Messages.SETTINGS_DIALOG_MESSAGE); @@ -197,23 +199,22 @@ private void validate() { @Override @FxThread - protected void createActions(@NotNull final VBox root) { + protected void createActions(@NotNull VBox root) { super.createActions(root); - final HBox container = new HBox(); + var container = new HBox(); - final Button okButton = new Button(Messages.SIMPLE_DIALOG_BUTTON_OK); + var okButton = new Button(Messages.SIMPLE_DIALOG_BUTTON_OK); okButton.setOnAction(event -> processOk()); - final Button cancelButton = new Button(Messages.SIMPLE_DIALOG_BUTTON_CLOSE); + var cancelButton = new Button(Messages.SIMPLE_DIALOG_BUTTON_CLOSE); cancelButton.setOnAction(event -> hide()); - FXUtils.addClassTo(okButton, cancelButton, CssClasses.DIALOG_BUTTON); - FXUtils.addClassTo(container, CssClasses.DEF_HBOX); + FxUtils.addClass(okButton, cancelButton, CssClasses.DIALOG_BUTTON) + .addClass(container, CssClasses.DEF_HBOX); - FXUtils.addToPane(okButton, container); - FXUtils.addToPane(cancelButton, container); - FXUtils.addToPane(container, root); + FxUtils.addChild(container, okButton, cancelButton) + .addChild(root, container); } /** @@ -222,48 +223,51 @@ protected void createActions(@NotNull final VBox root) { @FxThread private void processOk() { - final Array> controls = getControls(); + var controls = getControls(); if (controls == null) { throw new RuntimeException("Controls weren't initialized."); } - final EditorConfig editorConfig = EditorConfig.getInstance(); - final ObjectDictionary values = getVars().getValues(); + var editorConfig = EditorConfig.getInstance(); + + var values = getVars().getValues(); values.forEach(editorConfig::set); + editorConfig.save(); - final PropertyEditorControl requiredRestart = controls.search(control -> { - final String propertyId = control.getPropertyId(); - final SettingsProviderRegistry registry = SettingsProviderRegistry.getInstance(); + var requiredRestart = controls.search(control -> { + var propertyId = control.getPropertyId(); + var registry = SettingsProviderRegistry.getInstance(); return registry.isRequiredRestart(propertyId) && control.isNotDefault(); }); - final PropertyEditorControl requiredUpdateClasspath = controls.search(control -> { - final String propertyId = control.getPropertyId(); - final SettingsProviderRegistry registry = SettingsProviderRegistry.getInstance(); + var requiredUpdateClasspath = controls.search(control -> { + var propertyId = control.getPropertyId(); + var registry = SettingsProviderRegistry.getInstance(); return registry.isRequiredUpdateClasspath(propertyId) && control.isNotDefault(); }); - final PropertyEditorControl reshape3DView = controls.search(control -> { - final String propertyId = control.getPropertyId(); - final SettingsProviderRegistry registry = SettingsProviderRegistry.getInstance(); + var reshape3DView = controls.search(control -> { + var propertyId = control.getPropertyId(); + var registry = SettingsProviderRegistry.getInstance(); return registry.isRequiredReshape3DView(propertyId) && control.isNotDefault(); }); if (reshape3DView != null) { - final JfxApplication jfxApplication = JfxApplication.getInstance(); - final FrameTransferSceneProcessor sceneProcessor = jfxApplication.getSceneProcessor(); + var jfxApplication = JfxApplication.getInstance(); + var sceneProcessor = jfxApplication.getSceneProcessor(); sceneProcessor.reshape(); } EXECUTOR_MANAGER.addJmeTask(() -> { - final JmeApplication jmeApplication = JmeApplication.getInstance(); - final SceneEditor3DPart sceneEditor3DPart = jmeApplication.getStateManager() + var jmeApplication = JmeApplication.getInstance(); + var sceneEditor3DPart = jmeApplication.getStateManager() .getState(SceneEditor3DPart.class); - final ToneMapFilter filter = jmeApplication.getToneMapFilter(); - filter.setWhitePoint(editorConfig.getVector3f(PREF_FILTER_TONEMAP_WHITE_POINT, PREF_DEFAULT_TONEMAP_WHITE_POINT)); + var filter = jmeApplication.getToneMapFilter(); + filter.setWhitePoint(editorConfig.getVector3f(PREF_FILTER_TONEMAP_WHITE_POINT, + PREF_DEFAULT_TONEMAP_WHITE_POINT)); if (sceneEditor3DPart != null) { return; @@ -271,20 +275,20 @@ private void processOk() { filter.setEnabled(editorConfig.getBoolean(PREF_FILTER_TONEMAP, PREF_DEFAULT_TONEMAP_FILTER)); - final FXAAFilter fxaaFilter = jmeApplication.getFXAAFilter(); + var fxaaFilter = jmeApplication.getFXAAFilter(); fxaaFilter.setEnabled(editorConfig.getBoolean(PREF_FILTER_FXAA, PREF_DEFAULT_FXAA_FILTER)); }); if (requiredUpdateClasspath != null) { - final ClasspathManager classpathManager = ClasspathManager.getInstance(); + var classpathManager = ClasspathManager.getInstance(); classpathManager.reload(); - final AssetManager assetManager = EditorUtil.getAssetManager(); + var assetManager = EditorUtil.getAssetManager(); assetManager.clearCache(); } - final ResourceManager resourceManager = ResourceManager.getInstance(); + var resourceManager = ResourceManager.getInstance(); resourceManager.updateAdditionalEnvs(); if (requiredRestart != null) { diff --git a/src/main/java/com/ss/editor/ui/dialog/about/AboutDialog.java b/src/main/java/com/ss/editor/ui/dialog/about/AboutDialog.java index 70663327..f7f23bb5 100644 --- a/src/main/java/com/ss/editor/ui/dialog/about/AboutDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/about/AboutDialog.java @@ -9,8 +9,8 @@ import com.ss.editor.ui.component.creator.FileCreator; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.FileUtils; import javafx.application.HostServices; import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; diff --git a/src/main/java/com/ss/editor/ui/dialog/animation/ExtractSubAnimationDialog.java b/src/main/java/com/ss/editor/ui/dialog/animation/ExtractSubAnimationDialog.java index 5a661990..c50fa195 100644 --- a/src/main/java/com/ss/editor/ui/dialog/animation/ExtractSubAnimationDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/animation/ExtractSubAnimationDialog.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.dialog.animation; import static com.ss.editor.util.AnimationUtils.extractAnimation; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.animation.AnimControl; import com.jme3.animation.Animation; import com.ss.editor.Messages; @@ -17,8 +17,8 @@ import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.AnimationUtils; -import com.ss.rlib.ui.control.input.IntegerTextField; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.control.input.IntegerTextField; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/BaseAssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/BaseAssetEditorDialog.java index 86eb7322..c0f2e40c 100644 --- a/src/main/java/com/ss/editor/ui/dialog/asset/BaseAssetEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/asset/BaseAssetEditorDialog.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.dialog.asset; import static com.ss.editor.Messages.ASSET_EDITOR_DIALOG_TITLE; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.Icons; @@ -10,9 +10,9 @@ import com.ss.editor.ui.preview.FilePreview; import com.ss.editor.ui.preview.FilePreviewFactoryRegistry; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; import javafx.beans.binding.BooleanBinding; import javafx.beans.value.ObservableBooleanValue; import javafx.scene.control.Button; diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/file/AssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/file/AssetEditorDialog.java index 3f8b0581..76bb2c40 100644 --- a/src/main/java/com/ss/editor/ui/dialog/asset/file/AssetEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/asset/file/AssetEditorDialog.java @@ -2,9 +2,9 @@ import static com.ss.editor.ui.component.asset.tree.resource.ResourceElementFactory.createFor; import static com.ss.editor.ui.util.UiUtils.findItemForValue; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.ss.editor.annotation.FxThread; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.ui.component.asset.tree.ResourceTree; @@ -15,11 +15,10 @@ import com.ss.editor.ui.event.impl.CreatedFileEvent; import com.ss.editor.ui.event.impl.DeletedFileEvent; import com.ss.editor.ui.event.impl.RequestSelectFileEvent; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.value.ObservableBooleanValue; -import javafx.event.Event; import javafx.event.EventHandler; import javafx.scene.control.MultipleSelectionModel; import javafx.scene.control.TreeItem; @@ -58,19 +57,19 @@ public class AssetEditorDialog extends BaseAssetEditorDialog createdFileHandler = event -> processEvent((CreatedFileEvent) event); + private final EventHandler createdFileHandler = this::processEvent; /** * The handler selected file events. */ @NotNull - private final EventHandler selectFileHandle = event -> processEvent((RequestSelectFileEvent) event); + private final EventHandler selectFileHandle = this::processEvent; /** * The handler deleted file events, */ @NotNull - private final EventHandler deletedFileHandler = event -> processEvent((DeletedFileEvent) event); + private final EventHandler deletedFileHandler = this::processEvent; /** * The list of waited files to select. diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/virtual/StringVirtualAssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/virtual/StringVirtualAssetEditorDialog.java index 3a612153..38cbf251 100644 --- a/src/main/java/com/ss/editor/ui/dialog/asset/virtual/StringVirtualAssetEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/asset/virtual/StringVirtualAssetEditorDialog.java @@ -2,9 +2,9 @@ import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/virtual/VirtualAssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/virtual/VirtualAssetEditorDialog.java index 1d91aeeb..ba5c9890 100644 --- a/src/main/java/com/ss/editor/ui/dialog/asset/virtual/VirtualAssetEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/asset/virtual/VirtualAssetEditorDialog.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.dialog.asset.virtual; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.virtual.tree.VirtualResourceTree; @@ -8,7 +8,7 @@ import com.ss.editor.ui.component.virtual.tree.resource.VirtualResourceElement; import com.ss.editor.ui.component.virtual.tree.resource.VirtualResourceElementFactory; import com.ss.editor.ui.dialog.asset.BaseAssetEditorDialog; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import javafx.beans.binding.Bindings; import javafx.beans.binding.BooleanBinding; import javafx.beans.property.ReadOnlyObjectProperty; diff --git a/src/main/java/com/ss/editor/ui/dialog/file/chooser/ExternalFileEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/file/chooser/ExternalFileEditorDialog.java index 07ba8b38..b67acba0 100644 --- a/src/main/java/com/ss/editor/ui/dialog/file/chooser/ExternalFileEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/file/chooser/ExternalFileEditorDialog.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.dialog.file.chooser; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; @@ -10,9 +10,9 @@ import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.editor.ui.dialog.EditorDialog; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.scene.control.Button; import javafx.scene.control.TreeItem; import javafx.scene.layout.VBox; diff --git a/src/main/java/com/ss/editor/ui/dialog/geometry/lod/GenerateLodLevelsDialog.java b/src/main/java/com/ss/editor/ui/dialog/geometry/lod/GenerateLodLevelsDialog.java index 1fecf170..70068aff 100644 --- a/src/main/java/com/ss/editor/ui/dialog/geometry/lod/GenerateLodLevelsDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/geometry/lod/GenerateLodLevelsDialog.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.dialog.geometry.lod; -import static com.ss.editor.ui.FXConstants.DIALOG_LIST_WIDTH_PERCENT; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.editor.ui.FxConstants.DIALOG_LIST_WIDTH_PERCENT; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static javafx.collections.FXCollections.observableArrayList; import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; @@ -11,7 +11,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.property.operation.PropertyOperation; import com.ss.editor.ui.control.tree.NodeTree; @@ -19,7 +19,7 @@ import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.editor.ui.util.DynamicIconSupport; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import javafx.scene.control.Button; @@ -193,7 +193,7 @@ protected void createContent(@NotNull final VBox root) { levelsList.prefWidthProperty().bind(widthProperty().multiply(DIALOG_LIST_WIDTH_PERCENT)); levelsList.maxWidthProperty().bind(widthProperty().multiply(DIALOG_LIST_WIDTH_PERCENT)); levelsList.getItems().addListener((ListChangeListener) c -> updateButtonOk()); - levelsList.setFixedCellSize(FXConstants.LIST_CELL_HEIGHT); + levelsList.setFixedCellSize(FxConstants.LIST_CELL_HEIGHT); FXUtils.addToPane(levelsList, root); diff --git a/src/main/java/com/ss/editor/ui/dialog/imports/model/ModelImportDialog.java b/src/main/java/com/ss/editor/ui/dialog/imports/model/ModelImportDialog.java index 40616995..b376034a 100644 --- a/src/main/java/com/ss/editor/ui/dialog/imports/model/ModelImportDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/imports/model/ModelImportDialog.java @@ -5,7 +5,7 @@ import static com.ss.editor.extension.property.EditablePropertyType.*; import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.nio.file.StandardOpenOption.*; import com.jme3.asset.AssetKey; import com.jme3.asset.AssetManager; @@ -34,12 +34,12 @@ import com.ss.editor.util.MaterialSerializer; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.NodeUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.VarTable; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.VarTable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.beans.property.ObjectProperty; import javafx.scene.image.Image; import javafx.scene.image.ImageView; diff --git a/src/main/java/com/ss/editor/ui/dialog/node/selector/NodeSelectorDialog.java b/src/main/java/com/ss/editor/ui/dialog/node/selector/NodeSelectorDialog.java index 4f680b30..c70375d9 100644 --- a/src/main/java/com/ss/editor/ui/dialog/node/selector/NodeSelectorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/node/selector/NodeSelectorDialog.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.dialog.node.selector; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; @@ -9,8 +9,10 @@ import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.array.Array; import javafx.scene.control.Button; +import javafx.scene.control.SelectionMode; import javafx.scene.layout.GridPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -94,7 +96,7 @@ public NodeSelectorDialog(@NotNull final Spatial model, @NotNull final Class protected void createContent(@NotNull final GridPane root) { super.createContent(root); - nodeTree = new ModelNodeTree(this::processSelect, null); + nodeTree = new ModelNodeTree(this::processSelect, null, SelectionMode.SINGLE); nodeTree.prefHeightProperty().bind(heightProperty()); nodeTree.prefWidthProperty().bind(widthProperty()); @@ -130,10 +132,11 @@ protected boolean isGridStructure() { } /** - * Handle the selected object. + * Handle the selected objects. */ @FxThread - private void processSelect(@Nullable final Object object) { + private void processSelect(@Nullable final Array objects) { + final Object object = objects.first(); final Object result = object instanceof TreeNode ? ((TreeNode) object).getElement() : object; final Class type = getType(); final Button okButton = notNull(getOkButton()); diff --git a/src/main/java/com/ss/editor/ui/dialog/plugin/PluginListCell.java b/src/main/java/com/ss/editor/ui/dialog/plugin/PluginListCell.java index 07212b19..d212b5c7 100644 --- a/src/main/java/com/ss/editor/ui/dialog/plugin/PluginListCell.java +++ b/src/main/java/com/ss/editor/ui/dialog/plugin/PluginListCell.java @@ -4,8 +4,8 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.scene.control.ListCell; import javafx.scene.image.ImageView; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/dialog/plugin/PluginsDialog.java b/src/main/java/com/ss/editor/ui/dialog/plugin/PluginsDialog.java index 84d6037c..74f7cb6b 100644 --- a/src/main/java/com/ss/editor/ui/dialog/plugin/PluginsDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/plugin/PluginsDialog.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.dialog.plugin; import static com.ss.editor.ui.util.UiUtils.toWeb; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.analytics.google.GAEvent; import com.ss.editor.analytics.google.GAnalytics; @@ -9,17 +9,17 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.PluginManager; import com.ss.editor.plugin.EditorPlugin; -import com.ss.editor.ui.FXConstants; +import com.ss.editor.ui.FxConstants; import com.ss.editor.ui.Icons; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.editor.ui.dialog.ConfirmDialog; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.rlib.plugin.Version; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.plugin.Version; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.application.Platform; import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; @@ -109,7 +109,7 @@ protected void createContent(@NotNull final GridPane root) { pluginListView = new ListView<>(); pluginListView.setCellFactory(param -> new PluginListCell()); - pluginListView.setFixedCellSize(FXConstants.LIST_CELL_HEIGHT); + pluginListView.setFixedCellSize(FxConstants.LIST_CELL_HEIGHT); pluginListView.prefWidthProperty().bind(root.widthProperty().divide(2)); pluginListView.prefHeightProperty().bind(root.heightProperty()); diff --git a/src/main/java/com/ss/editor/ui/dialog/save/SaveAsEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/save/SaveAsEditorDialog.java index 6669445e..2431bdc4 100644 --- a/src/main/java/com/ss/editor/ui/dialog/save/SaveAsEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/save/SaveAsEditorDialog.java @@ -4,7 +4,7 @@ import static com.ss.editor.Messages.SAVE_AS_EDITOR_DIALOG_TITLE; import static com.ss.editor.ui.component.asset.tree.resource.ResourceElementFactory.createFor; import static com.ss.editor.ui.util.UiUtils.findItemForValue; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; @@ -18,12 +18,11 @@ import com.ss.editor.ui.event.impl.CreatedFileEvent; import com.ss.editor.ui.event.impl.DeletedFileEvent; import com.ss.editor.ui.event.impl.RequestSelectFileEvent; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import javafx.event.Event; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; import javafx.event.EventHandler; import javafx.scene.control.Button; import javafx.scene.control.Label; @@ -62,13 +61,13 @@ public class SaveAsEditorDialog extends AbstractSimpleEditorDialog { protected static final FxEventManager FX_EVENT_MANAGER = FxEventManager.getInstance(); @NotNull - private final EventHandler createdFileHandler = event -> processEvent((CreatedFileEvent) event); + private final EventHandler createdFileHandler = this::processEvent; @NotNull - private final EventHandler selectFileHandle = event -> processEvent((RequestSelectFileEvent) event); + private final EventHandler selectFileHandle = this::processEvent; @NotNull - private final EventHandler deletedFileHandler = event -> processEvent((DeletedFileEvent) event); + private final EventHandler deletedFileHandler = this::processEvent; /** * The list of waited files to select. diff --git a/src/main/java/com/ss/editor/ui/dialog/scene/selector/SceneSelectorDialog.java b/src/main/java/com/ss/editor/ui/dialog/scene/selector/SceneSelectorDialog.java index 3ce11b0a..c5bdfae4 100644 --- a/src/main/java/com/ss/editor/ui/dialog/scene/selector/SceneSelectorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/scene/selector/SceneSelectorDialog.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.dialog.scene.selector; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.ss.editor.Messages; import com.ss.editor.annotation.FromAnyThread; @@ -10,7 +10,7 @@ import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.control.Button; import javafx.scene.layout.GridPane; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/dialog/sky/CreateSkyDialog.java b/src/main/java/com/ss/editor/ui/dialog/sky/CreateSkyDialog.java index a19b986a..3bb91a60 100644 --- a/src/main/java/com/ss/editor/ui/dialog/sky/CreateSkyDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/sky/CreateSkyDialog.java @@ -2,7 +2,7 @@ import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static java.nio.file.StandardOpenOption.*; import static javafx.collections.FXCollections.observableArrayList; import com.jme3.asset.AssetManager; @@ -33,9 +33,9 @@ import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.MaterialSerializer; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.StringUtils; import javafx.collections.ObservableList; import javafx.scene.control.Button; import javafx.scene.control.*; @@ -325,7 +325,7 @@ protected void createContent(@NotNull final VBox root) { FXUtils.addClassTo(skyTypeLabel, normalScaleLabel, CssClasses.DIALOG_DYNAMIC_LABEL); FXUtils.addClassTo(skyTypeComboBox, CssClasses.DIALOG_FIELD); FXUtils.addClassesTo(normalScaleXField, normalScaleYField, normalScaleZField, - CssClasses.ABSTRACT_PARAM_CONTROL_VECTOR3F_FIELD, CssClasses.TRANSPARENT_TEXT_FIELD); + CssClasses.PROPERTY_CONTROL_VECTOR_3F_FIELD, CssClasses.TRANSPARENT_TEXT_FIELD); UiUtils.addFocusBinding(normalScaleContainer, normalScaleXField, normalScaleYField, normalScaleZField); } diff --git a/src/main/java/com/ss/editor/ui/dialog/terrain/CreateTerrainDialog.java b/src/main/java/com/ss/editor/ui/dialog/terrain/CreateTerrainDialog.java index d38b685f..881d6ec1 100644 --- a/src/main/java/com/ss/editor/ui/dialog/terrain/CreateTerrainDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/terrain/CreateTerrainDialog.java @@ -3,7 +3,7 @@ import static com.ss.editor.part3d.editor.impl.scene.AbstractSceneEditor3DPart.KEY_LOADED_MODEL; import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import static javafx.collections.FXCollections.observableArrayList; import com.jme3.asset.AssetManager; import com.jme3.asset.TextureKey; @@ -33,10 +33,10 @@ import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.control.input.FloatTextField; -import com.ss.rlib.ui.control.input.IntegerTextField; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; +import com.ss.rlib.fx.control.input.FloatTextField; +import com.ss.rlib.fx.control.input.IntegerTextField; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.FileUtils; import javafx.collections.ObservableList; import javafx.scene.Node; import javafx.scene.control.Button; diff --git a/src/main/java/com/ss/editor/ui/event/EventRedirector.java b/src/main/java/com/ss/editor/ui/event/EventRedirector.java index 621cb1f0..c88124d6 100644 --- a/src/main/java/com/ss/editor/ui/event/EventRedirector.java +++ b/src/main/java/com/ss/editor/ui/event/EventRedirector.java @@ -1,12 +1,12 @@ package com.ss.editor.ui.event; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.config.Config; import com.ss.editor.ui.component.editor.FileEditor; import com.ss.editor.ui.component.editor.area.EditorAreaComponent; import com.ss.editor.ui.util.UiUtils; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import javafx.event.Event; import javafx.event.EventTarget; import javafx.event.EventType; diff --git a/src/main/java/com/ss/editor/ui/event/FxEventManager.java b/src/main/java/com/ss/editor/ui/event/FxEventManager.java index 2f75db41..e9b73ef1 100644 --- a/src/main/java/com/ss/editor/ui/event/FxEventManager.java +++ b/src/main/java/com/ss/editor/ui/event/FxEventManager.java @@ -1,12 +1,13 @@ package com.ss.editor.ui.event; -import static com.ss.rlib.util.array.ArrayFactory.newArray; +import static com.ss.rlib.common.util.array.ArrayFactory.newArray; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.application.Platform; import javafx.event.Event; import javafx.event.EventHandler; @@ -32,7 +33,7 @@ public class FxEventManager { * The table of event handlers. */ @NotNull - private final ObjectDictionary, Array>> eventHandlers; + private final ObjectDictionary, Array>> eventHandlers; public FxEventManager() { this.eventHandlers = DictionaryFactory.newObjectDictionary(); @@ -45,8 +46,10 @@ public FxEventManager() { * @param eventHandler the event handler. */ @FxThread - public void addEventHandler(@NotNull final EventType eventType, - @NotNull final EventHandler eventHandler) { + public void addEventHandler( + @NotNull EventType eventType, + @NotNull EventHandler eventHandler + ) { getEventHandlers().get(eventType, () -> newArray(EventHandler.class)) .add(eventHandler); } @@ -58,20 +61,21 @@ public void addEventHandler(@NotNull final EventType eventType, * @param eventHandler the event handler. */ @FxThread - public void removeEventHandler(@NotNull final EventType eventType, - @NotNull final EventHandler eventHandler) { - - final Array> handlers = getEventHandlers().get(eventType); - if (handlers != null) { - handlers.slowRemove(eventHandler); - } + public void removeEventHandler( + @NotNull EventType eventType, + @NotNull EventHandler eventHandler + ) { + getEventHandlers().getOptional(eventType) + .ifPresent(handlers -> handlers.slowRemove(eventHandler)); } /** + * Get the table of event handlers. + * * @return the table of event handlers. */ @FxThread - private @NotNull ObjectDictionary, Array>> getEventHandlers() { + private @NotNull ObjectDictionary, Array>> getEventHandlers() { return eventHandlers; } @@ -81,11 +85,11 @@ public void removeEventHandler(@NotNull final EventType eventTy * @param event the new event. */ @FromAnyThread - public void notify(@NotNull final Event event) { + public void notify(@NotNull Event event) { if (Platform.isFxApplicationThread()) { notifyImpl(event); } else { - final ExecutorManager executorManager = ExecutorManager.getInstance(); + var executorManager = ExecutorManager.getInstance(); executorManager.addFxTask(() -> notifyImpl(event)); } } @@ -94,22 +98,23 @@ public void notify(@NotNull final Event event) { * The process of handling a new event. */ @FxThread - private void notifyImpl(@NotNull final Event event) { + private void notifyImpl(@NotNull Event event) { - final ObjectDictionary, Array>> eventHandlers = getEventHandlers(); + var eventHandlers = getEventHandlers(); for (EventType eventType = event.getEventType(); eventType != null; eventType = eventType.getSuperType()) { - final Array> handlers = eventHandlers.get(eventType); + var handlers = eventHandlers.get(eventType); if (handlers == null || handlers.isEmpty()) { continue; } - handlers.forEach(event, EventHandler::handle); + handlers.forEach(event, (handler, toHandle) -> + handler.handle(ClassUtils.unsafeCast(event))); } if (event instanceof ConsumableEvent && !event.isConsumed()) { - final ExecutorManager executorManager = ExecutorManager.getInstance(); + var executorManager = ExecutorManager.getInstance(); executorManager.addFxTask(() -> notifyImpl(event)); } } diff --git a/src/main/java/com/ss/editor/ui/event/SceneEvent.java b/src/main/java/com/ss/editor/ui/event/SceneEvent.java index 2b26af3a..4d497b26 100644 --- a/src/main/java/com/ss/editor/ui/event/SceneEvent.java +++ b/src/main/java/com/ss/editor/ui/event/SceneEvent.java @@ -1,8 +1,8 @@ package com.ss.editor.ui.event; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import javafx.event.Event; import javafx.event.EventType; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/event/impl/AssetComponentLoadedEvent.java b/src/main/java/com/ss/editor/ui/event/impl/AssetComponentLoadedEvent.java index b23e0305..1642f483 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/AssetComponentLoadedEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/AssetComponentLoadedEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; import javafx.event.EventType; @@ -15,11 +15,7 @@ */ public class AssetComponentLoadedEvent extends SceneEvent { - /** - * The constant EVENT_TYPE. - */ - @NotNull - public static final EventType EVENT_TYPE; + public static final EventType EVENT_TYPE; static { synchronized (Event.class) { @@ -29,7 +25,7 @@ public class AssetComponentLoadedEvent extends SceneEvent { private static final String ASSET = "asset"; - public AssetComponentLoadedEvent(@NotNull final Path assetFolder) { + public AssetComponentLoadedEvent(@NotNull Path assetFolder) { super(EVENT_TYPE); setAssetFolder(assetFolder); } @@ -48,7 +44,7 @@ public AssetComponentLoadedEvent(@NotNull final Path assetFolder) { * * @param assetFolder the asset folder. */ - public void setAssetFolder(@NotNull final Path assetFolder) { + public void setAssetFolder(@NotNull Path assetFolder) { set(ASSET, assetFolder); } } diff --git a/src/main/java/com/ss/editor/ui/event/impl/ChangedCurrentAssetFolderEvent.java b/src/main/java/com/ss/editor/ui/event/impl/ChangedCurrentAssetFolderEvent.java index 353b92a4..559d298d 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/ChangedCurrentAssetFolderEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/ChangedCurrentAssetFolderEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; import javafx.event.EventType; diff --git a/src/main/java/com/ss/editor/ui/event/impl/CreatedFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/CreatedFileEvent.java index 79a876aa..e3f8eebe 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/CreatedFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/CreatedFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; import javafx.event.EventType; @@ -15,11 +15,7 @@ */ public class CreatedFileEvent extends SceneEvent { - /** - * The constant EVENT_TYPE. - */ - @NotNull - public static final EventType EVENT_TYPE; + public static final EventType EVENT_TYPE; static { synchronized (Event.class) { @@ -36,7 +32,7 @@ public CreatedFileEvent() { } /** - * Set the need select. + * Set true if need to select a file. * * @param needSelect true if need to select a file. */ @@ -45,7 +41,7 @@ public void setNeedSelect(final boolean needSelect) { } /** - * Is need select boolean. + * Return true if need to select a file. * * @return true if need to select a file. */ @@ -54,16 +50,16 @@ public boolean isNeedSelect() { } /** - * Is directory boolean. + * Return true if it is a directory. * - * @return true if the file is directory. + * @return true if it is a directory. */ public boolean isDirectory() { return get(IS_DIRECTORY) == Boolean.TRUE; } /** - * Gets file. + * Get the new file. * * @return the new file. */ @@ -72,20 +68,20 @@ public boolean isDirectory() { } /** - * Sets file. + * Set the new file. * * @param file the new file. */ - public void setFile(@NotNull final Path file) { + public void setFile(@NotNull Path file) { set(FILE, file); } /** - * Sets directory. + * Set true if it is a directory. * - * @param directory the directory. + * @param directory true if it is a directory. */ - public void setDirectory(final boolean directory) { + public void setDirectory(boolean directory) { set(IS_DIRECTORY, directory); } } diff --git a/src/main/java/com/ss/editor/ui/event/impl/DeletedFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/DeletedFileEvent.java index 2672f54a..9a3cf41b 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/DeletedFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/DeletedFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; import javafx.event.EventType; @@ -15,11 +15,7 @@ */ public class DeletedFileEvent extends SceneEvent { - /** - * The constant EVENT_TYPE. - */ - @NotNull - public static final EventType EVENT_TYPE; + public static final EventType EVENT_TYPE; static { synchronized (Event.class) { @@ -30,9 +26,6 @@ public class DeletedFileEvent extends SceneEvent { private static final String FILE = "file"; private static final String IS_DIRECTORY = "is_directory"; - /** - * Instantiates a new Deleted file event. - */ public DeletedFileEvent() { super(EVENT_TYPE); } @@ -47,7 +40,7 @@ public DeletedFileEvent() { } /** - * Is directory boolean. + * Return true if the file is directory. * * @return true if the file is directory. */ @@ -60,16 +53,16 @@ public boolean isDirectory() { * * @param file the file. */ - public void setFile(@NotNull final Path file) { + public void setFile(@NotNull Path file) { set(FILE, file); } /** - * Set the directory. + * Return true if it is a directory. * - * @param directory the directory. + * @param directory true if it is a directory. */ - public void setDirectory(final boolean directory) { + public void setDirectory(boolean directory) { set(IS_DIRECTORY, directory); } } diff --git a/src/main/java/com/ss/editor/ui/event/impl/FileChangedEvent.java b/src/main/java/com/ss/editor/ui/event/impl/FileChangedEvent.java index 06b9de3d..21c01762 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/FileChangedEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/FileChangedEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; import javafx.event.EventType; @@ -15,11 +15,7 @@ */ public class FileChangedEvent extends SceneEvent { - /** - * The constant EVENT_TYPE. - */ - @NotNull - public static final EventType EVENT_TYPE; + public static final EventType EVENT_TYPE; static { synchronized (Event.class) { @@ -47,7 +43,7 @@ public FileChangedEvent() { * * @param file the file. */ - public void setFile(@NotNull final Path file) { + public void setFile(@NotNull Path file) { set(FILE, file); } } diff --git a/src/main/java/com/ss/editor/ui/event/impl/MovedFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/MovedFileEvent.java index 130d0522..7f5b319b 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/MovedFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/MovedFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; import javafx.event.EventType; diff --git a/src/main/java/com/ss/editor/ui/event/impl/RenamedFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/RenamedFileEvent.java index bd7cbdca..3866c167 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/RenamedFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/RenamedFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; import javafx.event.EventType; diff --git a/src/main/java/com/ss/editor/ui/event/impl/RequestSelectFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/RequestSelectFileEvent.java index 55385b83..e10d0334 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/RequestSelectFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/RequestSelectFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.event.SceneEvent; import javafx.event.EventType; import org.jetbrains.annotations.NotNull; @@ -14,10 +14,7 @@ */ public class RequestSelectFileEvent extends SceneEvent { - /** - * The constant EVENT_TYPE. - */ - public static final EventType EVENT_TYPE; + public static final EventType EVENT_TYPE; static { synchronized (EventType.class) { @@ -45,7 +42,7 @@ public RequestSelectFileEvent() { * * @param file the file. */ - public void setFile(@NotNull final Path file) { + public void setFile(@NotNull Path file) { set(FILE, file); } } diff --git a/src/main/java/com/ss/editor/ui/event/impl/RequestedConvertFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/RequestedConvertFileEvent.java index 47c99370..d81e37bb 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/RequestedConvertFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/RequestedConvertFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.file.converter.FileConverterDescription; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; diff --git a/src/main/java/com/ss/editor/ui/event/impl/RequestedCreateFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/RequestedCreateFileEvent.java index 4d22182e..4711522f 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/RequestedCreateFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/RequestedCreateFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.component.creator.FileCreatorDescription; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; diff --git a/src/main/java/com/ss/editor/ui/event/impl/RequestedOpenFileEvent.java b/src/main/java/com/ss/editor/ui/event/impl/RequestedOpenFileEvent.java index 022732e6..224a5240 100644 --- a/src/main/java/com/ss/editor/ui/event/impl/RequestedOpenFileEvent.java +++ b/src/main/java/com/ss/editor/ui/event/impl/RequestedOpenFileEvent.java @@ -1,6 +1,6 @@ package com.ss.editor.ui.event.impl; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.ui.component.editor.EditorDescription; import com.ss.editor.ui.event.SceneEvent; import javafx.event.Event; @@ -28,20 +28,11 @@ public class RequestedOpenFileEvent extends SceneEvent { } } - /** - * The constant EDITOR. - */ - public static final String EDITOR = "editor"; - + private static final String EDITOR = "editor"; private static final String FILE = "file"; private static final String NEED_SHOW = "need_show"; - public RequestedOpenFileEvent() { - super(EVENT_TYPE); - setNeedShow(true); - } - - public RequestedOpenFileEvent(@NotNull final Path file) { + public RequestedOpenFileEvent(@NotNull Path file) { super(EVENT_TYPE); setNeedShow(true); setFile(file); @@ -61,7 +52,7 @@ public RequestedOpenFileEvent(@NotNull final Path file) { * * @param description the editor descriptor. */ - public void setDescription(@Nullable final EditorDescription description) { + public void setDescription(@Nullable EditorDescription description) { if (description == null) { remove(EDITOR); } else { @@ -83,12 +74,12 @@ public void setDescription(@Nullable final EditorDescription description) { * * @param file the file to open. */ - public void setFile(final Path file) { + public void setFile(@NotNull Path file) { set(FILE, file); } /** - * Is need show boolean. + * Return true if need to show the editor. * * @return true if need to show the editor. */ @@ -97,11 +88,11 @@ public boolean isNeedShow() { } /** - * Set the need show. + * Set true if need to show the editor. * * @param needShow true if need to show the editor. */ - public void setNeedShow(final boolean needShow) { + public void setNeedShow(boolean needShow) { set(NEED_SHOW, needShow); } } diff --git a/src/main/java/com/ss/editor/ui/preview/FilePreview.java b/src/main/java/com/ss/editor/ui/preview/FilePreview.java index 930567b1..f2467736 100644 --- a/src/main/java/com/ss/editor/ui/preview/FilePreview.java +++ b/src/main/java/com/ss/editor/ui/preview/FilePreview.java @@ -1,9 +1,9 @@ package com.ss.editor.ui.preview; import com.ss.editor.annotation.FxThread; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.pools.Reusable; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.pools.Reusable; import javafx.scene.layout.StackPane; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/preview/FilePreviewFactory.java b/src/main/java/com/ss/editor/ui/preview/FilePreviewFactory.java index 7ba5fe2f..96eb8825 100644 --- a/src/main/java/com/ss/editor/ui/preview/FilePreviewFactory.java +++ b/src/main/java/com/ss/editor/ui/preview/FilePreviewFactory.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.preview; import com.ss.editor.annotation.FxThread; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/ui/preview/FilePreviewFactoryRegistry.java b/src/main/java/com/ss/editor/ui/preview/FilePreviewFactoryRegistry.java index 93925d23..159e882c 100644 --- a/src/main/java/com/ss/editor/ui/preview/FilePreviewFactoryRegistry.java +++ b/src/main/java/com/ss/editor/ui/preview/FilePreviewFactoryRegistry.java @@ -3,10 +3,10 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.preview.impl.DefaultFilePreviewFactory; -import com.ss.rlib.util.ArrayUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.array.ConcurrentArray; +import com.ss.rlib.common.util.ArrayUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.array.ConcurrentArray; import org.jetbrains.annotations.NotNull; import java.util.Collection; diff --git a/src/main/java/com/ss/editor/ui/preview/impl/AbstractFilePreview.java b/src/main/java/com/ss/editor/ui/preview/impl/AbstractFilePreview.java index 0a5450bc..7a7f6c1f 100644 --- a/src/main/java/com/ss/editor/ui/preview/impl/AbstractFilePreview.java +++ b/src/main/java/com/ss/editor/ui/preview/impl/AbstractFilePreview.java @@ -2,7 +2,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.preview.FilePreview; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.Node; import javafx.scene.layout.StackPane; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/preview/impl/DefaultFilePreviewFactory.java b/src/main/java/com/ss/editor/ui/preview/impl/DefaultFilePreviewFactory.java index 9ed1f024..d38e7561 100644 --- a/src/main/java/com/ss/editor/ui/preview/impl/DefaultFilePreviewFactory.java +++ b/src/main/java/com/ss/editor/ui/preview/impl/DefaultFilePreviewFactory.java @@ -3,7 +3,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.preview.FilePreview; import com.ss.editor.ui.preview.FilePreviewFactory; -import com.ss.rlib.util.array.Array; +import com.ss.rlib.common.util.array.Array; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/ui/preview/impl/TextFilePreview.java b/src/main/java/com/ss/editor/ui/preview/impl/TextFilePreview.java index 19f80b1b..dac5203a 100644 --- a/src/main/java/com/ss/editor/ui/preview/impl/TextFilePreview.java +++ b/src/main/java/com/ss/editor/ui/preview/impl/TextFilePreview.java @@ -4,9 +4,9 @@ import com.ss.editor.manager.ResourceManager; import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.EditorUtil; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.Utils; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.Utils; import javafx.scene.control.TextArea; import javafx.scene.layout.StackPane; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/scene/EditorFxScene.java b/src/main/java/com/ss/editor/ui/scene/EditorFxScene.java index 5b4c4b14..9ce78aaf 100644 --- a/src/main/java/com/ss/editor/ui/scene/EditorFxScene.java +++ b/src/main/java/com/ss/editor/ui/scene/EditorFxScene.java @@ -1,18 +1,18 @@ package com.ss.editor.ui.scene; import static com.ss.editor.ui.util.UiUtils.fillComponents; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import com.jme3x.jfx.injfx.input.JFXMouseInput; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; +import com.jme3.jfx.injfx.input.JfxMouseInput; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.manager.InitializationManager; import com.ss.editor.ui.component.ScreenComponent; import com.ss.editor.ui.css.CssIds; -import com.ss.rlib.ui.util.FXUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import javafx.collections.ObservableList; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.fx.util.FXUtils; +import com.ss.rlib.fx.util.FxUtils; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; @@ -33,7 +33,6 @@ */ public class EditorFxScene extends Scene { - @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); /** @@ -84,13 +83,13 @@ public class EditorFxScene extends Scene { @Nullable private Node focused; - public EditorFxScene(@NotNull final Group root) { + public EditorFxScene(@NotNull Group root) { super(root); this.canvas = new EditorFxImageView(); this.canvas.setMouseTransparent(true); this.canvas.getProperties() - .put(JFXMouseInput.PROP_USE_LOCAL_COORDS, true); + .put(JfxMouseInput.PROP_USE_LOCAL_COORDS, true); this.loadingCount = new AtomicInteger(); this.components = ArrayFactory.newArraySet(ScreenComponent.class); @@ -103,12 +102,10 @@ public EditorFxScene(@NotNull final Group root) { this.loadingLayer.setId(CssIds.EDITOR_LOADING_LAYER); this.loadingLayer.setVisible(false); - final Pane background = new Pane(); + var background = new Pane(); background.setId(CssIds.ROOT); - FXUtils.addDebugBorderTo(canvas); - - root.getChildren().addAll(hideLayer, background, container, loadingLayer); + FxUtils.addChild(root, hideLayer, background, container, loadingLayer); FXUtils.bindFixedWidth(background, widthProperty()); FXUtils.bindFixedHeight(background, heightProperty()); @@ -137,8 +134,10 @@ public EditorFxScene(@NotNull final Group root) { @FxThread public void hideCanvas() { - final ObservableList children = hideLayer.getChildren(); - if (children.contains(canvas)) return; + var children = hideLayer.getChildren(); + if (children.contains(canvas)) { + return; + } children.add(canvas); } @@ -151,14 +150,14 @@ public void hideCanvas() { * @return the component or null. */ @FxThread - public @Nullable T findComponent(@NotNull final String id) { - final Array components = getComponents(); + public @Nullable T findComponent(@NotNull String id) { + var components = getComponents(); return unsafeCast(components.search(id, (component, toCheck) -> StringUtils.equals(toCheck, component.getComponentId()))); } /** - * Gets components. + * Gets the list of components. * * @return the list of components. */ @@ -168,7 +167,7 @@ public void hideCanvas() { } /** - * Get the container. + * Get the container of this scene. * * @return the container of this scene. */ @@ -224,16 +223,17 @@ public synchronized void decrementLoading() { private void showLoading() { focused = getFocusOwner(); - final VBox loadingLayer = getLoadingLayer(); + var loadingLayer = getLoadingLayer(); loadingLayer.setVisible(true); + loadingLayer.setManaged(true); loadingLayer.toFront(); progressIndicator = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); progressIndicator.setId(CssIds.EDITOR_LOADING_PROGRESS); - FXUtils.addToPane(progressIndicator, loadingLayer); + FxUtils.addChild(loadingLayer, progressIndicator); - final StackPane container = getContainer(); + var container = getContainer(); container.setDisable(true); } @@ -243,13 +243,14 @@ private void showLoading() { @FxThread private void hideLoading() { - final VBox loadingLayer = getLoadingLayer(); + var loadingLayer = getLoadingLayer(); loadingLayer.setVisible(false); + loadingLayer.setManaged(false); loadingLayer.getChildren().clear(); progressIndicator = null; - final StackPane container = getContainer(); + var container = getContainer(); container.setDisable(false); if (focused != null) { @@ -266,11 +267,11 @@ private void hideLoading() { @FxThread public void notifyFinishBuild() { - final Array components = getComponents(); + var components = getComponents(); fillComponents(components, getContainer()); components.forEach(ScreenComponent::notifyFinishBuild); - final InitializationManager initializationManager = InitializationManager.getInstance(); + var initializationManager = InitializationManager.getInstance(); initializationManager.onFinishLoading(); } } diff --git a/src/main/java/com/ss/editor/ui/tooltip/CustomTooltip.java b/src/main/java/com/ss/editor/ui/tooltip/CustomTooltip.java index 02f42c96..959e16f8 100644 --- a/src/main/java/com/ss/editor/ui/tooltip/CustomTooltip.java +++ b/src/main/java/com/ss/editor/ui/tooltip/CustomTooltip.java @@ -2,7 +2,7 @@ import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.Scene; import javafx.scene.control.Tooltip; import javafx.scene.layout.Region; diff --git a/src/main/java/com/ss/editor/ui/tooltip/ImageChannelPreview.java b/src/main/java/com/ss/editor/ui/tooltip/ImageChannelPreview.java index 5e74988d..048a929d 100644 --- a/src/main/java/com/ss/editor/ui/tooltip/ImageChannelPreview.java +++ b/src/main/java/com/ss/editor/ui/tooltip/ImageChannelPreview.java @@ -1,10 +1,10 @@ package com.ss.editor.ui.tooltip; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.JavaFxImageManager; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.image.*; import javafx.scene.layout.GridPane; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/ss/editor/ui/tooltip/ImagePreview.java b/src/main/java/com/ss/editor/ui/tooltip/ImagePreview.java index d0b8b609..fc6be478 100644 --- a/src/main/java/com/ss/editor/ui/tooltip/ImagePreview.java +++ b/src/main/java/com/ss/editor/ui/tooltip/ImagePreview.java @@ -1,10 +1,10 @@ package com.ss.editor.ui.tooltip; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.JavaFxImageManager; import com.ss.editor.ui.css.CssClasses; -import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.fx.util.FXUtils; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; import javafx.stage.Window; diff --git a/src/main/java/com/ss/editor/ui/util/AwtFontSuggestionProvider.java b/src/main/java/com/ss/editor/ui/util/AwtFontSuggestionProvider.java new file mode 100644 index 00000000..e4cabd03 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/util/AwtFontSuggestionProvider.java @@ -0,0 +1,61 @@ +package com.ss.editor.ui.util; + +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayCollectors; +import com.ss.rlib.common.util.array.ArrayFactory; +import javafx.util.Callback; +import org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +/** + * The suggestion provider's implementation to provide available fonts. + * + * @author JavaSaBr + */ +public class AwtFontSuggestionProvider implements Callback> { + + private final Array options; + private final Array lowerCaseOptions; + + public AwtFontSuggestionProvider(@NotNull Collection options) { + this.options = ArrayFactory.newArray(Font.class, options.size()); + this.options.addAll(options); + this.lowerCaseOptions = options.stream() + .map(Font::getFontName) + .map(String::toLowerCase) + .collect(ArrayCollectors.toArray(String.class)); + } + + @Override + public Collection call(@NotNull ISuggestionRequest request) { + + var userText = request.getUserText(); + + if (StringUtils.isEmpty(userText)) { + return Collections.emptyList(); + } + + var lowerInput = userText.toLowerCase(); + + var result = new ArrayList(); + + for (int i = 0; i < lowerCaseOptions.size(); i++) { + + var original = options.get(i); + var fontName = original.getFontName(); + var lowerCase = lowerCaseOptions.get(i); + + if (!fontName.equals(userText) && lowerCase.contains(lowerInput)) { + result.add(original); + } + } + + return result; + } +} diff --git a/src/main/java/com/ss/editor/ui/util/SimpleStringSuggestionProvider.java b/src/main/java/com/ss/editor/ui/util/SimpleStringSuggestionProvider.java new file mode 100644 index 00000000..13c2f386 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/util/SimpleStringSuggestionProvider.java @@ -0,0 +1,58 @@ +package com.ss.editor.ui.util; + +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayCollectors; +import com.ss.rlib.common.util.array.ArrayFactory; +import javafx.util.Callback; +import org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +/** + * The simple suggestion provider's implementation. + * + * @author JavaSaBr + */ +public class SimpleStringSuggestionProvider implements Callback> { + + private final Array options; + private final Array lowerCaseOptions; + + public SimpleStringSuggestionProvider(@NotNull Collection options) { + this.options = ArrayFactory.newArray(String.class, options.size()); + this.options.addAll(options); + this.lowerCaseOptions = options.stream() + .map(String::toLowerCase) + .collect(ArrayCollectors.toArray(String.class)); + } + + @Override + public Collection call(@NotNull ISuggestionRequest request) { + + var userText = request.getUserText(); + + if (StringUtils.isEmpty(userText)) { + return Collections.emptyList(); + } + + var lowerInput = userText.toLowerCase(); + + var result = new ArrayList(); + + for (int i = 0; i < lowerCaseOptions.size(); i++) { + + var original = options.get(i); + var lowerCase = lowerCaseOptions.get(i); + + if (!original.equals(userText) && lowerCase.contains(lowerInput)) { + result.add(original); + } + } + + return result; + } +} diff --git a/src/main/java/com/ss/editor/ui/util/UiUtils.java b/src/main/java/com/ss/editor/ui/util/UiUtils.java index 6287a0ea..ef4d2d39 100644 --- a/src/main/java/com/ss/editor/ui/util/UiUtils.java +++ b/src/main/java/com/ss/editor/ui/util/UiUtils.java @@ -1,7 +1,7 @@ package com.ss.editor.ui.util; import static com.ss.editor.util.EditorUtil.getFxScene; -import static com.ss.rlib.util.ClassUtils.unsafeCast; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import static java.lang.Math.min; import com.jme3.math.ColorRGBA; import com.ss.editor.annotation.FromAnyThread; @@ -13,10 +13,10 @@ import com.ss.editor.ui.dialog.asset.file.FolderAssetEditorDialog; import com.ss.editor.ui.dialog.asset.virtual.StringVirtualAssetEditorDialog; import com.ss.editor.ui.dialog.save.SaveAsEditorDialog; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanPropertyBase; import javafx.beans.value.ChangeListener; @@ -40,6 +40,7 @@ import java.io.File; import java.nio.file.Path; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.Set; @@ -47,6 +48,7 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; +import java.util.stream.Stream; /** * The utility class with utility UI methods. @@ -74,9 +76,9 @@ public abstract class UiUtils { * @param controls the controls. */ @FxThread - public static void addFocusBinding(@NotNull final Pane pane, @NotNull final Control... controls) { + public static @NotNull BooleanProperty addFocusBinding(@NotNull Pane pane, @NotNull Control... controls) { - final BooleanProperty focused = new BooleanPropertyBase(false) { + var focused = new BooleanPropertyBase(true) { @Override public void invalidated() { @@ -94,23 +96,20 @@ public String getName() { } }; - final ChangeListener listener = (observable, oldValue, newValue) -> { - - boolean result = newValue; - - if (!result) { - for (final Control control : controls) { - result = control.isFocused(); - if (result) break; - } - } - - focused.setValue(result); + ChangeListener listener = (observable, oldValue, newValue) -> { + focused.setValue(newValue || Arrays.stream(controls) + .anyMatch(Node::isFocused)); }; - for (final Control control : controls) { + for (var control : controls) { control.focusedProperty().addListener(listener); + control.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> control.requestFocus()); } + + focused.setValue(Arrays.stream(controls) + .anyMatch(Node::isFocused)); + + return focused; } /** @@ -442,12 +441,26 @@ public static boolean visitUntil(@NotNull final TreeItem item, * @return the list with all items. */ @FxThread - public static Array> getAllItems(@NotNull final TreeItem root) { + public static Array> getAllItems(@NotNull TreeItem root) { final Array> container = ArrayFactory.newArray(TreeItem.class); collectAllItems(container, root); return container; } + /** + * Collect all elements of tree items. + * + * @param the type parameter + * @param root the tree item. + * @return the list with all items. + */ + @FxThread + public static Stream> allItems(@NotNull TreeItem root) { + Array> container = ArrayFactory.newArray(TreeItem.class); + collectAllItems(container, root); + return container.stream(); + } + /** * Collect all elements of tree items. * diff --git a/src/main/java/com/ss/editor/util/AnimationUtils.java b/src/main/java/com/ss/editor/util/AnimationUtils.java index 5529f3c1..cc02c342 100644 --- a/src/main/java/com/ss/editor/util/AnimationUtils.java +++ b/src/main/java/com/ss/editor/util/AnimationUtils.java @@ -1,6 +1,5 @@ package com.ss.editor.util; -import static com.ss.rlib.util.ClassUtils.unsafeCast; import com.jme3.animation.AnimControl; import com.jme3.animation.Animation; import com.jme3.animation.BoneTrack; @@ -8,8 +7,8 @@ import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.ClassUtils; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -34,7 +33,7 @@ public class AnimationUtils { ANIMATIONS_MAP_FIELD = AnimControl.class.getDeclaredField("animationMap"); ANIMATIONS_MAP_FIELD.setAccessible(true); - } catch (final NoSuchFieldException e) { + } catch (NoSuchFieldException e) { throw new RuntimeException(e); } } @@ -49,18 +48,22 @@ public class AnimationUtils { * @return the new sub animation. */ @FromAnyThread - public static @NotNull Animation extractAnimation(@NotNull final Animation source, @NotNull final String newName, - final int startFrame, final int endFrame) { - - final Track[] sourceTracks = source.getTracks(); - final BoneTrack firstSourceTrack = (BoneTrack) sourceTracks[0]; - final float[] sourceTimes = firstSourceTrack.getTimes(); - - final float newLength = (source.getLength() / (float) sourceTimes.length) * (float) (endFrame - startFrame); - final Animation result = new Animation(newName, newLength); - final Array newTracks = ArrayFactory.newArray(Track.class); - - for (final Track sourceTrack : sourceTracks) { + public static @NotNull Animation extractAnimation( + @NotNull Animation source, + @NotNull String newName, + int startFrame, + int endFrame + ) { + + var sourceTracks = source.getTracks(); + var firstSourceTrack = (BoneTrack) sourceTracks[0]; + var sourceTimes = firstSourceTrack.getTimes(); + + var newLength = (source.getLength() / (float) sourceTimes.length) * (float) (endFrame - startFrame); + var result = new Animation(newName, newLength); + var newTracks = ArrayFactory.newArray(Track.class); + + for (var sourceTrack : sourceTracks) { if (sourceTrack instanceof BoneTrack) { newTracks.add(extractBoneTrack((BoneTrack) sourceTrack, startFrame, endFrame)); } @@ -79,22 +82,22 @@ public class AnimationUtils { * @param endFrame the end frame. * @return the extracted bone track. */ - private static @NotNull BoneTrack extractBoneTrack(@NotNull final BoneTrack boneTrack, final int startFrame, - final int endFrame) { + @FromAnyThread + private static @NotNull BoneTrack extractBoneTrack(@NotNull BoneTrack boneTrack, int startFrame, int endFrame) { - final float[] sourceTimes = boneTrack.getTimes(); + var sourceTimes = boneTrack.getTimes(); - final Vector3f[] newTranslations = new Vector3f[endFrame - startFrame]; - final Quaternion[] newRotations = new Quaternion[endFrame - startFrame]; - final Vector3f[] newScales = new Vector3f[endFrame - startFrame]; - final float[] newTimes = new float[endFrame - startFrame]; + var newTranslations = new Vector3f[endFrame - startFrame]; + var newRotations = new Quaternion[endFrame - startFrame]; + var newScales = new Vector3f[endFrame - startFrame]; + var newTimes = new float[endFrame - startFrame]; for (int i = startFrame; i < endFrame; i++) { - final int newFrame = i - startFrame; - final Vector3f sourceTranslation = boneTrack.getTranslations()[i]; - final Vector3f sourceScale = boneTrack.getScales()[i]; - final Quaternion sourceRotation = boneTrack.getRotations()[i]; + var newFrame = i - startFrame; + var sourceTranslation = boneTrack.getTranslations()[i]; + var sourceScale = boneTrack.getScales()[i]; + var sourceRotation = boneTrack.getRotations()[i]; newTimes[newFrame] = sourceTimes[i] - sourceTimes[startFrame]; newTranslations[newFrame] = sourceTranslation.clone(); @@ -102,7 +105,8 @@ public class AnimationUtils { newScales[newFrame] = sourceScale.clone(); } - return new BoneTrack(boneTrack.getTargetBoneIndex(), newTimes, newTranslations, newRotations, newScales); + return new BoneTrack(boneTrack.getTargetBoneIndex(), newTimes, + newTranslations, newRotations, newScales); } /** @@ -114,11 +118,15 @@ public class AnimationUtils { * @param newName the new name. */ @FromAnyThread - public static void changeName(@NotNull final AnimControl control, @NotNull final Animation animation, - @NotNull final String oldName, @NotNull final String newName) { + public static void changeName( + @NotNull AnimControl control, + @NotNull Animation animation, + @NotNull String oldName, + @NotNull String newName + ) { try { - final Map animationMap = unsafeCast(ANIMATIONS_MAP_FIELD.get(control)); + var animationMap = ClassUtils.>unsafeCast(ANIMATIONS_MAP_FIELD.get(control)); if (!animationMap.containsKey(oldName)) { throw new IllegalArgumentException("Given animation does not exist " + "in this AnimControl"); @@ -133,7 +141,7 @@ public static void changeName(@NotNull final AnimControl control, @NotNull final animationMap.remove(oldName); animationMap.put(newName, animation); - } catch (final IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); } } @@ -145,12 +153,12 @@ public static void changeName(@NotNull final AnimControl control, @NotNull final * @return the frame count or -1. */ @FromAnyThread - public static int getFrameCount(@NotNull final Animation animation) { + public static int getFrameCount(@NotNull Animation animation) { - int min = Integer.MAX_VALUE; + var min = Integer.MAX_VALUE; - final Track[] tracks = animation.getTracks(); - for (final Track track : tracks) { + var tracks = animation.getTracks(); + for (var track : tracks) { if (track instanceof BoneTrack) { min = Math.min(min, ((BoneTrack) track).getTimes().length); } @@ -167,7 +175,7 @@ public static int getFrameCount(@NotNull final Animation animation) { * @return the free name. */ @FromAnyThread - public static @NotNull String findFreeName(@NotNull final AnimControl control, @NotNull final String base) { + public static @NotNull String findFreeName(@NotNull AnimControl control, @NotNull String base) { if (control.getAnim(base) == null) { return base; diff --git a/src/main/java/com/ss/editor/util/AudioNodeUtils.java b/src/main/java/com/ss/editor/util/AudioNodeUtils.java index fa14b8f8..253cb5ae 100644 --- a/src/main/java/com/ss/editor/util/AudioNodeUtils.java +++ b/src/main/java/com/ss/editor/util/AudioNodeUtils.java @@ -3,9 +3,8 @@ import com.jme3.audio.AudioData; import com.jme3.audio.AudioKey; import com.jme3.audio.AudioNode; -import com.ss.editor.annotation.JmeThread; import com.ss.editor.annotation.FromAnyThread; - +import com.ss.editor.annotation.JmeThread; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,10 +17,7 @@ */ public class AudioNodeUtils { - @NotNull private static final Field AUDIO_DATA_FIELD; - - @NotNull private static final Field AUDIO_KEY_FIELD; static { @@ -33,7 +29,7 @@ public class AudioNodeUtils { AUDIO_DATA_FIELD = AudioNode.class.getDeclaredField("data"); AUDIO_DATA_FIELD.setAccessible(true); - } catch (final NoSuchFieldException e) { + } catch (NoSuchFieldException e) { throw new RuntimeException(e); } } @@ -46,12 +42,15 @@ public class AudioNodeUtils { * @param audioKey the audio key. */ @JmeThread - public static void updateData(@NotNull final AudioNode audioNode, @Nullable final AudioData audioData, - @Nullable final AudioKey audioKey) { + public static void updateData( + @NotNull AudioNode audioNode, + @Nullable AudioData audioData, + @Nullable AudioKey audioKey + ) { try { AUDIO_DATA_FIELD.set(audioNode, audioData); AUDIO_KEY_FIELD.set(audioNode, audioKey); - } catch (final IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); } } @@ -63,10 +62,10 @@ public static void updateData(@NotNull final AudioNode audioNode, @Nullable fina * @return the audio key. */ @FromAnyThread - public static @Nullable AudioKey getAudioKey(@NotNull final AudioNode audioNode) { + public static @Nullable AudioKey getAudioKey(@NotNull AudioNode audioNode) { try { return (AudioKey) AUDIO_KEY_FIELD.get(audioNode); - } catch (final IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); } } diff --git a/src/main/java/com/ss/editor/util/ControlUtils.java b/src/main/java/com/ss/editor/util/ControlUtils.java index 0772c5bd..897b5477 100644 --- a/src/main/java/com/ss/editor/util/ControlUtils.java +++ b/src/main/java/com/ss/editor/util/ControlUtils.java @@ -10,7 +10,6 @@ import com.jme3.bullet.objects.PhysicsRigidBody; import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; import com.jme3.scene.control.Control; @@ -37,14 +36,14 @@ public class ControlUtils { * @return the control's stream. */ @FromAnyThread - public static boolean has(@NotNull final Spatial spatial, @NotNull final Class type) { + public static boolean has(@NotNull Spatial spatial, @NotNull Class type) { - final int numControls = spatial.getNumControls(); + var numControls = spatial.getNumControls(); if (numControls < 1) { return false; } - for (int i = 0; i < numControls; i++) { + for (var i = 0; i < numControls; i++) { if (type.isInstance(spatial.getControl(i))) { return true; } @@ -60,15 +59,15 @@ public static boolean has(@NotNull final Spatial spatial, @NotNull final Class controls(@NotNull final Spatial spatial) { + public static @NotNull Stream controls(@NotNull Spatial spatial) { - final int numControls = spatial.getNumControls(); + var numControls = spatial.getNumControls(); if (numControls < 1) { return Stream.empty(); } - final Control[] controls = new Control[numControls]; - for (int i = 0; i < numControls; i++) { + var controls = new Control[numControls]; + for (var i = 0; i < numControls; i++) { controls[i] = spatial.getControl(i); } @@ -82,7 +81,7 @@ public static boolean has(@NotNull final Spatial spatial, @NotNull final Class LOCATE_DATE_FORMAT = withInitial(() -> new SimpleDateFormat("HH:mm:ss:SSS")); - @NotNull - private static JmeApplication jmeApplication; + private static ThreadLocal, Enum[]>> ENUM_VALUES_LOCAL = + ThreadLocal.withInitial(DictionaryFactory::newObjectDictionary); - @NotNull + private static JmeApplication jmeApplication; private static JfxApplication jfxApplication; - public static void setJmeApplication(@NotNull final JmeApplication jmeApplication) { + public static void setJmeApplication(@NotNull JmeApplication jmeApplication) { EditorUtil.jmeApplication = jmeApplication; } - public static void setJfxApplication(@NotNull final JfxApplication jfxApplication) { + public static void setJfxApplication(@NotNull JfxApplication jfxApplication) { EditorUtil.jfxApplication = jfxApplication; } @@ -222,7 +220,7 @@ public static void enableGlobalLightProbe() { * @param progressAdapter the progress adapter */ @JmeThread - public static void updateGlobalLightProbe(@NotNull final JobProgressAdapter progressAdapter) { + public static void updateGlobalLightProbe(@NotNull JobProgressAdapter progressAdapter) { jmeApplication.updateLightProbe(progressAdapter); } @@ -256,6 +254,16 @@ public static void updateGlobalLightProbe(@NotNull final JobProgressAdapter paths, @NotNull final ClipboardContent content) { + public static @NotNull ClipboardContent addCopiedFile( + @NotNull Array paths, + @NotNull ClipboardContent content + ) { - final List files = paths.stream() + var files = paths.stream() .map(Path::toFile) .collect(toList()); content.putFiles(files); content.put(EditorUtil.JAVA_PARAM, "copy"); - final Platform platform = JmeSystem.getPlatform(); + var platform = JmeSystem.getPlatform(); if (platform == Platform.Linux64 || platform == Platform.Linux32) { - final StringBuilder builder = new StringBuilder("copy\n"); + var builder = new StringBuilder("copy\n"); paths.forEach(builder, (path, b) -> b.append(path.toUri().toASCIIString()).append('\n')); builder.delete(builder.length() - 1, builder.length()); - final ByteBuffer buffer = ByteBuffer.allocate(builder.length()); + var buffer = ByteBuffer.allocate(builder.length()); for (int i = 0, length = builder.length(); i < length; i++) { buffer.put((byte) builder.charAt(i)); @@ -331,6 +342,8 @@ public static void addCopiedFile(@NotNull final Array paths, @NotNull fina content.put(GNOME_FILES, buffer); } + + return content; } /** @@ -340,8 +353,8 @@ public static void addCopiedFile(@NotNull final Array paths, @NotNull fina * @return true if the resource is exists. */ @FromAnyThread - public static boolean checkExists(@NotNull final String path) { - final Class cs = EditorUtil.class; + public static boolean checkExists(@NotNull String path) { + var cs = EditorUtil.class; return cs.getResource(path) != null || cs.getResource("/" + path) != null; } @@ -353,7 +366,7 @@ public static boolean checkExists(@NotNull final String path) { * @return true if the resource is exists. */ @FromAnyThread - public static boolean checkExists(@NotNull final String path, @NotNull final ClassLoader classLoader) { + public static boolean checkExists(@NotNull String path, @NotNull ClassLoader classLoader) { return classLoader.getResource(path) != null || classLoader.getResource("/" + path) != null; } @@ -365,13 +378,13 @@ public static boolean checkExists(@NotNull final String path, @NotNull final Cla * @return the external form or null. */ @FromAnyThread - public static @Nullable String toExternal(@NotNull final String path, @NotNull final ClassLoader classLoader) { + public static @Nullable String toExternal(@NotNull String path, @NotNull ClassLoader classLoader) { if (!checkExists(path, classLoader)) { return null; } - URL resource = classLoader.getResource(path); + var resource = classLoader.getResource(path); if (resource == null) { resource = classLoader.getResource("/" + path); } @@ -388,18 +401,21 @@ public static boolean checkExists(@NotNull final String path, @NotNull final Cla * @return the angle between these points. */ @FromAnyThread - public static float getAngle(@NotNull final Vector2f center, @NotNull final Vector2f first, - @NotNull final Vector2f second) { + public static float getAngle( + @NotNull Vector2f center, + @NotNull Vector2f first, + @NotNull Vector2f second + ) { - final float x = center.getX(); - final float y = center.getY(); + var x = center.getX(); + var y = center.getY(); - final float ax = first.getX() - x; - final float ay = first.getY() - y; - final float bx = second.getX() - x; - final float by = second.getY() - y; + var ax = first.getX() - x; + var ay = first.getY() - y; + var bx = second.getX() - x; + var by = second.getY() - y; - final float delta = (float) ((ax * bx + ay * by) / Math.sqrt((ax * ax + ay * ay) * (bx * bx + by * by))); + var delta = (float) ((ax * bx + ay * by) / Math.sqrt((ax * ax + ay * ay) * (bx * bx + by * by))); if (delta > 1.0) { return 0.0F; @@ -411,25 +427,36 @@ public static float getAngle(@NotNull final Vector2f center, @NotNull final Vect } /** - * Gets input stream. + * Get an input stream. * * @param path the path to resource. * @return the input stream of the resource or null. */ @FromAnyThread - public static @Nullable InputStream getInputStream(@NotNull final String path) { + public static @Nullable InputStream getInputStream(@NotNull String path) { return JfxApplication.class.getResourceAsStream(path); } /** - * Gets input stream. + * Get an input stream or throw an exception. + * + * @param path the path to resource. + * @return the input stream of the resource or null. + */ + @FromAnyThread + public static @NotNull InputStream requireInputStream(@NotNull String path) { + return notNull(JfxApplication.class.getResourceAsStream(path)); + } + + /** + * Get the input stream. * * @param path the path to resource. * @param classLoader the class loader. * @return the input stream of the resource or null. */ @FromAnyThread - public static @Nullable InputStream getInputStream(@NotNull final String path, @NotNull final ClassLoader classLoader) { + public static @Nullable InputStream getInputStream(@NotNull String path, @NotNull ClassLoader classLoader) { return classLoader.getResourceAsStream(path); } @@ -451,15 +478,15 @@ public static float getAngle(@NotNull final Vector2f center, @NotNull final Vect * @return true of we can see the position on the screen. */ @FromAnyThread - public static boolean isVisibleOnScreen(@NotNull final Vector3f position, @NotNull final Camera camera) { + public static boolean isVisibleOnScreen(@NotNull Vector3f position, @NotNull Camera camera) { - final int maxHeight = camera.getHeight(); - final int maxWidth = camera.getWidth(); + var maxHeight = camera.getHeight(); + var maxWidth = camera.getWidth(); - final boolean isBottom = position.getY() < 0; - final boolean isTop = position.getY() > maxHeight; - final boolean isLeft = position.getX() < 0; - final boolean isRight = position.getX() > maxWidth; + var isBottom = position.getY() < 0; + var isTop = position.getY() > maxHeight; + var isLeft = position.getX() < 0; + var isRight = position.getX() > maxWidth; return !isBottom && !isLeft && !isTop && !isRight && position.getZ() < 1F; } @@ -473,8 +500,12 @@ public static boolean isVisibleOnScreen(@NotNull final Vector3f position, @NotNu * @param length the distance. */ @FromAnyThread - public static void movePoint(@NotNull final Vector3f first, @NotNull final Vector3f second, - @NotNull final Vector3f store, final int length) { + public static void movePoint( + @NotNull Vector3f first, + @NotNull Vector3f second, + @NotNull Vector3f store, + int length + ) { store.x = first.x + (second.x - first.x) * length; store.y = first.y + (second.y - first.y) * length; store.z = first.z + (second.z - first.z) * length; @@ -487,8 +518,8 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto * @return the string presentation. */ @FromAnyThread - public static @NotNull String timeFormat(final long time) { - final SimpleDateFormat format = LOCATE_DATE_FORMAT.get(); + public static @NotNull String timeFormat(long time) { + var format = LOCATE_DATE_FORMAT.get(); return format.format(new Date(time)); } @@ -500,7 +531,7 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto * @return the relative path. */ @FromAnyThread - public static @NotNull Path getAssetFile(@NotNull final Path assetFolder, @NotNull final Path file) { + public static @NotNull Path getAssetFile(@NotNull Path assetFolder, @NotNull Path file) { return assetFolder.relativize(file); } @@ -511,17 +542,17 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto * @return the relative path. */ @FromAnyThread - public static @Nullable Path getAssetFile(@NotNull final Path file) { + public static @Nullable Path getAssetFile(@NotNull Path file) { - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); if (currentAsset == null) { return null; } try { return currentAsset.relativize(file); - } catch (final IllegalArgumentException e) { + } catch (IllegalArgumentException e) { LOGGER.warning("Can't create asset file of the " + file + " for asset folder " + currentAsset); LOGGER.warning(e); return null; @@ -535,10 +566,14 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto * @return the absolute path to the file. */ @FromAnyThread - public static @Nullable Path getRealFile(@NotNull final Path assetFile) { - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); - if (currentAsset == null) return null; + public static @Nullable Path getRealFile(@NotNull Path assetFile) { + + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); + if (currentAsset == null) { + return null; + } + return currentAsset.resolve(assetFile); } @@ -549,10 +584,14 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto * @return the absolute path to the file. */ @FromAnyThread - public static @Nullable Path getRealFile(@NotNull final String assetFile) { - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); - if (currentAsset == null) return null; + public static @Nullable Path getRealFile(@NotNull String assetFile) { + + var editorConfig = EditorConfig.getInstance(); + var currentAsset = editorConfig.getCurrentAsset(); + if (currentAsset == null) { + return null; + } + return currentAsset.resolve(assetFile); } @@ -563,35 +602,43 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto * @return the valid asset path for the file. */ @FromAnyThread - public static @NotNull String toAssetPath(@NotNull final Path path) { - if (File.separatorChar == '/') return path.toString(); + public static @NotNull String toAssetPath(@NotNull Path path) { + + if (File.separatorChar == '/') { + return path.toString(); + } + return path.toString().replace("\\", "/"); } /** * Handle exception. * - * @param logger the logger - * @param owner the owner - * @param e the e + * @param logger the logger. + * @param owner the owner. + * @param e the exception. */ @FromAnyThread - public static void handleException(@Nullable final Logger logger, @Nullable final Object owner, - @NotNull final Exception e) { + public static void handleException(@Nullable Logger logger, @Nullable Object owner, @NotNull Exception e) { handleException(logger, owner, e, null); } /** * Handle exception. * - * @param logger the logger - * @param owner the owner - * @param e the e - * @param callback the callback + * @param logger the logger. + * @param owner the owner. + * @param e the exception. + * @param callback the callback. */ @FromAnyThread - public static void handleException(@Nullable Logger logger, @Nullable final Object owner, - @NotNull final Exception e, @Nullable final Runnable callback) { + public static void handleException( + @Nullable Logger logger, + @Nullable Object owner, + @NotNull Exception e, + @Nullable Runnable callback + ) { + if (logger == null) { logger = LOGGER; } @@ -602,15 +649,15 @@ public static void handleException(@Nullable Logger logger, @Nullable final Obje logger.warning(owner, e); } - final ExecutorManager executorManager = ExecutorManager.getInstance(); + var executorManager = ExecutorManager.getInstance(); executorManager.addFxTask(() -> { GAnalytics.sendException(e, false); - final String localizedMessage = e.getLocalizedMessage(); - final String stackTrace = buildStackTrace(e); + var localizedMessage = e.getLocalizedMessage(); + var stackTrace = buildStackTrace(e); - final Alert alert = UiUtils.createErrorAlert(e, localizedMessage, stackTrace); + var alert = UiUtils.createErrorAlert(e, localizedMessage, stackTrace); alert.show(); alert.setWidth(500); alert.setHeight(220); @@ -628,18 +675,18 @@ public static void handleException(@Nullable Logger logger, @Nullable final Obje * @return the built stack trace. */ @FromAnyThread - public static String buildStackTrace(@NotNull final Exception exception) { + public static String buildStackTrace(@NotNull Exception exception) { - StringWriter writer = new StringWriter(); - PrintWriter printWriter = new PrintWriter(writer); + var writer = new StringWriter(); + var printWriter = new PrintWriter(writer); exception.printStackTrace(printWriter); - String stackTrace = writer.toString(); + var stackTrace = writer.toString(); - int level = 0; + var level = 0; - for (Throwable cause = exception.getCause(); cause != null && level < 6; cause = cause.getCause(), level++) { + for (var cause = exception.getCause(); cause != null && level < 6; cause = cause.getCause(), level++) { writer = new StringWriter(); printWriter = new PrintWriter(writer); @@ -658,10 +705,10 @@ public static String buildStackTrace(@NotNull final Exception exception) { * @param path the path */ @FromAnyThread - public static void openFileInExternalEditor(@NotNull final Path path) { + public static void openFileInExternalEditor(@NotNull Path path) { - final Platform platform = JmeSystem.getPlatform(); - final List commands = new ArrayList<>(); + var platform = JmeSystem.getPlatform(); + var commands = new ArrayList(); if (platform == Platform.MacOSX64 || platform == Platform.MacOSX_PPC64) { commands.add("open"); @@ -673,24 +720,26 @@ public static void openFileInExternalEditor(@NotNull final Path path) { commands.add("xdg-open"); } - if (commands.isEmpty()) return; + if (commands.isEmpty()) { + return; + } - final String url; + String url; try { url = path.toUri().toURL().toString(); - } catch (final MalformedURLException e) { + } catch (MalformedURLException e) { handleException(LOGGER, null, e); return; } commands.add(url); - final ProcessBuilder processBuilder = new ProcessBuilder(); + var processBuilder = new ProcessBuilder(); processBuilder.command(commands); try { processBuilder.start(); - } catch (final IOException e) { + } catch (IOException e) { handleException(LOGGER, null, e); } } @@ -703,8 +752,8 @@ public static void openFileInExternalEditor(@NotNull final Path path) { @FromAnyThread public static void openFileInSystemExplorer(@NotNull Path path) { - final Platform platform = JmeSystem.getPlatform(); - final List commands = new ArrayList<>(); + var platform = JmeSystem.getPlatform(); + var commands = new ArrayList(); if (platform == Platform.MacOSX64 || platform == Platform.MacOSX_PPC64) { commands.add("open"); @@ -730,34 +779,34 @@ public static void openFileInSystemExplorer(@NotNull Path path) { return; } - final String url; + String url; try { url = path.toUri().toURL().toString(); - } catch (final MalformedURLException e) { + } catch (MalformedURLException e) { handleException(LOGGER, null, e); return; } commands.add(url); - final ProcessBuilder processBuilder = new ProcessBuilder(); + var processBuilder = new ProcessBuilder(); processBuilder.command(commands); try { processBuilder.start(); - } catch (final IOException e) { + } catch (IOException e) { handleException(LOGGER, null, e); } } @FromAnyThread - private static boolean isAppExists(@NotNull final String command) { + private static boolean isAppExists(@NotNull String command) { - final Runtime runtime = Runtime.getRuntime(); - final int result; + var runtime = Runtime.getRuntime(); + int result; try { - final Process exec = runtime.exec(command); + var exec = runtime.exec(command); result = exec.waitFor(); - } catch (final InterruptedException | IOException e) { + } catch (InterruptedException | IOException e) { return false; } @@ -771,13 +820,16 @@ private static boolean isAppExists(@NotNull final String command) { * @return the byte array. */ @FromAnyThread - public static @NotNull byte[] serialize(@NotNull final Serializable object) { - final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - try (final ObjectOutputStream out = new ObjectOutputStream(bout)) { + public static @NotNull byte[] serialize(@NotNull Serializable object) { + + var bout = new ByteArrayOutputStream(); + + try (var out = new ObjectOutputStream(bout)) { out.writeObject(object); - } catch (final IOException e) { + } catch (IOException e) { LOGGER.warning(e); } + return bout.toByteArray(); } @@ -789,11 +841,13 @@ private static boolean isAppExists(@NotNull final String command) { * @return the result object. */ @FromAnyThread - public static @NotNull T deserialize(@NotNull final byte[] bytes) { - final ByteArrayInputStream bin = new ByteArrayInputStream(bytes); - try (final ObjectInputStream in = new ExtObjectInputStream(bin)) { + public static @NotNull T deserialize(@NotNull byte[] bytes) { + + var bin = new ByteArrayInputStream(bytes); + + try (var in = new ExtObjectInputStream(bin)) { return unsafeCast(in.readObject()); - } catch (final ClassNotFoundException | IOException e) { + } catch (ClassNotFoundException | IOException e) { throw new RuntimeException(e); } } @@ -818,11 +872,16 @@ public static float clipNumber(float value, float mod) { * @return the array of enum values. */ @FromAnyThread - public static > @NotNull E[] getAvailableValues(@NotNull final E value) { - final Class valueClass = value.getClass(); - if (!valueClass.isEnum()) throw new RuntimeException("The class " + valueClass + " isn't enum."); - final Enum[] enumConstants = valueClass.getEnumConstants(); - return ClassUtils.unsafeCast(enumConstants); + public static > @NotNull E[] getAvailableValues(@NotNull E value) { + + var valueClass = value.getClass(); + if (!valueClass.isEnum()) { + throw new RuntimeException("The class " + valueClass + " isn't enum."); + } + + var enumConstants = valueClass.getEnumConstants(); + + return unsafeCast(enumConstants); } /** @@ -835,32 +894,35 @@ public static float clipNumber(float value, float mod) { * @return the new instance or null. */ @FromAnyThread - public static @Nullable T tryToCreateUserObject(@NotNull final Object owner, @NotNull final String className, - @NotNull final Class resultType) { + public static @Nullable T tryToCreateUserObject( + @NotNull Object owner, + @NotNull String className, + @NotNull Class resultType + ) { - final ResourceManager resourceManager = ResourceManager.getInstance(); - final ClasspathManager classpathManager = ClasspathManager.getInstance(); + var resourceManager = ResourceManager.getInstance(); + var classpathManager = ClasspathManager.getInstance(); Object newExample = null; try { newExample = ClassUtils.newInstance(className); - } catch (final RuntimeException e) { + } catch (RuntimeException e) { - final Array classLoaders = resourceManager.getClassLoaders(); + var classLoaders = resourceManager.getClassLoaders(); - for (final URLClassLoader classLoader : classLoaders) { + for (var classLoader : classLoaders) { try { - final Class targetClass = classLoader.loadClass(className); + var targetClass = classLoader.loadClass(className); newExample = ClassUtils.newInstance(targetClass); - } catch (final ClassNotFoundException ex) { + } catch (ClassNotFoundException ex) { LOGGER.warning(owner, e); } } - final URLClassLoader librariesLoader = classpathManager.getLibrariesLoader(); + var librariesLoader = classpathManager.getLibrariesLoader(); if (librariesLoader != null) { try { - final Class targetClass = librariesLoader.loadClass(className); + var targetClass = librariesLoader.loadClass(className); newExample = ClassUtils.newInstance(targetClass); } catch (final ClassNotFoundException ex) { LOGGER.warning(owner, e); @@ -878,14 +940,14 @@ public static float clipNumber(float value, float mod) { * @return the default layer or null. */ @FromAnyThread - public static @Nullable SceneLayer getDefaultLayer(@NotNull final ChangeConsumer consumer) { + public static @Nullable SceneLayer getDefaultLayer(@NotNull ChangeConsumer consumer) { if (!(consumer instanceof SceneChangeConsumer)) { return null; } - final SceneNode sceneNode = ((SceneChangeConsumer) consumer).getCurrentModel(); - final List layers = sceneNode.getLayers(); + var sceneNode = ((SceneChangeConsumer) consumer).getCurrentModel(); + var layers = sceneNode.getLayers(); if (layers.isEmpty()) { return null; @@ -893,4 +955,89 @@ public static float clipNumber(float value, float mod) { return layers.get(0); } + + /** + * Return true if the asset key is null or empty. + * + * @param assetKey the asset key. + * @return true if the asset key is null or empty. + */ + public static boolean isEmpty(@Nullable AssetKey assetKey) { + return assetKey == null || StringUtils.isEmpty(assetKey.getName()); + } + + /** + * Open the asset resource in an editor. + * + * @param assetKey the asset key. + */ + @FromAnyThread + public static void openInEditor(@Nullable AssetKey assetKey) { + + if (assetKey == null) { + return; + } + + var assetPath = assetKey.getName(); + if (StringUtils.isEmpty(assetPath)) { + return; + } + + var assetFile = Paths.get(assetPath); + var realFile = notNull(getRealFile(assetFile)); + if (!Files.exists(realFile)) { + return; + } + + FxEventManager.getInstance() + .notify(new RequestedOpenFileEvent(realFile)); + } + + /** + * Get the list of files in the current dragboard. + * + * @param dragboard the current dragboard. + * @return the list of files. + */ + @FromAnyThread + public static @NotNull List getFiles(@NotNull Dragboard dragboard) { + List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); + return files == null ? Collections.emptyList() : files; + } + + /** + * Get an array of enum constants by the class. + * + * @param enumType the enum's class. + * @param the enum's type. + * @return the array of enum's constants. + */ + @FromAnyThread + public static T[] getEnumValues(@NotNull Class enumType) { + + if(!enumType.isEnum()) { + throw new IllegalArgumentException("The type " + enumType + " isn't a enum."); + } + + return unsafeCast(ENUM_VALUES_LOCAL.get() + .get(enumType, type -> (Enum[]) type.getEnumConstants())); + } + + /** + * Find a root key of the spatial. + * + * @param spatial the spatial. + * @return the root key or null. + */ + public static @Nullable String findRootKey(@Nullable Spatial spatial) { + + if(spatial == null) { + return null; + } + + return NodeUtils.findParentOpt(spatial, sp -> sp.getKey() != null) + .map(Spatial::getKey) + .map(AssetKey::getName) + .orElse(null); + } } diff --git a/src/main/java/com/ss/editor/util/ExtObjectInputStream.java b/src/main/java/com/ss/editor/util/ExtObjectInputStream.java index 9eae4452..b82c1a3b 100644 --- a/src/main/java/com/ss/editor/util/ExtObjectInputStream.java +++ b/src/main/java/com/ss/editor/util/ExtObjectInputStream.java @@ -1,9 +1,8 @@ package com.ss.editor.util; import com.ss.editor.manager.PluginManager; -import com.ss.rlib.util.ref.Reference; -import com.ss.rlib.util.ref.ReferenceFactory; -import com.ss.rlib.util.ref.ReferenceType; +import com.ss.rlib.common.util.ref.ReferenceFactory; +import com.ss.rlib.common.util.ref.ReferenceType; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -18,29 +17,31 @@ */ public class ExtObjectInputStream extends ObjectInputStream { - public ExtObjectInputStream(@NotNull final InputStream in) throws IOException { + public ExtObjectInputStream(@NotNull InputStream in) throws IOException { super(in); } @Override - protected Class resolveClass(@NotNull final ObjectStreamClass desc) throws IOException, ClassNotFoundException { + protected Class resolveClass(@NotNull ObjectStreamClass desc) throws IOException, ClassNotFoundException { try { return super.resolveClass(desc); - } catch (final ClassNotFoundException e) { + } catch (ClassNotFoundException e) { - final String name = desc.getName(); + var name = desc.getName(); - try (final Reference ref = ReferenceFactory.takeFromTLPool(ReferenceType.OBJECT)) { + try (var ref = ReferenceFactory.takeFromTLPool(ReferenceType.OBJECT)) { - final PluginManager pluginManager = PluginManager.getInstance(); + var pluginManager = PluginManager.getInstance(); pluginManager.handlePlugins(plugin -> { - if (ref.getObject() != null) return; + if (ref.getObject() != null) { + return; + } - final ClassLoader classLoader = plugin.getClassLoader(); + var classLoader = plugin.getClassLoader(); try { ref.setObject(classLoader.loadClass(name)); - } catch (final ClassNotFoundException ex) { + } catch (ClassNotFoundException ex) { // ignore this exception } }); diff --git a/src/main/java/com/ss/editor/util/GeomUtils.java b/src/main/java/com/ss/editor/util/GeomUtils.java index ed9c5054..448c369a 100644 --- a/src/main/java/com/ss/editor/util/GeomUtils.java +++ b/src/main/java/com/ss/editor/util/GeomUtils.java @@ -2,9 +2,7 @@ import com.jme3.collision.CollisionResult; import com.jme3.collision.CollisionResults; -import com.jme3.input.InputManager; import com.jme3.math.Quaternion; -import com.jme3.math.Ray; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; @@ -16,7 +14,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; @@ -35,7 +32,7 @@ public class GeomUtils { * @return the up. */ @FromAnyThread - public static @NotNull Vector3f getUp(@NotNull final Quaternion rotation, @NotNull final Vector3f store) { + public static @NotNull Vector3f getUp(@NotNull Quaternion rotation, @NotNull Vector3f store) { return rotation.getRotationColumn(1, store); } @@ -47,7 +44,7 @@ public class GeomUtils { * @return the left. */ @FromAnyThread - public static @NotNull Vector3f getLeft(@NotNull final Quaternion rotation, @NotNull final Vector3f store) { + public static @NotNull Vector3f getLeft(@NotNull Quaternion rotation, @NotNull Vector3f store) { return rotation.getRotationColumn(0, store); } @@ -59,7 +56,7 @@ public class GeomUtils { * @return the direction. */ @FromAnyThread - public static @NotNull Vector3f getDirection(@NotNull final Quaternion rotation, @NotNull final Vector3f store) { + public static @NotNull Vector3f getDirection(@NotNull Quaternion rotation, @NotNull Vector3f store) { return rotation.getRotationColumn(2, store); } @@ -71,7 +68,7 @@ public class GeomUtils { * @return the index. */ @FromAnyThread - public static int getIndex(@NotNull final Spatial model, @NotNull final Object object) { + public static int getIndex(@NotNull Spatial model, @NotNull Object object) { Spatial parent = model; int parentIndex = 0; @@ -86,12 +83,11 @@ public static int getIndex(@NotNull final Spatial model, @NotNull final Object o return -1; } - final AtomicInteger counter = new AtomicInteger(0); - final Node node = (Node) model; + var counter = new AtomicInteger(0); + var node = (Node) model; + var children = node.getChildren(); - final List children = node.getChildren(); - - for (final Spatial child : children) { + for (var child : children) { if (getIndex(child, object, counter)) { return counter.get(); } @@ -104,8 +100,7 @@ public static int getIndex(@NotNull final Spatial model, @NotNull final Object o * Get the index of the object in the model. */ @FromAnyThread - private static boolean getIndex(@NotNull final Object model, @NotNull final Object object, - @NotNull final AtomicInteger counter) { + private static boolean getIndex(@NotNull Object model, @NotNull Object object, @NotNull AtomicInteger counter) { counter.incrementAndGet(); if (Objects.equals(model, object)) { @@ -116,10 +111,10 @@ private static boolean getIndex(@NotNull final Object model, @NotNull final Obje return false; } - final Node node = (Node) model; - final List children = node.getChildren(); + var node = (Node) model; + var children = node.getChildren(); - for (final Spatial child : children) { + for (var child : children) { if (getIndex(child, object, counter)) { return true; } @@ -136,7 +131,7 @@ private static boolean getIndex(@NotNull final Object model, @NotNull final Obje * @return the object by index. */ @FromAnyThread - public static @Nullable Object getObjectByIndex(@NotNull final Spatial model, final int index) { + public static @Nullable Object getObjectByIndex(@NotNull Spatial model, int index) { Spatial parent = model; int parentIndex = 0; @@ -151,14 +146,15 @@ private static boolean getIndex(@NotNull final Object model, @NotNull final Obje return null; } - final AtomicInteger counter = new AtomicInteger(0); - final Node node = (Node) model; - - final List children = node.getChildren(); + var counter = new AtomicInteger(0); + var node = (Node) model; + var children = node.getChildren(); - for (final Spatial child : children) { - final Object object = getObjectByIndex(child, index, counter); - if (object != null) return object; + for (var child : children) { + var object = getObjectByIndex(child, index, counter); + if (object != null) { + return object; + } } return null; @@ -168,8 +164,11 @@ private static boolean getIndex(@NotNull final Object model, @NotNull final Obje * Find the object by the index in the model. */ @FromAnyThread - private static @Nullable Object getObjectByIndex(@NotNull final Object model, final int index, - @NotNull final AtomicInteger counter) { + private static @Nullable Object getObjectByIndex( + @NotNull Object model, + int index, + @NotNull AtomicInteger counter + ) { if (counter.incrementAndGet() == index) { return model; @@ -179,12 +178,14 @@ private static boolean getIndex(@NotNull final Object model, @NotNull final Obje return null; } - final Node node = (Node) model; - final List children = node.getChildren(); + var node = (Node) model; + var children = node.getChildren(); - for (final Spatial child : children) { - final Object object = getObjectByIndex(child, index, counter); - if (object != null) return object; + for (var child : children) { + var object = getObjectByIndex(child, index, counter); + if (object != null) { + return object; + } } return null; @@ -199,7 +200,7 @@ private static boolean getIndex(@NotNull final Object model, @NotNull final Obje * @return true if the spatial can be attached to the node. */ @FromAnyThread - public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial spatial, final boolean isCopy) { + public static boolean canAttach(@NotNull Node node, @NotNull Spatial spatial, boolean isCopy) { if (spatial.getParent() == node && !isCopy) { return false; @@ -207,8 +208,8 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial return false; } - final AssetLinkNode linkNode = isCopy ? null : - NodeUtils.findParent(spatial.getParent(), AssetLinkNode.class::isInstance); + var linkNode = isCopy ? null : NodeUtils.findParent(spatial.getParent(), + AssetLinkNode.class::isInstance); return linkNode == null; } @@ -221,9 +222,9 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the contact point or null. */ @FromAnyThread - public static @Nullable Vector3f getContactPointFromCursor(@NotNull final Spatial spatial, @NotNull final Camera camera) { - final InputManager inputManager = EditorUtil.getInputManager(); - final Vector2f cursor = inputManager.getCursorPosition(); + public static @Nullable Vector3f getContactPointFromCursor(@NotNull Spatial spatial, @NotNull Camera camera) { + var inputManager = EditorUtil.getInputManager(); + var cursor = inputManager.getCursorPosition(); return getContactPointFromScreenPos(spatial, camera, cursor.getX(), cursor.getY()); } @@ -235,10 +236,9 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the collision result or null. */ @FromAnyThread - public static @Nullable CollisionResult getCollisionFromCursor(@NotNull final Spatial spatial, - @NotNull final Camera camera) { - final InputManager inputManager = EditorUtil.getInputManager(); - final Vector2f cursor = inputManager.getCursorPosition(); + public static @Nullable CollisionResult getCollisionFromCursor(@NotNull Spatial spatial, @NotNull Camera camera) { + var inputManager = EditorUtil.getInputManager(); + var cursor = inputManager.getCursorPosition(); return getCollisionFromScreenPos(spatial, camera, cursor.getX(), cursor.getY()); } @@ -250,10 +250,9 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the collisions result. */ @FromAnyThread - public static @NotNull CollisionResults getCollisionsFromCursor(@NotNull final Spatial spatial, - @NotNull final Camera camera) { - final InputManager inputManager = EditorUtil.getInputManager(); - final Vector2f cursor = inputManager.getCursorPosition(); + public static @NotNull CollisionResults getCollisionsFromCursor(@NotNull Spatial spatial, @NotNull Camera camera) { + var inputManager = EditorUtil.getInputManager(); + var cursor = inputManager.getCursorPosition(); return getCollisionsFromScreenPos(spatial, camera, cursor.getX(), cursor.getY()); } @@ -267,10 +266,13 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the contact point or null. */ @FromAnyThread - public static @Nullable Vector3f getContactPointFromScreenPos(@NotNull final Spatial spatial, - @NotNull final Camera camera, final float screenX, - final float screenY) { - final CollisionResult collision = getCollisionFromScreenPos(spatial, camera, screenX, screenY); + public static @Nullable Vector3f getContactPointFromScreenPos( + @NotNull Spatial spatial, + @NotNull Camera camera, + float screenX, + float screenY + ) { + var collision = getCollisionFromScreenPos(spatial, camera, screenX, screenY); return collision == null ? null : collision.getContactPoint(); } @@ -284,10 +286,13 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the contact normal or null. */ @FromAnyThread - public static @Nullable Vector3f getContactNormalFromScreenPos(@NotNull final Spatial spatial, - @NotNull final Camera camera, final float screenX, - final float screenY) { - final CollisionResult collision = getCollisionFromScreenPos(spatial, camera, screenX, screenY); + public static @Nullable Vector3f getContactNormalFromScreenPos( + @NotNull Spatial spatial, + @NotNull Camera camera, + float screenX, + float screenY + ) { + var collision = getCollisionFromScreenPos(spatial, camera, screenX, screenY); return collision == null ? null : collision.getContactNormal(); } @@ -299,9 +304,9 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the geometry or null. */ @FromAnyThread - public static @Nullable Geometry getGeometryFromCursor(@NotNull final Spatial spatial, @NotNull final Camera camera) { - final InputManager inputManager = EditorUtil.getInputManager(); - final Vector2f cursor = inputManager.getCursorPosition(); + public static @Nullable Geometry getGeometryFromCursor(@NotNull Spatial spatial, @NotNull Camera camera) { + var inputManager = EditorUtil.getInputManager(); + var cursor = inputManager.getCursorPosition(); return getGeometryFromScreenPos(spatial, camera, cursor.getX(), cursor.getY()); } @@ -315,10 +320,13 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the geometry or null. */ @FromAnyThread - public static @Nullable Geometry getGeometryFromScreenPos(@NotNull final Spatial spatial, - @NotNull final Camera camera, final float screenX, - final float screenY) { - final CollisionResult collision = getCollisionFromScreenPos(spatial, camera, screenX, screenY); + public static @Nullable Geometry getGeometryFromScreenPos( + @NotNull Spatial spatial, + @NotNull Camera camera, + float screenX, + float screenY + ) { + var collision = getCollisionFromScreenPos(spatial, camera, screenX, screenY); return collision == null ? null : collision.getGeometry(); } @@ -332,11 +340,14 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the collision or null. */ @FromAnyThread - public static @Nullable CollisionResult getCollisionFromScreenPos(@NotNull final Spatial spatial, - @NotNull final Camera camera, final float screenX, - final float screenY) { - - final CollisionResults results = getCollisionsFromScreenPos(spatial, camera, screenX, screenY); + public static @Nullable CollisionResult getCollisionFromScreenPos( + @NotNull Spatial spatial, + @NotNull Camera camera, + float screenX, + float screenY + ) { + + var results = getCollisionsFromScreenPos(spatial, camera, screenX, screenY); if (results.size() < 1) { return null; } @@ -354,27 +365,93 @@ public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial * @return the collisions . */ @FromAnyThread - public static @NotNull CollisionResults getCollisionsFromScreenPos(@NotNull final Spatial spatial, - @NotNull final Camera camera, - final float screenX, final float screenY) { - - final LocalObjects local = LocalObjects.get(); - - final Vector2f cursor = local.nextVector(screenX, screenY); - final Vector3f click3d = camera.getWorldCoordinates(cursor, 0f, local.nextVector()); - final Vector3f dir = camera.getWorldCoordinates(cursor, 1f, local.nextVector()) + public static @NotNull CollisionResults getCollisionsFromScreenPos( + @NotNull Spatial spatial, + @NotNull Camera camera, + float screenX, + float screenY + ) { + + var local = LocalObjects.get(); + + var cursor = local.nextVector(screenX, screenY); + var click3d = camera.getWorldCoordinates(cursor, 0f, local.nextVector()); + var dir = camera.getWorldCoordinates(cursor, 1f, local.nextVector()) .subtractLocal(click3d) .normalizeLocal(); - final Ray ray = local.nextRay(); + var ray = local.nextRay(); ray.setOrigin(click3d); ray.setDirection(dir); - final CollisionResults results = local.nextCollisionResults(); + var results = local.nextCollisionResults(); spatial.updateModelBound(); spatial.collideWith(ray, results); return results; } + + /** + * Compare the vector with coordinates. + * + * @param vector the vector. + * @param x the X coordinate. + * @param y the Y coordinate. + * @param z the Z coordinate. + * @return true if the vector is equal for the coordinates. + */ + @FromAnyThread + public static boolean equals(@Nullable Vector3f vector, float x, float y, float z) { + + if (vector == null) { + return false; + } else if (Float.compare(vector.getX(), x) != 0) { + return false; + } else if (Float.compare(vector.getY(), y) != 0) { + return false; + } else { + return Float.compare(vector.getZ(), z) == 0; + } + } + + /** + * Compare the vector with coordinates. + * + * @param vector the vector. + * @param x the X coordinate. + * @param y the Y coordinate. + * @return true if the vector is equal for the coordinates. + */ + @FromAnyThread + public static boolean equals(@Nullable Vector2f vector, float x, float y) { + + if (vector == null) { + return false; + } else if (Float.compare(vector.getX(), x) != 0) { + return false; + } else { + return Float.compare(vector.getY(), y) == 0; + } + } + + /** + * Return {@link Vector3f#ZERO} if the vector is null or the same vector. + * + * @param vector the vector. + * @return {@link Vector3f#ZERO} if the vector is null or the same vector. + */ + public static @NotNull Vector3f zeroIfNull(@Nullable Vector3f vector) { + return vector == null ? Vector3f.ZERO : vector; + } + + /** + * Return {@link Vector2f#ZERO} if the vector is null or the same vector. + * + * @param vector the vector. + * @return {@link Vector2f#ZERO} if the vector is null or the same vector. + */ + public static @NotNull Vector2f zeroIfNull(@Nullable Vector2f vector) { + return vector == null ? Vector2f.ZERO : vector; + } } diff --git a/src/main/java/com/ss/editor/util/GlslType.java b/src/main/java/com/ss/editor/util/GlslType.java index 963e01ea..793c1056 100644 --- a/src/main/java/com/ss/editor/util/GlslType.java +++ b/src/main/java/com/ss/editor/util/GlslType.java @@ -1,9 +1,9 @@ package com.ss.editor.util; -import static com.ss.rlib.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.dictionary.DictionaryFactory; -import com.ss.rlib.util.dictionary.ObjectDictionary; +import com.ss.rlib.common.util.dictionary.DictionaryFactory; +import com.ss.rlib.common.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; /** @@ -34,17 +34,13 @@ public enum GlslType { SAMPLER_2D("sampler2D", "Texture 2D"), SAMPLER_CUBE("samplerCube", "Cube Texture"); - @NotNull public static final GlslType[] VALUES = values(); - @NotNull private static final ObjectDictionary RAW_TYPE_TO_ENUM = DictionaryFactory.newObjectDictionary(); - - @NotNull private static final ObjectDictionary UI_NAME_TO_ENUM = DictionaryFactory.newObjectDictionary(); static { - for (final GlslType glslType : VALUES) { + for (var glslType : VALUES) { RAW_TYPE_TO_ENUM.put(glslType.getRawType(), glslType); UI_NAME_TO_ENUM.put(glslType.getUIName(), glslType); } @@ -57,7 +53,7 @@ public enum GlslType { * @return the enum value. */ @FromAnyThread - public static @NotNull GlslType ofRawType(@NotNull final String rawType) { + public static @NotNull GlslType ofRawType(@NotNull String rawType) { return notNull(RAW_TYPE_TO_ENUM.get(rawType)); } @@ -68,7 +64,7 @@ public enum GlslType { * @return the enum value. */ @FromAnyThread - public static @NotNull GlslType ofUIName(@NotNull final String uiName) { + public static @NotNull GlslType ofUIName(@NotNull String uiName) { return notNull(RAW_TYPE_TO_ENUM.get(uiName)); } @@ -84,7 +80,7 @@ public enum GlslType { @NotNull private String uiName; - GlslType(@NotNull final String rawType, @NotNull final String uiName) { + GlslType(@NotNull String rawType, @NotNull String uiName) { this.rawType = rawType; this.uiName = uiName; } diff --git a/src/main/java/com/ss/editor/util/LocalObjects.java b/src/main/java/com/ss/editor/util/LocalObjects.java index 07550ce1..a122ec89 100644 --- a/src/main/java/com/ss/editor/util/LocalObjects.java +++ b/src/main/java/com/ss/editor/util/LocalObjects.java @@ -6,10 +6,10 @@ import com.jme3.scene.Spatial; import com.ss.editor.EditorThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.CycleBuffer; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.pools.Reusable; +import com.ss.rlib.common.util.CycleBuffer; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.pools.Reusable; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -23,7 +23,6 @@ public class LocalObjects { private static final int SIZE = 50; - @NotNull private static final ThreadLocal THREAD_LOCAL = ThreadLocal.withInitial(LocalObjects::new); /** @@ -210,7 +209,7 @@ public LocalObjects() { * @return the next free vector with values from the source vector. */ @FromAnyThread - public @NotNull Vector3f nextVector(@NotNull final Vector3f vector3f) { + public @NotNull Vector3f nextVector(@NotNull Vector3f vector3f) { return vectorBuffer.next().set(vector3f); } @@ -223,7 +222,7 @@ public LocalObjects() { * @return the next free vector with the values. */ @FromAnyThread - public @NotNull Vector3f nextVector(final float x, final float y, final float z) { + public @NotNull Vector3f nextVector(float x, float y, float z) { return vectorBuffer.next().set(x, y, z); } @@ -245,7 +244,7 @@ public LocalObjects() { * @return the next free vector with the values. */ @FromAnyThread - public @NotNull Vector2f nextVector(final float x, final float y) { + public @NotNull Vector2f nextVector(float x, float y) { return vector2fBuffer.next().set(x, y); } diff --git a/src/main/java/com/ss/editor/util/MaterialSerializer.java b/src/main/java/com/ss/editor/util/MaterialSerializer.java index 9d44bc0f..2c066f0d 100644 --- a/src/main/java/com/ss/editor/util/MaterialSerializer.java +++ b/src/main/java/com/ss/editor/util/MaterialSerializer.java @@ -3,7 +3,6 @@ import com.jme3.asset.TextureKey; import com.jme3.material.MatParam; import com.jme3.material.Material; -import com.jme3.material.MaterialDef; import com.jme3.material.RenderState; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; @@ -14,11 +13,9 @@ import com.jme3.texture.Texture2D; import com.jme3.texture.TextureCubeMap; import com.ss.editor.annotation.FromAnyThread; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.StringUtils; import org.jetbrains.annotations.NotNull; -import java.util.Collection; - /** * The implementation of a material serializer. * @@ -33,21 +30,21 @@ public class MaterialSerializer { * @return the string */ @FromAnyThread - public static @NotNull String serializeToString(@NotNull final Material material) { + public static @NotNull String serializeToString(@NotNull Material material) { - final MaterialDef materialDef = material.getMaterialDef(); - final Collection params = material.getParams(); + var materialDef = material.getMaterialDef(); + var params = material.getParams(); - final StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.append("Material MyMaterial : ").append(materialDef.getAssetName()).append(" {\n"); builder.append(" MaterialParameters {\n"); params.forEach(matParam -> addMaterialParameter(builder, matParam)); builder.append(" }\n"); builder.append(" AdditionalRenderState {\n"); - final RenderState renderState = material.getAdditionalRenderState(); - final RenderState.BlendMode blendMode = renderState.getBlendMode(); - final RenderState.FaceCullMode faceCullMode = renderState.getFaceCullMode(); + var renderState = material.getAdditionalRenderState(); + var blendMode = renderState.getBlendMode(); + var faceCullMode = renderState.getFaceCullMode(); if (blendMode != RenderState.BlendMode.Off) { builder.append(" Blend ").append(blendMode.name()).append('\n'); @@ -62,8 +59,8 @@ public class MaterialSerializer { if (!renderState.isDepthWrite()) builder.append(" DepthWrite Off\n"); if (!renderState.isColorWrite()) builder.append(" ColorWrite Off\n"); - final float polyOffsetFactor = renderState.getPolyOffsetFactor(); - final float polyOffsetUnits = renderState.getPolyOffsetUnits(); + var polyOffsetFactor = renderState.getPolyOffsetFactor(); + var polyOffsetUnits = renderState.getPolyOffsetUnits(); if (polyOffsetFactor != 0 || polyOffsetUnits != 0) { builder.append(" PolyOffset ") @@ -86,9 +83,9 @@ public class MaterialSerializer { * @param matParam the material parameter. */ @FromAnyThread - private static void addMaterialParameter(@NotNull final StringBuilder builder, @NotNull final MatParam matParam) { + private static void addMaterialParameter(@NotNull StringBuilder builder, @NotNull MatParam matParam) { - final String value = toString(matParam.getVarType(), matParam.getValue()); + var value = toString(matParam.getVarType(), matParam.getValue()); if (StringUtils.isEmpty(value)) { return; } @@ -101,7 +98,7 @@ private static void addMaterialParameter(@NotNull final StringBuilder builder, @ } @FromAnyThread - private static @NotNull String toString(@NotNull final VarType varType, @NotNull final Object value) { + private static @NotNull String toString(@NotNull VarType varType, @NotNull Object value) { switch (varType) { case Int: @@ -111,32 +108,33 @@ private static void addMaterialParameter(@NotNull final StringBuilder builder, @ case Vector4: { if (value instanceof ColorRGBA) { - final ColorRGBA color = (ColorRGBA) value; + var color = (ColorRGBA) value; return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha(); } else if (value instanceof Vector4f) { - final Vector4f vector4f = (Vector4f) value; + var vector4f = (Vector4f) value; return vector4f.getX() + " " + vector4f.getY() + " " + vector4f.getZ() + " " + vector4f.getW(); } break; } case Vector2: { - final Vector2f vector2f = (Vector2f) value; + var vector2f = (Vector2f) value; return vector2f.getX() + " " + vector2f.getY(); } case Vector3: { - final Vector3f vector3f = (Vector3f) value; + var vector3f = (Vector3f) value; return vector3f.getX() + " " + vector3f.getY() + " " + vector3f.getZ(); } case Texture2D: { - final Texture2D texture2D = (Texture2D) value; - final TextureKey textureKey = (TextureKey) texture2D.getKey(); + var texture2D = (Texture2D) value; + var textureKey = (TextureKey) texture2D.getKey(); if (textureKey == null) { return ""; } - final StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); + if (textureKey.isFlipY()) { builder.append("Flip "); } @@ -151,13 +149,15 @@ private static void addMaterialParameter(@NotNull final StringBuilder builder, @ } case TextureCubeMap: { - final TextureCubeMap textureCubeMap = (TextureCubeMap) value; - final TextureKey textureKey = (TextureKey) textureCubeMap.getKey(); + var textureCubeMap = (TextureCubeMap) value; + var textureKey = (TextureKey) textureCubeMap.getKey(); + if (textureKey == null) { return ""; } - final StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); + if (textureKey.isFlipY()) { builder.append("Flip "); } diff --git a/src/main/java/com/ss/editor/util/MaterialUtils.java b/src/main/java/com/ss/editor/util/MaterialUtils.java index b91c9f6e..4983c990 100644 --- a/src/main/java/com/ss/editor/util/MaterialUtils.java +++ b/src/main/java/com/ss/editor/util/MaterialUtils.java @@ -1,38 +1,32 @@ package com.ss.editor.util; import static com.ss.editor.util.EditorUtil.*; -import static com.ss.rlib.util.ObjectUtils.notNull; -import static com.ss.rlib.util.array.ArrayFactory.toArray; +import static com.ss.rlib.common.util.ObjectUtils.notNull; +import static com.ss.rlib.common.util.array.ArrayFactory.toArray; import static java.nio.file.StandardOpenOption.*; import com.jme3.asset.AssetKey; -import com.jme3.asset.AssetManager; import com.jme3.asset.MaterialKey; import com.jme3.asset.TextureKey; -import com.jme3.material.*; +import com.jme3.material.MatParam; +import com.jme3.material.Material; +import com.jme3.material.MaterialDef; import com.jme3.scene.Spatial; -import com.jme3.shader.Shader; import com.jme3.shader.VarType; -import com.jme3.texture.Image; import com.jme3.texture.Texture; import com.ss.editor.FileExtensions; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; -import com.ss.rlib.util.FileUtils; -import com.ss.rlib.util.StringUtils; +import com.ss.rlib.common.util.FileUtils; +import com.ss.rlib.common.util.StringUtils; import jme3tools.converters.ImageToAwt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; import java.io.IOException; -import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumMap; -import java.util.List; /** * The class with utility methods for working with {@link Material}. @@ -66,7 +60,7 @@ public class MaterialUtils { * @return the texture type or 0. */ @FromAnyThread - public static int getPossibleTextureType(@NotNull final String textureName) { + public static int getPossibleTextureType(@NotNull String textureName) { if (textureName.contains("NORMAL") || textureName.contains("Normal") || textureName.contains("normal")) { return TEXTURE_NORMAL; @@ -114,7 +108,7 @@ public static int getPossibleTextureType(@NotNull final String textureName) { * @return the array of possible param names. */ @FromAnyThread - public static @NotNull String[] getPossibleParamNames(final int textureType) { + public static @NotNull String[] getPossibleParamNames(int textureType) { return TEXTURE_TYPE_PARAM_NAMES[textureType]; } @@ -126,28 +120,34 @@ public static int getPossibleTextureType(@NotNull final String textureName) { * @return the updated material or null. */ @JmeThread - public static @Nullable Material updateMaterialIdNeed(@NotNull final Path file, @NotNull final Material material) { + public static @Nullable Material updateMaterialIdNeed(@NotNull Path file, @NotNull Material material) { - final AssetManager assetManager = EditorUtil.getAssetManager(); + var assetManager = EditorUtil.getAssetManager(); boolean needToReload = false; String textureKey = null; if (MaterialUtils.isShaderFile(file)) { - if (!MaterialUtils.containsShader(material, file)) return null; + + if (!MaterialUtils.containsShader(material, file)) { + return null; + } + needToReload = true; // if the shader was changed we need to reload material definition - final MaterialDef materialDef = material.getMaterialDef(); - final String assetName = materialDef.getAssetName(); + var materialDef = material.getMaterialDef(); + var assetName = materialDef.getAssetName(); assetManager.deleteFromCache(new AssetKey<>(assetName)); } else if (MaterialUtils.isTextureFile(file)) { textureKey = MaterialUtils.containsTexture(material, file); - if (textureKey == null) return null; + if (textureKey == null) { + return null; + } } - final String assetName = material.getAssetName(); + var assetName = material.getAssetName(); // try to refresh texture directly if (textureKey != null) { @@ -157,11 +157,11 @@ public static int getPossibleTextureType(@NotNull final String textureName) { return null; } - final MaterialKey materialKey = new MaterialKey(assetName); + var materialKey = new MaterialKey(assetName); assetManager.deleteFromCache(materialKey); - final Material newMaterial = new Material(assetManager, material.getMaterialDef().getAssetName()); + var newMaterial = new Material(assetManager, material.getMaterialDef().getAssetName()); migrateTo(newMaterial, material); @@ -176,12 +176,11 @@ public static int getPossibleTextureType(@NotNull final String textureName) { * @return true if the material contains the shader. */ @FromAnyThread - private static boolean containsShader(@NotNull final Material material, @NotNull final Path file) { - - final MaterialDef materialDef = material.getMaterialDef(); + private static boolean containsShader(@NotNull Material material, @NotNull Path file) { - final Path assetFile = notNull(getAssetFile(file), "Can't get an asset file."); - final String assetPath = toAssetPath(assetFile); + var materialDef = material.getMaterialDef(); + var assetFile = notNull(getAssetFile(file), "Can't get an asset file."); + var assetPath = toAssetPath(assetFile); return containsShader(materialDef, assetPath); } @@ -194,10 +193,10 @@ private static boolean containsShader(@NotNull final Material material, @NotNull * @return changed texture key or null. */ @FromAnyThread - private static @Nullable String containsTexture(@NotNull final Material material, @NotNull final Path file) { + private static @Nullable String containsTexture(@NotNull Material material, @NotNull Path file) { - final Path assetFile = notNull(getAssetFile(file), "Can't get an asset file."); - final String assetPath = toAssetPath(assetFile); + var assetFile = notNull(getAssetFile(file), "Can't get an asset file."); + var assetPath = toAssetPath(assetFile); return containsTexture(material, assetPath) ? assetPath : null; } @@ -210,13 +209,15 @@ private static boolean containsShader(@NotNull final Material material, @NotNull * @return true if the material definition contains the shader. */ @FromAnyThread - private static boolean containsShader(@NotNull final MaterialDef materialDef, @NotNull final String assetPath) { + private static boolean containsShader(@NotNull MaterialDef materialDef, @NotNull String assetPath) { - final List defaultTechniques = materialDef.getTechniqueDefs("Default"); + var defaultTechniques = materialDef.getTechniqueDefs("Default"); - for (final TechniqueDef technique : defaultTechniques) { - final EnumMap shaderProgramNames = technique.getShaderProgramNames(); - if (shaderProgramNames.containsValue(assetPath)) return true; + for (var technique : defaultTechniques) { + var shaderProgramNames = technique.getShaderProgramNames(); + if (shaderProgramNames.containsValue(assetPath)) { + return true; + } } return false; @@ -230,13 +231,18 @@ private static boolean containsShader(@NotNull final MaterialDef materialDef, @N * @return true if the material definition contains the texture. */ @FromAnyThread - private static boolean containsTexture(@NotNull final Material material, @NotNull final String assetPath) { + private static boolean containsTexture(@NotNull Material material, @NotNull String assetPath) { + + var materialParams = material.getParams(); + + for (var materialParam : materialParams) { - final Collection materialParams = material.getParams(); - for (final MatParam materialParam : materialParams) { - if (materialParam.getVarType() != VarType.Texture2D) continue; - final Texture value = (Texture) materialParam.getValue(); - final TextureKey textureKey = value == null ? null : (TextureKey) value.getKey(); + if (materialParam.getVarType() != VarType.Texture2D) { + continue; + } + + var value = (Texture) materialParam.getValue(); + var textureKey = value == null ? null : (TextureKey) value.getKey(); if (textureKey != null && StringUtils.equals(textureKey.getName(), assetPath)) { return true; } @@ -252,9 +258,10 @@ private static boolean containsTexture(@NotNull final Material material, @NotNul * @return true if the file is shader. */ @FromAnyThread - public static boolean isShaderFile(@NotNull final Path path) { - final String extension = FileUtils.getExtension(path); - return FileExtensions.GLSL_FRAGMENT.equals(extension) || FileExtensions.GLSL_VERTEX.equals(extension); + public static boolean isShaderFile(@NotNull Path path) { + var extension = FileUtils.getExtension(path); + return FileExtensions.GLSL_FRAGMENT.equals(extension) || + FileExtensions.GLSL_VERTEX.equals(extension); } /** @@ -264,8 +271,8 @@ public static boolean isShaderFile(@NotNull final Path path) { * @return true if the file is texture. */ @FromAnyThread - public static boolean isTextureFile(@NotNull final Path path) { - final String extension = FileUtils.getExtension(path); + public static boolean isTextureFile(@NotNull Path path) { + var extension = FileUtils.getExtension(path); return FileExtensions.IMAGE_DDS.equals(extension) || FileExtensions.IMAGE_HDR.equals(extension) || FileExtensions.IMAGE_HDR.equals(extension) || FileExtensions.IMAGE_JPEG.equals(extension) || FileExtensions.IMAGE_JPG.equals(extension) || FileExtensions.IMAGE_PNG.equals(extension) || @@ -280,23 +287,24 @@ public static boolean isTextureFile(@NotNull final Path path) { * @param textureKey the texture key. */ @JmeThread - private static void refreshTextures(@NotNull final Material material, @NotNull final String textureKey) { + private static void refreshTextures(@NotNull Material material, @NotNull String textureKey) { - final AssetManager assetManager = EditorUtil.getAssetManager(); + var assetManager = EditorUtil.getAssetManager(); - final Collection params = material.getParams(); - params.forEach(matParam -> { + material.getParams().forEach(matParam -> { - final VarType varType = matParam.getVarType(); - final Object value = matParam.getValue(); + var varType = matParam.getVarType(); + var value = matParam.getValue(); - if (varType != VarType.Texture2D || value == null) return; + if (varType != VarType.Texture2D || value == null) { + return; + } - final Texture texture = (Texture) value; - final TextureKey key = (TextureKey) texture.getKey(); + var texture = (Texture) value; + var key = (TextureKey) texture.getKey(); if (key != null && StringUtils.equals(key.getName(), textureKey)) { - final Texture newTexture = assetManager.loadAsset(key); + var newTexture = assetManager.loadAsset(key); matParam.setValue(newTexture); } }); @@ -310,28 +318,24 @@ private static void refreshTextures(@NotNull final Material material, @NotNull f * @param material the target material. */ @JmeThread - private static void updateTo(@NotNull final Material toUpdate, @NotNull final Material material) { + private static void updateTo(@NotNull Material toUpdate, @NotNull Material material) { - final Collection oldParams = new ArrayList<>(toUpdate.getParams()); + var oldParams = new ArrayList(toUpdate.getParams()); oldParams.forEach(matParam -> { - - final MatParam param = material.getParam(matParam.getName()); - + var param = material.getParam(matParam.getName()); if (param == null || param.getValue() == null) { toUpdate.clearParam(matParam.getName()); } }); - final Collection actualParams = material.getParams(); + var actualParams = material.getParams(); actualParams.forEach(matParam -> { - - final VarType varType = matParam.getVarType(); - final Object value = matParam.getValue(); - + var varType = matParam.getVarType(); + var value = matParam.getValue(); toUpdate.setParam(matParam.getName(), varType, value); }); - final RenderState additionalRenderState = toUpdate.getAdditionalRenderState(); + var additionalRenderState = toUpdate.getAdditionalRenderState(); additionalRenderState.set(material.getAdditionalRenderState()); } @@ -342,14 +346,14 @@ private static void updateTo(@NotNull final Material toUpdate, @NotNull final Ma * @param source the source material. */ @JmeThread - public static void migrateTo(@NotNull final Material target, @NotNull final Material source) { + public static void migrateTo(@NotNull Material target, @NotNull Material source) { - final MaterialDef materialDef = target.getMaterialDef(); - final Collection actualParams = source.getParams(); + var materialDef = target.getMaterialDef(); + var actualParams = source.getParams(); actualParams.forEach(matParam -> { - final MatParam param = materialDef.getMaterialParam(matParam.getName()); + var param = materialDef.getMaterialParam(matParam.getName()); if (param == null || param.getVarType() != matParam.getVarType()) { return; @@ -358,7 +362,7 @@ public static void migrateTo(@NotNull final Material target, @NotNull final Mate target.setParam(matParam.getName(), matParam.getVarType(), matParam.getValue()); }); - final RenderState additionalRenderState = target.getAdditionalRenderState(); + var additionalRenderState = target.getAdditionalRenderState(); additionalRenderState.set(source.getAdditionalRenderState()); target.setKey(source.getKey()); @@ -370,10 +374,12 @@ public static void migrateTo(@NotNull final Material target, @NotNull final Mate * @param spatial the model. */ @JmeThread - public static void cleanUpMaterialParams(@NotNull final Spatial spatial) { + public static void cleanUpMaterialParams(@NotNull Spatial spatial) { NodeUtils.visitGeometry(spatial, geometry -> { - final Material material = geometry.getMaterial(); - if (material != null) cleanUp(material); + var material = geometry.getMaterial(); + if (material != null) { + cleanUp(material); + } }); } @@ -383,8 +389,8 @@ public static void cleanUpMaterialParams(@NotNull final Spatial spatial) { * @param material the material. */ @JmeThread - private static void cleanUp(@NotNull final Material material) { - final Collection params = new ArrayList<>(material.getParams()); + private static void cleanUp(@NotNull Material material) { + var params = new ArrayList(material.getParams()); params.stream().filter(param -> param.getValue() == null) .forEach(matParam -> material.clearParam(matParam.getName())); } @@ -395,8 +401,8 @@ private static void cleanUp(@NotNull final Material material) { * @param material the material. */ @FromAnyThread - public static void saveIfNeedTextures(@NotNull final Material material) { - final Collection params = material.getParams(); + public static void saveIfNeedTextures(@NotNull Material material) { + var params = material.getParams(); params.stream().filter(matParam -> matParam.getVarType() == VarType.Texture2D) .map(MatParam::getValue) .map(Texture.class::cast) @@ -409,18 +415,20 @@ public static void saveIfNeedTextures(@NotNull final Material material) { * @param texture the texture. */ @FromAnyThread - private static void saveIfNeedTexture(@NotNull final Texture texture) { + private static void saveIfNeedTexture(@NotNull Texture texture) { - final Image image = texture.getImage(); - if (!image.isChanged()) return; + var image = texture.getImage(); + if (!image.isChanged()) { + return; + } - final AssetKey key = texture.getKey(); - final Path file = notNull(getRealFile(key.getName())); - final BufferedImage bufferedImage = ImageToAwt.convert(image, false, true, 0); + var key = texture.getKey(); + var file = notNull(getRealFile(key.getName())); + var bufferedImage = ImageToAwt.convert(image, false, true, 0); - try (final OutputStream out = Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE)) { + try (var out = Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE)) { ImageIO.write(bufferedImage, "png", out); - } catch (final IOException e) { + } catch (IOException e) { e.printStackTrace(); } @@ -435,12 +443,15 @@ private static void saveIfNeedTexture(@NotNull final Texture texture) { * @param value the value. */ @FromAnyThread - public static void safeSet(@Nullable final Material material, @NotNull final String name, final float value) { + public static void safeSet(@Nullable Material material, @NotNull String name, float value) { + if (material == null) { return; } - final MatParam materialParam = material.getMaterialDef().getMaterialParam(name); + var materialParam = material.getMaterialDef() + .getMaterialParam(name); + if (materialParam != null) { material.setFloat(name, value); } @@ -454,12 +465,15 @@ public static void safeSet(@Nullable final Material material, @NotNull final Str * @param value the value. */ @FromAnyThread - public static void safeSet(@Nullable final Material material, @NotNull final String name, final boolean value) { + public static void safeSet(@Nullable Material material, @NotNull String name, boolean value) { + if (material == null) { return; } - final MatParam materialParam = material.getMaterialDef().getMaterialParam(name); + var materialParam = material.getMaterialDef() + .getMaterialParam(name); + if (materialParam != null) { material.setBoolean(name, value); } diff --git a/src/main/java/com/ss/editor/util/NodeUtils.java b/src/main/java/com/ss/editor/util/NodeUtils.java index c9a498ad..eec2cf11 100644 --- a/src/main/java/com/ss/editor/util/NodeUtils.java +++ b/src/main/java/com/ss/editor/util/NodeUtils.java @@ -1,23 +1,23 @@ package com.ss.editor.util; -import static com.ss.rlib.util.ClassUtils.unsafeCast; -import com.jme3.asset.AssetKey; +import static com.ss.rlib.common.util.ClassUtils.unsafeCast; import com.jme3.audio.AudioNode; import com.jme3.light.Light; -import com.jme3.light.LightList; import com.jme3.material.Material; import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.Spatial; +import com.jme3.scene.Spatial.DFSMode; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; -import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.util.StringUtils; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; +import java.util.Optional; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Stream; @@ -29,14 +29,13 @@ */ public class NodeUtils { - @NotNull private static final Field FIELD_WORLD_BOUND; static { try { FIELD_WORLD_BOUND = Spatial.class.getDeclaredField("worldBound"); FIELD_WORLD_BOUND.setAccessible(true); - } catch (final Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -50,14 +49,13 @@ public class NodeUtils { * @return the found parent or null. */ @FromAnyThread - public static @Nullable T findParent(@NotNull final Spatial spatial, - @NotNull final Predicate condition) { + public static @Nullable T findParent(@NotNull Spatial spatial, @NotNull Predicate condition) { if (condition.test(spatial)) { return unsafeCast(spatial); } - final Node parent = spatial.getParent(); + var parent = spatial.getParent(); if (parent == null) { return null; } @@ -65,6 +63,32 @@ public class NodeUtils { return findParent(parent, condition); } + /** + * Find a parent of the model. + * + * @param the node's type. + * @param spatial the spatial. + * @param condition the condition. + * @return the optional result. + */ + @FromAnyThread + public static @NotNull Optional findParentOpt( + @NotNull Spatial spatial, + @NotNull Predicate condition + ) { + + if (condition.test(spatial)) { + return Optional.of(unsafeCast(spatial)); + } + + var parent = spatial.getParent(); + if (parent == null) { + return Optional.empty(); + } + + return findParentOpt(parent, condition); + } + /** * Find a parent of the model by the steps. * @@ -73,7 +97,7 @@ public class NodeUtils { * @return the result parent. */ @FromAnyThread - public static @Nullable Spatial findParent(@NotNull final Spatial spatial, int count) { + public static @Nullable Spatial findParent(@NotNull Spatial spatial, int count) { Spatial parent = spatial; @@ -91,7 +115,7 @@ public class NodeUtils { * @return the geometry or null. */ @FromAnyThread - public static @Nullable Geometry findGeometry(@NotNull final Spatial spatial) { + public static @Nullable Geometry findGeometry(@NotNull Spatial spatial) { if (spatial instanceof Geometry) { return (Geometry) spatial; @@ -99,10 +123,10 @@ public class NodeUtils { return null; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { - final Geometry geometry = findGeometry(children); + for (var children : node.getChildren()) { + var geometry = findGeometry(children); if (geometry != null) { return geometry; } else if (children instanceof Geometry) { @@ -121,17 +145,21 @@ public class NodeUtils { * @return the geometry or null. */ @FromAnyThread - public static @Nullable Geometry findGeometry(@NotNull final Spatial spatial, @NotNull final String name) { + public static @Nullable Geometry findGeometry(@NotNull Spatial spatial, @NotNull String name) { if (!(spatial instanceof Node)) { return null; } - final Node node = (Node) spatial; + var node = (Node) spatial; + + for (var children : node.getChildren()) { + + var geometry = findGeometry(children, name); + if (geometry != null) { + return geometry; + } - for (final Spatial children : node.getChildren()) { - final Geometry geometry = findGeometry(children, name); - if (geometry != null) return geometry; if (children instanceof Geometry && StringUtils.equals(children.getName(), name)) { return (Geometry) children; } @@ -148,18 +176,17 @@ public class NodeUtils { * @return the geometry or null. */ @FromAnyThread - public static @Nullable Geometry findGeometry(@NotNull final Spatial spatial, - @NotNull final Predicate condition) { + public static @Nullable Geometry findGeometry(@NotNull Spatial spatial, @NotNull Predicate condition) { if (!(spatial instanceof Node)) { return null; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial child : node.getChildren()) { + for (var child : node.getChildren()) { - final Geometry geometry = findGeometry(child, condition); + var geometry = findGeometry(child, condition); if (geometry != null) { return geometry; } @@ -180,18 +207,17 @@ public class NodeUtils { * @return the material or null. */ @FromAnyThread - public static @Nullable Material findMateial(@NotNull final Spatial spatial, - @NotNull final Predicate condition) { + public static @Nullable Material findMateial(@NotNull Spatial spatial, @NotNull Predicate condition) { if (!(spatial instanceof Node)) { return null; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial child : node.getChildren()) { + for (var child : node.getChildren()) { - final Material material = findMateial(child, condition); + var material = findMateial(child, condition); if (material != null) { return material; } @@ -212,8 +238,12 @@ public class NodeUtils { * @return the spatial or null. */ @FromAnyThread - public static @Nullable Spatial findSpatial(@NotNull final Spatial spatial, @NotNull final String name) { - if (!(spatial instanceof Node)) return null; + public static @Nullable Spatial findSpatial(@NotNull Spatial spatial, @NotNull String name) { + + if (!(spatial instanceof Node)) { + return null; + } + return ((Node) spatial).getChild(name); } @@ -225,7 +255,7 @@ public class NodeUtils { * @return the spatial. */ @FromAnyThread - public static @Nullable Spatial findSpatial(@NotNull final Spatial spatial, @NotNull final Predicate condition) { + public static @Nullable Spatial findSpatial(@NotNull Spatial spatial, @NotNull Predicate condition) { if (condition.test(spatial)) { return spatial; @@ -233,10 +263,10 @@ public class NodeUtils { return null; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { - final Spatial child = findSpatial(children, condition); + for (var children : node.getChildren()) { + var child = findSpatial(children, condition); if (child != null) { return child; } @@ -253,15 +283,21 @@ public class NodeUtils { * @param assetPath the asset path. */ @FromAnyThread - public static void addGeometryWithMaterial(@NotNull final Spatial spatial, @NotNull final Array container, - @NotNull final String assetPath) { - if (StringUtils.isEmpty(assetPath)) return; + public static void addGeometryWithMaterial( + @NotNull Spatial spatial, + @NotNull Array container, + @NotNull String assetPath + ) { + + if (StringUtils.isEmpty(assetPath)) { + return; + } if (spatial instanceof Geometry) { - final Geometry geometry = (Geometry) spatial; - final Material material = geometry.getMaterial(); - final String assetName = material == null ? null : material.getAssetName(); + var geometry = (Geometry) spatial; + var material = geometry.getMaterial(); + var assetName = material == null ? null : material.getAssetName(); if (StringUtils.equals(assetName, assetPath)) { container.add(geometry); @@ -273,9 +309,9 @@ public static void addGeometryWithMaterial(@NotNull final Spatial spatial, @NotN return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { + for (var children : node.getChildren()) { addGeometryWithMaterial(children, container, assetPath); } } @@ -288,11 +324,17 @@ public static void addGeometryWithMaterial(@NotNull final Spatial spatial, @NotN * @param assetPath the asset path. */ @FromAnyThread - public static void addSpatialWithAssetPath(@NotNull final Spatial spatial, @NotNull final Array container, - @NotNull final String assetPath) { - if (StringUtils.isEmpty(assetPath)) return; + public static void addSpatialWithAssetPath( + @NotNull Spatial spatial, + @NotNull Array container, + @NotNull String assetPath + ) { + + if (StringUtils.isEmpty(assetPath)) { + return; + } - final AssetKey key = spatial.getKey(); + var key = spatial.getKey(); if (key != null && StringUtils.equals(key.getName(), assetPath)) { container.add(spatial); @@ -302,9 +344,9 @@ public static void addSpatialWithAssetPath(@NotNull final Spatial spatial, @NotN return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { + for (var children : node.getChildren()) { addSpatialWithAssetPath(children, container, assetPath); } } @@ -316,20 +358,12 @@ public static void addSpatialWithAssetPath(@NotNull final Spatial spatial, @NotN * @param consumer the consumer. */ @FromAnyThread - public static void visitGeometry(@NotNull final Spatial spatial, @NotNull final Consumer consumer) { - - if (spatial instanceof Geometry) { - consumer.accept((Geometry) spatial); - return; - } else if (!(spatial instanceof Node)) { - return; - } - - final Node node = (Node) spatial; - - for (final Spatial children : node.getChildren()) { - visitGeometry(children, consumer); - } + public static void visitGeometry(@NotNull Spatial spatial, @NotNull Consumer consumer) { + spatial.depthFirstTraversal(sp -> { + if (spatial instanceof Geometry) { + consumer.accept((Geometry) sp); + } + }, DFSMode.PRE_ORDER); } /** @@ -339,7 +373,7 @@ public static void visitGeometry(@NotNull final Spatial spatial, @NotNull final * @param handler the handler which should return true if need to visit children of a spatial. */ @FromAnyThread - public static void visitSpatial(@NotNull final Spatial spatial, @NotNull final Predicate handler) { + public static void visitSpatial(@NotNull Spatial spatial, @NotNull Predicate handler) { if (!handler.test(spatial)) { return; @@ -347,9 +381,9 @@ public static void visitSpatial(@NotNull final Spatial spatial, @NotNull final P return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial child : node.getChildren()) { + for (var child : node.getChildren()) { visitSpatial(child, handler); } } @@ -361,7 +395,7 @@ public static void visitSpatial(@NotNull final Spatial spatial, @NotNull final P * @param consumer the consumer. */ @FromAnyThread - public static void visitMaterials(@NotNull final Spatial spatial, @NotNull final Consumer consumer) { + public static void visitMaterials(@NotNull Spatial spatial, @NotNull Consumer consumer) { if (spatial instanceof Geometry) { consumer.accept(((Geometry) spatial).getMaterial()); @@ -370,9 +404,9 @@ public static void visitMaterials(@NotNull final Spatial spatial, @NotNull final return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { + for (var children : node.getChildren()) { visitMaterials(children, consumer); } } @@ -386,8 +420,11 @@ public static void visitMaterials(@NotNull final Spatial spatial, @NotNull final * @param consumer the consumer. */ @FromAnyThread - public static void visitSpatial(@NotNull final Spatial spatial, @NotNull final Class type, - @NotNull final Consumer consumer) { + public static void visitSpatial( + @NotNull Spatial spatial, + @NotNull Class type, + @NotNull Consumer consumer + ) { if (type.isInstance(spatial)) { consumer.accept(type.cast(spatial)); @@ -397,9 +434,9 @@ public static void visitSpatial(@NotNull final Spatial spati return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { + for (var children : node.getChildren()) { visitSpatial(children, type, consumer); } } @@ -411,8 +448,8 @@ public static void visitSpatial(@NotNull final Spatial spati * @return the list of all geometries. */ @FromAnyThread - public static @NotNull Array getGeometries(@NotNull final Spatial spatial) { - final Array result = ArrayFactory.newArray(Geometry.class); + public static @NotNull Array getGeometries(@NotNull Spatial spatial) { + var result = ArrayFactory.newArray(Geometry.class); addGeometry(spatial, result); return result; } @@ -424,7 +461,7 @@ public static void visitSpatial(@NotNull final Spatial spati * @param container the container. */ @FromAnyThread - public static void addGeometry(@NotNull final Spatial spatial, @NotNull final Array container) { + public static void addGeometry(@NotNull Spatial spatial, @NotNull Array container) { if (spatial instanceof Geometry) { container.add((Geometry) spatial); @@ -433,9 +470,9 @@ public static void addGeometry(@NotNull final Spatial spatial, @NotNull final Ar return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { + for (var children : node.getChildren()) { addGeometry(children, container); } } @@ -447,18 +484,18 @@ public static void addGeometry(@NotNull final Spatial spatial, @NotNull final Ar * @param container the container. */ @FromAnyThread - public static void addLight(@NotNull final Spatial spatial, @NotNull final Array container) { + public static void addLight(@NotNull Spatial spatial, @NotNull Array container) { - final LightList lightList = spatial.getLocalLightList(); + var lightList = spatial.getLocalLightList(); lightList.forEach(container::add); if (!(spatial instanceof Node)) { return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { + for (var children : node.getChildren()) { addLight(children, container); } } @@ -470,15 +507,15 @@ public static void addLight(@NotNull final Spatial spatial, @NotNull final Array * @param container the container. */ @FromAnyThread - public static void addAudioNodes(@NotNull final Spatial spatial, @NotNull final Array container) { + public static void addAudioNodes(@NotNull Spatial spatial, @NotNull Array container) { if (!(spatial instanceof Node)) { return; } - final Node node = (Node) spatial; + var node = (Node) spatial; - for (final Spatial children : node.getChildren()) { + for (var children : node.getChildren()) { if (children instanceof AudioNode) { container.add((AudioNode) children); } @@ -493,9 +530,9 @@ public static void addAudioNodes(@NotNull final Spatial spatial, @NotNull final * @return the spatial's stream. */ @FromAnyThread - public static Stream children(@NotNull final Spatial spatial) { + public static Stream children(@NotNull Spatial spatial) { - final Array result = ArrayFactory.newArray(Spatial.class); + var result = ArrayFactory.newArray(Spatial.class); visitSpatial(spatial, sp -> { result.add(sp); @@ -511,7 +548,7 @@ public static Stream children(@NotNull final Spatial spatial) { * @param spatial the spatial. */ @JmeThread - public static void updateWorldBound(@NotNull final Spatial spatial) { + public static void updateWorldBound(@NotNull Spatial spatial) { children(spatial).forEach(sp -> sp.forceRefresh(true, true, false)); children(spatial).forEach(Spatial::getWorldBound); } diff --git a/src/main/java/com/ss/editor/util/OpenGLVersion.java b/src/main/java/com/ss/editor/util/OpenGLVersion.java index ef0bc113..b3f126b7 100644 --- a/src/main/java/com/ss/editor/util/OpenGLVersion.java +++ b/src/main/java/com/ss/editor/util/OpenGLVersion.java @@ -19,11 +19,9 @@ public enum OpenGLVersion { GL_44(AppSettings.LWJGL_OPENGL44, "4.4 with core profile"), GL_45(AppSettings.LWJGL_OPENGL45, "4.5 with core profile"); - @NotNull private static final OpenGLVersion[] VERSIONS = values(); - @NotNull - public static OpenGLVersion valueOf(final int index) { + public static @NotNull OpenGLVersion valueOf(int index) { return VERSIONS[index]; } @@ -39,20 +37,23 @@ public static OpenGLVersion valueOf(final int index) { @NotNull private final String label; - OpenGLVersion(@NotNull final String render, @NotNull final String label) { + OpenGLVersion(@NotNull String render, @NotNull String label) { this.render = render; this.label = label; } /** + * Get the value for render. + * * @return the value for render. */ - @NotNull - public String getRender() { + public @NotNull String getRender() { return render; } /** + * Get the label for UI. + * * @return the label for UI. */ @Override diff --git a/src/main/java/com/ss/editor/util/PaintingUtils.java b/src/main/java/com/ss/editor/util/PaintingUtils.java index 9fd9b2fb..70c4e44c 100644 --- a/src/main/java/com/ss/editor/util/PaintingUtils.java +++ b/src/main/java/com/ss/editor/util/PaintingUtils.java @@ -1,14 +1,12 @@ package com.ss.editor.util; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.shape.Sphere; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.control.painting.PaintingControl; +import com.ss.rlib.common.geom.util.CoordsUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,7 +24,7 @@ public class PaintingUtils { * @return the painting control or null. */ @FromAnyThread - public static @Nullable PaintingControl getPaintingControl(@NotNull final Node cursorNode) { + public static @Nullable PaintingControl getPaintingControl(@NotNull Node cursorNode) { return cursorNode.getControl(PaintingControl.class); } @@ -37,9 +35,9 @@ public class PaintingUtils { * @return the edited model or null. */ @FromAnyThread - public static @Nullable Spatial getPaintedModel(@NotNull final Node cursorNode) { - final PaintingControl control = getPaintingControl(cursorNode); - final Object paintedModel = control == null ? null : control.getPaintedModel(); + public static @Nullable Spatial getPaintedModel(@NotNull Node cursorNode) { + var control = getPaintingControl(cursorNode); + var paintedModel = control == null ? null : control.getPaintedModel(); return paintedModel instanceof Spatial ? (Spatial) paintedModel : null; } @@ -50,30 +48,29 @@ public class PaintingUtils { * @return the painted model or null. */ @FromAnyThread - public static @Nullable Spatial getPaintedModel(@Nullable final PaintingControl control) { - final Object paintedModel = control == null ? null : control.getPaintedModel(); + public static @Nullable Spatial getPaintedModel(@Nullable PaintingControl control) { + var paintedModel = control == null ? null : control.getPaintedModel(); return paintedModel instanceof Spatial ? (Spatial) paintedModel : null; } /** - * Check that the point is contains in a geometry. + * Check that the point is contains in the geometry. * * @param geometry the geometry. - * @param x the X coord. - * @param y the Y coord. - * @return true of the mesh contains the point. + * @param x the X component. + * @param y the Y component. + * @return true if the geometry contains the point. */ @FromAnyThread - public static boolean isContains(@NotNull final Geometry geometry, final float x, final float y) { + public static boolean isContains(@NotNull Geometry geometry, float x, float y) { - final Mesh mesh = geometry.getMesh(); - final Vector3f localScale = geometry.getLocalScale(); + var mesh = geometry.getMesh(); + var localScale = geometry.getLocalScale(); if (mesh instanceof Sphere) { - final float radius = ((Sphere) mesh).getRadius() * localScale.getX(); - final Vector2f point = new Vector2f(x, y); + var radius = ((Sphere) mesh).getRadius() * localScale.getX(); // return true if the distance is less than equal to the radius - return Math.abs(point.length()) <= radius; + return Math.abs(CoordsUtils.length(x, y)) <= radius; } return false; @@ -87,70 +84,28 @@ public static boolean isContains(@NotNull final Geometry geometry, final float x * * @param radius of the tool. * @param heightFactor potential height value to be adjusted. - * @param x location. - * @param z location. + * @param x the X component. + * @param y the Y component. * @return the adjusted height value. */ @FromAnyThread - public static float calculateHeight(final float radius, final float heightFactor, final float x, final float z) { - float val = calculateRadiusPercent(radius, x, z); - return heightFactor * val; + public static float calculateHeight(float radius, float heightFactor, float x, float y) { + return heightFactor * calculateRadiusPercent(radius, x, y); } /** - * Calculate radius percent float. + * Calculate percent of vector length and radius. * * @param radius the radius. - * @param x the x. - * @param z the z. - * @return the float. + * @param x the X component. + * @param y the Y component. + * @return the result percent. */ @FromAnyThread - public static float calculateRadiusPercent(final float radius, final float x, final float z) { + public static float calculateRadiusPercent(float radius, float x, float y) { // find percentage for each 'unit' in radius - final Vector2f point = LocalObjects.get().nextVector(x, z); - float val = Math.abs(point.length()) / radius; + var val = Math.abs(CoordsUtils.length(x, y)) / radius; val = 1f - val; return val; } - - /** - * Compare the two float values by the epsilon. - * - * @param first the first. - * @param second the second. - * @param epsilon the epsilon. - * @return true if the values are equals. - */ - @FromAnyThread - public static boolean floatEquals(final float first, final float second, final float epsilon) { - return first == second || Math.abs(first - second) < epsilon; - } - - /** - * Compare the two float values by the epsilon. - * - * @param first the first. - * @param second the second. - * @param epsilon the epsilon. - * @return true if the first value is less than the second value. - */ - @FromAnyThread - public static boolean floatLessThan(final float first, final float second, final float epsilon) { - return second - first > epsilon; - } - - /** - * Compare the two float values by the epsilon. - * - * @param first the first. - * @param second the second. - * @param epsilon the epsilon. - * @return the boolean - * @return true if the first value is greater than the second value. - */ - @FromAnyThread - public static boolean floatGreaterThan(final float first, final float second, final float epsilon) { - return first - second > epsilon; - } } diff --git a/src/main/java/com/ss/editor/util/ReusableCollisionResults.java b/src/main/java/com/ss/editor/util/ReusableCollisionResults.java index 3d39e844..42b79a75 100644 --- a/src/main/java/com/ss/editor/util/ReusableCollisionResults.java +++ b/src/main/java/com/ss/editor/util/ReusableCollisionResults.java @@ -3,9 +3,9 @@ import com.jme3.collision.CollisionResult; import com.jme3.collision.CollisionResults; import com.ss.editor.annotation.JmeThread; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; -import com.ss.rlib.util.pools.Reusable; +import com.ss.rlib.common.util.array.Array; +import com.ss.rlib.common.util.array.ArrayFactory; +import com.ss.rlib.common.util.pools.Reusable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,19 +37,19 @@ public ReusableCollisionResults() { @Override @JmeThread - public void addCollision(@NotNull final CollisionResult result) { + public void addCollision(@NotNull CollisionResult result) { collisions.add(result); original.add(result); } @Override - public Iterator iterator() { + public @NotNull Iterator iterator() { return collisions.iterator(); } @Override @JmeThread - public CollisionResult getCollisionDirect(final int index) { + public CollisionResult getCollisionDirect(int index) { return original.get(index); } diff --git a/src/main/java/com/ss/editor/util/SimpleFileVisitor.java b/src/main/java/com/ss/editor/util/SimpleFileVisitor.java index b109c4d6..efaefd18 100644 --- a/src/main/java/com/ss/editor/util/SimpleFileVisitor.java +++ b/src/main/java/com/ss/editor/util/SimpleFileVisitor.java @@ -17,35 +17,32 @@ public interface SimpleFileVisitor extends FileVisitor { @Override - default FileVisitResult preVisitDirectory(@NotNull final Path dir, @NotNull final BasicFileAttributes attrs) + default FileVisitResult preVisitDirectory(@NotNull Path dir, @NotNull BasicFileAttributes attrs) throws IOException { return FileVisitResult.CONTINUE; } @Override - default FileVisitResult visitFile(@NotNull final Path file, @NotNull final BasicFileAttributes attrs) - throws IOException { + default FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) throws IOException { visit(file, attrs); return FileVisitResult.CONTINUE; } /** - * Visit. + * Visit the file. * - * @param file the file - * @param attrs the attrs + * @param file the file. + * @param attrs the attributes of the file. */ - void visit(@NotNull final Path file, @NotNull final BasicFileAttributes attrs); + void visit(@NotNull Path file, @NotNull BasicFileAttributes attrs); @Override - default FileVisitResult visitFileFailed(@NotNull final Path file, @Nullable final IOException exc) - throws IOException { + default FileVisitResult visitFileFailed(@NotNull Path file, @Nullable IOException exc) throws IOException { return FileVisitResult.CONTINUE; } @Override - default FileVisitResult postVisitDirectory(@NotNull final Path dir, @Nullable final IOException exc) - throws IOException { + default FileVisitResult postVisitDirectory(@NotNull Path dir, @Nullable IOException exc) throws IOException { return FileVisitResult.CONTINUE; } } diff --git a/src/main/java/com/ss/editor/util/SimpleFolderVisitor.java b/src/main/java/com/ss/editor/util/SimpleFolderVisitor.java index 68656e84..c55e8466 100644 --- a/src/main/java/com/ss/editor/util/SimpleFolderVisitor.java +++ b/src/main/java/com/ss/editor/util/SimpleFolderVisitor.java @@ -15,14 +15,15 @@ public interface SimpleFolderVisitor extends SimpleFileVisitor { @Override - default @NotNull FileVisitResult preVisitDirectory(@NotNull final Path dir, - @NotNull final BasicFileAttributes attrs) throws IOException { + default @NotNull FileVisitResult preVisitDirectory( + @NotNull Path dir, @NotNull BasicFileAttributes attrs + ) throws IOException { visit(dir, attrs); return FileVisitResult.CONTINUE; } @Override - default @NotNull FileVisitResult visitFile(@NotNull final Path file, @NotNull final BasicFileAttributes attrs) + default @NotNull FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) throws IOException { return FileVisitResult.CONTINUE; } diff --git a/src/main/java/com/ss/editor/util/TangentGenerator.java b/src/main/java/com/ss/editor/util/TangentGenerator.java index e9ce5453..5340bbd2 100644 --- a/src/main/java/com/ss/editor/util/TangentGenerator.java +++ b/src/main/java/com/ss/editor/util/TangentGenerator.java @@ -1,12 +1,11 @@ package com.ss.editor.util; -import com.jme3.scene.Mesh; import com.jme3.scene.Spatial; -import com.jme3.scene.VertexBuffer; +import com.jme3.scene.VertexBuffer.Type; import com.jme3.util.TangentBinormalGenerator; import com.jme3.util.mikktspace.MikktspaceTangentGenerator; -import com.ss.rlib.logging.Logger; -import com.ss.rlib.logging.LoggerManager; +import com.ss.rlib.common.logging.Logger; +import com.ss.rlib.common.logging.LoggerManager; import org.jetbrains.annotations.NotNull; /** @@ -25,20 +24,20 @@ public class TangentGenerator { * @param spatial the spatial. * @param splitMirrored the split mirrored. */ - public static void useStandardGenerator(@NotNull final Spatial spatial, final boolean splitMirrored) { + public static void useStandardGenerator(@NotNull Spatial spatial, boolean splitMirrored) { try { NodeUtils.visitGeometry(spatial, geometry -> { - final Mesh mesh = geometry.getMesh(); - final VertexBuffer texCoord = mesh.getBuffer(VertexBuffer.Type.TexCoord); + var mesh = geometry.getMesh(); + var texCoord = mesh.getBuffer(Type.TexCoord); if (texCoord != null) { TangentBinormalGenerator.generate(geometry, splitMirrored); } }); - } catch (final Exception e) { + } catch (Exception e) { EditorUtil.handleException(LOGGER, null, e); } } @@ -48,20 +47,20 @@ public static void useStandardGenerator(@NotNull final Spatial spatial, final bo * * @param spatial the spatial. */ - public static void useMikktspaceGenerator(@NotNull final Spatial spatial) { + public static void useMikktspaceGenerator(@NotNull Spatial spatial) { try { NodeUtils.visitGeometry(spatial, geometry -> { - final Mesh mesh = geometry.getMesh(); - final VertexBuffer texCoord = mesh.getBuffer(VertexBuffer.Type.TexCoord); + var mesh = geometry.getMesh(); + var texCoord = mesh.getBuffer(Type.TexCoord); if (texCoord != null) { MikktspaceTangentGenerator.generate(geometry); } }); - } catch (final Exception e) { + } catch (Exception e) { EditorUtil.handleException(LOGGER, null, e); } } diff --git a/src/main/java/com/ss/editor/util/svg/SvgImageLoader.java b/src/main/java/com/ss/editor/util/svg/SvgImageLoader.java index e0a3084e..b77e14e7 100644 --- a/src/main/java/com/ss/editor/util/svg/SvgImageLoader.java +++ b/src/main/java/com/ss/editor/util/svg/SvgImageLoader.java @@ -4,7 +4,7 @@ import static org.apache.batik.transcoder.SVGAbstractTranscoder.KEY_WIDTH; import com.ss.editor.annotation.FxThread; import com.sun.javafx.iio.ImageFrame; -import com.sun.javafx.iio.ImageStorage; +import com.sun.javafx.iio.ImageStorage.ImageType; import de.codecentric.centerdevice.javafxsvg.BufferedImageTranscoder; import de.codecentric.centerdevice.javafxsvg.FixedPixelDensityImageFrame; import de.codecentric.centerdevice.javafxsvg.ScreenHelper; @@ -13,6 +13,7 @@ import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.transcoder.TranscoderInput; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.awt.image.BufferedImage; import java.io.IOException; @@ -25,7 +26,7 @@ public class SvgImageLoader extends de.codecentric.centerdevice.javafxsvg.SvgImageLoader { @NotNull - public static ThreadLocal OVERRIDE_COLOR = new ThreadLocal<>(); + public static final ThreadLocal OVERRIDE_COLOR = new ThreadLocal<>(); private static final int DEFAULT_SIZE = 400; private static final int BYTES_PER_PIXEL = 4; // RGBA @@ -35,7 +36,7 @@ public class SvgImageLoader extends de.codecentric.centerdevice.javafxsvg.SvgIma @NotNull private final InputStream input; - protected SvgImageLoader(@NotNull final InputStream input) { + protected SvgImageLoader(@NotNull InputStream input) { super(input); this.input = input; } @@ -53,15 +54,15 @@ public float getPixelScale() { @Override @FxThread - public @NotNull ImageFrame load(int imageIndex, int width, int height, boolean preserveAspectRatio, boolean smooth) + public @Nullable ImageFrame load(int imageIndex, int width, int height, boolean preserveAspectRatio, boolean smooth) throws IOException { if (0 != imageIndex) { return null; } - int imageWidth = width > 0 ? width : DEFAULT_SIZE; - int imageHeight = height > 0 ? height : DEFAULT_SIZE; + var imageWidth = width > 0 ? width : DEFAULT_SIZE; + var imageHeight = height > 0 ? height : DEFAULT_SIZE; try { return createImageFrame(imageWidth, imageHeight, getPixelScale()); @@ -74,11 +75,10 @@ public float getPixelScale() { @FxThread public float calculateMaxRenderScale() { - float maxRenderScale = 0; + var maxRenderScale = 0F; + var accessor = ScreenHelper.getScreenAccessor(); - ScreenHelper.ScreenAccessor accessor = ScreenHelper.getScreenAccessor(); - - for (final Screen screen : Screen.getScreens()) { + for (var screen : Screen.getScreens()) { maxRenderScale = Math.max(maxRenderScale, accessor.getRenderScale(screen)); } @@ -86,19 +86,19 @@ public float calculateMaxRenderScale() { } @FxThread - private @NotNull ImageFrame createImageFrame(final int width, final int height, final float pixelScale) + private @NotNull ImageFrame createImageFrame(int width, int height, float pixelScale) throws TranscoderException { - final BufferedImage bufferedImage = getTranscodedImage(width * pixelScale, height * pixelScale); - final ByteBuffer imageData = getImageData(bufferedImage); + var bufferedImage = getTranscodedImage(width * pixelScale, height * pixelScale); + var imageData = getImageData(bufferedImage); - return new FixedPixelDensityImageFrame(ImageStorage.ImageType.RGBA, imageData, bufferedImage.getWidth(), + return new FixedPixelDensityImageFrame(ImageType.RGBA, imageData, bufferedImage.getWidth(), bufferedImage.getHeight(), getStride(bufferedImage), null, pixelScale, null); } @FxThread - private @NotNull BufferedImage getTranscodedImage(final float width, final float height) throws TranscoderException { - final BufferedImageTranscoder trans = new BufferedImageTranscoder(BufferedImage.TYPE_INT_ARGB); + private @NotNull BufferedImage getTranscodedImage(float width, float height) throws TranscoderException { + var trans = new BufferedImageTranscoder(BufferedImage.TYPE_INT_ARGB); trans.addTranscodingHint(KEY_WIDTH, width); trans.addTranscodingHint(KEY_HEIGHT, height); trans.transcode(new TranscoderInput(this.input), null); @@ -106,7 +106,7 @@ public float calculateMaxRenderScale() { } @FxThread - private int getStride(@NotNull final BufferedImage bufferedImage) { + private int getStride(@NotNull BufferedImage bufferedImage) { return bufferedImage.getWidth() * BYTES_PER_PIXEL; } @@ -117,11 +117,11 @@ private int getStride(@NotNull final BufferedImage bufferedImage) { * @return the bytes pixels. */ @FxThread - private @NotNull ByteBuffer getImageData(@NotNull final BufferedImage bufferedImage) { + private @NotNull ByteBuffer getImageData(@NotNull BufferedImage bufferedImage) { - final int[] argbData = bufferedImage.getRGB(0, 0, bufferedImage.getWidth(), + var argbData = bufferedImage.getRGB(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), null, 0, bufferedImage.getWidth()); - final byte[] imageData = new byte[getStride(bufferedImage) * bufferedImage.getHeight()]; + var imageData = new byte[getStride(bufferedImage) * bufferedImage.getHeight()]; copyColorToBytes(argbData, imageData); @@ -135,22 +135,21 @@ private int getStride(@NotNull final BufferedImage bufferedImage) { * @param imageData the bytes pixels data. */ @FxThread - private void copyColorToBytes(final int[] argbData, final byte[] imageData) { + private void copyColorToBytes(int[] argbData, byte[] imageData) { if (argbData.length * BYTES_PER_PIXEL != imageData.length) { throw new ArrayIndexOutOfBoundsException(); } - final Color overrideColor = OVERRIDE_COLOR.get(); + var overrideColor = OVERRIDE_COLOR.get(); for (int i = 0; i < argbData.length; i++) { - final int argb = argbData[i]; - - int alpha = argb >>> 24; - int red = (argb >> 16) & 0xff; - int green = (argb >> 8) & 0xff; - int blue = (argb) & 0xff; + var argb = argbData[i]; + var alpha = argb >>> 24; + var red = (argb >> 16) & 0xff; + var green = (argb >> 8) & 0xff; + var blue = (argb) & 0xff; if (overrideColor != null) { red = (int) (overrideColor.getRed() * 255); @@ -158,7 +157,8 @@ private void copyColorToBytes(final int[] argbData, final byte[] imageData) { blue = (int) (overrideColor.getBlue() * 255); } - int dataOffset = BYTES_PER_PIXEL * i; + var dataOffset = BYTES_PER_PIXEL * i; + imageData[dataOffset] = (byte) red; imageData[dataOffset + 1] = (byte) green; imageData[dataOffset + 2] = (byte) blue; diff --git a/src/main/java/com/ss/editor/util/svg/SvgImageLoaderFactory.java b/src/main/java/com/ss/editor/util/svg/SvgImageLoaderFactory.java index d0026199..4d66215e 100644 --- a/src/main/java/com/ss/editor/util/svg/SvgImageLoaderFactory.java +++ b/src/main/java/com/ss/editor/util/svg/SvgImageLoaderFactory.java @@ -16,7 +16,6 @@ */ public class SvgImageLoaderFactory implements ImageLoaderFactory { - @NotNull private static final ImageLoaderFactory INSTANCE = new SvgImageLoaderFactory(); @FxThread @@ -37,7 +36,7 @@ public ImageFormatDescription getFormatDescription() { @Override @FxThread - public ImageLoader createImageLoader(@NotNull final InputStream input) throws IOException { + public ImageLoader createImageLoader(@NotNull InputStream input) throws IOException { return new SvgImageLoader(input); } } diff --git a/src/main/resources/messages/messages.properties b/src/main/resources/messages/messages.properties index 5370c0cb..4a71c727 100644 --- a/src/main/resources/messages/messages.properties +++ b/src/main/resources/messages/messages.properties @@ -456,6 +456,22 @@ ModelPropertyLightMode=Light mode ModelPropertyColorSpace=Color space ModelPropertyLanguage=Language ModelPropertyTexture=Texture +ModelPropertyBrushSize=Brush size +ModelPropertyBrushPower=Brush power +ModelPropertySmoothly=Smoothly +ModelPropertyLimited=Limited +ModelPropertyUseMarker=User marker +ModelPropertyRoughness=Roughness +ModelPropertyFrequency=Frequency +ModelPropertyLacunarity=Lacunarity +ModelPropertyOctaves=Octaves +ModelPropertyMinScale=Min scale +ModelPropertyMaxScale=Max scale +ModelPropertyPadding=Padding +ModelPropertyTriPlanar=Tri-planar +ModelPropertyShininess=Shininess +ModelPropertyModel=Model +ModelPropertyMethod=Method MaterialModelPropertyControlNoTexture=No texture MaterialModelPropertyControlTextureSettings=Texture settings @@ -616,23 +632,6 @@ CreateParticleEmitterQuadShapeDialogTitle=Creating a quad shape CreateParticleEmitterTorusShapeDialogTitle=Creating a torus shape CreateParticleEmitterTriangleShapeDialogTitle=Creating a triangle shape -PaintingComponentBrushSize=Brush size -PaintingComponentBrushPower=Brush power -PaintingComponentSmoothly=Smoothly -PaintingComponentLimited=Limited -PaintingComponentUseMarker=User marker -PaintingComponentLevel=Level -PaintingComponentRoughness=Roughness -PaintingComponentFrequency=Frequency -PaintingComponentLacunarity=Lacunarity -PaintingComponentOctaves=Octaves -PaintingComponentScale=Scale -PaintingComponentTriPlanar=Tri-planar -PaintingComponentShininess=Shininess -PaintingComponentLayer=Layer -PaintingComponentModel=Model -PaintingComponentMethod=Method - ModelConverterDialogTitle=Model converting ModelConverterDialogResultName=Result name ModelConverterDialogDestinationFolder=Destination folder diff --git a/src/main/resources/messages/messages_de.properties b/src/main/resources/messages/messages_de.properties index 94ad9ad6..51d53a99 100644 --- a/src/main/resources/messages/messages_de.properties +++ b/src/main/resources/messages/messages_de.properties @@ -456,6 +456,22 @@ ModelPropertyLightMode=Lichtmodus ModelPropertyColorSpace=Farbraum ModelPropertyLanguage=Sprache ModelPropertyTexture=Textur +ModelPropertyBrushSize=Pinselgröße +ModelPropertyBrushPower=Pinselstärke +ModelPropertySmoothly=Weich +ModelPropertyLimited=Begrenzt +ModelPropertyUseMarker=Benutze Marker +ModelPropertyRoughness=Rauheit +ModelPropertyFrequency=Frequenz +ModelPropertyLacunarity=Lakunarität +ModelPropertyOctaves=Oktaven +ModelPropertyMinScale=Min scale +ModelPropertyMaxScale=Max scale +ModelPropertyPadding=Padding +ModelPropertyTriPlanar=Dreiflächig +ModelPropertyShininess=Glänzend +ModelPropertyModel=Model +ModelPropertyMethod=Method MaterialModelPropertyControlNoTexture=Keine Textur MaterialModelPropertyControlTextureSettings=Textureinstellungen @@ -616,23 +632,6 @@ CreateParticleEmitterQuadShapeDialogTitle=Viereck-Form erstellen CreateParticleEmitterTorusShapeDialogTitle=Torus-Form erstellen CreateParticleEmitterTriangleShapeDialogTitle=Dreieck-Form erstellen -PaintingComponentBrushSize=Pinselgröße -PaintingComponentBrushPower=Pinselstärke -PaintingComponentSmoothly=Weich -PaintingComponentLimited=Begrenzt -PaintingComponentUseMarker=Benutze Marker -PaintingComponentLevel=Stufe -PaintingComponentRoughness=Rauheit -PaintingComponentFrequency=Frequenz -PaintingComponentLacunarity=Lakunarität -PaintingComponentOctaves=Oktaven -PaintingComponentScale=Maßstab -PaintingComponentTriPlanar=Dreiflächig -PaintingComponentShininess=Glänzend -PaintingComponentLayer=Schicht -PaintingComponentModel=Model -PaintingComponentMethod=Method - ModelConverterDialogTitle=Modellkonvertierung ModelConverterDialogResultName=Resultierender Name ModelConverterDialogDestinationFolder=Ablageverzeichnis diff --git a/src/main/resources/messages/messages_fr.properties b/src/main/resources/messages/messages_fr.properties index bf0622b8..b93d42cf 100644 --- a/src/main/resources/messages/messages_fr.properties +++ b/src/main/resources/messages/messages_fr.properties @@ -456,7 +456,22 @@ ModelPropertyLightMode=Mode lumière ModelPropertyColorSpace=Espace colorimétrique ModelPropertyLanguage=Langue ModelPropertyTexture=Texture - +ModelPropertyBrushSize=Taille du pinceau +ModelPropertyBrushPower=Force du pincen (Intensité) +ModelPropertySmoothly=En douceur +ModelPropertyLimited=Limité +ModelPropertyUseMarker=Marqueur de l'utilisateur +ModelPropertyRoughness=Rugosité +ModelPropertyFrequency=Fréquence +ModelPropertyLacunarity=Lacunarité +ModelPropertyOctaves=Octaves +ModelPropertyMinScale=Min scale +ModelPropertyMaxScale=Max scale +ModelPropertyPadding=Padding +ModelPropertyTriPlanar=Tri-planaire +ModelPropertyShininess=Brillance +ModelPropertyModel=Model +ModelPropertyMethod=Method MaterialModelPropertyControlNoTexture=Aucune texture @@ -618,23 +633,6 @@ CreateParticleEmitterQuadShapeDialogTitle=Création d'une forme de quad CreateParticleEmitterTorusShapeDialogTitle=Création d'une forme de tore CreateParticleEmitterTriangleShapeDialogTitle=Création d'une forme de triangle -PaintingComponentBrushSize=Taille du pinceau -PaintingComponentBrushPower=Force du pincen (Intensité) -PaintingComponentSmoothly=En douceur -PaintingComponentLimited=Limité -PaintingComponentUseMarker=Marqueur de l'utilisateur -PaintingComponentLevel=Niveau -PaintingComponentRoughness=Rugosité -PaintingComponentFrequency=Fréquence -PaintingComponentLacunarity=Lacunarité -PaintingComponentOctaves=Octaves -PaintingComponentScale=Echelle -PaintingComponentTriPlanar=Tri-planaire -PaintingComponentShininess=Brillance -PaintingComponentLayer=Couche -PaintingComponentModel=Model -PaintingComponentMethod=Method - ModelConverterDialogTitle=Conversion de modèle ModelConverterDialogResultName=Nom du résultat ModelConverterDialogDestinationFolder=Dossier de destination diff --git a/src/main/resources/messages/messages_ru.properties b/src/main/resources/messages/messages_ru.properties index 058c948d..d9328f54 100644 --- a/src/main/resources/messages/messages_ru.properties +++ b/src/main/resources/messages/messages_ru.properties @@ -458,6 +458,22 @@ ModelPropertyLightMode=Режим света ModelPropertyColorSpace=Цвет. пространст. ModelPropertyLanguage=Язык ModelPropertyTexture=Текстура +ModelPropertyBrushSize=Размер кисти +ModelPropertyBrushPower=Сила кисти +ModelPropertySmoothly=Плавно +ModelPropertyLimited=Ограничено +ModelPropertyUseMarker=Использовать маркер +ModelPropertyRoughness=Шершавость +ModelPropertyFrequency=Частота +ModelPropertyLacunarity=Лакунарность +ModelPropertyOctaves=Октав +ModelPropertyMinScale=Мин. маштаб +ModelPropertyMaxScale=Макс. маштаб +ModelPropertyPadding=Паддинг +ModelPropertyTriPlanar=Три-плоскостной +ModelPropertyShininess=Блеск +ModelPropertyModel=Модель +ModelPropertyMethod=Метод MaterialModelPropertyControlNoTexture=Нет текстуры MaterialModelPropertyControlTextureSettings=Настройки текстуры @@ -618,23 +634,6 @@ CreateParticleEmitterQuadShapeDialogTitle=Создание формы квадр CreateParticleEmitterTorusShapeDialogTitle=Создание формы торуса CreateParticleEmitterTriangleShapeDialogTitle=Создание формы треугольника -PaintingComponentBrushSize=Размер кисти -PaintingComponentBrushPower=Сила кисти -PaintingComponentSmoothly=Плавно -PaintingComponentLimited=Ограничено -PaintingComponentUseMarker=Использовать маркер -PaintingComponentLevel=Уровень -PaintingComponentRoughness=Шершавость -PaintingComponentFrequency=Частота -PaintingComponentLacunarity=Лакунарность -PaintingComponentOctaves=Октав -PaintingComponentScale=Маштаб -PaintingComponentTriPlanar=Три-плоскостной -PaintingComponentShininess=Блеск -PaintingComponentLayer=Слой -PaintingComponentModel=Модель -PaintingComponentMethod=Метод - ModelConverterDialogTitle=Конвертирование модели ModelConverterDialogResultName=Итоговое имя ModelConverterDialogDestinationFolder=Папка для сохранения diff --git a/src/main/resources/messages/messages_zh_CN.properties b/src/main/resources/messages/messages_zh_CN.properties index 0a0b8b6e..a764eb61 100644 --- a/src/main/resources/messages/messages_zh_CN.properties +++ b/src/main/resources/messages/messages_zh_CN.properties @@ -1,683 +1,682 @@ -#Updated 2017-11-11 01:28 am +#Updated 2018-05-20 16:19 pm #By yan (115050813@qq.com) -EditorMenuFile=\u6587\u4ef6 -EditorMenuFileOpenAsset=\u6253\u5f00\u8d44\u6e90\u76ee\u5f55 -EditorMenuFileOpenAssetDirectoryChooser=\u9009\u62e9\u8d44\u6e90 -EditorMenuFileReopenAssetFolder=\u91cd\u65b0\u6253\u5f00\u76ee\u5f55 -EditorMenuFileExit=\u9000\u51fa -EditorMenuOther=\u5176\u4ed6 -EditorMenuOtherSettings=\u8bbe\u7f6e -EditorMenuOtherPlugins=\u63d2\u4ef6 -EditorMenuOtherClearAssetCache=\u6e05\u7a7a\u8d44\u6e90\u7f13\u5b58 -EditorMenuOtherUpdateClasspathAndAssetCache=\u66f4\u65b0Classpath -EditorMenuHelp=\u5e2e\u52a9 -EditorMenuHelpAbout=\u5173\u4e8e - -EditorToolAsset=\u8d44\u6e90 - -EditorAreaSaveFileQuestion=\u6587\u4ef6 "%file_name%" \u4fee\u6539\u540e\u5c1a\u672a\u4fdd\u5b58, \u662f\u5426\u9700\u8981\u4fdd\u5b58? - -AssetComponentResourceTreeContextMenuNewFile=\u65b0\u5efa -AssetComponentResourceTreeContextMenuOpenFile=\u6253\u5f00 -AssetComponentResourceTreeContextMenuOpenWithFile=\u6253\u5f00\u65b9\u5f0f -AssetComponentResourceTreeContextMenuCopyFile=\u590d\u5236 -AssetComponentResourceTreeContextMenuCutFile=\u526a\u5207 -AssetComponentResourceTreeContextMenuPasteFile=\u7c98\u8d34 +EditorMenuFile=\u6587\u4EF6 +EditorMenuFileOpenAsset=\u6253\u5F00\u8D44\u6E90\u76EE\u5F55 +EditorMenuFileOpenAssetDirectoryChooser=\u9009\u62E9\u8D44\u6E90 +EditorMenuFileReopenAssetFolder=\u91CD\u65B0\u6253\u5F00\u76EE\u5F55 +EditorMenuFileExit=\u9000\u51FA +EditorMenuOther=\u5176\u4ED6 +EditorMenuOtherSettings=\u8BBE\u7F6E +EditorMenuOtherPlugins=\u63D2\u4EF6 +EditorMenuOtherClearAssetCache=\u6E05\u7A7A\u8D44\u6E90\u7F13\u5B58 +EditorMenuOtherUpdateClasspathAndAssetCache=\u66F4\u65B0Classpath +EditorMenuHelp=\u5E2E\u52A9 +EditorMenuHelpAbout=\u5173\u4E8E + +EditorToolAsset=\u8D44\u6E90 + +EditorAreaSaveFileQuestion=\u6587\u4EF6 "%file_name%" \u4FEE\u6539\u540E\u5C1A\u672A\u4FDD\u5B58, \u662F\u5426\u9700\u8981\u4FDD\u5B58? + +AssetComponentResourceTreeContextMenuNewFile=\u65B0\u5EFA +AssetComponentResourceTreeContextMenuOpenFile=\u6253\u5F00 +AssetComponentResourceTreeContextMenuOpenWithFile=\u6253\u5F00\u65B9\u5F0F +AssetComponentResourceTreeContextMenuCopyFile=\u590D\u5236 +AssetComponentResourceTreeContextMenuCutFile=\u526A\u5207 +AssetComponentResourceTreeContextMenuPasteFile=\u7C98\u8D34 AssetComponentResourceTreeContextMenuDeleteFile=\u5220\u9664 -AssetComponentResourceTreeContextMenuDeleteFileQuestion=\u662f\u5426\u6253\u7b97\u5220\u9664 "%file_name%"? -AssetComponentResourceTreeContextMenuDeleteFilesQuestion=\u662f\u5426\u6253\u7b97\u5220\u9664 %file_count% \u4e2a\u6587\u4ef6? -AssetComponentResourceTreeContextMenuConvertFile=\u8f6c\u6362 -AssetComponentResourceTreeContextMenuOpenFileByExternalEditor=\u7528\u5176\u4ed6\u65b9\u5f0f\u6253\u5f00 -AssetComponentResourceTreeContextMenuOpenFileBySystemExplorer=\u6253\u5f00\u6240\u5728\u6587\u4ef6\u5939 -AssetComponentResourceTreeContextMenuRenameFile=\u91cd\u547d\u540d -AssetComponentResourceTreeContextMenuImportModel=\u5bfc\u5165\u6a21\u578b - -FileEditorActionSave=\u4fdd\u5b58 - -SceneFileEditorActionSelection=\u663e\u793a/\u9690\u85cf \u9009\u62e9\u9879 -SceneFileEditorActionGrid=\u663e\u793a/\u9690\u85cf \u7f51\u683c -SceneFileEditorActionStatistics=\u663e\u793a/\u9690\u85cf \u6e32\u67d3\u72b6\u6001 -SceneFileEditorActionMoveTool=\u4f7f\u7528\u64cd\u7eb5\u5668\u63a7\u5236:\u79fb\u52a8 -SceneFileEditorActionScaleTool=\u4f7f\u7528\u64cd\u7eb5\u5668\u63a7\u5236:\u7f29\u653e -SceneFileEditorActionRotationTool=\u4f7f\u7528\u64cd\u7eb5\u5668\u63a7\u5236:\u65cb\u8f6c -SceneFileEditorActionCameraLight=\u6253\u5f00/\u5173\u95ed \u6444\u50cf\u673a\u706f\u5149 -SceneFileEditorActionPhysics=\u6fc0\u6d3b/\u7981\u7528 Bullet\u7269\u7406\u5f15\u64ce -SceneFileEditorActionDebugPhysics=\u663e\u793a/\u9690\u85cf Bullet\u8c03\u8bd5\u7f51\u683c -SceneFileEditorActionShowLights=\u663e\u793a/\u9690\u85cf \u573a\u666f\u4e2d\u7684\u706f\u5149\u6807\u8bc6 -SceneFileEditorActionShowAudio=\u663e\u793a/\u9690\u85cf\u3000\u573a\u666f\u4e2d\u7684\u97f3\u6548\u8282\u70b9 - -MaterialFileEditorActionCube=\u663e\u793a\u4e3a\u65b9\u5757 -MaterialFileEditorActionSphere=\u663e\u793a\u4e3a\u7403\u4f53 -MaterialFileEditorActionPlane=\u663e\u793a\u4e3a\u5e73\u9762 -MaterialFileEditorActionLight=\u5f00\u542f/\u5173\u95ed\u706f\u5149 - -TextFileEditorName=\u6587\u672c\u7f16\u8f91\u5668 -MaterialFileEditorName=\u6750\u8d28\u7f16\u8f91\u5668 - -AssetEditorDialogTitle=\u8bf7\u9009\u62e9\u8d44\u6e90 -AssetEditorDialogWarningSelectFile=\u8bf7\u9009\u62e9\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u6587\u4ef6\u5939\u3002 - -SaveAsEditorDialogTitle=\u53e6\u5b58\u4e3a\u6587\u4ef6 -SaveAsEditorDialogFieldFilename=\u6587\u4ef6\u540d - -ParticlesAssetEditorDialogTextureParamLabel=\u7eb9\u7406\u53c2\u6570\u540d -ParticlesAssetEditorDialogTextureLightingTransformLabel=\u662f\u5426\u4f7f\u7528Lighting\u7740\u8272\u5668 - -MaterialFileEditorMaterialTypeLabel=\u6750\u8d28\u7c7b\u578b -MaterialFileEditorBucketTypeLabel=Queue Bucket +AssetComponentResourceTreeContextMenuDeleteFileQuestion=\u662F\u5426\u6253\u7B97\u5220\u9664 "%file_name%"? +AssetComponentResourceTreeContextMenuDeleteFilesQuestion=\u662F\u5426\u6253\u7B97\u5220\u9664 %file_count% \u4E2A\u6587\u4EF6? +AssetComponentResourceTreeContextMenuConvertFile=\u8F6C\u6362 +AssetComponentResourceTreeContextMenuOpenFileByExternalEditor=\u7528\u5176\u4ED6\u65B9\u5F0F\u6253\u5F00 +AssetComponentResourceTreeContextMenuOpenFileBySystemExplorer=\u6253\u5F00\u6240\u5728\u6587\u4EF6\u5939 +AssetComponentResourceTreeContextMenuRenameFile=\u91CD\u547D\u540D +AssetComponentResourceTreeContextMenuImportModel=\u5BFC\u5165\u6A21\u578B + +FileEditorActionSave=\u4FDD\u5B58 + +SceneFileEditorActionSelection=\u663E\u793A/\u9690\u85CF \u9009\u62E9\u9879 +SceneFileEditorActionGrid=\u663E\u793A/\u9690\u85CF \u7F51\u683C +SceneFileEditorActionStatistics=\u663E\u793A/\u9690\u85CF \u6E32\u67D3\u72B6\u6001 +SceneFileEditorActionMoveTool=\u4F7F\u7528\u64CD\u7EB5\u5668\u63A7\u5236:\u79FB\u52A8 +SceneFileEditorActionScaleTool=\u4F7F\u7528\u64CD\u7EB5\u5668\u63A7\u5236:\u7F29\u653E +SceneFileEditorActionRotationTool=\u4F7F\u7528\u64CD\u7EB5\u5668\u63A7\u5236:\u65CB\u8F6C +SceneFileEditorActionCameraLight=\u6253\u5F00/\u5173\u95ED \u6444\u50CF\u673A\u706F\u5149 +SceneFileEditorActionPhysics=\u6FC0\u6D3B/\u7981\u7528 Bullet\u7269\u7406\u5F15\u64CE +SceneFileEditorActionDebugPhysics=\u663E\u793A/\u9690\u85CF Bullet\u8C03\u8BD5\u7F51\u683C +SceneFileEditorActionShowLights=\u663E\u793A/\u9690\u85CF \u573A\u666F\u4E2D\u7684\u706F\u5149\u6807\u8BC6 +SceneFileEditorActionShowAudio=\u663E\u793A/\u9690\u85CF\u3000\u573A\u666F\u4E2D\u7684\u97F3\u6548\u8282\u70B9 + +MaterialFileEditorActionCube=\u663E\u793A\u4E3A\u65B9\u5757 +MaterialFileEditorActionSphere=\u663E\u793A\u4E3A\u7403\u4F53 +MaterialFileEditorActionPlane=\u663E\u793A\u4E3A\u5E73\u9762 +MaterialFileEditorActionLight=\u5F00\u542F/\u5173\u95ED\u706F\u5149 + +TextFileEditorName=\u6587\u672C\u7F16\u8F91\u5668 +MaterialFileEditorName=\u6750\u8D28\u7F16\u8F91\u5668 + +AssetEditorDialogTitle=\u8BF7\u9009\u62E9\u8D44\u6E90 +AssetEditorDialogWarningSelectFile=\u8BF7\u9009\u62E9\u6587\u4EF6\uFF0C\u800C\u4E0D\u662F\u6587\u4EF6\u5939\u3002 + +SaveAsEditorDialogTitle=\u53E6\u5B58\u4E3A\u6587\u4EF6 +SaveAsEditorDialogFieldFilename=\u6587\u4EF6\u540D + +ParticlesAssetEditorDialogTextureParamLabel=\u7EB9\u7406\u53C2\u6570\u540D +ParticlesAssetEditorDialogTextureLightingTransformLabel=\u662F\u5426\u4F7F\u7528Lighting\u7740\u8272\u5668 + +MaterialFileEditorMaterialTypeLabel=\u6750\u8D28\u7C7B\u578B +MaterialFileEditorBucketTypeLabel=\u6E32\u67D3\u961F\u5217 Texture2DMaterialParamControlRepeat=Repeat -Texture2DMaterialParamControlFlip=Flip -Texture2DMaterialParamControlAdd=\u6dfb\u52a0\u7eb9\u7406 -Texture2DMaterialParamControlRemove=\u79fb\u9664\u7eb9\u7406 - -ColorMaterialParamControlRemove=\u79fb\u9664\u989c\u8272 - -MaterialSettingsMain=\u8bbe\u7f6e -MaterialSettingsTextures=\u7eb9\u7406 -MaterialSettingsColors=\u989c\u8272 -MaterialSettingsRender=\u6e32\u67d3\u5668 -MaterialSettingsOther=\u5176\u4ed6 -MaterialRenderStateFaceCullMode=\u9762\u5254\u9664\u6a21\u5f0f(FaceCullMode) -MaterialRenderStateBlendMode=\u6df7\u5408\u6a21\u5f0f(BlendMode) -MaterialRenderStateBlendEquation=Blend equation -MaterialRenderStateBlendEquationAlpha=Blend equation alpha -MaterialRenderStatePolyOffsetFactor=Polygon offset factor -MaterialRenderStatePolyOffsetUnits=Polygon offset units -MaterialRenderStateDepthWrite=\u5199\u5165\u6df1\u5ea6\u7f13\u51b2 -MaterialRenderStateColorWrite=\u5199\u5165\u989c\u8272\u7f13\u51b2 -MaterialRenderStateDepthTest=\u5f00\u542f\u6df1\u5ea6\u68c0\u6d4b -MaterialRenderStateWireframe=\u7ebf\u6846\u6a21\u5f0f - -FileCreatorFileNameLabel=\u6587\u4ef6\u540d - -MaterialFileCreatorTitle=\u521b\u5efa\u6750\u8d28(j3m) -MaterialFileCreatorMaterialTypeLabel=\u6750\u8d28\u7c7b\u578b -MaterialFileCreatorFileDescription=\u65b0\u5efa\u6750\u8d28\u6587\u4ef6(j3m) -MaterialDefinitionFileCreatorFileDescription=\u521b\u5efa\u6750\u8d28\u5b9a\u4e49(j3md) -MaterialDefinitionFileCreatorTitle=\u65b0\u5efa\u6750\u8d28\u5b9a\u4e49\u6587\u4ef6(j3md) -MaterialDefinitionFileCreatorGlslLabel=GLSL\u7248\u672c - -SingleColorTextureFileCreatorTitle=\u521b\u5efa\u5355\u8272\u7eb9\u7406 -SingleColorTextureFileCreatorWidth=\u5bbd\u5ea6 -SingleColorTextureFileCreatorHeight=\u9ad8\u5ea6 -SingleColorTextureFileCreatorColor=\u989c\u8272 -SingleColorTextureFileCreatorDescription=\u65b0\u5efa\u5355\u8272\u7eb9\u7406\u8d34\u56fe - -SettingsDialogTitle=\u8bbe\u7f6e -SettingsDialogMessage=\u4fee\u6539\u540e\u9700\u8981\u91cd\u542f\u7a0b\u5e8f\uff0c\u8bbe\u7f6e\u624d\u80fd\u751f\u6548\u3002 -SettingsDialogClassesFolderChooserTitle=\u8bf7\u9009\u62e9class\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55 -SettingsDialogLibrariesFolderChooserTitle=\u8bf7\u9009\u62e9.jar\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55 -SettingsDialogEnvsFolderChooserTitle=\u8bf7\u9009\u62e9\u73af\u5883\u8d34\u56fe\u6240\u5728\u7684\u76ee\u5f55 - -SettingsPropertyFXAA=\u5f00\u542f FXAA -SettingsPropertyNativeFileChooser=\u4f7f\u7528\u672c\u5730\u6587\u4ef6\u9009\u62e9\u5668 -SettingsPropertyStopRenderOnLostFocus=\u5728\u753b\u9762\u5931\u53bb\u7126\u70b9\u540e\u505c\u6b62\u6e32\u67d3 -SettingsPropertyFrameRate=\u5237\u65b0\u7387 -SettingsPropertyGammaCorrection=\u4f3d\u9a6c\u6821\u6b63 -SettingsPropertyToneMapFilter=\u66dd\u5149\u6ee4\u955c -SettingsPropertyToneMapFilterWhitePoint=\u767d\u5e73\u8861 -SettingsPropertyAnisotropy=\u5404\u5411\u5f02\u6027 -SettingsPropertyAnalytics=Google\u3000Analytics -SettingsPropertyCameraAngle=\u6444\u50cf\u673a\u89d2\u5ea6 -SettingsPropertyTangentGeneration=\u81ea\u52a8\u751f\u6210\u5207\u7ebf -SettingsPropertyFlippedTexture=\u9ed8\u8ba4\u4f7f\u7528\u7ffb\u8f6c\u7eb9\u7406 -SettingsPropertyEditorCameraLamp=\u9ed8\u8ba4\u5f00\u542f\u6444\u50cf\u673a\u706f\u5149 -SettingsPropertyUserLibrariesFolder=User libraries\u76ee\u5f55 -SettingsPropertyUserClassesFolder=User classes\u76ee\u5f55 -SettingsPropertyTheme=\u6837\u5f0f +Texture2DMaterialParamControlFlip=\u5782\u76F4\u7FFB\u8F6C +Texture2DMaterialParamControlAdd=\u6DFB\u52A0\u7EB9\u7406 +Texture2DMaterialParamControlRemove=\u79FB\u9664\u7EB9\u7406 + +ColorMaterialParamControlRemove=\u79FB\u9664\u989C\u8272 + +MaterialSettingsMain=\u8BBE\u7F6E +MaterialSettingsTextures=\u7EB9\u7406 +MaterialSettingsColors=\u989C\u8272 +MaterialSettingsRender=\u6E32\u67D3\u5668 +MaterialSettingsOther=\u5176\u4ED6 +MaterialRenderStateFaceCullMode=\u9762\u5254\u9664\u6A21\u5F0F +MaterialRenderStateBlendMode=\u6DF7\u5408\u6A21\u5F0F +MaterialRenderStateBlendEquation=\u6DF7\u5408\u516C\u5F0F +MaterialRenderStateBlendEquationAlpha=\u900F\u660E\u5EA6\u6DF7\u5408\u516C\u5F0F +MaterialRenderStatePolyOffsetFactor=\u591A\u8FB9\u5F62\u504F\u79FB\u6BD4\u4F8B +MaterialRenderStatePolyOffsetUnits=\u591A\u8FB9\u5F62\u504F\u79FB\u5355\u4F4D +MaterialRenderStateDepthWrite=\u5199\u5165\u6DF1\u5EA6\u7F13\u51B2 +MaterialRenderStateColorWrite=\u5199\u5165\u989C\u8272\u7F13\u51B2 +MaterialRenderStateDepthTest=\u5F00\u542F\u6DF1\u5EA6\u68C0\u6D4B +MaterialRenderStateWireframe=\u7EBF\u6846\u6A21\u5F0F + +FileCreatorFileNameLabel=\u6587\u4EF6\u540D + +MaterialFileCreatorTitle=\u521B\u5EFA\u6750\u8D28(j3m) +MaterialFileCreatorMaterialTypeLabel=\u6750\u8D28\u7C7B\u578B +MaterialFileCreatorFileDescription=\u65B0\u5EFA\u6750\u8D28\u6587\u4EF6(j3m) +MaterialDefinitionFileCreatorFileDescription=\u521B\u5EFA\u6750\u8D28\u5B9A\u4E49(j3md) +MaterialDefinitionFileCreatorTitle=\u65B0\u5EFA\u6750\u8D28\u5B9A\u4E49\u6587\u4EF6(j3md) +MaterialDefinitionFileCreatorGlslLabel=GLSL\u7248\u672C + +SingleColorTextureFileCreatorTitle=\u521B\u5EFA\u5355\u8272\u7EB9\u7406 +SingleColorTextureFileCreatorWidth=\u5BBD\u5EA6 +SingleColorTextureFileCreatorHeight=\u9AD8\u5EA6 +SingleColorTextureFileCreatorColor=\u989C\u8272 +SingleColorTextureFileCreatorDescription=\u65B0\u5EFA\u5355\u8272\u7EB9\u7406\u8D34\u56FE + +SettingsDialogTitle=\u8BBE\u7F6E +SettingsDialogMessage=\u4FEE\u6539\u540E\u9700\u8981\u91CD\u542F\u7A0B\u5E8F\uFF0C\u8BBE\u7F6E\u624D\u80FD\u751F\u6548\u3002 +SettingsDialogClassesFolderChooserTitle=\u8BF7\u9009\u62E9class\u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55 +SettingsDialogLibrariesFolderChooserTitle=\u8BF7\u9009\u62E9.jar\u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55 +SettingsDialogEnvsFolderChooserTitle=\u8BF7\u9009\u62E9\u73AF\u5883\u8D34\u56FE\u6240\u5728\u7684\u76EE\u5F55 + +SettingsPropertyFXAA=\u5F00\u542F\u5FEB\u901F\u8FD1\u4F3C\u6297\u952F\u9F7F +SettingsPropertyNativeFileChooser=\u4F7F\u7528\u7CFB\u7EDF\u6587\u4EF6\u9009\u62E9\u5668 +SettingsPropertyStopRenderOnLostFocus=\u5728\u753B\u9762\u5931\u53BB\u7126\u70B9\u540E\u505C\u6B62\u6E32\u67D3 +SettingsPropertyFrameRate=\u5237\u65B0\u7387 +SettingsPropertyGammaCorrection=\u4F3D\u9A6C\u6821\u6B63 +SettingsPropertyToneMapFilter=\u66DD\u5149\u6EE4\u955C +SettingsPropertyToneMapFilterWhitePoint=\u767D\u5E73\u8861 +SettingsPropertyAnisotropy=\u5404\u5411\u5F02\u6027 +SettingsPropertyAnalytics=\u5F00\u542F\u8C37\u6B4C\u5206\u6790\u670D\u52A1 +SettingsPropertyCameraAngle=\u6444\u50CF\u673A\u89D2\u5EA6 +SettingsPropertyTangentGeneration=\u81EA\u52A8\u751F\u6210\u5207\u7EBF +SettingsPropertyFlippedTexture=\u9ED8\u8BA4\u4F7F\u7528\u7FFB\u8F6C\u7EB9\u7406 +SettingsPropertyEditorCameraLamp=\u9ED8\u8BA4\u5F00\u542F\u6444\u50CF\u673A\u706F\u5149 +SettingsPropertyUserLibrariesFolder=User libraries\u76EE\u5F55 +SettingsPropertyUserClassesFolder=User classes\u76EE\u5F55 +SettingsPropertyTheme=\u6837\u5F0F SettingsPropertyOpenGL=OpenGL -SettingsPropertyFastSkyFolder=Fast Sky folder - -SettingsCategoryGraphics=\u56fe\u5f62 -SettingsCategoryOther=\u5176\u4ed6 -SettingsCategoryEditor=Editor - -BlendToJ3oFileConverterDescription=\u5c06 .blend \u8f6c\u6362\u4e3a .j3o -GLTFToJ3oFileConverterDescription=\u5c06 .gltf \u8f6c\u6362\u4e3a .j3o -FBXToJ3oFileConverterDescription=\u5c06 .fbx \u8f6c\u6362\u4e3a .j3o -ObjToJ3oFileConverterDescription=\u5c06 .obj \u8f6c\u6362\u4e3a .j3o -SceneToJ3oFileConverterDescription=\u5c06 .scene \u8f6c\u6362\u4e3a .j3o -MeshXmlToJ3oFileConverterDescription=\u5c06 .mesh.xml \u8f6c\u6362\u4e3a .j3o -XBufToJ3oFileConverterDescription=\u5c06 .xbuf \u8f6c\u6362\u4e3a .j3o - -ModelFileEditorName=\u6a21\u578b\u7f16\u8f91\u5668 -ModelFileEditorNoSky=\u65e0\u5929\u7a7a\u76d2 -ModelFileEditorFastSky=\u5207\u6362\u5929\u7a7a\u76d2 -ModelFileEditorTransformMode=\u7a7a\u95f4\u8f6c\u6362\u6a21\u5f0f -ModelFileEditorNodeMesh=\u7f51\u683c -ModelFileEditorNodeMaterial=\u6750\u8d28 -ModelFileEditorNodeAmbientLight=\u73af\u5883\u5149 -ModelFileEditorNodeDirectionLight=\u5b9a\u5411\u5149 -ModelFileEditorNodePointLight=\u70b9\u5149\u6e90 -ModelFileEditorNodeSpotLight=\u805a\u5149\u706f -ModelFileEditorNodeLightProbe=\u706f\u5149\u63a2\u9488 -ModelFileEditorNodeAnimControl=\u52a8\u753b -ModelFileEditorNodeParticleEmitterInfluencers=\u7c92\u5b50\u53d1\u5c04\u5f71\u54cd\u5668 -ModelFileEditorNodeParticleEmitterInfluencerEmpty=\u65e0\u5f71\u54cd\u5668 -ModelFileEditorNodeParticleEmitterInfluencerDefault=\u9ed8\u8ba4\u5f71\u54cd\u5668 -ModelFileEditorNodeParticleEmitterInfluencerRadial=\u8f90\u5c04\u72b6\u5f71\u54cd\u5668 -ModelFileEditorNodeParticleEmitterShapeBox=\u76d2\u72b6 -ModelFileEditorNodeParticleEmitterShapeSphere=\u7403\u72b6 -ModelFileEditorNodeParticleEmitterShapePoint=\u70b9\u72b6 -ModelFileEditorNodeParticleEmitterShapeMeshVertex=\u7f51\u683c\u9876\u70b9 -ModelFileEditorNodeParticleEmitterShapeMeshFace=\u7f51\u683c\u8868\u9762 -ModelFileEditorNodeParticleEmitterShapeMeshConvexHull=\u7cbe\u786e\u7f51\u683c\u5f62\u72b6 -ModelFileEditorNodeStaticRigidBodyControl=\u9759\u6001\u521a\u4f53 -ModelFileEditorNodeRigidBodyControl=\u521a\u4f53 -ModelFileEditorNodeCharacterControl=\u89d2\u8272 -ModelFileEditorNodeSkeletonControl=\u9aa8\u9abc -ModelFileEditorNodeVehicleControl=\u4ea4\u901a\u5de5\u5177 -ModelFileEditorNodeRagDollControl=\u5e03\u5a03\u5a03 -ModelFileEditorNodeBoxCollisionShape=\u7acb\u65b9\u4f53 BoxCollisionShape -ModelFileEditorNodeCapsuleCollisionShape=\u80f6\u56ca\u4f53 CapsuleCollisionShape -ModelFileEditorNodeChildCollisionShape=\u5b50\u78b0\u649e\u5f62\u72b6 ChildCollisionShape -ModelFileEditorNodeComputedCollisionShape=\u751f\u6210\u7ec4\u5408\u78b0\u649e\u5f62\u72b6 CompoundCollisionShape -ModelFileEditorNodeConeCollisionShape=\u5706\u9525\u4f53 ConeCollisionShape -ModelFileEditorNodeCylinderCollisionShape=\u5706\u67f1\u4f53 CylinderCollisionShape -ModelFileEditorNodeGImpactCollisionShape=\u52a8\u6001\u7cbe\u786e\u7f51\u683c\u5f62\u72b6 GImpactCollisionShape -ModelFileEditorNodeHeightFieldCollisionShape=\u57fa\u4e8e\u9ad8\u5ea6\u5730\u5f62\u7684\u7cbe\u786e\u7f51\u683c\u5f62\u72b6 HeightFieldCollisionShape -ModelFileEditorNodeHullCollisionShape=\u4e0d\u592a\u7cbe\u786e\u7684\u7f51\u683c\u5f62\u72b6 HullCollisionShape -ModelFileEditorNodeMeshCollisionShape=\u7cbe\u786e\u7f51\u683c\u5f62\u72b6 MeshCollisionShape -ModelFileEditorNodePlaneCollisionShape=\u5e73\u9762 PlaneCollisionShape -ModelFileEditorNodeSphereCollisionShape=\u7403\u4f53 SphereCollisionShape -ModelFileEditorNodeWheel=\u8f66\u8f6e -ModelFileEditorNodeMotionControl=\u8fd0\u52a8\u63a7\u5236\u5668 -ModelFileEditorNodeMotionPath=\u8fd0\u52a8\u8def\u5f84 -ModelFileEditorNodeWayPoint=\u8def\u5f84\u70b9 -ModelFileEditorNodeVertexBuffer=\u9876\u70b9\u7f13\u5b58 -ModelFileEditorNodeLightControl=Light control - -SceneFileEditorNodeFilters=Filters -SceneFileEditorNodeAppStates=App states - -SceneFileEditorName=\u573a\u666f\u7f16\u8f91\u5668 -SceneFileEditorToolObjects=\u7269\u4f53 -SceneFileEditorToolPainting=Painting -SceneFileEditorToolScripting=\u811a\u672c -SceneFileEditorToolAppStates=\u72b6\u6001\u673a -SceneFileEditorToolFilters=\u6ee4\u955c -SceneFileEditorToolLayers=\u5c42 - -ModelNodeTreeActionRemove=\u79fb\u9664 -ModelNodeTreeActionRename=\u91cd\u547d\u540d -ModelNodeTreeActionOptimizeGeometry=\u4f18\u5316\u51e0\u4f55\u4f53 -ModelNodeTreeActionTools=\u5de5\u5177 -ModelNodeTreeActionCreate=\u521b\u5efa -ModelNodeTreeActionCreateNode=Node -ModelNodeTreeActionCreateSky=\u5929\u7a7a\u76d2 -ModelNodeTreeActionCreateEditableSky=\u53ef\u7f16\u8f91\u7684\u5929\u7a7a\u76d2 -ModelNodeTreeActionCreatePrimitive=\u57fa\u672c\u5f62\u72b6 -ModelNodeTreeActionCreatePrimitiveBox=\u7acb\u65b9\u4f53 -ModelNodeTreeActionCreatePrimitiveSphere=\u7403\u4f53 -ModelNodeTreeActionCreatePrimitiveQuad=\u56db\u8fb9\u5f62 -ModelNodeTreeActionLoadModel=\u52a0\u8f7d\u6a21\u578b -ModelNodeTreeActionSaveAs=\u53e6\u5b58\u4e3a -ModelNodeTreeActionMakeEmbedded=\u505a\u4e3a\u5185\u5d4c\u6a21\u578b -ModelNodeTreeActionLinkModel=\u94fe\u63a5\u6a21\u578b -ModelNodeTreeActionTangentGenerator=\u751f\u6210\u5207\u7ebf -ModelNodeTreeActionLoDGenerator=\u751f\u6210\u5c42\u6b21\u7ec6\u8282(LOD) -ModelNodeTreeActionLight=\u706f\u5149 -ModelNodeTreeActionAmbientLight=\u73af\u5883\u5149 -ModelNodeTreeActionDirectionLight=\u5b9a\u5411\u5149 -ModelNodeTreeActionPointLight=\u70b9\u5149\u6e90 -ModelNodeTreeActionSpotLight=\u805a\u5149\u706f -ModelNodeTreeActionAnimationPlay=\u64ad\u653e\u52a8\u753b -ModelNodeTreeActionAnimationPlaySettings=\u64ad\u653e\u8bbe\u7f6e -ModelNodeTreeActionAnimationStop=\u505c\u6b62\u52a8\u753b -ModelNodeTreeActionAnimationPause=\u6682\u505c\u52a8\u753b -ModelNodeTreeActionAnimationManualExtractSubAnimation=\u624b\u52a8\u89e3\u538b\u5b50\u52a8\u753b -ModelNodeTreeActionCreateAudioNode=AudioNode -ModelNodeTreeActionAudioPlay=\u64ad\u653e -ModelNodeTreeActionAudioStop=\u505c\u6b62 -ModelNodeTreeActionCopy=Copy -ModelNodeTreeActionPaste=Paste -ModelNodeTreeActionCreateDefaultParticleEmitter=\u9ed8\u8ba4\u7c92\u5b50\u53d1\u751f\u5668 -ModelNodeTreeActionResetParticleEmitters=\u91cd\u7f6e\u7c92\u5b50\u53d1\u751f\u5668 -ModelNodeTreeActionParticleEmitterChangeShape=\u6539\u53d8\u53d1\u751f\u5668\u5f62\u72b6 -ModelNodeTreeActionParticleEmitterBoxShape=\u76d2\u72b6 -ModelNodeTreeActionParticleEmitterSphereShape=\u7403\u72b6 -ModelNodeTreeActionParticleEmitterPointShape=\u70b9\u72b6 -ModelNodeTreeActionParticleEmitterMeshVertexShape=\u7f51\u683c\u9876\u70b9 -ModelNodeTreeActionParticleEmitterMeshFaceShape=\u7f51\u683c\u8868\u9762 -ModelNodeTreeActionParticleEmitterMeshConvexHullShape=\u7cbe\u786e\u7f51\u683c\u5f62\u72b6 -ModelNodeTreeActionParticleEmitterTriangleShape=\u4e09\u89d2\u5f62 -ModelNodeTreeActionParticleEmitterCylinderShape=\u5706\u67f1\u72b6 -ModelNodeTreeActionParticleEmitterDomeShape=\u534a\u7403\u72b6 -ModelNodeTreeActionParticleEmitterQuadShape=\u65b9\u5757 -ModelNodeTreeActionParticleEmitterTorusShape=\u73af\u72b6 -ModelNodeTreeActionParticleEmitterModelShape=\u5bfc\u5165\u6a21\u578b -ModelNodeTreeActionParticleEmitterChangeInfluencer=\u6539\u53d8\u7c92\u5b50\u5f71\u54cd\u5668 -ModelNodeTreeActionParticleEmitterInfluencerDefault=\u9ed8\u8ba4 -ModelNodeTreeActionParticleEmitterInfluencerEmpty=\u7a7a -ModelNodeTreeActionParticleEmitterInfluencerRadial=\u8f90\u5c04\u72b6\u5f71\u54cd\u5668 -ModelNodeTreeActionParticleEmitterChangeParticlesMesh=\u6539\u53d8\u7c92\u5b50\u7f51\u683c\u5f62\u72b6 -ModelNodeTreeActionParticleEmitterParticlesMeshQuad=\u56db\u8fb9\u5f62 -ModelNodeTreeActionParticleEmitterParticlesMeshPoint=\u70b9\u72b6 -ModelNodeTreeActionParticleEmitterParticlesMeshImpostor=Impostor -ModelNodeTreeActionParticleEmitterParticlesMeshModel=\u6a21\u578b -ModelNodeTreeActionCreateLayer=\u521b\u5efa\u5c42 -ModelNodeTreeActionAddUserData=\u6dfb\u52a0\u7528\u6237\u6570\u636e(UserData) -ModelNodeTreeActionAddControl=\u63a7\u5236\u5668(Control) -ModelNodeTreeActionAddControlRigidBody=\u521a\u4f53 -ModelNodeTreeActionAddControlStaticRigidBody=\u9759\u6001\u521a\u4f53 -ModelNodeTreeActionAddControlMotion=\u8fd0\u52a8 -ModelNodeTreeActionAddControlLight=Light -ModelNodeTreeActionAddControlCharacter=\u89d2\u8272 -ModelNodeTreeActionAddControlCustom=\u81ea\u5b9a\u4e49 -ModelNodeTreeActionAddControlVehicle=\u4ea4\u901a\u5de5\u5177 -ModelNodeTreeActionAddControlKinematicRagdoll=\u53ef\u8fd0\u52a8\u7684\u5e03\u5a03\u5a03 -ModelNodeTreeActionReactivate=\u91cd\u65b0\u6fc0\u6d3b -ModelNodeTreeActionChangeCollisionShape=\u6539\u53d8\u78b0\u649e\u5f62\u72b6 -ModelNodeTreeActionGenerateCollisionShape=\u751f\u6210 -ModelNodeTreeActionBoxCollisionShape=\u7acb\u65b9\u4f53 -ModelNodeTreeActionCapsuleCollisionShape=\u80f6\u56ca\u4f53 -ModelNodeTreeActionConeCollisionShape=\u5706\u9525\u4f53 -ModelNodeTreeActionCylinderCollisionShape=\u5706\u67f1\u4f53 -ModelNodeTreeActionSphereCollisionShape=\u7403\u4f53 -ModelNodeTreeActionAddWheel=\u6dfb\u52a0\u8f66\u8f6e -ModelNodeTreeActionAddTerrain=\u6dfb\u52a0\u5730\u5f62 -ModelNodeTreeActionEnableAllControls=Enable all controls -ModelNodeTreeActionDisableAllControls=Disable all controls - -ModelPropertyCullHint=\u9762\u5254\u9664 -ModelPropertyShadowMode=\u9634\u5f71\u6a21\u5f0f -ModelPropertyQueueBucket=Queue bucket -ModelPropertyLocation=\u4f4d\u7f6e -ModelPropertyScale=\u7f29\u653e -ModelPropertyRotation=\u65cb\u8f6c -ModelPropertyTransformation=Transformation -ModelPropertyMaterial=\u6750\u8d28 -ModelPropertyDirection=\u5b9a\u5411\u58f0\u6e90\u7684\u4f20\u64ad\u65b9\u5411 -ModelPropertyRadius=\u534a\u5f84 -ModelPropertyColor=\u989c\u8272 -ModelPropertyInnerAngle=\u5b9a\u5411\u58f0\u6ce2\u7684\u5185\u89d2\u89d2\u5ea6 -ModelPropertyOuterAngle=\u5b9a\u5411\u58f0\u6e90\u7684\u5916\u89d2\u89d2\u5ea6 -ModelPropertyMin=\u6700\u5c0f +SettingsPropertyFastSkyFolder=\u5FEB\u901F\u5929\u7A7A\u76EE\u5F55 + +SettingsCategoryGraphics=\u56FE\u5F62 +SettingsCategoryOther=\u5176\u4ED6 +SettingsCategoryEditor=\u7F16\u8F91\u5668 + +BlendToJ3oFileConverterDescription=\u5C06 .blend \u8F6C\u6362\u4E3A .j3o +GLTFToJ3oFileConverterDescription=\u5C06 .gltf \u8F6C\u6362\u4E3A .j3o +FBXToJ3oFileConverterDescription=\u5C06 .fbx \u8F6C\u6362\u4E3A .j3o +ObjToJ3oFileConverterDescription=\u5C06 .obj \u8F6C\u6362\u4E3A .j3o +SceneToJ3oFileConverterDescription=\u5C06 .scene \u8F6C\u6362\u4E3A .j3o +MeshXmlToJ3oFileConverterDescription=\u5C06 .mesh.xml \u8F6C\u6362\u4E3A .j3o +XBufToJ3oFileConverterDescription=\u5C06 .xbuf \u8F6C\u6362\u4E3A .j3o + +ModelFileEditorName=\u6A21\u578B\u7F16\u8F91\u5668 +ModelFileEditorNoSky=\u65E0\u5929\u7A7A\u76D2 +ModelFileEditorFastSky=\u5207\u6362\u5929\u7A7A\u76D2 +ModelFileEditorTransformMode=\u7A7A\u95F4\u8F6C\u6362\u6A21\u5F0F +ModelFileEditorNodeMesh=\u7F51\u683C +ModelFileEditorNodeMaterial=\u6750\u8D28 +ModelFileEditorNodeAmbientLight=\u73AF\u5883\u5149 +ModelFileEditorNodeDirectionLight=\u5B9A\u5411\u5149 +ModelFileEditorNodePointLight=\u70B9\u5149\u6E90 +ModelFileEditorNodeSpotLight=\u805A\u5149\u706F +ModelFileEditorNodeLightProbe=\u706F\u5149\u63A2\u9488 +ModelFileEditorNodeAnimControl=\u52A8\u753B +ModelFileEditorNodeParticleEmitterInfluencers=\u7C92\u5B50\u53D1\u5C04\u5F71\u54CD\u5668 +ModelFileEditorNodeParticleEmitterInfluencerEmpty=\u65E0\u5F71\u54CD\u5668 +ModelFileEditorNodeParticleEmitterInfluencerDefault=\u9ED8\u8BA4\u5F71\u54CD\u5668 +ModelFileEditorNodeParticleEmitterInfluencerRadial=\u8F90\u5C04\u72B6\u5F71\u54CD\u5668 +ModelFileEditorNodeParticleEmitterShapeBox=\u76D2\u72B6 +ModelFileEditorNodeParticleEmitterShapeSphere=\u7403\u72B6 +ModelFileEditorNodeParticleEmitterShapePoint=\u70B9\u72B6 +ModelFileEditorNodeParticleEmitterShapeMeshVertex=\u7F51\u683C\u9876\u70B9 +ModelFileEditorNodeParticleEmitterShapeMeshFace=\u7F51\u683C\u8868\u9762 +ModelFileEditorNodeParticleEmitterShapeMeshConvexHull=\u7CBE\u786E\u7F51\u683C\u5F62\u72B6 +ModelFileEditorNodeStaticRigidBodyControl=\u9759\u6001\u521A\u4F53 +ModelFileEditorNodeRigidBodyControl=\u521A\u4F53 +ModelFileEditorNodeCharacterControl=\u89D2\u8272 +ModelFileEditorNodeSkeletonControl=\u9AA8\u9ABC +ModelFileEditorNodeVehicleControl=\u4EA4\u901A\u5DE5\u5177 +ModelFileEditorNodeRagDollControl=\u5E03\u5A03\u5A03 +ModelFileEditorNodeBoxCollisionShape=\u7ACB\u65B9\u4F53 +ModelFileEditorNodeCapsuleCollisionShape=\u80F6\u56CA\u4F53 +ModelFileEditorNodeChildCollisionShape=\u5B50\u78B0\u649E\u4F53 +ModelFileEditorNodeComputedCollisionShape=\u7EC4\u5408\u78B0\u649E\u4F53 +ModelFileEditorNodeConeCollisionShape=\u5706\u9525\u4F53 +ModelFileEditorNodeCylinderCollisionShape=\u5706\u67F1\u4F53 +ModelFileEditorNodeGImpactCollisionShape=\u52A8\u6001\u7CBE\u786E\u7F51\u683C\u5F62\u72B6 +ModelFileEditorNodeHeightFieldCollisionShape=\u57FA\u4E8E\u9AD8\u5EA6\u5730\u5F62\u7684\u7CBE\u786E\u7F51\u683C\u5F62\u72B6 +ModelFileEditorNodeHullCollisionShape=\u4E0D\u592A\u7CBE\u786E\u7684\u7F51\u683C\u5F62\u72B6 +ModelFileEditorNodeMeshCollisionShape=\u7CBE\u786E\u7F51\u683C\u5F62\u72B6 +ModelFileEditorNodePlaneCollisionShape=\u5E73\u9762 +ModelFileEditorNodeSphereCollisionShape=\u7403\u4F53 +ModelFileEditorNodeWheel=\u8F66\u8F6E +ModelFileEditorNodeMotionControl=\u8FD0\u52A8\u63A7\u5236\u5668 +ModelFileEditorNodeMotionPath=\u8FD0\u52A8\u8DEF\u5F84 +ModelFileEditorNodeWayPoint=\u8DEF\u5F84\u70B9 +ModelFileEditorNodeVertexBuffer=\u9876\u70B9\u7F13\u5B58 +ModelFileEditorNodeLightControl=\u5149\u6E90\u63A7\u5236\u5668 + +SceneFileEditorNodeFilters=\u540E\u5904\u7406\u6EE4\u955C +SceneFileEditorNodeAppStates=AppState + +SceneFileEditorName=\u573A\u666F\u7F16\u8F91\u5668 +SceneFileEditorToolObjects=\u7269\u4F53 +SceneFileEditorToolPainting=\u7ED8\u5236 +SceneFileEditorToolScripting=\u811A\u672C +SceneFileEditorToolAppStates=AppState +SceneFileEditorToolFilters=\u540E\u5904\u7406\u6EE4\u955C +SceneFileEditorToolLayers=\u5C42 + +ModelNodeTreeActionRemove=\u79FB\u9664 +ModelNodeTreeActionRename=\u91CD\u547D\u540D +ModelNodeTreeActionOptimizeGeometry=\u4F18\u5316\u51E0\u4F55\u4F53 +ModelNodeTreeActionTools=\u5DE5\u5177 +ModelNodeTreeActionCreate=\u521B\u5EFA +ModelNodeTreeActionCreateNode=\u8282\u70B9 +ModelNodeTreeActionCreateSky=\u5929\u7A7A\u76D2 +ModelNodeTreeActionCreateEditableSky=\u53EF\u7F16\u8F91\u7684\u5929\u7A7A\u76D2 +ModelNodeTreeActionCreatePrimitive=\u57FA\u672C\u5F62\u72B6 +ModelNodeTreeActionCreatePrimitiveBox=\u7ACB\u65B9\u4F53 +ModelNodeTreeActionCreatePrimitiveSphere=\u7403\u4F53 +ModelNodeTreeActionCreatePrimitiveQuad=\u56DB\u8FB9\u5F62 +ModelNodeTreeActionLoadModel=\u52A0\u8F7D\u6A21\u578B +ModelNodeTreeActionSaveAs=\u53E6\u5B58\u4E3A +ModelNodeTreeActionMakeEmbedded=\u505A\u4E3A\u5185\u5D4C\u6A21\u578B +ModelNodeTreeActionLinkModel=\u94FE\u63A5\u6A21\u578B +ModelNodeTreeActionTangentGenerator=\u751F\u6210\u5207\u7EBF +ModelNodeTreeActionLoDGenerator=\u751F\u6210\u5C42\u6B21\u7EC6\u8282(LOD) +ModelNodeTreeActionLight=\u706F\u5149 +ModelNodeTreeActionAmbientLight=\u73AF\u5883\u5149 +ModelNodeTreeActionDirectionLight=\u5B9A\u5411\u5149 +ModelNodeTreeActionPointLight=\u70B9\u5149\u6E90 +ModelNodeTreeActionSpotLight=\u805A\u5149\u706F +ModelNodeTreeActionAnimationPlay=\u64AD\u653E\u52A8\u753B +ModelNodeTreeActionAnimationPlaySettings=\u64AD\u653E\u8BBE\u7F6E +ModelNodeTreeActionAnimationStop=\u505C\u6B62\u52A8\u753B +ModelNodeTreeActionAnimationPause=\u6682\u505C\u52A8\u753B +ModelNodeTreeActionAnimationManualExtractSubAnimation=\u624B\u52A8\u89E3\u538B\u5B50\u52A8\u753B +ModelNodeTreeActionCreateAudioNode=\u97F3\u9891\u8282\u70B9 +ModelNodeTreeActionAudioPlay=\u64AD\u653E +ModelNodeTreeActionAudioStop=\u505C\u6B62 +ModelNodeTreeActionCopy=\u590D\u5236 +ModelNodeTreeActionPaste=\u7C98\u8D34 +ModelNodeTreeActionCreateDefaultParticleEmitter=\u9ED8\u8BA4\u7C92\u5B50\u53D1\u751F\u5668 +ModelNodeTreeActionResetParticleEmitters=\u91CD\u7F6E\u7C92\u5B50\u53D1\u751F\u5668 +ModelNodeTreeActionParticleEmitterChangeShape=\u6539\u53D8\u53D1\u751F\u5668\u5F62\u72B6 +ModelNodeTreeActionParticleEmitterBoxShape=\u76D2\u72B6 +ModelNodeTreeActionParticleEmitterSphereShape=\u7403\u72B6 +ModelNodeTreeActionParticleEmitterPointShape=\u70B9\u72B6 +ModelNodeTreeActionParticleEmitterMeshVertexShape=\u7F51\u683C\u9876\u70B9 +ModelNodeTreeActionParticleEmitterMeshFaceShape=\u7F51\u683C\u8868\u9762 +ModelNodeTreeActionParticleEmitterMeshConvexHullShape=\u7CBE\u786E\u7F51\u683C\u5F62\u72B6 +ModelNodeTreeActionParticleEmitterTriangleShape=\u4E09\u89D2\u5F62 +ModelNodeTreeActionParticleEmitterCylinderShape=\u5706\u67F1\u72B6 +ModelNodeTreeActionParticleEmitterDomeShape=\u534A\u7403\u72B6 +ModelNodeTreeActionParticleEmitterQuadShape=\u65B9\u5757 +ModelNodeTreeActionParticleEmitterTorusShape=\u73AF\u72B6 +ModelNodeTreeActionParticleEmitterModelShape=\u5BFC\u5165\u6A21\u578B +ModelNodeTreeActionParticleEmitterChangeInfluencer=\u6539\u53D8\u7C92\u5B50\u5F71\u54CD\u5668 +ModelNodeTreeActionParticleEmitterInfluencerDefault=\u9ED8\u8BA4 +ModelNodeTreeActionParticleEmitterInfluencerEmpty=\u7A7A +ModelNodeTreeActionParticleEmitterInfluencerRadial=\u8F90\u5C04\u72B6\u5F71\u54CD\u5668 +ModelNodeTreeActionParticleEmitterChangeParticlesMesh=\u6539\u53D8\u7C92\u5B50\u7F51\u683C\u5F62\u72B6 +ModelNodeTreeActionParticleEmitterParticlesMeshQuad=\u56DB\u8FB9\u5F62 +ModelNodeTreeActionParticleEmitterParticlesMeshPoint=\u70B9\u72B6 +ModelNodeTreeActionParticleEmitterParticlesMeshImpostor=\u66FF\u4EE3\u8005 +ModelNodeTreeActionParticleEmitterParticlesMeshModel=\u6A21\u578B +ModelNodeTreeActionCreateLayer=\u521B\u5EFA\u5C42 +ModelNodeTreeActionAddUserData=\u6DFB\u52A0\u7528\u6237\u6570\u636E +ModelNodeTreeActionAddControl=\u63A7\u5236\u5668 +ModelNodeTreeActionAddControlRigidBody=\u521A\u4F53 +ModelNodeTreeActionAddControlStaticRigidBody=\u9759\u6001\u521A\u4F53 +ModelNodeTreeActionAddControlMotion=\u8FD0\u52A8 +ModelNodeTreeActionAddControlLight=\u706F\u5149 +ModelNodeTreeActionAddControlCharacter=\u89D2\u8272 +ModelNodeTreeActionAddControlCustom=\u81EA\u5B9A\u4E49 +ModelNodeTreeActionAddControlVehicle=\u4EA4\u901A\u5DE5\u5177 +ModelNodeTreeActionAddControlKinematicRagdoll=\u53EF\u8FD0\u52A8\u7684\u5E03\u5A03\u5A03 +ModelNodeTreeActionReactivate=\u91CD\u65B0\u6FC0\u6D3B +ModelNodeTreeActionChangeCollisionShape=\u6539\u53D8\u78B0\u649E\u5F62\u72B6 +ModelNodeTreeActionGenerateCollisionShape=\u751F\u6210 +ModelNodeTreeActionBoxCollisionShape=\u7ACB\u65B9\u4F53 +ModelNodeTreeActionCapsuleCollisionShape=\u80F6\u56CA\u4F53 +ModelNodeTreeActionConeCollisionShape=\u5706\u9525\u4F53 +ModelNodeTreeActionCylinderCollisionShape=\u5706\u67F1\u4F53 +ModelNodeTreeActionSphereCollisionShape=\u7403\u4F53 +ModelNodeTreeActionAddWheel=\u6DFB\u52A0\u8F66\u8F6E +ModelNodeTreeActionAddTerrain=\u6DFB\u52A0\u5730\u5F62 +ModelNodeTreeActionEnableAllControls=\u542F\u7528\u6240\u6709\u63A7\u5236\u5668 +ModelNodeTreeActionDisableAllControls=\u7981\u7528\u6240\u6709\u63A7\u5236\u5668 + +ModelPropertyCullHint=\u5254\u9664\u63D0\u793A +ModelPropertyShadowMode=\u9634\u5F71\u6A21\u5F0F +ModelPropertyQueueBucket=\u6E32\u67D3\u961F\u5217 +ModelPropertyLocation=\u4F4D\u7F6E +ModelPropertyScale=\u7F29\u653E +ModelPropertyRotation=\u65CB\u8F6C +ModelPropertyTransformation=\u7A7A\u95F4\u53D8\u6362 +ModelPropertyMaterial=\u6750\u8D28 +ModelPropertyDirection=\u5B9A\u5411\u58F0\u6E90\u7684\u4F20\u64AD\u65B9\u5411 +ModelPropertyRadius=\u534A\u5F84 +ModelPropertyColor=\u989C\u8272 +ModelPropertyInnerAngle=\u5B9A\u5411\u58F0\u6CE2\u7684\u5185\u89D2\u89D2\u5EA6 +ModelPropertyOuterAngle=\u5B9A\u5411\u58F0\u6E90\u7684\u5916\u89D2\u89D2\u5EA6 +ModelPropertyMin=\u6700\u5C0F ModelPropertyMax=\u6700\u5927 -ModelPropertyIsLooping=\u5faa\u73af\u6a21\u5f0f -ModelPropertyIsReverb=\u56de\u58f0 -ModelPropertyIsDirectional=\u5b9a\u5411\u58f0\u6e90 -ModelPropertyIsPositional=\u5b9a\u4f4d\u58f0\u6e90 -ModelPropertyAudioPitch=\u91c7\u6837\u9891\u7387 -ModelPropertyAudioVolume=\u97f3\u91cf -ModelPropertyTimeOffset=\u64ad\u653e\u65f6\u95f4 -ModelPropertyMaxDistance=\u6700\u5927\u4f20\u64ad\u8ddd\u79bb -ModelPropertyRefDistance=\u534a\u8870\u8ddd\u79bb -ModelPropertyAudioData=\u97f3\u9891\u6570\u636e -ModelPropertyVelocity=\u97f3\u6e90\u8fd0\u52a8\u901f\u5ea6 -ModelPropertyLoD=\u5c42\u6b21\u7ec6\u8282(LoD) -ModelPropertyTriangleCount=\u4e09\u89d2\u5f62\u6570 +ModelPropertyIsLooping=\u5FAA\u73AF\u6A21\u5F0F +ModelPropertyIsReverb=\u56DE\u58F0 +ModelPropertyIsDirectional=\u5B9A\u5411\u58F0\u6E90 +ModelPropertyIsPositional=\u5B9A\u4F4D\u58F0\u6E90 +ModelPropertyAudioPitch=\u91C7\u6837\u9891\u7387 +ModelPropertyAudioVolume=\u97F3\u91CF +ModelPropertyTimeOffset=\u64AD\u653E\u65F6\u95F4 +ModelPropertyMaxDistance=\u6700\u5927\u4F20\u64AD\u8DDD\u79BB +ModelPropertyRefDistance=\u534A\u8870\u8DDD\u79BB +ModelPropertyAudioData=\u97F3\u9891\u6570\u636E +ModelPropertyVelocity=\u97F3\u6E90\u8FD0\u52A8\u901F\u5EA6 +ModelPropertyLoD=\u5C42\u6B21\u7EC6\u8282(LoD) +ModelPropertyTriangleCount=\u4E09\u89D2\u5F62\u6570 ModelPropertyLevel=Level -ModelPropertyLayer=Layer -ModelPropertyValue=\u503c +ModelPropertyLayer=\u5C42 +ModelPropertyValue=\u503C ModelPropertyId=Id -ModelPropertyInstanceCount=\u5b9e\u4f8b\u6570\u91cf -ModelPropertyVertexCount=\u9876\u70b9\u6570\u91cf -ModelPropertyNumLodLevels=Lod\u6570\u91cf -ModelPropertyMode=\u6a21\u5f0f -ModelPropertyType=\u7c7b\u578b -ModelPropertyFormat=\u683c\u5f0f +ModelPropertyInstanceCount=\u5B9E\u4F8B\u6570\u91CF +ModelPropertyVertexCount=\u9876\u70B9\u6570\u91CF +ModelPropertyNumLodLevels=Lod\u6570\u91CF +ModelPropertyMode=\u6A21\u5F0F +ModelPropertyType=\u7C7B\u578B +ModelPropertyFormat=\u683C\u5F0F ModelPropertyUsage=\u7528\u9014 -ModelPropertyUniqId=\u552f\u4e00ID -ModelPropertyBaseInstanceCount=Base instances -ModelPropertyInstanceSpan=Instance span -ModelPropertyNumComponents=\u7ec4\u4ef6\u6570\u91cf -ModelPropertyNumElements=\u5143\u7d20\u6570\u91cf -ModelPropertyOffset=\u504f\u79fb -ModelPropertyStride=\u6b65\u5e45 -ModelPropertyCapacity=\u5bb9\u91cf -ModelPropertyIsEnabled=\u542f\u7528 -ModelPropertyIsHardwareSkinningPreferred=\u5f00\u542f\u786c\u4ef6\u8499\u76ae -ModelPropertyViewDirection=\u9762\u671d\u65b9\u5411 -ModelPropertyWalkDirection=\u884c\u8d70\u65b9\u5411 -ModelPropertyFallSpeed=\u6389\u843d\u901f\u5ea6 -ModelPropertyGravity=\u91cd\u529b\u52a0\u901f\u5ea6 -ModelPropertyJumpSpeed=\u8df3\u8dc3\u901f\u5ea6 -ModelPropertyJumpForce=Jump force -ModelPropertyPhysicsDamping=Physics damping -ModelPropertyMaxSlope=\u6700\u5927\u659c\u7387 -ModelPropertyIsApplyPhysicsLocal=\u662f\u5426\u542f\u7528\u672c\u5730\u7269\u7406 -ModelPropertyIsUseViewDirection=\u662f\u5426\u4f7f\u7528\u9762\u671d\u65b9\u5411 -ModelPropertyIsKinematicSpatial=\u662f\u5426\u4e3a\u8fd0\u52a8\u7269\u4f53 -ModelPropertyIsKinematic=\u662f\u5426\u53ef\u52a8 -ModelPropertyAngularVelocity=\u89d2\u901f\u5ea6 -ModelPropertyLinearFactor=\u7ebf\u6027\u56e0\u5b50 -ModelPropertyAngularDamping=\u65cb\u8f6c\u963b\u5c3c\u7cfb\u6570 -ModelPropertyAngularFactor=\u65cb\u8f6c\u56e0\u5b50 -ModelPropertyFriction=\u6469\u64e6\u7cfb\u6570 -ModelPropertyLinearDamping=\u7ebf\u6027\u963b\u5c3c\u7cfb\u6570 -ModelPropertyMass=\u8d28\u91cf -ModelPropertyRestitution=\u5f39\u6027 -ModelPropertyCurrentValue=\u5f53\u524d\u503c -ModelPropertyCurrentWayPoint=\u5f53\u524d\u8def\u5f84\u70b9 -ModelPropertyDirectionType=\u671d\u5411\u7c7b\u578b -ModelPropertyAngularSleepingThreshold=Angular sleeping threshold -ModelPropertyLoopMode=\u5faa\u73af\u6a21\u5f0f -ModelPropertyInitialDuration=\u521d\u59cb\u65f6\u957f -ModelPropertySpeed=\u901f\u5ea6 -ModelPropertyTime=\u65f6\u95f4 -ModelPropertyMargin=\u8fb9\u7f18\u7a7a\u767d -ModelPropertyHalfExtents=\u534a\u957f\u5ea6 -ModelPropertyHeight=\u9ad8\u5ea6 -ModelPropertyAxis=\u5750\u6807\u8f74 -ModelPropertyObjectId=\u5bf9\u8c61ID -ModelPropertyAxle=\u8f66\u8f74 -ModelPropertyRestLength=\u4f11\u606f\u65f6\u957f -ModelPropertyIsFront=\u524d\u65b9 -ModelPropertyDampingCompression=\u963b\u5c3c\u538b\u7f29 -ModelPropertyFrictionSlip=\u6469\u64e6\u6ed1\u5757 -ModelPropertyMaxSuspensionForce=\u6700\u5927\u60ac\u6d6e\u529b -ModelPropertyMaxSuspensionTravelCm=\u6700\u5927\u60ac\u6d6e\u884c\u7a0b -ModelPropertyDampingRelaxation=\u963b\u5c3c\u677e\u5f1b -ModelPropertySuspensionStiffness=\u60ac\u67b6\u521a\u5ea6 -ModelPropertyRollInfluence=\u65cb\u8f6c\u5f71\u54cd\u5668 +ModelPropertyUniqId=\u552F\u4E00ID +ModelPropertyBaseInstanceCount=\u57FA\u672C\u5B9E\u4F8B +ModelPropertyInstanceSpan=\u5B9E\u4F8B\u5C55\u5F00 +ModelPropertyNumComponents=\u7EC4\u4EF6\u6570\u91CF +ModelPropertyNumElements=\u5143\u7D20\u6570\u91CF +ModelPropertyOffset=\u504F\u79FB +ModelPropertyStride=\u6B65\u5E45 +ModelPropertyCapacity=\u5BB9\u91CF +ModelPropertyIsEnabled=\u542F\u7528 +ModelPropertyIsHardwareSkinningPreferred=\u5F00\u542F\u786C\u4EF6\u8499\u76AE +ModelPropertyViewDirection=\u9762\u671D\u65B9\u5411 +ModelPropertyWalkDirection=\u884C\u8D70\u65B9\u5411 +ModelPropertyFallSpeed=\u6389\u843D\u901F\u5EA6 +ModelPropertyGravity=\u91CD\u529B\u52A0\u901F\u5EA6 +ModelPropertyJumpSpeed=\u8DF3\u8DC3\u901F\u5EA6 +ModelPropertyJumpForce=\u8DF3\u8DC3\u529B\u91CF +ModelPropertyPhysicsDamping=\u7269\u7406\u963B\u5C3C +ModelPropertyMaxSlope=\u6700\u5927\u659C\u7387 +ModelPropertyIsApplyPhysicsLocal=\u662F\u5426\u542F\u7528\u672C\u5730\u7269\u7406 +ModelPropertyIsUseViewDirection=\u662F\u5426\u4F7F\u7528\u9762\u671D\u65B9\u5411 +ModelPropertyIsKinematicSpatial=\u662F\u5426\u4E3A\u8FD0\u52A8\u7269\u4F53 +ModelPropertyIsKinematic=\u662F\u5426\u53EF\u52A8 +ModelPropertyAngularVelocity=\u89D2\u901F\u5EA6 +ModelPropertyLinearFactor=\u7EBF\u6027\u56E0\u5B50 +ModelPropertyAngularDamping=\u65CB\u8F6C\u963B\u5C3C\u7CFB\u6570 +ModelPropertyAngularFactor=\u65CB\u8F6C\u56E0\u5B50 +ModelPropertyFriction=\u6469\u64E6\u7CFB\u6570 +ModelPropertyLinearDamping=\u7EBF\u6027\u963B\u5C3C\u7CFB\u6570 +ModelPropertyMass=\u8D28\u91CF +ModelPropertyRestitution=\u5F39\u6027 +ModelPropertyCurrentValue=\u5F53\u524D\u503C +ModelPropertyCurrentWayPoint=\u5F53\u524D\u8DEF\u5F84\u70B9 +ModelPropertyDirectionType=\u671D\u5411\u7C7B\u578B +ModelPropertyAngularSleepingThreshold=\u89D2\u4F11\u7720\u9608\u503C +ModelPropertyLoopMode=\u5FAA\u73AF\u6A21\u5F0F +ModelPropertyInitialDuration=\u521D\u59CB\u65F6\u957F +ModelPropertySpeed=\u901F\u5EA6 +ModelPropertyTime=\u65F6\u95F4 +ModelPropertyMargin=\u8FB9\u7F18\u7A7A\u767D +ModelPropertyHalfExtents=\u534A\u957F\u5EA6 +ModelPropertyHeight=\u9AD8\u5EA6 +ModelPropertyAxis=\u5750\u6807\u8F74 +ModelPropertyObjectId=\u5BF9\u8C61ID +ModelPropertyAxle=\u8F66\u8F74 +ModelPropertyRestLength=\u4F11\u606F\u65F6\u957F +ModelPropertyIsFront=\u524D\u65B9 +ModelPropertyDampingCompression=\u963B\u5C3C\u538B\u7F29 +ModelPropertyFrictionSlip=\u6469\u64E6\u6ED1\u5757 +ModelPropertyMaxSuspensionForce=\u6700\u5927\u60AC\u6D6E\u529B +ModelPropertyMaxSuspensionTravelCm=\u6700\u5927\u60AC\u6D6E\u884C\u7A0B +ModelPropertyDampingRelaxation=\u963B\u5C3C\u677E\u5F1B +ModelPropertySuspensionStiffness=\u60AC\u67B6\u521A\u5EA6 +ModelPropertyRollInfluence=\u65CB\u8F6C\u5F71\u54CD\u5668 ModelPropertyWheelSpatial=Wheel spatial -ModelPropertyLength=\u957f\u5ea6 -ModelPropertyCurrentTime=\u5f53\u524d\u65f6\u95f4 -ModelPropertyPoint=\u70b9 -ModelPropertyCenter=\u4e2d\u5fc3 -ModelPropertyVelocityVariation=\u901f\u5ea6\u7684\u53d8\u5316 -ModelPropertyInitialVelocity=\u521d\u59cb\u901f\u5ea6 -ModelPropertyOrigin=\u539f\u70b9 -ModelPropertyRadialVelocity=\u8f90\u5c04\u901f\u5ea6 -ModelPropertyIsHorizontal=\u662f\u5426\u6c34\u5e73 -ModelPropertyIsTestMode=\u6d4b\u8bd5\u53d1\u751f\u5668 -ModelPropertyIsRandomPoint=\u4f7f\u7528\u968f\u673a\u70b9 -ModelPropertyIsSequentialFace=\u4f7f\u7528\u6309\u6b21\u5e8f\u8868\u9762 -ModelPropertyIsSkipPattern=\u662f\u5426\u8df3\u8fc7\u6a21\u5f0f -ModelPropertyEmissionPoint=\u7c92\u5b50\u53d1\u751f\u70b9 -ModelPropertyMaxParticles=\u6700\u5927\u7c92\u5b50\u6570\u91cf -ModelPropertyEmissionPerSecond=\u53d1\u5c04\u6570/\u79d2 -ModelPropertyParticlesPerSecond=\u7c92\u5b50\u6570/\u79d2 -ModelPropertyEmitterLife=\u53d1\u5c04\u65f6\u95f4 -ModelPropertyEmitterDelay=\u53d1\u5c04\u5ef6\u8fdf -ModelPropertyIsTestParticles=\u6d4b\u8bd5\u7c92\u5b50 -ModelPropertyIsFollowEmitter=\u8ddf\u968f\u53d1\u5c04\u5668 -ModelPropertyStretching=\u62c9\u4f38 -ModelPropertyMagnitude=\u5e45\u5ea6 -ModelPropertyBillboard=\u5e7f\u544a\u724c(Billboard) -ModelPropertyInitialForce=\u521d\u59cb\u529b -ModelPropertyLife=\u751f\u5b58\u65f6\u95f4 +ModelPropertyLength=\u957F\u5EA6 +ModelPropertyCurrentTime=\u5F53\u524D\u65F6\u95F4 +ModelPropertyPoint=\u70B9 +ModelPropertyCenter=\u4E2D\u5FC3 +ModelPropertyVelocityVariation=\u901F\u5EA6\u7684\u53D8\u5316 +ModelPropertyInitialVelocity=\u521D\u59CB\u901F\u5EA6 +ModelPropertyOrigin=\u539F\u70B9 +ModelPropertyRadialVelocity=\u8F90\u5C04\u901F\u5EA6 +ModelPropertyIsHorizontal=\u662F\u5426\u6C34\u5E73 +ModelPropertyIsTestMode=\u6D4B\u8BD5\u53D1\u751F\u5668 +ModelPropertyIsRandomPoint=\u4F7F\u7528\u968F\u673A\u70B9 +ModelPropertyIsSequentialFace=\u4F7F\u7528\u6309\u6B21\u5E8F\u8868\u9762 +ModelPropertyIsSkipPattern=\u662F\u5426\u8DF3\u8FC7\u6A21\u5F0F +ModelPropertyEmissionPoint=\u7C92\u5B50\u53D1\u751F\u70B9 +ModelPropertyMaxParticles=\u6700\u5927\u7C92\u5B50\u6570\u91CF +ModelPropertyEmissionPerSecond=\u53D1\u5C04\u6570/\u79D2 +ModelPropertyParticlesPerSecond=\u7C92\u5B50\u6570/\u79D2 +ModelPropertyEmitterLife=\u53D1\u5C04\u65F6\u95F4 +ModelPropertyEmitterDelay=\u53D1\u5C04\u5EF6\u8FDF +ModelPropertyIsTestParticles=\u6D4B\u8BD5\u7C92\u5B50 +ModelPropertyIsFollowEmitter=\u8DDF\u968F\u53D1\u5C04\u5668 +ModelPropertyStretching=\u62C9\u4F38 +ModelPropertyMagnitude=\u5E45\u5EA6 +ModelPropertyBillboard=\u5E7F\u544A\u724C(Billboard) +ModelPropertyInitialForce=\u521D\u59CB\u529B +ModelPropertyLife=\u751F\u5B58\u65F6\u95F4 ModelPropertyLight=Light ModelPropertyColumns=\u5217\u6570 -ModelPropertyRows=\u884c\u6570 -ModelPropertySpriteCount=\u7cbe\u7075(Sprite)\u6570\u91cf -ModelPropertyIsFacingVelocity=\u6b63\u9762\u671d\u5411\u8fd0\u52a8\u65b9\u5411 -ModelPropertyIsInWorldSpace=\u5904\u4e8e\u4e16\u754c\u7a7a\u95f4 -ModelPropertyIsRandomAngle=\u968f\u673a\u89d2\u5ea6 -ModelPropertyIsSelectRandomImage=\u968f\u673a\u9009\u62e9\u56fe\u7247 -ModelPropertySize=\u5c3a\u5bf8 -ModelPropertyRotateSpeed=\u65cb\u8f6c\u901f\u5ea6 -ModelPropertyStartColor=\u521d\u59cb\u989c\u8272 -ModelPropertyEndColor=\u6700\u7ec8\u989c\u8272 -ModelPropertyMeshType=\u7f51\u683c\u7c7b\u578b -ModelPropertyFaceNormal=\u6b63\u9762\u671d\u5411\u6cd5\u5411\u91cf -ModelPropertyFixedDuration=\u56fa\u5b9a\u6301\u7eed\u65f6\u95f4 -ModelPropertyIsRandomStartColor=\u968f\u673a\u521d\u59cb\u989c\u8272 -ModelPropertyIsRandomStartSize=\u968f\u673a\u521d\u59cb\u5c3a\u5bf8 -ModelPropertySizeVariationFactor=\u5c3a\u5bf8\u53d8\u5316\u7cfb\u6570 -ModelPropertyIsRandomStartDestination=\u968f\u673a\u521d\u59cb\u76ee\u7684\u5730 -ModelPropertyChance=\u51e0\u7387 -ModelPropertyStrength=\u5f3a\u5ea6 -ModelPropertyAlignment=\u5bf9\u9f50 -ModelPropertyIsRandomDirection=\u968f\u673a\u65b9\u5411 -ModelPropertyPullCenter=Pull center -ModelPropertyPullAlignment=Pull alignment -ModelPropertyUpAlignment=\u4e0a\u5bf9\u9f50 -ModelPropertyRadialPull=Radial pull -ModelPropertyTangetForce=\u5207\u5411\u529b -ModelPropertyAlphaInterpolation=Alpha\u63d2\u503c -ModelPropertyColorInterpolation=\u989c\u8272\u63d2\u503c -ModelPropertyDestinationInterpolation=\u76ee\u7684\u5730\u63d2\u503c -ModelPropertyRotationInterpolation=\u65cb\u8f6c\u63d2\u503c -ModelPropertySizeInterpolation=\u5c3a\u5bf8\u63d2\u503c -ModelPropertyInfluencerAlpha=Alpha -ModelPropertyFrameSequence=\u5e27\u5e8f\u5217 -ModelPropertyIsRandomStartImage=\u968f\u673a\u521d\u59cb\u56fe\u7247 -ModelPropertyIsAnimate=\u6709\u52a8\u753b\u7684 -ModelPropertyReaction=\u53cd\u4f5c\u7528\u529b -ModelPropertyIsRandomSpeed=\u968f\u673a\u901f\u5ea6 -ModelPropertyIsStartRandomRotationX=\u968f\u673a\u65cb\u8f6c\u65b9\u5411 -ModelPropertyInterpolation=\u63d2\u503c -ModelPropertyGeometryList=\u51e0\u4f55\u4f53\u5217\u8868(\u672a\u4fdd\u5b58) -ModelPropertyGeometry=\u51e0\u4f55\u4f53 -ModelPropertyAxisSamples=Axis samples -ModelPropertyRadialSamples=Radial samples -ModelPropertyPlanes=\u5e73\u9762 -ModelPropertyWidth=\u5bbd\u5ea6 -ModelPropertyFlipCoords=\u7ffb\u8f6c\u5750\u6807 -ModelPropertyZSamples=Z samples -ModelPropertyCircleSamples=Circle samples -ModelPropertyInnerRadius=\u5185\u89d2\u534a\u5f84 -ModelPropertyOuterRadius=\u5916\u89d2\u534a\u5f84 -ModelPropertyName=\u540d\u79f0 -ModelPropertyDataType=\u6570\u636e\u7c7b\u578b -ModelPropertyDefaultValue=\u9ed8\u8ba4\u503c -ModelPropertyLightMode=\u706f\u5149\u6a21\u5f0f -ModelPropertyColorSpace=\u989c\u8272\u7a7a\u95f4 -ModelPropertyLanguage=\u8bed\u8a00 -ModelPropertyTexture=\u7eb9\u7406 - -MaterialModelPropertyControlNoTexture=\u6ca1\u6709\u7eb9\u7406 -MaterialModelPropertyControlTextureSettings=\u7eb9\u7406\u8bbe\u7f6e -MaterialModelPropertyControlNoMaterial=\u5185\u5d4c\u7684\u6750\u8d28 -MaterialModelPropertyControlFlipY=\u5782\u76f4\u7ffb\u8f6c -MaterialModelPropertyControlWrapModeS=Horizontal wrap mode -MaterialModelPropertyControlWrapModeT=Vertical wrap mode -MaterialModelPropertyControlMagFilter=Magnification filter -MaterialModelPropertyControlMinFilter=Minification filter - -AbstractElementPropertyControlNoElement=\u6ca1\u6709\u5143\u7d20 -LayerPropertyControlNoLayer=\u6ca1\u6709\u5c42 -AudioKeyPropertyControlNoAudio=\u6ca1\u6709\u97f3\u9891 -ChooseFolderControlNoFolder=\u6ca1\u6709\u6587\u4ef6\u5939 - -RenameDialogTitle=\u91cd\u547d\u540d -RenameDialogNewNameLabel=\u65b0\u540d\u5b57 -RenameDialogButtonOk=\u91cd\u547d\u540d - -PlayAnimationSettingsDialogTitle=\u64ad\u653e\u8bbe\u7f6e - -ManualExtractAnimationDialogTitle=\u63d0\u53d6\u4e00\u6bb5\u5b50\u52a8\u753b -ManualExtractAnimationDialogName=\u540d\u79f0 -ManualExtractAnimationDialogNameExample=\u65b0\u7684\u52a8\u753b -ManualExtractAnimationDialogStartFrame=\u5f00\u59cb\u5e27 -ManualExtractAnimationDialogEndFrame=\u7ed3\u675f\u5e27 -ManualExtractAnimationDialogButtonOk=\u63d0\u53d6 - -QuestionDialogTitle=Question - -FolderCreatorDescription=\u65b0\u5efa\u76ee\u5f55 -FolderCreatorTitle=\u65b0\u5efa\u76ee\u5f55 -FolderCreatorFileNameLabel=\u76ee\u5f55\u540d - -EmptyFileCreatorDescription=\u65b0\u5efa\u7a7a\u767d\u6587\u4ef6 -EmptyFileCreatorTitle=\u521b\u5efa\u7a7a\u767d\u6587\u4ef6 - -ImageViewerEditorName=\u67e5\u770b\u56fe\u7247 - -AudioViewerEditorName=\u67e5\u770b\u97f3\u9891 -AudioViewerEditorDurationLabel=\u6301\u7eed\u65f6\u95f4 -AudioViewerEditorBitsPerSampleLabel=\u6bd4\u7279\u7387 -AudioViewerEditorChannelsLabel=\u58f0\u9053 -AudioViewerEditorDataTypeLabel=\u6570\u636e\u7c7b\u578b -AudioViewerEditorSampleRateLabel=\u91c7\u6837\u7387 - -SimpleDialogButtonOk=\u786e\u5b9a -SimpleDialogButtonSelect=\u9009\u62e9 -SimpleDialogButtonAdd=\u6dfb\u52a0 -SimpleDialogButtonSave=\u4fdd\u5b58 -SimpleDialogButtonGenerate=\u751f\u6210 -SimpleDialogButtonApply=\u5e94\u7528 -SimpleDialogButtonCreate=\u521b\u5efa -SimpleDialogButtonCancel=\u53d6\u6d88 -SimpleDialogButtonClose=\u5173\u95ed -SimpleDialogButtonYes=\u662f +ModelPropertyRows=\u884C\u6570 +ModelPropertySpriteCount=\u7CBE\u7075(Sprite)\u6570\u91CF +ModelPropertyIsFacingVelocity=\u6B63\u9762\u671D\u5411\u8FD0\u52A8\u65B9\u5411 +ModelPropertyIsInWorldSpace=\u5904\u4E8E\u4E16\u754C\u7A7A\u95F4 +ModelPropertyIsRandomAngle=\u968F\u673A\u89D2\u5EA6 +ModelPropertyIsSelectRandomImage=\u968F\u673A\u9009\u62E9\u56FE\u7247 +ModelPropertySize=\u5C3A\u5BF8 +ModelPropertyRotateSpeed=\u65CB\u8F6C\u901F\u5EA6 +ModelPropertyStartColor=\u521D\u59CB\u989C\u8272 +ModelPropertyEndColor=\u6700\u7EC8\u989C\u8272 +ModelPropertyMeshType=\u7F51\u683C\u7C7B\u578B +ModelPropertyFaceNormal=\u6B63\u9762\u671D\u5411\u6CD5\u5411\u91CF +ModelPropertyFixedDuration=\u56FA\u5B9A\u6301\u7EED\u65F6\u95F4 +ModelPropertyIsRandomStartColor=\u968F\u673A\u521D\u59CB\u989C\u8272 +ModelPropertyIsRandomStartSize=\u968F\u673A\u521D\u59CB\u5C3A\u5BF8 +ModelPropertySizeVariationFactor=\u5C3A\u5BF8\u53D8\u5316\u7CFB\u6570 +ModelPropertyIsRandomStartDestination=\u968F\u673A\u521D\u59CB\u76EE\u7684\u5730 +ModelPropertyChance=\u51E0\u7387 +ModelPropertyStrength=\u5F3A\u5EA6 +ModelPropertyAlignment=\u5BF9\u9F50 +ModelPropertyIsRandomDirection=\u968F\u673A\u65B9\u5411 +ModelPropertyPullCenter=\u62C9\u529B\u4E2D\u5FC3 +ModelPropertyPullAlignment=\u62C9\u529B\u5BF9\u9F50\u65B9\u5411 +ModelPropertyUpAlignment=\u4E0A\u5BF9\u9F50 +ModelPropertyRadialPull=\u5411\u5FC3\u529B +ModelPropertyTangetForce=\u5207\u5411\u529B +ModelPropertyAlphaInterpolation=\u900F\u660E\u5EA6 +ModelPropertyColorInterpolation=\u989C\u8272 +ModelPropertyDestinationInterpolation=\u76EE\u6807\u8DEF\u5F84 +ModelPropertyRotationInterpolation=\u65CB\u8F6C +ModelPropertySizeInterpolation=\u5C3A\u5BF8 +ModelPropertyInfluencerAlpha=\u900F\u660E\u5EA6 +ModelPropertyFrameSequence=\u5E27\u5E8F\u5217 +ModelPropertyIsRandomStartImage=\u968F\u673A\u521D\u59CB\u56FE\u7247 +ModelPropertyIsAnimate=\u6709\u52A8\u753B\u7684 +ModelPropertyReaction=\u53CD\u5E94 +ModelPropertyIsRandomSpeed=\u968F\u673A\u901F\u5EA6 +ModelPropertyIsStartRandomRotationX=\u968F\u673A\u65CB\u8F6C\u65B9\u5411 +ModelPropertyInterpolation=\u63D2\u503C +ModelPropertyGeometryList=\u51E0\u4F55\u4F53\u5217\u8868(\u672A\u4FDD\u5B58) +ModelPropertyGeometry=\u51E0\u4F55\u4F53 +ModelPropertyAxisSamples=\u8F74\u5411\u91C7\u6837\u6570 +ModelPropertyRadialSamples=\u5F84\u5411\u91C7\u6837\u6570 +ModelPropertyPlanes=\u5E73\u9762 +ModelPropertyWidth=\u5BBD\u5EA6 +ModelPropertyFlipCoords=\u7FFB\u8F6C\u5750\u6807 +ModelPropertyZSamples=Z\u8F74\u91C7\u6837\u6570 +ModelPropertyCircleSamples=\u5706\u73AF\u91C7\u6837\u6570 +ModelPropertyInnerRadius=\u5185\u89D2\u534A\u5F84 +ModelPropertyOuterRadius=\u5916\u89D2\u534A\u5F84 +ModelPropertyName=\u540D\u79F0 +ModelPropertyDataType=\u6570\u636E\u7C7B\u578B +ModelPropertyDefaultValue=\u9ED8\u8BA4\u503C +ModelPropertyLightMode=\u706F\u5149\u6A21\u5F0F +ModelPropertyColorSpace=\u989C\u8272\u7A7A\u95F4 +ModelPropertyLanguage=\u8BED\u8A00 +ModelPropertyTexture=\u7EB9\u7406 +ModelPropertyBrushSize=\u7B14\u5237\u5C3A\u5BF8 +ModelPropertyBrushPower=\u7B14\u5237\u529B\u5EA6 +ModelPropertySmoothly=\u5E73\u6ED1\u7684 +ModelPropertyLimited=\u53D7\u9650\u7684 +ModelPropertyUseMarker=\u7528\u6237\u6807\u8BB0 +ModelPropertyRoughness=\u7C97\u7CD9\u5EA6 +ModelPropertyFrequency=\u9891\u7387 +ModelPropertyLacunarity=\u5B54\u9699\u5EA6 +ModelPropertyOctaves=\u516B\u8FB9\u5F62 +ModelPropertyMinScale=\u6700\u5C0F\u7F29\u653E\u6BD4\u4F8B +ModelPropertyMaxScale=\u6700\u5927\u7F29\u653E\u6BD4\u4F8B +ModelPropertyPadding=\u95F4\u9694 +ModelPropertyTriPlanar=\u4E09\u5E73\u9762 +ModelPropertyShininess=\u5149\u4EAE\u5EA6 +ModelPropertyModel=\u6A21\u578B +ModelPropertyMethod=\u65B9\u6CD5 + +MaterialModelPropertyControlNoTexture=\u6CA1\u6709\u7EB9\u7406 +MaterialModelPropertyControlTextureSettings=\u7EB9\u7406\u8BBE\u7F6E +MaterialModelPropertyControlNoMaterial=\u5185\u5D4C\u7684\u6750\u8D28 +MaterialModelPropertyControlFlipY=\u5782\u76F4\u7FFB\u8F6C +MaterialModelPropertyControlWrapModeS=\u6C34\u5E73\u5305\u56F4\u6A21\u5F0F +MaterialModelPropertyControlWrapModeT=\u5782\u76F4\u5305\u56F4\u6A21\u5F0F +MaterialModelPropertyControlMagFilter=\u653E\u5927\u6EE4\u6CE2 +MaterialModelPropertyControlMinFilter=\u7F29\u5C0F\u6EE4\u6CE2 + +AbstractElementPropertyControlNoElement=\u6CA1\u6709\u5143\u7D20 +LayerPropertyControlNoLayer=\u6CA1\u6709\u5C42 +AudioKeyPropertyControlNoAudio=\u6CA1\u6709\u97F3\u9891 +ChooseFolderControlNoFolder=\u6CA1\u6709\u6587\u4EF6\u5939 + +RenameDialogTitle=\u91CD\u547D\u540D +RenameDialogNewNameLabel=\u65B0\u540D\u5B57 +RenameDialogButtonOk=\u91CD\u547D\u540D + +PlayAnimationSettingsDialogTitle=\u64AD\u653E\u8BBE\u7F6E + +ManualExtractAnimationDialogTitle=\u63D0\u53D6\u4E00\u6BB5\u5B50\u52A8\u753B +ManualExtractAnimationDialogName=\u540D\u79F0 +ManualExtractAnimationDialogNameExample=\u65B0\u7684\u52A8\u753B +ManualExtractAnimationDialogStartFrame=\u5F00\u59CB\u5E27 +ManualExtractAnimationDialogEndFrame=\u7ED3\u675F\u5E27 +ManualExtractAnimationDialogButtonOk=\u63D0\u53D6 + +QuestionDialogTitle=\u95EE\u9898 + +FolderCreatorDescription=\u65B0\u5EFA\u76EE\u5F55 +FolderCreatorTitle=\u65B0\u5EFA\u76EE\u5F55 +FolderCreatorFileNameLabel=\u76EE\u5F55\u540D + +EmptyFileCreatorDescription=\u65B0\u5EFA\u7A7A\u767D\u6587\u4EF6 +EmptyFileCreatorTitle=\u521B\u5EFA\u7A7A\u767D\u6587\u4EF6 + +ImageViewerEditorName=\u67E5\u770B\u56FE\u7247 + +AudioViewerEditorName=\u67E5\u770B\u97F3\u9891 +AudioViewerEditorDurationLabel=\u6301\u7EED\u65F6\u95F4 +AudioViewerEditorBitsPerSampleLabel=\u6BD4\u7279\u7387 +AudioViewerEditorChannelsLabel=\u58F0\u9053 +AudioViewerEditorDataTypeLabel=\u6570\u636E\u7C7B\u578B +AudioViewerEditorSampleRateLabel=\u91C7\u6837\u7387 + +SimpleDialogButtonOk=\u786E\u5B9A +SimpleDialogButtonSelect=\u9009\u62E9 +SimpleDialogButtonAdd=\u6DFB\u52A0 +SimpleDialogButtonSave=\u4FDD\u5B58 +SimpleDialogButtonGenerate=\u751F\u6210 +SimpleDialogButtonApply=\u5E94\u7528 +SimpleDialogButtonCreate=\u521B\u5EFA +SimpleDialogButtonCancel=\u53D6\u6D88 +SimpleDialogButtonClose=\u5173\u95ED +SimpleDialogButtonYes=\u662F SimpleDialogButtonNo=\u5426 -SimpleDialogConvert=\u8f6c\u6362 -SimpleDialogImport=\u5bfc\u5165 - -CreateSkyDialogTitle=\u521b\u5efa\u5929\u7a7a -CreateSkyDialogSkyTypeSingle=\u5355\u4e2a\u7eb9\u7406 -CreateSkyDialogSkyTypeMultiple=\u591a\u4e2a\u7eb9\u7406 -CreateSkyDialogSkyType=\u5929\u7a7a\u7c7b\u578b -CreateSkyDialogNormalScale=Normal scale(x,y,z) -CreateSkyDialogMaterialFolder=\u6750\u8d28\u6587\u4ef6\u5939 -CreateSkyDialogMaterialName=\u6750\u8d28\u540d -CreateSkyDialogTexture=\u7eb9\u7406 -CreateSkyDialogTextureType=\u7eb9\u7406\u7c7b\u578b -CreateSkyDialogFlipY=\u5782\u76f4\u7ffb\u8f6c -CreateSkyDialogNorth=Front texture -CreateSkyDialogSouth=Back texture -CreateSkyDialogEast=Right texture -CreateSkyDialogWest=Left texture -CreateSkyDialogTop=Top texture -CreateSkyDialogBottom=Bottom texture - -EmptyModelCreatorDescription=\u65b0\u5efa\u6a21\u578b -EmptyModelCreatorTitle=\u521b\u5efa\u65b0\u6a21\u578b - -EmptySceneCreatorDescription=\u65b0\u5efa\u7a7a\u767d\u573a\u666f -DefaultSceneCreatorDescription=\u65b0\u5efa\u9ed8\u8ba4\u573a\u666f -EmptySceneCreatorTitle=\u521b\u5efa\u7a7a\u767d\u573a\u666f -DefaultSceneCreatorTitle=\u521b\u5efa\u9ed8\u8ba4\u573a\u666f - -GLSLFileEditorName=GLSL\u7f16\u8f91\u5668 -MaterialDefinitionFileEditorName=\u6750\u8d28\u5b9a\u4e49\u6587\u4ef6\u7f16\u8f91\u5668 - -GenerateTangentsDialogTitle=\u751f\u6210\u5207\u7ebf -GenerateTangentsDialogAlgorithmLabel=\u7b97\u6cd5\u7c7b\u578b -GenerateTangentsDialogSplitMirrored=Split vertices with mirrored UVs - -GenerateLoDDialogTitle=\u751f\u6210\u5c42\u6b21\u7ec6\u8282(LOD) -GenerateLoDDialogMethod=\u65b9\u6cd5 - -BoundingVolumeModelPropertyControlName=\u6a21\u578b\u5927\u5c0f -BoundingVolumeModelPropertyControlSphere=\u5305\u56f4\u7403 -BoundingVolumeModelPropertyControlSphereRadius=\u534a\u5f84 -BoundingVolumeModelPropertyControlBox=\u5305\u56f4\u76d2 - -NodeSelectorDialogTitle=\u8282\u70b9(Node)\u9009\u62e9\u5668 -SceneElementSelectorDialogTitle=Scene element selector - -GeometrySelectorDialogTitle=\u51e0\u4f55(Geometry)\u4f53\u9009\u62e9\u5668 -LightSelectorDialogTitle=\u706f\u5149\u9009\u62e9\u5668 - -LogViewTitle=\u65e5\u5fd7 - -CreateSceneAppStateDialogTitle=\u5411\u573a\u666f\u4e2d\u6dfb\u52a0\u72b6\u6001\u673a -CreateSceneAppStateDialogBuiltIn=\u5185\u7f6e\u72b6\u6001\u673a -CreateSceneAppStateDialogCustomBox=\u81ea\u5b9a\u4e49 -CreateSceneAppStateDialogCustomField=\u7c7b\u7684\u5168\u540d - -CreateSceneFilterDialogTitle=\u50cf\u573a\u666f\u4e2d\u6dfb\u52a0\u6ee4\u955c -CreateSceneFilterDialogBuiltIn=\u5185\u7f6e\u6ee4\u955c -CreateSceneFilterDialogCustomBox=\u81ea\u5b9a\u4e49 -CreateSceneFilterDialogCustomField=\u7c7b\u7684\u5168\u540d - -AddUserDataDialogTitle=\u6dfb\u52a0\u7528\u6237\u6570\u636e(UserData) - -CreateCustomControlDialogTitle=\u521b\u5efa\u81ea\u5b9a\u4e49\u63a7\u5236\u5668 -CreateCustomControlDialogBuiltIn=\u5185\u7f6e\u63a7\u5236\u5668 -CreateCustomControlDialogCustomBox=\u81ea\u5b9a\u4e49 -CreateCustomControlDialogCustomField=\u7c7b\u7684\u5168\u540d - -AnalyticsConfirmDialogMessage=\u60a8\u662f\u5426\u5141\u8bb8\u4e3a\u672c\u8f6f\u4ef6\u5f00\u542f\u8c37\u6b4c\u5206\u6790(GA)\u670d\u52a1\uff1f\u8fd9\u5c06\u5e2e\u52a9\u6211\u4eec\u6539\u8fdb\u8f6f\u4ef6\u8d28\u91cf\u3002 - -CreateBoxCollisionShapeDialogTitle=\u521b\u5efa\u7acb\u65b9\u4f53\u78b0\u649e\u5f62\u72b6 -CreateSphereCollisionShapeDialogTitle=\u521b\u5efa\u7403\u4f53\u78b0\u649e\u5f62\u72b6 -CreateCylinderCollisionShapeDialogTitle=\u521b\u5efa\u5706\u67f1\u4f53\u78b0\u649e\u5f62\u72b6 -CreateConeCollisionShapeDialogTitle=\u521b\u5efa\u5706\u9525\u4f53\u78b0\u649e\u5f62\u72b6 -CreateCapsuleCollisionShapeDialogTitle=\u521b\u5efa\u80f6\u56ca\u4f53\u78b0\u649e\u5f62\u72b6 -AddVehicleWheelDialogTitle=\u521b\u5efa\u8f66\u8f6e - -CreateTerrainDialogTitle=\u521b\u5efa\u5730\u5f62 -CreateTerrainDialogBaseTexture=\u57fa\u672c\u7eb9\u7406 -CreateTerrainDialogFolderAlphaTexture=\u8bf7\u9009\u62e9\u4fdd\u5b58AlphaMap\u7684\u76ee\u5f55 -CreateTerrainDialogTotalSize=\u603b\u8fb9\u957f -CreateTerrainDialogPatchSize=\u5757\u8fb9\u957f -CreateTerrainDialogAlphaBlendTextureSize=Alpha\u6df7\u5408\u7eb9\u7406\u8fb9\u957f -CreateTerrainDialogTerrainType=\u5730\u5f62\u7c7b\u578b -CreateTerrainDialogTerrainTypeFlat=\u8d85\u5e73\u5766 -CreateTerrainDialogTerrainTypeImageBased=\u57fa\u4e8e\u9ad8\u5ea6\u56fe -CreateTerrainDialogTerrainTypeHill=\u5c71\u5730 -CreateTerrainDialogHeightMapImage=\u9ad8\u5ea6\u56fe -CreateTerrainDialogHeightSmooth=\u9ad8\u5ea6\u56fe\u5e73\u6ed1\u5ea6 -CreateTerrainDialogHeightScale=\u9ad8\u5ea6\u7f29\u653e\u6bd4\u4f8b -CreateTerrainDialogIterations=\u8fed\u4ee3\u6b21\u6570 -CreateTerrainDialogFlattening=\u6241\u5e73\u7387 -CreateTerrainDialogMinRadius=\u6700\u5c0f\u534a\u5f84 -CreateTerrainDialogMaxRadius=\u6700\u5927\u534a\u5f84 - -CreateParticleEmitterPointShapeDialogTitle=\u521b\u5efa\u70b9\u72b6\u53d1\u751f\u5668 -CreateParticleEmitterBoxShapeDialogTitle=\u521b\u5efa\u76d2\u72b6\u53d1\u751f\u5668 -CreateParticleEmitterSphereShapeDialogTitle=\u521b\u5efa\u7403\u72b6\u53d1\u751f\u5668 -CreateParticleEmitterDomeShapeDialogTitle=\u521b\u5efa\u534a\u7403\u72b6\u53d1\u751f\u5668 -CreateParticleEmitterQuadShapeDialogTitle=\u521b\u5efa\u56db\u8fb9\u5f62\u72b6\u53d1\u751f\u5668 -CreateParticleEmitterTorusShapeDialogTitle=\u521b\u5efa\u5706\u73af\u72b6\u53d1\u751f\u5668 -CreateParticleEmitterTriangleShapeDialogTitle=\u521b\u5efa\u4e09\u89d2\u5f62\u53d1\u751f\u5668 - -PaintingComponentBrushSize=\u7b14\u5237\u5c3a\u5bf8 -PaintingComponentBrushPower=\u7b14\u5237\u529b\u5ea6 -PaintingComponentSmoothly=\u5e73\u6ed1\u7684 -PaintingComponentLimited=\u53d7\u9650\u7684 -PaintingComponentUseMarker=\u7528\u6237\u6807\u8bb0 -PaintingComponentLevel=\u7b49\u7ea7 -PaintingComponentRoughness=\u7c97\u7cd9\u5ea6 -PaintingComponentFrequency=\u9891\u7387 -PaintingComponentLacunarity=\u5b54\u9699\u5ea6 -PaintingComponentOctaves=\u516b\u8fb9\u5f62 -PaintingComponentScale=\u7f29\u653e -PaintingComponentTriPlanar=\u4e09\u5e73\u9762 -PaintingComponentShininess=\u5149\u4eae\u5ea6 -PaintingComponentLayer=\u5c42\u6b21 -PaintingComponentModel=Model -PaintingComponentMethod=Method - -ModelConverterDialogTitle=\u6a21\u578b\u8f6c\u6362 -ModelConverterDialogResultName=\u6587\u4ef6\u540d -ModelConverterDialogDestinationFolder=\u6587\u4ef6\u4fdd\u5b58\u76ee\u5f55 -ModelConverterDialogExportMaterials=\u5bfc\u51fa\u6750\u8d28 -ModelConverterDialogMaterialsFolder=\u6750\u8d28\u4fdd\u5b58\u76ee\u5f55 -ModelConverterDialogOverwriteMaterials=\u8986\u76d6\u540c\u540d\u6750\u8d28 - -ImportModelDialogTitle=\u5bfc\u5165\u6a21\u578b -ImportModelDialogExternalFile=\u5916\u90e8\u6587\u4ef6 -ImportModelDialogTexturesFolder=\u7eb9\u7406\u6240\u5728\u76ee\u5f55 -ImportModelDialogOverwriteTextures=\u8986\u76d6\u540c\u540d\u7eb9\u7406 - -FileDeleteHandlerDeleteMaterials=\u662f\u5426\u9700\u8981\u5220\u9664 %file_name% \u4e2d\u4f7f\u7528\u7684\u6240\u6709\u6750\u8d28? - -CheckNewVersionDialogTitle=\u66f4\u65b0\u4fe1\u606f -CheckNewVersionDialogHyperText=\u60a8\u53ef\u4ee5\u4e0b\u8f7d\u65b0\u7248\u672c: -CheckNewVersionDialogHeaderText=\u53ef\u7528\u66f4\u65b0\u7248\u672c: - -EditorScriptingComponentHeaders=\u811a\u672c\u6587\u4ef6\u5934 -EditorScriptingComponentBody=\u811a\u672c\u5185\u5bb9 -EditorScriptingComponentRun=\u8fd0\u884c\u811a\u672c - -AboutDialogTitle=\u5173\u4e8e -AboutDialogVersion=\u7248\u672c -AboutDialogProjectHome=\u9879\u76ee\u4e3b\u9875 -AboutDialogForumThread=\u8bba\u575b\u4e3b\u9898 -AboutDialogUsedLibraries=\u4f7f\u7528\u7684\u5e93 -AboutDialogUsedIcons=\u4f7f\u7528\u56fe\u6807 - -ResourcePropertyEditControlNothingIsSelected=\u672a\u9009\u62e9\u4efb\u4f55\u76ee\u6807 - -PluginsDialogTitle=\u63d2\u4ef6 -PluginsDialogFileChooserTitle=\u8bf7\u9009\u62e9\u63d2\u4ef6\u6587\u4ef6 -PluginsDialogFileChooserFilter=\u63d2\u4ef6\u6587\u4ef6\u4e3a .zip \u538b\u7f29\u6587\u4ef6 -PluginsDialogQuestion=\u6539\u52a8\u9700\u8981\u91cd\u65b0\u542f\u52a8\u7a0b\u5e8f\u65b9\u53ef\u751f\u6548. -PluginsDialogVersion=Version -PluginsDialogHomePage=Home page -PluginsDialogUsedDependencies=Used dependencies - -PaintingComponentContainerTool=Tool -PaintingComponentContainerNoTools=No tools -PaintingComponentTerrainEditor=Terrain editor -PaintingComponentSpawnModels=Spawn models +SimpleDialogConvert=\u8F6C\u6362 +SimpleDialogImport=\u5BFC\u5165 + +CreateSkyDialogTitle=\u521B\u5EFA\u5929\u7A7A +CreateSkyDialogSkyTypeSingle=\u5355\u4E2A\u7EB9\u7406 +CreateSkyDialogSkyTypeMultiple=\u591A\u4E2A\u7EB9\u7406 +CreateSkyDialogSkyType=\u5929\u7A7A\u7C7B\u578B +CreateSkyDialogNormalScale=\u6CD5\u7EBF\u7F29\u653E\u6BD4\u4F8B(x,y,z) +CreateSkyDialogMaterialFolder=\u6750\u8D28\u6587\u4EF6\u5939 +CreateSkyDialogMaterialName=\u6750\u8D28\u540D +CreateSkyDialogTexture=\u7EB9\u7406 +CreateSkyDialogTextureType=\u7EB9\u7406\u7C7B\u578B +CreateSkyDialogFlipY=\u5782\u76F4\u7FFB\u8F6C +CreateSkyDialogNorth=\u6B63\u9762\u7EB9\u7406 +CreateSkyDialogSouth=\u80CC\u9762\u7EB9\u7406 +CreateSkyDialogEast=\u53F3\u9762\u7EB9\u7406 +CreateSkyDialogWest=\u5DE6\u9762\u7EB9\u7406 +CreateSkyDialogTop=\u9876\u9762\u7EB9\u7406 +CreateSkyDialogBottom=\u5E95\u9762\u7EB9\u7406 + +EmptyModelCreatorDescription=\u65B0\u5EFA\u6A21\u578B +EmptyModelCreatorTitle=\u521B\u5EFA\u65B0\u6A21\u578B + +EmptySceneCreatorDescription=\u65B0\u5EFA\u7A7A\u767D\u573A\u666F +DefaultSceneCreatorDescription=\u65B0\u5EFA\u9ED8\u8BA4\u573A\u666F +EmptySceneCreatorTitle=\u521B\u5EFA\u7A7A\u767D\u573A\u666F +DefaultSceneCreatorTitle=\u521B\u5EFA\u9ED8\u8BA4\u573A\u666F + +GLSLFileEditorName=GLSL\u7F16\u8F91\u5668 +MaterialDefinitionFileEditorName=\u6750\u8D28\u5B9A\u4E49\u6587\u4EF6\u7F16\u8F91\u5668 + +GenerateTangentsDialogTitle=\u751F\u6210\u5207\u7EBF +GenerateTangentsDialogAlgorithmLabel=\u7B97\u6CD5\u7C7B\u578B +GenerateTangentsDialogSplitMirrored=\u6839\u636E\u955C\u50CFUV\u5206\u5272\u9876\u70B9 + +GenerateLoDDialogTitle=\u751F\u6210\u5C42\u6B21\u7EC6\u8282(LOD) +GenerateLoDDialogMethod=\u65B9\u6CD5 + +BoundingVolumeModelPropertyControlName=\u6A21\u578B\u5927\u5C0F +BoundingVolumeModelPropertyControlSphere=\u5305\u56F4\u7403 +BoundingVolumeModelPropertyControlSphereRadius=\u534A\u5F84 +BoundingVolumeModelPropertyControlBox=\u5305\u56F4\u76D2 + +NodeSelectorDialogTitle=\u8282\u70B9(Node)\u9009\u62E9\u5668 +SceneElementSelectorDialogTitle=\u573A\u666F\u5143\u7D20\u9009\u62E9\u5668 + +GeometrySelectorDialogTitle=\u51E0\u4F55(Geometry)\u4F53\u9009\u62E9\u5668 +LightSelectorDialogTitle=\u706F\u5149\u9009\u62E9\u5668 + +LogViewTitle=\u65E5\u5FD7 + +CreateSceneAppStateDialogTitle=\u5411\u573A\u666F\u4E2D\u6DFB\u52A0\u72B6\u6001\u673A +CreateSceneAppStateDialogBuiltIn=\u5185\u7F6E\u72B6\u6001\u673A +CreateSceneAppStateDialogCustomBox=\u81EA\u5B9A\u4E49 +CreateSceneAppStateDialogCustomField=\u7C7B\u7684\u5168\u540D + +CreateSceneFilterDialogTitle=\u50CF\u573A\u666F\u4E2D\u6DFB\u52A0\u6EE4\u955C +CreateSceneFilterDialogBuiltIn=\u5185\u7F6E\u6EE4\u955C +CreateSceneFilterDialogCustomBox=\u81EA\u5B9A\u4E49 +CreateSceneFilterDialogCustomField=\u7C7B\u7684\u5168\u540D + +AddUserDataDialogTitle=\u6DFB\u52A0\u7528\u6237\u6570\u636E + +CreateCustomControlDialogTitle=\u521B\u5EFA\u81EA\u5B9A\u4E49\u63A7\u5236\u5668 +CreateCustomControlDialogBuiltIn=\u5185\u7F6E\u63A7\u5236\u5668 +CreateCustomControlDialogCustomBox=\u81EA\u5B9A\u4E49 +CreateCustomControlDialogCustomField=\u7C7B\u7684\u5168\u540D + +AnalyticsConfirmDialogMessage=\u60A8\u662F\u5426\u5141\u8BB8\u4E3A\u672C\u8F6F\u4EF6\u5F00\u542F\u8C37\u6B4C\u5206\u6790(GA)\u670D\u52A1\uFF1F\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u6539\u8FDB\u8F6F\u4EF6\u8D28\u91CF\u3002 + +CreateBoxCollisionShapeDialogTitle=\u521B\u5EFA\u7ACB\u65B9\u4F53\u78B0\u649E\u5F62\u72B6 +CreateSphereCollisionShapeDialogTitle=\u521B\u5EFA\u7403\u4F53\u78B0\u649E\u5F62\u72B6 +CreateCylinderCollisionShapeDialogTitle=\u521B\u5EFA\u5706\u67F1\u4F53\u78B0\u649E\u5F62\u72B6 +CreateConeCollisionShapeDialogTitle=\u521B\u5EFA\u5706\u9525\u4F53\u78B0\u649E\u5F62\u72B6 +CreateCapsuleCollisionShapeDialogTitle=\u521B\u5EFA\u80F6\u56CA\u4F53\u78B0\u649E\u5F62\u72B6 +AddVehicleWheelDialogTitle=\u521B\u5EFA\u8F66\u8F6E + +CreateTerrainDialogTitle=\u521B\u5EFA\u5730\u5F62 +CreateTerrainDialogBaseTexture=\u57FA\u672C\u7EB9\u7406 +CreateTerrainDialogFolderAlphaTexture=\u8BF7\u9009\u62E9\u4FDD\u5B58AlphaMap\u7684\u76EE\u5F55 +CreateTerrainDialogTotalSize=\u603B\u8FB9\u957F +CreateTerrainDialogPatchSize=\u5757\u8FB9\u957F +CreateTerrainDialogAlphaBlendTextureSize=Alpha\u6DF7\u5408\u7EB9\u7406\u8FB9\u957F +CreateTerrainDialogTerrainType=\u5730\u5F62\u7C7B\u578B +CreateTerrainDialogTerrainTypeFlat=\u8D85\u5E73\u5766 +CreateTerrainDialogTerrainTypeImageBased=\u57FA\u4E8E\u9AD8\u5EA6\u56FE +CreateTerrainDialogTerrainTypeHill=\u5C71\u5730 +CreateTerrainDialogHeightMapImage=\u9AD8\u5EA6\u56FE +CreateTerrainDialogHeightSmooth=\u9AD8\u5EA6\u56FE\u5E73\u6ED1\u5EA6 +CreateTerrainDialogHeightScale=\u9AD8\u5EA6\u7F29\u653E\u6BD4\u4F8B +CreateTerrainDialogIterations=\u8FED\u4EE3\u6B21\u6570 +CreateTerrainDialogFlattening=\u6241\u5E73\u7387 +CreateTerrainDialogMinRadius=\u6700\u5C0F\u534A\u5F84 +CreateTerrainDialogMaxRadius=\u6700\u5927\u534A\u5F84 + +CreateParticleEmitterPointShapeDialogTitle=\u521B\u5EFA\u70B9\u72B6\u53D1\u751F\u5668 +CreateParticleEmitterBoxShapeDialogTitle=\u521B\u5EFA\u76D2\u72B6\u53D1\u751F\u5668 +CreateParticleEmitterSphereShapeDialogTitle=\u521B\u5EFA\u7403\u72B6\u53D1\u751F\u5668 +CreateParticleEmitterDomeShapeDialogTitle=\u521B\u5EFA\u534A\u7403\u72B6\u53D1\u751F\u5668 +CreateParticleEmitterQuadShapeDialogTitle=\u521B\u5EFA\u56DB\u8FB9\u5F62\u72B6\u53D1\u751F\u5668 +CreateParticleEmitterTorusShapeDialogTitle=\u521B\u5EFA\u5706\u73AF\u72B6\u53D1\u751F\u5668 +CreateParticleEmitterTriangleShapeDialogTitle=\u521B\u5EFA\u4E09\u89D2\u5F62\u53D1\u751F\u5668 + +ModelConverterDialogTitle=\u6A21\u578B\u8F6C\u6362 +ModelConverterDialogResultName=\u6587\u4EF6\u540D +ModelConverterDialogDestinationFolder=\u6587\u4EF6\u4FDD\u5B58\u76EE\u5F55 +ModelConverterDialogExportMaterials=\u5BFC\u51FA\u6750\u8D28 +ModelConverterDialogMaterialsFolder=\u6750\u8D28\u4FDD\u5B58\u76EE\u5F55 +ModelConverterDialogOverwriteMaterials=\u8986\u76D6\u540C\u540D\u6750\u8D28 + +ImportModelDialogTitle=\u5BFC\u5165\u6A21\u578B +ImportModelDialogExternalFile=\u5916\u90E8\u6587\u4EF6 +ImportModelDialogTexturesFolder=\u7EB9\u7406\u6240\u5728\u76EE\u5F55 +ImportModelDialogOverwriteTextures=\u8986\u76D6\u540C\u540D\u7EB9\u7406 + +FileDeleteHandlerDeleteMaterials=\u662F\u5426\u9700\u8981\u5220\u9664 %file_name% \u4E2D\u4F7F\u7528\u7684\u6240\u6709\u6750\u8D28? + +CheckNewVersionDialogTitle=\u66F4\u65B0\u4FE1\u606F +CheckNewVersionDialogHyperText=\u60A8\u53EF\u4EE5\u4E0B\u8F7D\u65B0\u7248\u672C: +CheckNewVersionDialogHeaderText=\u53EF\u7528\u66F4\u65B0\u7248\u672C: + +EditorScriptingComponentHeaders=\u811A\u672C\u6587\u4EF6\u5934 +EditorScriptingComponentBody=\u811A\u672C\u5185\u5BB9 +EditorScriptingComponentRun=\u8FD0\u884C\u811A\u672C + +AboutDialogTitle=\u5173\u4E8E +AboutDialogVersion=\u7248\u672C +AboutDialogProjectHome=\u9879\u76EE\u4E3B\u9875 +AboutDialogForumThread=\u8BBA\u575B\u4E3B\u9898 +AboutDialogUsedLibraries=\u4F7F\u7528\u7684\u5E93 +AboutDialogUsedIcons=\u4F7F\u7528\u56FE\u6807 + +ResourcePropertyEditControlNothingIsSelected=\u672A\u9009\u62E9\u4EFB\u4F55\u76EE\u6807 + +PluginsDialogTitle=\u63D2\u4EF6 +PluginsDialogFileChooserTitle=\u8BF7\u9009\u62E9\u63D2\u4EF6\u6587\u4EF6 +PluginsDialogFileChooserFilter=\u63D2\u4EF6\u6587\u4EF6\u4E3A .zip \u538B\u7F29\u6587\u4EF6 +PluginsDialogQuestion=\u6539\u52A8\u9700\u8981\u91CD\u65B0\u542F\u52A8\u7A0B\u5E8F\u65B9\u53EF\u751F\u6548. +PluginsDialogVersion=\u7248\u672C +PluginsDialogHomePage=\u4E3B\u9875 +PluginsDialogUsedDependencies=\u4F7F\u7528\u7684\u4F9D\u8D56\u5E93 + +PaintingComponentContainerTool=\u5DE5\u5177 +PaintingComponentContainerNoTools=\u65E0 +PaintingComponentTerrainEditor=\u5730\u5F62\u7F16\u8F91\u5668 +PaintingComponentSpawnModels=\u751F\u6210\u6A21\u578B PaintingComponentSpawnModelsMethodAsIs=As Is -PaintingComponentSpawnModelsMethodLink=Using links -PaintingComponentSpawnModelsMethodBatch=Using batches \ No newline at end of file +PaintingComponentSpawnModelsMethodLink=\u4F7F\u7528\u94FE\u63A5(Link) +PaintingComponentSpawnModelsMethodBatch=\u4F7F\u7528\u5408\u6279(Batch) diff --git a/src/main/resources/ui/css/base.css b/src/main/resources/ui/css/base.css index bcc33639..71d0a5ec 100644 --- a/src/main/resources/ui/css/base.css +++ b/src/main/resources/ui/css/base.css @@ -24,6 +24,7 @@ -var-default-label-height: 22px; -var-default-field-height: 26px; + -var-default-field-inner-height: 22px; -var-default-field-preview-height: 24px; -var-default-inner-field-height: 22px; -var-default-cell-height: 22px; diff --git a/src/main/resources/ui/css/custom_classes.css b/src/main/resources/ui/css/custom_classes.css index 588642d4..a35daba7 100644 --- a/src/main/resources/ui/css/custom_classes.css +++ b/src/main/resources/ui/css/custom_classes.css @@ -134,6 +134,7 @@ -fx-border-radius: 1px; -fx-padding: 1px 1px 1px 4px; -fx-min-height: -var-default-field-height; + -fx-alignment: center; } .text-input-container:focused { @@ -699,34 +700,78 @@ /******************************************************************************* * * - * Abstract Property Component * + * Property Editor * * * ******************************************************************************/ -.abstract-param-control-container { +.property-editor { +} + +.property-editor-container { -fx-alignment: top-center; - -fx-padding: 2px 6px 4px 4px; + -fx-padding: 2px 2px 2px 2px; + -fx-spacing: 2px; } -.abstract-param-control-container-split-line { +.property-editor-container-split-line { -fx-padding: 6px 0px 6px 0px; } -.abstract-param-control-container-split-line > .hbox { +.property-editor-container-split-line > .hbox { + -fx-border-color: -var-border-color transparent transparent transparent, - transparent transparent transparent transparent; + transparent transparent transparent transparent; + -fx-border-insets: 0, 1 0 0 0; -fx-border-style: none; -fx-padding: 0px; } +/******************************************************************************* + * * + * Property Control * + * * + ******************************************************************************/ + + +.property-control-resource { + +} + +.property-control-resource > .hbox { + -fx-padding: 0px 0px 0px 4px; +} + +.property-control-combo-box { +} + +.property-control-vector-3f-field { + -fx-min-height: -var-default-field-inner-height; +} + +.property-control-vector-3f-field:focused { + -fx-min-height: -var-default-field-inner-height; +} + +.property-control-check-box { +} + +.property-control-check-box-color-picker { +} + +/******************************************************************************* + * * + * Abstract Property Component * + * * + ******************************************************************************/ + .abstract-param-control { -fx-padding: 1px 0px 1px 0px; -fx-spacing: 2px; } .abstract-param-control > .hbox { - -fx-spacing: 2px; + -fx-spacing: 2px; } .abstract-param-control-multi-value-container { @@ -771,20 +816,10 @@ -fx-max-height: -var-default-inner-field-height; } -.abstract-param-control-param-color-picker { -} - -.abstract-param-control-checkbox { -} - -.abstract-param-control-combobox { -} .abstract-param-control-vector2f-field { } -.abstract-param-control-vector3f-field { -} .abstract-param-control-label-value { -fx-alignment: center-left; @@ -811,39 +846,6 @@ -fx-max-width: -fx-min-width; } -.abstract-param-control-influencer-element { - -fx-spacing: 2px; - -fx-padding: 0px; -} - -.abstract-param-control-influencer-element > .hbox { - -fx-spacing: 2px; -} - -.abstract-param-control-influencer { - -fx-padding: 4px 0px 0px 0px; - -fx-alignment: top-center; - -fx-spacing: 4px; -} - -.abstract-param-control-influencer > .vbox { - -fx-spacing: 2px; -} - -.abstract-param-control-influencer > .hbox { - -fx-alignment: center; - -fx-padding: 4px 0px 0px 0px; -} - -.abstract-param-control-influencer > .hbox > .button { - -fx-min-height: -var-default-toolbar-button-size; - -fx-pref-height: -fx-min-height; - -fx-max-height: -fx-min-height; - -fx-min-width: -var-default-toolbar-button-size; - -fx-pref-width: -fx-min-width; - -fx-max-width: -fx-min-width; -} - /******************************************************************************* * * * Editor Scripting Component * @@ -1243,25 +1245,11 @@ /******************************************************************************* * * - * Abstract Resource Property Control * - * * - ******************************************************************************/ - -.abstract-resource-property-control { - -} - -.abstract-resource-property-control > .hbox { - -fx-padding: 0px 0px 0px 4px; -} - -/******************************************************************************* - * * - * Abstract Param Editor Control * + * Property Editor Control * * * ******************************************************************************/ -.abstract-param-editor-control { +.property-editor-control { -fx-padding: 1px 0px 1px 0px; -fx-spacing: 2px; } diff --git a/src/main/resources/ui/css/dark-color.css b/src/main/resources/ui/css/dark-color.css index 4af17ffb..cc8e73da 100644 --- a/src/main/resources/ui/css/dark-color.css +++ b/src/main/resources/ui/css/dark-color.css @@ -54,50 +54,60 @@ .plain-code { -fx-fill: white; + -fx-text-fill: -fx-fill; } .keyword { -fx-fill: #f92670; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .value-type { -fx-fill: #62c59f; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .value-value { -fx-fill: #a776a7; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .semicolon { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .paren { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .bracket { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .brace { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .string { -fx-fill: #ddb03f; + -fx-text-fill: -fx-fill; } .comment { -fx-fill: #5f6c5a; + -fx-text-fill: -fx-fill; } .paragraph-box:has-caret { @@ -106,12 +116,15 @@ .log-severity { -fx-fill: #f92670; + -fx-text-fill: -fx-fill; } .log-framework { -fx-fill: #ddb03f; + -fx-text-fill: -fx-fill; } .log-class { -fx-fill: #62c59f; + -fx-text-fill: -fx-fill; } \ No newline at end of file diff --git a/src/main/resources/ui/css/light-color.css b/src/main/resources/ui/css/light-color.css index 5c625469..d848add1 100644 --- a/src/main/resources/ui/css/light-color.css +++ b/src/main/resources/ui/css/light-color.css @@ -54,50 +54,60 @@ .plain-code { -fx-fill: -var-font-color; + -fx-text-fill: -fx-fill; } .keyword { -fx-fill: #7f0c78; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .value-type { -fx-fill: #2a5332; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .value-value { -fx-fill: #b6270c; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .semicolon { -fx-fill: -var-font-color; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .paren { -fx-fill: -var-font-color; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .bracket { -fx-fill: -var-font-color; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .brace { -fx-fill: -var-font-color; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .string { -fx-fill: #1017c7; + -fx-text-fill: -fx-fill; } .comment { -fx-fill: #3f7f5f; + -fx-text-fill: -fx-fill; } .paragraph-box:has-caret { @@ -106,12 +116,15 @@ .log-severity { -fx-fill: red; + -fx-text-fill: -fx-fill; } .log-framework { -fx-fill: #7f0c78; + -fx-text-fill: -fx-fill; } .log-class { -fx-fill: #2a5332; + -fx-text-fill: -fx-fill; } \ No newline at end of file diff --git a/src/main/resources/ui/css/shadow-color.css b/src/main/resources/ui/css/shadow-color.css index a170a5ca..8aee5dc5 100644 --- a/src/main/resources/ui/css/shadow-color.css +++ b/src/main/resources/ui/css/shadow-color.css @@ -54,50 +54,60 @@ .plain-code { -fx-fill: white; + -fx-text-fill: -fx-fill; } .keyword { -fx-fill: #f92670; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .value-type { -fx-fill: #62c59f; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .value-value { -fx-fill: #a776a7; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .semicolon { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .paren { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .bracket { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .brace { -fx-fill: white; -fx-font-weight: bold; + -fx-text-fill: -fx-fill; } .string { -fx-fill: #ddb03f; + -fx-text-fill: -fx-fill; } .comment { -fx-fill: #5f6c5a; + -fx-text-fill: -fx-fill; } .paragraph-box:has-caret { @@ -106,12 +116,15 @@ .log-severity { -fx-fill: #f92670; + -fx-text-fill: -fx-fill; } .log-framework { -fx-fill: #ddb03f; + -fx-text-fill: -fx-fill; } .log-class { -fx-fill: #62c59f; + -fx-text-fill: -fx-fill; } \ No newline at end of file diff --git a/src/test/java/com/ss/editor/test/external/BaseExternalTest.java b/src/test/java/com/ss/editor/test/external/BaseExternalTest.java index a4647dab..7e2f2308 100644 --- a/src/test/java/com/ss/editor/test/external/BaseExternalTest.java +++ b/src/test/java/com/ss/editor/test/external/BaseExternalTest.java @@ -5,7 +5,7 @@ import com.jme3.math.ColorRGBA; import com.jme3.post.FilterPostProcessor; import com.jme3.system.AppSettings; -import com.ss.rlib.util.ClassUtils; +import com.ss.rlib.common.util.ClassUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/test/java/com/ss/editor/test/external/TreeViewTest.java b/src/test/java/com/ss/editor/test/external/TreeViewTest.java new file mode 100644 index 00000000..eb0a5c4b --- /dev/null +++ b/src/test/java/com/ss/editor/test/external/TreeViewTest.java @@ -0,0 +1,210 @@ +package com.ss.editor.test.external; + +import javafx.application.Application; +import javafx.beans.property.SimpleStringProperty; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.input.KeyCode; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.stage.Stage; + +import java.util.Arrays; +import java.util.List; + +public class TreeViewTest extends Application { + + List employees = Arrays.asList( + new Employee("Ethan Williams", "Sales Department", "Ethan Williams", "Sales Department"), + new Employee("Emma Jones", "Sales Department", "Emma Jones", "Sales Department"), + new Employee("Michael Brown", "Sales Department", "Michael Brown", "Sales Department"), + new Employee("Anna Black", "Sales Department", "Anna Black", "Sales Department"), + new Employee("Rodger York", "Sales Department", "Rodger York", "Sales Department"), + new Employee("Susan Collins", "Sales Department", "Susan Collins", "Sales Department"), + new Employee("Mike Graham", "IT Support", "Mike Graham", "IT Support"), + new Employee("Judy Mayer", "IT Support", "Judy Mayer", "IT Support"), + new Employee("Gregory Smith", "IT Support", "Gregory Smith", "IT Support"), + new Employee("Jacob Smith", "Accounts Department", "Jacob Smith", "Accounts Department"), + new Employee("Isabella Johnson", "Accounts Departmentllzzz", "Isabella Johnson", "Accounts Departmentllzzz"), + new Employee("Isabella Johnson", "Accounts Departmentllzzz", "Isabella Johnson", "Accounts Departmentllzzz"), + new Employee("Isabella Johnson", "Accounts Departmentllzzz", "Isabella Johnson", "Accounts Departmentllzzz")); + + TreeItem rootNode = new TreeItem<>("MyCompany Human Resources"); + + public static void main(String[] args) { + Application.launch(args); + } + + @Override + public void start(Stage stage) { + stage.setTitle("Tree View Sample"); + stage.setWidth(1024); + stage.setHeight(768); + + rootNode.setExpanded(true); + + for (Employee employee : employees) { + + TreeItem empLeaf = new TreeItem<>(employee.getName()); + + boolean found = false; + + for (TreeItem depNode : rootNode.getChildren()) { + if (depNode.getValue().contentEquals(employee.getDepartment())) { + depNode.getChildren().add(empLeaf); + found = true; + break; + } + } + + if (!found) { + TreeItem depNode = new TreeItem<>(employee.getDepartment()); + rootNode.getChildren().add(depNode); + depNode.getChildren().add(empLeaf); + } + } + + TreeView treeView = new TreeView<>(rootNode); + treeView.setShowRoot(true); + treeView.setEditable(false); + treeView.setCellFactory(p -> new TextFieldTreeCellImpl()); + + VBox emptyBox = new VBox(); + emptyBox.prefWidthProperty().bind(stage.widthProperty().multiply(0.5)); + + SplitPane splitPane = new SplitPane(); + splitPane.getItems() + .addAll(treeView, emptyBox); + + Scene scene = new Scene(splitPane, 400, 300); + scene.setFill(Color.LIGHTGRAY); + + stage.setScene(scene); + stage.show(); + } + + private final class TextFieldTreeCellImpl extends TreeCell { + + private TextField textField; + private ContextMenu addMenu = new ContextMenu(); + + public TextFieldTreeCellImpl() { + MenuItem addMenuItem = new MenuItem("Add Employee"); + addMenu.getItems().add(addMenuItem); + addMenuItem.setOnAction(t -> { + TreeItem newEmployee = new TreeItem<>("New Employee"); + getTreeItem().getChildren().add(newEmployee); + }); + } + + @Override + public void startEdit() { + super.startEdit(); + + if (textField == null) { + createTextField(); + } + setText(null); + setGraphic(textField); + textField.selectAll(); + } + + @Override + public void cancelEdit() { + super.cancelEdit(); + + setText(getItem()); + setGraphic(getTreeItem().getGraphic()); + } + + @Override + public void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + + if (empty) { + setText(null); + setGraphic(null); + } else { + if (isEditing()) { + if (textField != null) { + textField.setText(getString()); + } + setText(null); + setGraphic(textField); + } else { + setText(getString()); + setGraphic(getTreeItem().getGraphic()); + if (!getTreeItem().isLeaf() && getTreeItem().getParent() != null) { + setContextMenu(addMenu); + } + } + } + } + + private void createTextField() { + textField = new TextField(getString()); + textField.setOnKeyReleased(t -> { + if (t.getCode() == KeyCode.ENTER) { + commitEdit(textField.getText()); + } else if (t.getCode() == KeyCode.ESCAPE) { + cancelEdit(); + } + }); + + } + + private String getString() { + return getItem() == null ? "" : getItem().toString(); + } + } + + public static class Employee { + + private final SimpleStringProperty name; + private final SimpleStringProperty department; + private final SimpleStringProperty test; + private final SimpleStringProperty testtwo; + + + private Employee(String name, String department, String test, String testtwo) { + this.name = new SimpleStringProperty(name); + this.department = new SimpleStringProperty(department); + this.test = new SimpleStringProperty(test); + this.testtwo = new SimpleStringProperty(testtwo); + } + + public String getName() { + return name.get(); + } + + public void setName(String fName) { + name.set(fName); + } + + public String getDepartment() { + return department.get(); + } + + public void setDepartment(String fName) { + department.set(fName); + } + + + public String getTest() { + return test.get(); + } + + public void setTest(String testd) { + test.set(testd); + } + + + public String getTesttwo() { + return testtwo.get(); + } + + public void setTesttwo(String fNdme) { + testtwo.set(fNdme); + } + } +} diff --git a/src/test/java/com/ss/editor/test/internal/SetUpApplicationTest.java b/src/test/java/com/ss/editor/test/internal/SetUpApplicationTest.java index 57e6705d..6c40c565 100644 --- a/src/test/java/com/ss/editor/test/internal/SetUpApplicationTest.java +++ b/src/test/java/com/ss/editor/test/internal/SetUpApplicationTest.java @@ -3,8 +3,8 @@ import com.ss.editor.JfxApplication; import com.ss.editor.config.CommandLineConfig; import com.ss.editor.manager.InitializationManager; -import com.ss.rlib.concurrent.util.ThreadUtils; -import com.ss.rlib.util.array.ArrayFactory; +import com.ss.rlib.common.concurrent.util.ThreadUtils; +import com.ss.rlib.common.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.AfterAll;