diff --git a/README.md b/README.md index 69e966f4..2bec0659 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# jMonkeyEngine 3 SpaceShift Editor 1.1.0 # +# jMonkeyEngine 3 SpaceShift Editor 1.2.0 # ## License: Apache Version 2.0 ## [![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) @@ -11,6 +11,14 @@ ## [Video about this editor](https://youtu.be/5nX8HXYdENU) ## +## ver. 1.2.0 ## +* -Fixed the far view plane distance of the editor camera. +* -Updated tonegod.emitter library. +* -Added the new plugin Shader Node Tools. +* -Updated jME libraries. +* -Updated Tree Generator plugin. +* -Fixed some bugs. + ## ver. 1.1.0 ## * -Added the new plugin to generate trees. * -Updated the Material Editor. diff --git a/app.version b/app.version index 1cc5f657..867e5243 100644 --- a/app.version +++ b/app.version @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.2.0 \ No newline at end of file diff --git a/build-native.xml b/build-native.xml index 6039a420..d8f908be 100644 --- a/build-native.xml +++ b/build-native.xml @@ -2,11 +2,11 @@ - + - + diff --git a/build.gradle b/build.gradle index 9616d393..e98fb8f0 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'idea' apply plugin: 'org.junit.platform.gradle.plugin' group = 'com.spaceshift' -version = '1.1.0' +version = '1.2.0' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -41,7 +41,6 @@ junitPlatform { logManager 'org.apache.logging.log4j.jul.LogManager' } - repositories { mavenCentral() jcenter() @@ -59,7 +58,7 @@ dependencies { compile 'org.controlsfx:controlsfx:8.40.13' compile 'com.github.JavaSaBr:RlibFX:4.1.3' - compile 'com.github.JavaSaBr:RLib:6.3.6' + compile 'com.github.JavaSaBr:RLib:6.4.1' compile 'com.github.JavaSaBr:JME3-JFX:1.6.1' // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 @@ -126,10 +125,10 @@ dependencies { compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3' // extensions - compile ('com.github.JavaSaBr:jme3-spaceshift-extension:1.6.0') { + compile ('com.github.JavaSaBr:jme3-spaceshift-extension:1.7.2') { exclude group: 'org.jmonkeyengine' } - compile ('com.github.JavaSaBr:tonegodemitter:2.3.4') { + compile ('com.github.JavaSaBr:tonegodemitter:2.4.0') { exclude group: 'org.jmonkeyengine' } @@ -174,7 +173,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) { } task wrapper(type: Wrapper) { - gradleVersion = '4.1' + gradleVersion = '4.2' } artifacts { diff --git a/embedded-plugins/ss-editor-font-generator/ss-editor-font-generator-1.0.2.jar b/embedded-plugins/ss-editor-font-generator/ss-editor-font-generator-1.0.2.jar deleted file mode 100644 index 11c982e0..00000000 Binary files a/embedded-plugins/ss-editor-font-generator/ss-editor-font-generator-1.0.2.jar and /dev/null differ diff --git a/embedded-plugins/ss-editor-font-generator/ss-editor-font-generator-1.0.3.jar b/embedded-plugins/ss-editor-font-generator/ss-editor-font-generator-1.0.3.jar new file mode 100644 index 00000000..ca83fe4b Binary files /dev/null and b/embedded-plugins/ss-editor-font-generator/ss-editor-font-generator-1.0.3.jar differ diff --git a/embedded-plugins/ss-editor-shader-nodes/ss-editor-shader-nodes-1.0.0.jar b/embedded-plugins/ss-editor-shader-nodes/ss-editor-shader-nodes-1.0.0.jar new file mode 100644 index 00000000..bd8eb508 Binary files /dev/null and b/embedded-plugins/ss-editor-shader-nodes/ss-editor-shader-nodes-1.0.0.jar differ diff --git a/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.0-assets.jar b/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.1-assets.jar similarity index 99% rename from embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.0-assets.jar rename to embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.1-assets.jar index 235e519e..8132fd35 100644 Binary files a/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.0-assets.jar and b/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.1-assets.jar differ diff --git a/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.0.jar b/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.1.jar similarity index 93% rename from embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.0.jar rename to embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.1.jar index a2f60d4d..8c158ab2 100644 Binary files a/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.0.jar and b/embedded-plugins/ss-editor-tree-generator/libs/SimArboreal-1.2.1.jar differ diff --git a/embedded-plugins/ss-editor-tree-generator/ss-editor-tree-generator-1.0.0.jar b/embedded-plugins/ss-editor-tree-generator/ss-editor-tree-generator-1.0.0.jar deleted file mode 100644 index 7970dbbb..00000000 Binary files a/embedded-plugins/ss-editor-tree-generator/ss-editor-tree-generator-1.0.0.jar and /dev/null differ diff --git a/embedded-plugins/ss-editor-tree-generator/ss-editor-tree-generator-1.0.4.jar b/embedded-plugins/ss-editor-tree-generator/ss-editor-tree-generator-1.0.4.jar new file mode 100644 index 00000000..b51cc7e7 Binary files /dev/null and b/embedded-plugins/ss-editor-tree-generator/ss-editor-tree-generator-1.0.4.jar differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index bc1c08bb..7a3265ee 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 9e37093f..52dd1f04 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Aug 10 08:06:48 MSK 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip diff --git a/src/main/java/com/jme3/material/MatParam.java b/src/main/java/com/jme3/material/MatParam.java new file mode 100644 index 00000000..15706ff3 --- /dev/null +++ b/src/main/java/com/jme3/material/MatParam.java @@ -0,0 +1,413 @@ +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.material; + +import com.jme3.asset.TextureKey; +import com.jme3.export.*; +import com.jme3.math.*; +import com.jme3.shader.VarType; +import com.jme3.texture.Texture; +import com.jme3.texture.Texture.WrapMode; + +import java.io.IOException; + +/** + * Describes a material parameter. This is used for both defining a name and type + * as well as a material parameter value. + * + * @author Kirill Vainer + */ +public class MatParam implements Savable, Cloneable { + + protected VarType type; + protected String name; + protected String prefixedName; + protected Object value; + + /** + * Create a new material parameter. For internal use only. + */ + public MatParam(VarType type, String name, Object value) { + this.type = type; + this.name = name; + this.prefixedName = "m_" + name; + this.value = value; + } + + /** + * Serialization only. Do not use. + */ + public MatParam() { + } + + /** + * Returns the material parameter type. + * + * @return the material parameter type. + */ + public VarType getVarType() { + return type; + } + + /** + * Returns the name of the material parameter. + * @return the name of the material parameter. + */ + public String getName() { + return name; + } + + /** + * Returns the name with "m_" prefixed to it. + * + * @return the name with "m_" prefixed to it + */ + public String getPrefixedName() { + return prefixedName; + } + + /** + * Used internally + * @param name + */ + void setName(String name) { + this.name = name; + this.prefixedName = "m_" + name; + } + + /** + * Returns the value of this material parameter. + *

+ * Material parameters that are used for material definitions + * will not have a value, unless there's a default value declared + * in the definition. + * + * @return the value of this material parameter. + */ + public Object getValue() { + return value; + } + + /** + * Sets the value of this material parameter. + *

+ * It is assumed the value is of the same {@link MatParam#getVarType() type} + * as this material parameter. + * + * @param value the value of this material parameter. + */ + public void setValue(Object value) { + this.value = value; + } + + + /** + * Returns the material parameter value as it would appear in a J3M + * file. E.g.
+ * + * MaterialParameters {
+ * ABC : 1 2 3 4
+ * }
+ *
+ * Assuming "ABC" is a Vector4 parameter, then the value + * "1 2 3 4" would be returned by this method. + *

+ * @return material parameter value as it would appear in a J3M file. + */ + public String getValueAsString() { + switch (type) { + case Boolean: + case Float: + case Int: + return value.toString(); + case Vector2: + Vector2f v2 = (Vector2f) value; + return v2.getX() + " " + v2.getY(); +/* +This may get used at a later point of time +When arrays can be inserted in J3M files + + case Vector2Array: + Vector2f[] v2Arr = (Vector2f[]) value; + String v2str = ""; + for (int i = 0; i < v2Arr.length ; i++) { + v2str += v2Arr[i].getX() + " " + v2Arr[i].getY() + "\n"; + } + return v2str; +*/ + case Vector3: + Vector3f v3 = (Vector3f) value; + return v3.getX() + " " + v3.getY() + " " + v3.getZ(); +/* + case Vector3Array: + Vector3f[] v3Arr = (Vector3f[]) value; + String v3str = ""; + for (int i = 0; i < v3Arr.length ; i++) { + v3str += v3Arr[i].getX() + " " + + v3Arr[i].getY() + " " + + v3Arr[i].getZ() + "\n"; + } + return v3str; + case Vector4Array: + // can be either ColorRGBA, Vector4f or Quaternion + if (value instanceof Vector4f) { + Vector4f[] v4arr = (Vector4f[]) value; + String v4str = ""; + for (int i = 0; i < v4arr.length ; i++) { + v4str += v4arr[i].getX() + " " + + v4arr[i].getY() + " " + + v4arr[i].getZ() + " " + + v4arr[i].getW() + "\n"; + } + return v4str; + } else if (value instanceof ColorRGBA) { + ColorRGBA[] colorArr = (ColorRGBA[]) value; + String colStr = ""; + for (int i = 0; i < colorArr.length ; i++) { + colStr += colorArr[i].getRed() + " " + + colorArr[i].getGreen() + " " + + colorArr[i].getBlue() + " " + + colorArr[i].getAlpha() + "\n"; + } + return colStr; + } else if (value instanceof Quaternion) { + Quaternion[] quatArr = (Quaternion[]) value; + String quatStr = ""; + for (int i = 0; i < quatArr.length ; i++) { + quatStr += quatArr[i].getX() + " " + + quatArr[i].getY() + " " + + quatArr[i].getZ() + " " + + quatArr[i].getW() + "\n"; + } + return quatStr; + } else { + throw new UnsupportedOperationException("Unexpected Vector4Array type: " + value); + } +*/ + case Vector4: + // can be either ColorRGBA, Vector4f or Quaternion + if (value instanceof Vector4f) { + Vector4f v4 = (Vector4f) value; + return v4.getX() + " " + v4.getY() + " " + + v4.getZ() + " " + v4.getW(); + } else if (value instanceof ColorRGBA) { + ColorRGBA color = (ColorRGBA) value; + return color.getRed() + " " + color.getGreen() + " " + + color.getBlue() + " " + color.getAlpha(); + } else if (value instanceof Quaternion) { + Quaternion quat = (Quaternion) value; + return quat.getX() + " " + quat.getY() + " " + + quat.getZ() + " " + quat.getW(); + } else { + throw new UnsupportedOperationException("Unexpected Vector4 type: " + value); + } + case Texture2D: + case Texture3D: + case TextureArray: + case TextureBuffer: + case TextureCubeMap: + Texture texVal = (Texture) value; + TextureKey texKey = (TextureKey) texVal.getKey(); + if (texKey == null){ + //throw new UnsupportedOperationException("The specified MatParam cannot be represented in J3M"); + // this is used in toString and the above line causes blender materials to throw this exception. + // toStrings should be very robust IMO as even debuggers often invoke toString and logging code + // often does as well, even implicitly. + return texVal+":returned null key"; + } + + String ret = ""; + if (texKey.isFlipY()) { + ret += "Flip "; + } + + //Wrap mode + ret += getWrapMode(texVal, Texture.WrapAxis.S); + ret += getWrapMode(texVal, Texture.WrapAxis.T); + ret += getWrapMode(texVal, Texture.WrapAxis.R); + + //Min and Mag filter + Texture.MinFilter def = Texture.MinFilter.BilinearNoMipMaps; + if(texVal.getImage().hasMipmaps() || texKey.isGenerateMips()){ + def = Texture.MinFilter.Trilinear; + } + if(texVal.getMinFilter() != def){ + ret += "Min" + texVal.getMinFilter().name()+ " "; + } + + if(texVal.getMagFilter() != Texture.MagFilter.Bilinear){ + ret += "Mag" + texVal.getMagFilter().name()+ " "; + } + + return ret + "\"" + texKey.getName() + "\""; + default: + return null; // parameter type not supported in J3M + } + } + + private String getWrapMode(Texture texVal, Texture.WrapAxis axis) { + WrapMode mode = WrapMode.EdgeClamp; + try{ + mode = texVal.getWrap(axis); + }catch (IllegalArgumentException e){ + //this axis doesn't exist on the texture + return ""; + } + if(mode != WrapMode.EdgeClamp){ + return"Wrap"+ mode.name() + "_" + axis.name() + " "; + } + return ""; + } + + @Override + public MatParam clone() { + try { + MatParam param = (MatParam) super.clone(); + return param; + } catch (CloneNotSupportedException ex) { + throw new AssertionError(); + } + } + + public void write(JmeExporter ex) throws IOException { + OutputCapsule oc = ex.getCapsule(this); + oc.write(type, "varType", null); + oc.write(name, "name", null); + if (value == null) { + } else if (value instanceof Savable) { + oc.write((Savable) value, "value_savable", null); + } else if (value instanceof Float) { + oc.write((Float) value, "value_float", 0f); + } else if (value instanceof Integer) { + oc.write((Integer) value, "value_int", 0); + } else if (value instanceof Boolean) { + oc.write((Boolean) value, "value_bool", false); + } else if (value.getClass().isArray() && value instanceof Savable[]) { + oc.write((Savable[]) value, "value_savable_array", null); + } + } + + public void read(JmeImporter im) throws IOException { + InputCapsule ic = im.getCapsule(this); + type = ic.readEnum("varType", VarType.class, null); + name = ic.readString("name", null); + prefixedName = "m_" + name; + switch (getVarType()) { + case Boolean: + value = ic.readBoolean("value_bool", false); + break; + case Float: + value = ic.readFloat("value_float", 0f); + break; + case Int: + value = ic.readInt("value_int", 0); + break; + case Vector2Array: + Savable[] savableArray = ic.readSavableArray("value_savable_array", null); + if (savableArray != null) { + value = new Vector2f[savableArray.length]; + System.arraycopy(savableArray, 0, value, 0, savableArray.length); + } + break; + case Vector3Array: + savableArray = ic.readSavableArray("value_savable_array", null); + if (savableArray != null) { + value = new Vector3f[savableArray.length]; + System.arraycopy(savableArray, 0, value, 0, savableArray.length); + } + break; + case Vector4Array: + savableArray = ic.readSavableArray("value_savable_array", null); + if (savableArray != null) { + value = new Vector4f[savableArray.length]; + System.arraycopy(savableArray, 0, value, 0, savableArray.length); + } + break; + case Matrix3Array: + savableArray = ic.readSavableArray("value_savable_array", null); + if (savableArray != null) { + value = new Matrix3f[savableArray.length]; + System.arraycopy(savableArray, 0, value, 0, savableArray.length); + } + break; + case Matrix4Array: + savableArray = ic.readSavableArray("value_savable_array", null); + if (savableArray != null) { + value = new Matrix4f[savableArray.length]; + System.arraycopy(savableArray, 0, value, 0, savableArray.length); + } + break; + default: + value = ic.readSavable("value_savable", null); + break; + } + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MatParam other = (MatParam) obj; + if (this.type != other.type) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 59 * hash + (this.type != null ? this.type.hashCode() : 0); + hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 59 * hash + (this.value != null ? this.value.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + if (value != null) { + return type.name() + " " + name + " : " + getValueAsString(); + } else { + return type.name() + " " + name; + } + } +} diff --git a/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java new file mode 100644 index 00000000..b20a220e --- /dev/null +++ b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java @@ -0,0 +1,299 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.material.plugin.export.materialdef; + +import com.jme3.material.MatParam; +import com.jme3.material.RenderState; +import com.jme3.material.TechniqueDef; +import com.jme3.shader.Shader; +import com.jme3.shader.ShaderNode; +import com.jme3.shader.UniformBinding; +import com.jme3.shader.VariableMapping; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.Collection; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author nehon + */ +public class J3mdTechniqueDefWriter { + + public J3mdTechniqueDefWriter() { + } + + public void write(TechniqueDef techniqueDef, Collection matParams, OutputStreamWriter out) throws IOException { + out.write(" Technique"); + if(!techniqueDef.getName().equals("Default")) { + out.write(" "); + out.write(techniqueDef.getName()); + } + out.write(" {\n"); + + //Light mode + if(techniqueDef.getLightMode() != TechniqueDef.LightMode.Disable ){ + out.write(" LightMode "); + out.write(techniqueDef.getLightMode().name()); + out.write("\n\n"); + } + + //Shadow mode + if(techniqueDef.getShadowMode() != TechniqueDef.ShadowMode.Disable ){ + out.write(" ShadowMode "); + out.write(techniqueDef.getShadowMode().name()); + out.write("\n\n"); + } + + //Shaders + if(!techniqueDef.isUsingShaderNodes()) { + writeShaders(techniqueDef, out); + } + + //World params + if(!techniqueDef.getWorldBindings().isEmpty()){ + writeWorldParams(techniqueDef, out); + } + + //ShaderNodes + if(techniqueDef.isUsingShaderNodes()){ + writeShaderNodes(techniqueDef, matParams, out); + + } else { + //When we have ShaderNodes, Defines are handled differently so we don't have to write them. + //Defines + if (techniqueDef.getDefineNames().length != 0) { + writeDefines(techniqueDef, matParams, out); + } + } + + //render state + RenderState rs = techniqueDef.getRenderState(); + if(rs != null){ + out.write(" RenderState {\n"); + writeRenderState(rs, out); + out.write(" }\n\n"); + } + + //forced render state + rs = techniqueDef.getForcedRenderState(); + if(rs != null){ + out.write(" ForcedRenderState {\n"); + writeRenderState(rs, out); + out.write(" }\n\n"); + } + + //no render + if(techniqueDef.isNoRender()){ + out.write(" NoRender\n\n"); + } + + out.write(" }\n"); + } + + private void writeDefines(TechniqueDef techniqueDef, Collection matParams, OutputStreamWriter out) throws IOException { + out.write(" Defines {\n"); + + for (int i = 0; i < techniqueDef.getDefineNames().length; i++) { + String matParamName = getMatParamNameForDefineId(techniqueDef, matParams, i); + if (matParamName != null) { + String defineName = techniqueDef.getDefineNames()[i]; + out.write(" "); + out.write(defineName); + out.write(": "); + out.write(matParamName); + out.write("\n"); + } + } + out.write(" }\n\n"); + } + + private void writeShaderNodes(TechniqueDef techniqueDef, Collection matParams, OutputStreamWriter out) throws IOException { + out.write(" VertexShaderNodes {\n"); + for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { + if(shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex){ + writeShaderNode(out, shaderNode, matParams); + } + } + out.write(" }\n\n"); + + out.write(" FragmentShaderNodes {\n"); + for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { + if(shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment){ + writeShaderNode(out, shaderNode, matParams); + } + } + out.write(" }\n\n"); + } + + private void writeWorldParams(TechniqueDef techniqueDef, OutputStreamWriter out) throws IOException { + out.write(" WorldParameters {\n"); + for (UniformBinding uniformBinding : techniqueDef.getWorldBindings()) { + out.write(" "); + out.write(uniformBinding.toString()); + out.write("\n"); + } + out.write(" }\n\n"); + } + + private void writeShaders(TechniqueDef techniqueDef, OutputStreamWriter out) throws IOException { + if (techniqueDef.getShaderProgramNames().size() > 0) { + for (Shader.ShaderType shaderType : techniqueDef.getShaderProgramNames().keySet()) { + // System.err.println(shaderType + " " +techniqueDef.getShaderProgramNames().get(shaderType) + " " +techniqueDef.getShaderProgramLanguage(shaderType)) + out.write(" "); + out.write(shaderType.name()); + out.write("Shader "); + out.write(techniqueDef.getShaderProgramLanguage(shaderType)); + out.write(": "); + out.write(techniqueDef.getShaderProgramNames().get(shaderType)); + out.write("\n"); + } + out.write("\n"); + } + } + + private void writeShaderNode( OutputStreamWriter out, ShaderNode shaderNode, Collection matParams) throws IOException { + out.write(" ShaderNode "); + out.write(shaderNode.getName()); + out.write(" {\n"); + + if (shaderNode.getCondition() != null){ + out.write(" Condition: "); + out.write(formatCondition(shaderNode.getCondition(), matParams)); + out.write("\n"); + } + + out.write(" Definition: "); + out.write(shaderNode.getDefinition().getName()); + out.write(": "); + out.write(shaderNode.getDefinition().getPath()); + out.write("\n"); + + out.write(" InputMappings {\n"); + for (VariableMapping mapping : shaderNode.getInputMapping()) { + writeVariableMapping(out, shaderNode, mapping, matParams); + } + out.write(" }\n"); + + out.write(" OutputMappings {\n"); + for (VariableMapping mapping : shaderNode.getOutputMapping()) { + writeVariableMapping(out, shaderNode, mapping, matParams); + } + out.write(" }\n"); + + + out.write(" }\n"); + } + + private void writeVariableMapping(OutputStreamWriter out, ShaderNode shaderNode, VariableMapping mapping, Collection matParams) throws IOException { + out.write(" "); + if(!mapping.getLeftVariable().getNameSpace().equals(shaderNode.getName())) { + out.write(mapping.getLeftVariable().getNameSpace()); + out.write("."); + } + out.write(mapping.getLeftVariable().getName()); + if(!mapping.getLeftSwizzling().equals("")){ + out.write("."); + out.write(mapping.getLeftSwizzling()); + } + out.write(" = "); + if(!mapping.getRightVariable().getNameSpace().equals(shaderNode.getName())) { + out.write(mapping.getRightVariable().getNameSpace()); + out.write("."); + } + out.write(mapping.getRightVariable().getName().replaceFirst("g_","").replaceFirst("m_","")); + if(!mapping.getRightSwizzling().equals("")){ + out.write("."); + out.write(mapping.getRightSwizzling()); + } + + if (mapping.getCondition() != null){ + out.write(" : "); + out.write(formatCondition(mapping.getCondition(),matParams)); + } + + out.write("\n"); + } + + private String formatCondition(String condition, Collection matParams){ + //condition = condition.replaceAll("defined\\(",""); + + String res = condition; + Pattern pattern = Pattern.compile("defined\\(([A-Z0-9]*)\\)"); + Matcher m = pattern.matcher(condition); + + while(m.find()){ + String match = m.group(0); + String defineName = m.group(1).toLowerCase(); + for (MatParam matParam : matParams) { + if(matParam.getName().toLowerCase().equals(defineName)){ + res = res.replace(match, matParam.getName()); + } + } + } + + return res; + } + + private void writeRenderStateAttribute(OutputStreamWriter out, String name, String value) throws IOException { + out.write(" "); + out.write(name); + out.write(" "); + out.write(value); + out.write("\n"); + } + + private void writeRenderState(RenderState rs, OutputStreamWriter out) throws IOException { + RenderState defRs = RenderState.DEFAULT; + if(rs.getBlendMode() != defRs.getBlendMode()) { + writeRenderStateAttribute(out, "Blend", rs.getBlendMode().name()); + } + if(rs.isWireframe() != defRs.isWireframe()) { + writeRenderStateAttribute(out, "Wireframe", rs.isWireframe()?"On":"Off"); + } + if(rs.getFaceCullMode() != defRs.getFaceCullMode()) { + writeRenderStateAttribute(out, "FaceCull", rs.getFaceCullMode().name()); + } + if(rs.isDepthWrite() != defRs.isDepthWrite()) { + writeRenderStateAttribute(out, "DepthWrite", rs.isDepthWrite()?"On":"Off"); + } + if(rs.isDepthTest() != defRs.isDepthTest()) { + writeRenderStateAttribute(out, "DepthTest", rs.isDepthTest()?"On":"Off"); + } + if(rs.getBlendEquation() != defRs.getBlendEquation()) { + writeRenderStateAttribute(out, "BlendEquation", rs.getBlendEquation().name()); + } + if(rs.getBlendEquationAlpha() != defRs.getBlendEquationAlpha()) { + writeRenderStateAttribute(out, "BlendEquationAlpha", rs.getBlendEquationAlpha().name()); + } + if(rs.getPolyOffsetFactor() != defRs.getPolyOffsetFactor() || rs.getPolyOffsetUnits() != defRs.getPolyOffsetUnits()) { + writeRenderStateAttribute(out, "PolyOffset", rs.getPolyOffsetFactor() + " " + rs.getPolyOffsetUnits()); + } + if(rs.isColorWrite() != defRs.isColorWrite()) { + writeRenderStateAttribute(out, "ColorWrite", rs.isColorWrite()?"On":"Off"); + } + if(rs.getDepthFunc() != defRs.getDepthFunc()) { + writeRenderStateAttribute(out, "DepthFunc", rs.getDepthFunc().name()); + } + if(rs.getLineWidth() != defRs.getLineWidth()) { + writeRenderStateAttribute(out, "LineWidth", Float.toString(rs.getLineWidth())); + } + } + + private String getMatParamNameForDefineId(TechniqueDef techniqueDef, Collection matParams, int defineId) { + for (MatParam matParam : matParams) { + Integer id = techniqueDef.getShaderParamDefineId(matParam.getName()); + if(id !=null && id == defineId){ + return matParam.getName(); + } + } + return null; + } + +} + + diff --git a/src/main/java/com/jme3/scene/AssetLinkNode.java b/src/main/java/com/jme3/scene/AssetLinkNode.java new file mode 100644 index 00000000..82711ac6 --- /dev/null +++ b/src/main/java/com/jme3/scene/AssetLinkNode.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.scene; + +import com.jme3.asset.AssetManager; +import com.jme3.asset.ModelKey; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.util.SafeArrayList; +import com.jme3.util.clone.Cloner; + +import java.io.IOException; +import java.util.*; +import java.util.Map.Entry; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * The AssetLinkNode does not store its children when exported to file. + * Instead, you can add a list of AssetKeys that will be loaded and attached + * when the AssetLinkNode is restored. + * + * @author normenhansen + */ +public class AssetLinkNode extends Node { + + protected ArrayList assetLoaderKeys = new ArrayList(); + protected Map assetChildren = new HashMap(); + + public AssetLinkNode() { + } + + public AssetLinkNode(ModelKey key) { + this(key.getName(), key); + } + + public AssetLinkNode(String name, ModelKey key) { + super(name); + assetLoaderKeys.add(key); + } + + /** + * Called internally by com.jme3.util.clone.Cloner. Do not call directly. + */ + @Override + public void cloneFields( Cloner cloner, Object original ) { + super.cloneFields(cloner, original); + + // This is a change in behavior because the old version did not clone + // this list... changes to one clone would be reflected in all. + // I think that's probably undesirable. -pspeed + this.assetLoaderKeys = cloner.clone(assetLoaderKeys); + this.assetChildren = new HashMap(); + } + + /** + * Add a "linked" child. These are loaded from the assetManager when the + * AssetLinkNode is loaded from a binary file. + * @param key + */ + public void addLinkedChild(ModelKey key) { + if (assetLoaderKeys.contains(key)) { + return; + } + assetLoaderKeys.add(key); + } + + public void removeLinkedChild(ModelKey key) { + assetLoaderKeys.remove(key); + } + + public ArrayList getAssetLoaderKeys() { + return assetLoaderKeys; + } + + public void attachLinkedChild(AssetManager manager, ModelKey key) { + addLinkedChild(key); + Spatial child = manager.loadAsset(key); + assetChildren.put(key, child); + attachChild(child); + } + + public void attachLinkedChild(Spatial spat, ModelKey key) { + addLinkedChild(key); + assetChildren.put(key, spat); + attachChild(spat); + } + + public void detachLinkedChild(ModelKey key) { + Spatial spatial = assetChildren.get(key); + if (spatial != null) { + detachChild(spatial); + } + removeLinkedChild(key); + assetChildren.remove(key); + } + + public void detachLinkedChild(Spatial child, ModelKey key) { + removeLinkedChild(key); + assetChildren.remove(key); + detachChild(child); + } + + /** + * Loads the linked children AssetKeys from the AssetManager and attaches them to the Node
+ * If they are already attached, they will be reloaded. + * @param manager + */ + public void attachLinkedChildren(AssetManager manager) { + detachLinkedChildren(); + for (Iterator it = assetLoaderKeys.iterator(); it.hasNext();) { + ModelKey assetKey = it.next(); + Spatial curChild = assetChildren.get(assetKey); + if (curChild != null) { + curChild.removeFromParent(); + } + Spatial child = manager.loadAsset(assetKey); + attachChild(child); + assetChildren.put(assetKey, child); + } + } + + public void detachLinkedChildren() { + Set> set = assetChildren.entrySet(); + for (Iterator> it = set.iterator(); it.hasNext();) { + Entry entry = it.next(); + entry.getValue().removeFromParent(); + it.remove(); + } + } + + @Override + public void read(JmeImporter e) throws IOException { + super.read(e); + + final InputCapsule capsule = e.getCapsule(this); + final AssetManager assetManager = e.getAssetManager(); + + assetLoaderKeys = (ArrayList) capsule.readSavableArrayList("assetLoaderKeyList", new ArrayList()); + + for (final Iterator iterator = assetLoaderKeys.iterator(); iterator.hasNext(); ) { + + final ModelKey modelKey = iterator.next(); + final Spatial child = assetManager.loadAsset(modelKey); + + if (child != null) { + child.parent = this; + children.add(child); + assetChildren.put(modelKey, child); + } else { + Logger.getLogger(this.getClass().getName()).log(Level.WARNING, + "Cannot locate {0} for asset link node {1}", new Object[]{modelKey, key}); + } + } + } + + @Override + public void write(JmeExporter e) throws IOException { + SafeArrayList childs = children; + children = new SafeArrayList<>(Spatial.class); + super.write(e); + OutputCapsule capsule = e.getCapsule(this); + capsule.writeSavableArrayList(assetLoaderKeys, "assetLoaderKeyList", null); + children = childs; + } +} diff --git a/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java b/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java new file mode 100644 index 00000000..6510c352 --- /dev/null +++ b/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java @@ -0,0 +1,642 @@ +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.shader; + +import com.jme3.asset.AssetManager; +import com.jme3.material.ShaderGenerationInfo; +import com.jme3.material.plugins.ConditionParser; +import com.jme3.shader.Shader.ShaderType; + +import java.util.ArrayList; +import java.util.List; + +/** + * This shader Generator can generate Vertex and Fragment shaders from + * shadernodes for GLSL 1.0 + * + * @author Nehon + */ +public class Glsl100ShaderGenerator extends ShaderGenerator { + + private ShaderNodeVariable inPosTmp; + + /** + * creates a Glsl100ShaderGenerator + * @param assetManager the assetManager + */ + public Glsl100ShaderGenerator(AssetManager assetManager) { + super(assetManager); + } + + @Override + protected void generateUniforms(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + generateUniforms(source, type == ShaderType.Vertex ? info.getVertexUniforms() : info.getFragmentUniforms()); + } + + /** + * declare a list of uniforms + * + * @param source the source to append to + * @param uniforms the list of uniforms + */ + protected void generateUniforms(StringBuilder source, List uniforms) { + source.append("\n"); + for (ShaderNodeVariable var : uniforms) { + declareVariable(source, var, false, "uniform"); + } + } + + /** + * {@inheritDoc} + * + * attributes are all declared, inPositon is declared even if it's not in + * the list and it's condition is nulled. + */ + @Override + protected void generateAttributes(StringBuilder source, ShaderGenerationInfo info) { + source.append("\n"); + boolean inPosition = false; + for (ShaderNodeVariable var : info.getAttributes()) { + if (var.getName().equals("inPosition")) { + inPosition = true; + var.setCondition(null); + fixInPositionType(var); + //keep track on the InPosition variable to avoid iterating through attributes again + inPosTmp = var; + } + declareAttribute(source, var); + + } + if (!inPosition) { + inPosTmp = new ShaderNodeVariable("vec3", "inPosition"); + declareAttribute(source, inPosTmp); + } + + } + + @Override + protected void generateVaryings(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + source.append("\n"); + for (ShaderNodeVariable var : info.getVaryings()) { + declareVarying(source, var, type == ShaderType.Vertex ? false : true); + } + } + + /** + * {@inheritDoc} + * + * if the declaration contains no code nothing is done, else it's appended + */ + @Override + protected void generateDeclarativeSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info) { + if (nodeSource.replaceAll("\\n", "").trim().length() > 0) { + nodeSource = updateDefinesName(nodeSource, shaderNode); + source.append("\n"); + unIndent(); + startCondition(shaderNode.getCondition(), source); + source.append(nodeSource); + source.append("\n"); + endCondition(shaderNode.getCondition(), source); + indent(); + } + } + + /** + * {@inheritDoc} + * + * Shader outputs are declared and initialized inside the main section + */ + @Override + protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + source.append("\n"); + source.append("void main() {\n"); + indent(); + appendIndent(source); + if (type == ShaderType.Vertex) { + declareGlobalPosition(info, source); + } else if (type == ShaderType.Fragment) { + for (ShaderNodeVariable global : info.getFragmentGlobals()) { + declareVariable(source, global, "vec4(1.0)"); + } + } + source.append("\n"); + } + + /** + * {@inheritDoc} + * + * outputs are assigned to built in glsl output. then the main section is + * closed + * + * This code accounts for multi render target and correctly output to + * gl_FragData if several output are declared for the fragment shader + */ + @Override + protected void generateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + source.append("\n"); + if (type == ShaderType.Vertex) { + appendOutput(source, "gl_Position", info.getVertexGlobal()); + } else if (type == ShaderType.Fragment) { + List globals = info.getFragmentGlobals(); + if (globals.size() == 1) { + appendOutput(source, "gl_FragColor", globals.get(0)); + } else { + int i = 0; + //Multi Render Target + for (ShaderNodeVariable global : globals) { + appendOutput(source, "gl_FragData[" + i + "]", global); + i++; + } + } + } + unIndent(); + appendIndent(source); + source.append("}\n"); + } + + /** + * Appends an output assignment to a shader globalOutputName = + * nameSpace_varName; + * + * @param source the source StringBuilter to append the code. + * @param globalOutputName the name of the global output (can be gl_Position + * or gl_FragColor etc...). + * @param var the variable to assign to the output. + */ + protected void appendOutput(StringBuilder source, String globalOutputName, ShaderNodeVariable var) { + appendIndent(source); + source.append(globalOutputName); + source.append(" = "); + source.append(var.getNameSpace()); + source.append("_"); + source.append(var.getName()); + source.append(";\n"); + } + + /** + * {@inheritDoc} + * + * this methods does things in this order : + * + * 1. declaring and mapping input
+ * variables : variable replaced with MatParams or WorldParams that are Samplers are not + * declared and are replaced by the param actual name in the code. For others + * variables, the name space is appended with a "_" before the variable name + * in the code to avoid names collision between shaderNodes.
+ * + * 2. declaring output variables :
+ * variables are declared if they were not already + * declared as input (inputs can also be outputs) or if they are not + * declared as varyings. The variable name is also prefixed with the s=name + * space and "_" in the shaderNode code
+ * + * 3. append of the actual ShaderNode code
+ * + * 4. mapping outputs to global output if needed
+ * + *
+ * All of this is embed in a #if conditional statement if needed + */ + @Override + protected void generateNodeMainSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info) { + + nodeSource = updateDefinesName(nodeSource, shaderNode); + source.append("\n"); + comment(source, shaderNode, "Begin"); + startCondition(shaderNode.getCondition(), source); + + final List declaredInputs = new ArrayList<>(); + + for (VariableMapping mapping : shaderNode.getInputMapping()) { + + final ShaderNodeVariable rightVariable = mapping.getRightVariable(); + final ShaderNodeVariable leftVariable = mapping.getLeftVariable(); + + //Variables fed with a sampler matparam or world param are replaced by the matparam itself + //It avoids issue with samplers that have to be uniforms. + if (isWorldOrMaterialParam(rightVariable) && rightVariable.getType().startsWith("sampler")) { + nodeSource = replace(nodeSource, leftVariable, rightVariable.getPrefix() + rightVariable.getName()); + } else { + + if (leftVariable.getType().startsWith("sampler")) { + throw new IllegalArgumentException("a Sampler must be a uniform"); + } + + map(mapping, source); + } + + String newName = shaderNode.getName() + "_" + leftVariable.getName(); + if (!declaredInputs.contains(newName)) { + nodeSource = replace(nodeSource, leftVariable, newName); + declaredInputs.add(newName); + } + } + + final ShaderNodeDefinition definition = shaderNode.getDefinition(); + + for (final ShaderNodeVariable var : definition.getInputs()) { + final ShaderNodeVariable variable = new ShaderNodeVariable(var.getType(), shaderNode.getName(), var.getName(), var.getMultiplicity()); + final String fullName = shaderNode.getName() + "_" + var.getName(); + if (!declaredInputs.contains(fullName)) { + if (!isVarying(info, variable)) { + declareVariable(source, variable); + } + nodeSource = replaceVariableName(nodeSource, variable); + declaredInputs.add(fullName); + } + } + + for (ShaderNodeVariable var : definition.getOutputs()) { + ShaderNodeVariable v = new ShaderNodeVariable(var.getType(), shaderNode.getName(), var.getName(), var.getMultiplicity()); + if (!declaredInputs.contains(shaderNode.getName() + "_" + var.getName())) { + if (!isVarying(info, v)) { + declareVariable(source, v); + } + nodeSource = replaceVariableName(nodeSource, v); + } + } + + source.append(nodeSource); + + for (VariableMapping mapping : shaderNode.getOutputMapping()) { + map(mapping, source); + } + endCondition(shaderNode.getCondition(), source); + comment(source, shaderNode, "End"); + } + + /** + * declares a variable, embed in a conditional block if needed + * @param source the StringBuilder to use + * @param var the variable to declare + * @param appendNameSpace true to append the nameSpace + "_" + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace) { + declareVariable(source, var, appendNameSpace, null); + } + + /** + * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" + * @param source the StringBuilder to use + * @param var the variable to declare + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var) { + declareVariable(source, var, true, null); + } + + /** + * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" + * @param source the StringBuilder to use + * @param var the variable to declare + * @param value the initialization value to assign the the variable + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, String value) { + declareVariable(source, var, value, true, null); + } + + /** + * declares a variable, embed in a conditional block if needed. + * @param source the StringBuilder to use + * @param var the variable to declare + * @param appendNameSpace true to append the nameSpace + "_" + * @param modifier the modifier of the variable (attribute, varying, in , out,...) + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace, String modifier) { + declareVariable(source, var, null, appendNameSpace, modifier); + } + + /** + * declares a variable, embed in a conditional block if needed. + * @param source the StringBuilder to use + * @param var the variable to declare + * @param value the initialization value to assign the the variable + * @param appendNameSpace true to append the nameSpace + "_" + * @param modifier the modifier of the variable (attribute, varying, in , out,...) + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, String value, boolean appendNameSpace, String modifier) { + startCondition(var.getCondition(), source); + appendIndent(source); + if (modifier != null) { + source.append(modifier); + source.append(" "); + } + + source.append(var.getType()); + source.append(" "); + if (appendNameSpace) { + source.append(var.getNameSpace()); + source.append("_"); + } + source.append(var.getPrefix()); + source.append(var.getName()); + if (var.getMultiplicity() != null) { + source.append("["); + source.append(var.getMultiplicity().toUpperCase()); + source.append("]"); + } + if (value != null) { + source.append(" = "); + source.append(value); + } + source.append(";\n"); + endCondition(var.getCondition(), source); + } + + /** + * Starts a conditional block + * @param condition the block condition + * @param source the StringBuilder to use + */ + protected void startCondition(String condition, StringBuilder source) { + if (condition != null) { + appendIndent(source); + source.append("#if "); + source.append(condition); + source.append("\n"); + indent(); + } + } + + /** + * Ends a conditional block + * @param condition the block condition + * @param source the StringBuilder to use + */ + protected void endCondition(String condition, StringBuilder source) { + if (condition != null) { + unIndent(); + appendIndent(source); + source.append("#endif\n"); + + } + } + + /** + * Appends a mapping to the source, embed in a conditional block if needed, + * with variables nameSpaces and swizzle. + * @param mapping the VariableMapping to append + * @param source the StringBuilder to use + */ + protected void map(VariableMapping mapping, StringBuilder source) { + startCondition(mapping.getCondition(), source); + appendIndent(source); + if (!mapping.getLeftVariable().isShaderOutput()) { + source.append(mapping.getLeftVariable().getType()); + source.append(" "); + } + source.append(mapping.getLeftVariable().getNameSpace()); + source.append("_"); + source.append(mapping.getLeftVariable().getName()); + if (mapping.getLeftVariable().getMultiplicity() != null){ + source.append("["); + source.append(mapping.getLeftVariable().getMultiplicity()); + source.append("]"); + } + + //left swizzle, the variable can't be declared and assigned on the same line. + if (mapping.getLeftSwizzling().length() > 0) { + //initialize the declared variable to 0.0 + source.append(" = "); + source.append(mapping.getLeftVariable().getType()); + source.append("(0.0);\n"); + appendIndent(source); + //assign the value on a new line + source.append(mapping.getLeftVariable().getNameSpace()); + source.append("_"); + source.append(mapping.getLeftVariable().getName()); + source.append("."); + source.append(mapping.getLeftSwizzling()); + } + source.append(" = "); + String namePrefix = getAppendableNameSpace(mapping.getRightVariable()); + source.append(namePrefix); + source.append(mapping.getRightVariable().getPrefix()); + source.append(mapping.getRightVariable().getName()); + if (mapping.getRightSwizzling().length() > 0) { + source.append("."); + source.append(mapping.getRightSwizzling()); + } + source.append(";\n"); + endCondition(mapping.getCondition(), source); + } + + /** + * replaces a variable name in a shaderNode source code by prefixing it + * with its nameSpace and "_" if needed. + * @param nodeSource the source to modify + * @param var the variable to replace + * @return the modified source + */ + protected String replaceVariableName(String nodeSource, ShaderNodeVariable var) { + String namePrefix = getAppendableNameSpace(var); + String newName = namePrefix + var.getName(); + nodeSource = replace(nodeSource, var, newName); + return nodeSource; + } + + /** + * Finds if a variable is a varying + * @param info the ShaderGenerationInfo + * @param v the variable + * @return true is the given variable is a varying + */ + protected boolean isVarying(ShaderGenerationInfo info, ShaderNodeVariable v) { + boolean isVarying = false; + for (ShaderNodeVariable shaderNodeVariable : info.getVaryings()) { + if (shaderNodeVariable.equals(v)) { + isVarying = true; + } + } + return isVarying; + } + + /** + * Appends a comment to the generated code + * @param source the StringBuilder to use + * @param shaderNode the shader node being processed (to append its name) + * @param comment the comment to append + */ + protected void comment(StringBuilder source, ShaderNode shaderNode, String comment) { + appendIndent(source); + source.append("//"); + source.append(shaderNode.getName()); + source.append(" : "); + source.append(comment); + source.append("\n"); + } + + /** + * returns the name space to append for a variable. + * Attributes, WorldParam and MatParam names space must not be appended + * @param var the variable + * @return the namespace to append for this variable + */ + protected String getAppendableNameSpace(ShaderNodeVariable var) { + String namePrefix = var.getNameSpace() + "_"; + if (namePrefix.equals("Attr_") || namePrefix.equals("WorldParam_") || namePrefix.equals("MatParam_")) { + namePrefix = ""; + } + return namePrefix; + } + + /** + * transforms defines name is the shader node code. + * One can use a #if defined(inputVariableName) in a shaderNode code. + * This method is responsible for changing the variable name with the + * appropriate defined based on the mapping condition of this variable. + * Complex condition syntax are handled. + * + * @param nodeSource the sahderNode source code + * @param shaderNode the ShaderNode being processed + * @return the modified shaderNode source. + */ + protected String updateDefinesName(String nodeSource, ShaderNode shaderNode) { + String[] lines = nodeSource.split("\\n"); + ConditionParser parser = new ConditionParser(); + for (String line : lines) { + + if (line.trim().startsWith("#if")) { + List params = parser.extractDefines(line.trim()); + String l = line.trim().replaceAll("defined", "").replaceAll("#if ", "").replaceAll("#ifdef", "");//parser.getFormattedExpression(); + boolean match = false; + for (String param : params) { + for (VariableMapping map : shaderNode.getInputMapping()) { + if ((map.getLeftVariable().getName()).equals(param)) { + if (map.getCondition() != null) { + l = l.replaceAll(param, map.getCondition()); + match = true; + } + } + } + } + if (match) { + nodeSource = nodeSource.replace(line.trim(), "#if " + l); + } + } + } + return nodeSource; + } + + /** + * replaced a variable name in a source code with the given name + * @param nodeSource the source to use + * @param var the variable + * @param newName the new name of the variable + * @return the modified source code + */ + protected String replace(String nodeSource, ShaderNodeVariable var, String newName) { + nodeSource = nodeSource.replaceAll("(?<=\\W)" + var.getName() + "(?=\\W)", newName); + return nodeSource; + } + + /** + * Finds if a variable is a world or a material parameter + * @param var the variable + * @return true if the variable is a Word or material parameter + */ + protected boolean isWorldOrMaterialParam(ShaderNodeVariable var) { + return var.getNameSpace().equals("MatParam") || var.getNameSpace().equals("WorldParam"); + } + + @Override + protected String getLanguageAndVersion(ShaderType type) { + return "GLSL100"; + } + + /** + * appends indentation. + * @param source + */ + protected void appendIndent(StringBuilder source) { + source.append(getIndent(indent)); + } + + /** + * Declares an attribute + * @param source the StringBuilder to use + * @param var the variable to declare as an attribute + */ + protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { + declareVariable(source, var, false, "attribute"); + } + + /** + * Declares a varying + * @param source the StringBuilder to use + * @param var the variable to declare as an varying + * @param input a boolean set to true if the this varying is an input. + * this in not used in this implementation but can be used in overridings + * implementation + */ + protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { + declareVariable(source, var, true, "varying"); + } + + /** + * Decrease indentation with a check so the indent is never negative. + */ + protected void unIndent() { + indent--; + indent = Math.max(0, indent); + } + + /** + * increase indentation with a check so that indentation is never over 10 + */ + protected void indent() { + indent++; + indent = Math.min(10, indent); + } + + /** + * makes sure inPosition attribute is of type vec3 or vec4 + * @param var the inPosition attribute + */ + private void fixInPositionType(ShaderNodeVariable var) { + if(!var.getType().equals("vec3") || !var.getType().equals("vec4")){ + var.setType("vec3"); + } + } + + /** + * declare and assign the global position in the vertex shader. + * @param info the shader generation info + * @param source the shader source being generated + */ + protected void declareGlobalPosition(ShaderGenerationInfo info, StringBuilder source) { + if(inPosTmp.getType().equals(info.getVertexGlobal().getType())){ + declareVariable(source, info.getVertexGlobal(), "inPosition"); + }else{ + declareVariable(source, info.getVertexGlobal(), "vec4(inPosition,1.0)"); + } + } +} diff --git a/src/main/java/com/jme3/shader/Glsl150ShaderGenerator.java b/src/main/java/com/jme3/shader/Glsl150ShaderGenerator.java new file mode 100644 index 00000000..4572387c --- /dev/null +++ b/src/main/java/com/jme3/shader/Glsl150ShaderGenerator.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.shader; + +import com.jme3.asset.AssetManager; +import com.jme3.material.ShaderGenerationInfo; +import com.jme3.shader.Shader.ShaderType; + +/** + * This shader Generator can generate Vertex and Fragment shaders from + * ShaderNodes for GLSL 1.5 + * + * @author Nehon + */ +public class Glsl150ShaderGenerator extends Glsl100ShaderGenerator { + + /** + * Creates a Glsl150ShaderGenerator + * + * @param assetManager the assetmanager + */ + public Glsl150ShaderGenerator(AssetManager assetManager) { + super(assetManager); + } + + @Override + protected String getLanguageAndVersion(ShaderType type) { + return "GLSL150"; + } + + /** + * {@inheritDoc} in glsl 1.5 attributes are prefixed with the "in" keyword + * and not the "attribute" keyword + */ + @Override + protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { + declareVariable(source, var, false, "in"); + } + + /** + * {@inheritDoc} in glsl 1.5 varying are prefixed with the "in" or "out" + * keyword and not the "varying" keyword. + * + * "in" is used for Fragment shader (maybe Geometry shader later) "out" is + * used for Vertex shader (maybe Geometry shader later) + */ + @Override + protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { + declareVariable(source, var, true, input ? "in" : "out"); + } + + @Override + protected void generateUniforms(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + generateCompatibilityDefines(source, type); + super.generateUniforms(source, info, type); + } + + private void generateCompatibilityDefines(StringBuilder source, ShaderType type) { + //Adding compatibility defines, as it's more efficient than replacing the function calls in the source code + if (type == ShaderType.Fragment) { + source.append("\n") + .append("#define texture1D texture\n") + .append("#define texture2D texture\n") + .append("#define texture3D texture\n") + .append("#define textureCube texture\n") + .append("#define texture2DLod textureLod\n") + .append("#define textureCubeLod textureLod\n"); + } + } + + /** + * {@inheritDoc} + * + * Fragment shader outputs are declared before the "void main(){" with the + * "out" keyword. + * + * after the "void main(){", the vertex output are declared and initialized + * and the fragment outputs are declared + */ + @Override + protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + source.append("\n"); + + if (type == ShaderType.Fragment) { + for (ShaderNodeVariable global : info.getFragmentGlobals()) { + declareVariable(source, global, null, true, "out"); + } + } + source.append("\n"); + + appendIndent(source); + source.append("void main() {\n"); + indent(); + + if (type == ShaderType.Vertex) { + declareGlobalPosition(info, source); + } else if (type == ShaderType.Fragment) { + for (ShaderNodeVariable global : info.getFragmentGlobals()) { + initVariable(source, global, "vec4(1.0)"); + } + } + } + + /** + * {@inheritDoc} + * + * only vertex shader output are mapped here, since fragment shader outputs + * must have been mapped in the main section. + */ + @Override + protected void generateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + if (type == ShaderType.Vertex) { + appendOutput(source, "gl_Position", info.getVertexGlobal()); + } + unIndent(); + appendIndent(source); + source.append("}\n"); + } + + /** + * Append a variable initialization to the code + * + * @param source the StringBuilder to use + * @param var the variable to initialize + * @param initValue the init value to assign to the variable + */ + protected void initVariable(StringBuilder source, ShaderNodeVariable var, String initValue) { + appendIndent(source); + source.append(var.getNameSpace()); + source.append("_"); + source.append(var.getName()); + source.append(" = "); + source.append(initValue); + source.append(";\n"); + } +} diff --git a/src/main/java/com/jme3/shader/ShaderGenerator.java b/src/main/java/com/jme3/shader/ShaderGenerator.java new file mode 100644 index 00000000..bfa46aba --- /dev/null +++ b/src/main/java/com/jme3/shader/ShaderGenerator.java @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.shader; + +import com.jme3.asset.AssetKey; +import com.jme3.asset.AssetManager; +import com.jme3.material.ShaderGenerationInfo; +import com.jme3.material.TechniqueDef; +import com.jme3.shader.Shader.ShaderType; + +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * This class is the base for a shader generator using the ShaderNodes system, + * it contains basis mechanism of generation, but no actual generation code. + * This class is abstract, any Shader generator must extend it. + * + * @author Nehon + */ +public abstract class ShaderGenerator { + + protected static final char[] EMPTY_CHARS = new char[0]; + + /** + * Calculate the indent using space characters. + * + * @param level the level. + * @return the result indent. + */ + protected static char[] getIndent(final int level) { + + if (level == 0) { + return EMPTY_CHARS; + } + + final int characters = level * 4; + final char[] result = new char[characters]; + + for (int i = 0; i < result.length; i++) { + result[i] = ' '; + } + + return result; + } + + /** + * the asset manager + */ + protected AssetManager assetManager; + /** + * indentation value for generation + */ + protected int indent; + /** + * the technique def to use for the shader generation + */ + protected TechniqueDef techniqueDef = null; + /** + * Extension pattern + */ + Pattern extensions = Pattern.compile("(#extension.*\\s+)"); + + /** + * Build a shaderGenerator + * + * @param assetManager + */ + protected ShaderGenerator(AssetManager assetManager) { + this.assetManager = assetManager; + } + + public void initialize(TechniqueDef techniqueDef){ + this.techniqueDef = techniqueDef; + } + + /** + * Generate vertex and fragment shaders for the given technique + * + * @return a Shader program + */ + public Shader generateShader(String definesSourceCode) { + if (techniqueDef == null) { + throw new UnsupportedOperationException("The shaderGenerator was not " + + "properly initialized, call " + + "initialize(TechniqueDef) before any generation"); + } + + String techniqueName = techniqueDef.getName(); + ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); + + Shader shader = new Shader(); + for (ShaderType type : ShaderType.values()) { + String extension = type.getExtension(); + String language = getLanguageAndVersion(type); + String shaderSourceCode = buildShader(techniqueDef.getShaderNodes(), info, type); + + if (shaderSourceCode != null) { + String shaderSourceAssetName = techniqueName + "." + extension; + shader.addSource(type, shaderSourceAssetName, shaderSourceCode, definesSourceCode, language); + } + } + + techniqueDef = null; + return shader; + } + + /** + * This method is responsible for the shader generation. + * + * @param shaderNodes the list of shader nodes + * @param info the ShaderGenerationInfo filled during the Technique loading + * @param type the type of shader to generate + * @return the code of the generated vertex shader + */ + protected String buildShader(List shaderNodes, ShaderGenerationInfo info, ShaderType type) { + if (type == ShaderType.TessellationControl || + type == ShaderType.TessellationEvaluation || + type == ShaderType.Geometry) { + // TODO: Those are not supported. + // Too much code assumes that type is either Vertex or Fragment + return null; + } + + indent = 0; + + StringBuilder sourceDeclaration = new StringBuilder(); + StringBuilder source = new StringBuilder(); + + generateUniforms(sourceDeclaration, info, type); + + if (type == ShaderType.Vertex) { + generateAttributes(sourceDeclaration, info); + } + generateVaryings(sourceDeclaration, info, type); + + generateStartOfMainSection(source, info, type); + + generateDeclarationAndMainBody(shaderNodes, sourceDeclaration, source, info, type); + + generateEndOfMainSection(source, info, type); + + sourceDeclaration.append(source); + + return moveExtensionsUp(sourceDeclaration); + } + + /** + * parses the source and moves all the extensions at the top of the shader source as having extension declarations + * in the middle of a shader is against the specs and not supported by all drivers. + * @param sourceDeclaration + * @return + */ + private String moveExtensionsUp(StringBuilder sourceDeclaration) { + Matcher m = extensions.matcher( sourceDeclaration.toString()); + StringBuilder finalSource = new StringBuilder(); + while(m.find()){ + finalSource.append(m.group()); + } + finalSource.append(m.replaceAll("")); + return finalSource.toString(); + } + + /** + * iterates through shader nodes to load them and generate the shader + * declaration part and main body extracted from the shader nodes, for the + * given shader type + * + * @param shaderNodes the list of shader nodes + * @param sourceDeclaration the declaration part StringBuilder of the shader + * to generate + * @param source the main part StringBuilder of the shader to generate + * @param info the ShaderGenerationInfo + * @param type the Shader type + */ + protected void generateDeclarationAndMainBody(List shaderNodes, StringBuilder sourceDeclaration, StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + for (ShaderNode shaderNode : shaderNodes) { + if (info.getUnusedNodes().contains(shaderNode.getName())) { + continue; + } + if (shaderNode.getDefinition().getType() == type) { + int index = findShaderIndexFromVersion(shaderNode, type); + String shaderPath = shaderNode.getDefinition().getShadersPath().get(index); + String loadedSource = (String) assetManager.loadAsset(new AssetKey(shaderPath)); + appendNodeDeclarationAndMain(loadedSource, sourceDeclaration, source, shaderNode, info, shaderPath); + } + } + } + + /** + * Appends declaration and main part of a node to the shader declaration and + * main part. the loadedSource is split by "void main(){" to split + * declaration from main part of the node source code.The trailing "}" is + * removed from the main part. Each part is then respectively passed to + * generateDeclarativeSection and generateNodeMainSection. + * + * @see ShaderGenerator#generateDeclarativeSection + * @see ShaderGenerator#generateNodeMainSection + * + * @param loadedSource the actual source code loaded for this node. + * @param shaderPath path the the shader file + * @param sourceDeclaration the Shader declaration part string builder. + * @param source the Shader main part StringBuilder. + * @param shaderNode the shader node. + * @param info the ShaderGenerationInfo. + */ + protected void appendNodeDeclarationAndMain(String loadedSource, StringBuilder sourceDeclaration, StringBuilder source, ShaderNode shaderNode, ShaderGenerationInfo info, String shaderPath) { + if (loadedSource.length() > 1) { + loadedSource = loadedSource.substring(0, loadedSource.lastIndexOf("}")); + String[] sourceParts = loadedSource.split("\\s*void\\s*main\\s*\\(\\s*\\)\\s*\\{"); + if(sourceParts.length<2){ + throw new IllegalArgumentException("Syntax error in "+ shaderPath +". Cannot find 'void main(){' in \n"+ loadedSource); + } + generateDeclarativeSection(sourceDeclaration, shaderNode, sourceParts[0], info); + generateNodeMainSection(source, shaderNode, sourceParts[1], info); + } else { + //if source is empty, we still call generateNodeMainSection so that mappings can be done. + generateNodeMainSection(source, shaderNode, loadedSource, info); + } + + } + + /** + * returns the language + version of the shader should be something like + * "GLSL100" for glsl 1.0 "GLSL150" for glsl 1.5. + * + * @param type the shader type for which the version should be returned. + * + * @return the shaderLanguage and version. + */ + protected abstract String getLanguageAndVersion(ShaderType type); + + /** + * generates the uniforms declaration for a shader of the given type. + * + * @param source the source StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the uniforms have to be generated for. + */ + protected abstract void generateUniforms(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * generates the attributes declaration for the vertex shader. There is no + * Shader type passed here as attributes are only used in vertex shaders + * + * @param source the source StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + */ + protected abstract void generateAttributes(StringBuilder source, ShaderGenerationInfo info); + + /** + * generates the varyings for the given shader type shader. Note that + * varyings are deprecated in glsl 1.3, but this method will still be called + * to generate all non global inputs and output of the shaders. + * + * @param source the source StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the varyings have to be generated for. + */ + protected abstract void generateVaryings(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * Appends the given shaderNode declarative part to the shader declarative + * part. If needed the sahder type can be determined by fetching the + * shaderNode's definition type. + * + * @see ShaderNode#getDefinition() + * @see ShaderNodeDefinition#getType() + * + * @param nodeDecalarationSource the declaration part of the node + * @param source the StringBuilder to append generated code. + * @param shaderNode the shaderNode. + * @param info the ShaderGenerationInfo. + */ + protected abstract void generateDeclarativeSection(StringBuilder source, ShaderNode shaderNode, String nodeDecalarationSource, ShaderGenerationInfo info); + + /** + * generates the start of the shader main section. this method is + * responsible of appending the "void main(){" in the shader and declaring + * all global outputs of the shader + * + * @param source the StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the section has to be generated for. + */ + protected abstract void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * generates the end of the shader main section. this method is responsible + * of appending the last "}" in the shader and mapping all global outputs of + * the shader + * + * @param source the StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the section has to be generated for. + */ + protected abstract void generateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * Appends the given shaderNode main part to the shader declarative part. If + * needed the shader type can be determined by fetching the shaderNode's + * definition type. + * + * @see ShaderNode#getDefinition() + * @see ShaderNodeDefinition#getType() + * + * @param source the StringBuilder to append generated code. + * @param shaderNode the shaderNode. + * @param nodeSource the declaration part of the loaded shaderNode source. + * @param info the ShaderGenerationInfo. + */ + protected abstract void generateNodeMainSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info); + + /** + * returns the shaderpath index according to the version of the generator. + * This allow to select the higher version of the shader that the generator + * can handle + * + * @param shaderNode the shaderNode being processed + * @param type the shaderType + * @return the index of the shader path in ShaderNodeDefinition shadersPath + * list + * @throws NumberFormatException + */ + protected int findShaderIndexFromVersion(ShaderNode shaderNode, ShaderType type) throws NumberFormatException { + int index = 0; + List lang = shaderNode.getDefinition().getShadersLanguage(); + int genVersion = Integer.parseInt(getLanguageAndVersion(type).substring(4)); + int curVersion = 0; + for (int i = 0; i < lang.size(); i++) { + int version = Integer.parseInt(lang.get(i).substring(4)); + if (version > curVersion && version <= genVersion) { + curVersion = version; + index = i; + } + } + return index; + } +} diff --git a/src/main/java/com/jme3/shader/plugins/GLSLLoader.java b/src/main/java/com/jme3/shader/plugins/GLSLLoader.java new file mode 100644 index 00000000..184dcffd --- /dev/null +++ b/src/main/java/com/jme3/shader/plugins/GLSLLoader.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.shader.plugins; + +import com.jme3.asset.*; +import com.jme3.asset.cache.AssetCache; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.*; + +/** + * GLSL File parser that supports #import pre-processor statement + */ +public class GLSLLoader implements AssetLoader { + + private AssetManager assetManager; + private Map dependCache = new HashMap<>(); + + /** + * Used to load {@link ShaderDependencyNode}s. + * Asset caching is disabled. + */ + private class ShaderDependencyKey extends AssetKey { + + public ShaderDependencyKey(String name) { + super(name); + } + + @Override + public Class getCacheType() { + // Disallow caching here + return null; + } + } + + /** + * Creates a {@link ShaderDependencyNode} from a stream representing shader code. + * + * @param reader the reader with shader code + * @param nodeName the node name. + * @return the shader dependency node + * @throws AssetLoadException if we failed to load the shader code. + */ + private ShaderDependencyNode loadNode(Reader reader, String nodeName) { + + ShaderDependencyNode node = new ShaderDependencyNode(nodeName); + StringBuilder sb = new StringBuilder(); + StringBuilder sbExt = new StringBuilder(); + + try (final BufferedReader bufferedReader = new BufferedReader(reader)) { + + String ln; + + if (!nodeName.equals("[main]")) { + sb.append("// -- begin import ").append(nodeName).append(" --\n"); + } + + while ((ln = bufferedReader.readLine()) != null) { + if (ln.trim().startsWith("#import ")) { + ln = ln.trim().substring(8).trim(); + if (ln.startsWith("\"") && ln.endsWith("\"") && ln.length() > 3) { + // import user code + // remove quotes to get filename + ln = ln.substring(1, ln.length() - 1); + if (ln.equals(nodeName)) { + throw new IOException("Node depends on itself."); + } + + // check cache first + ShaderDependencyNode dependNode = dependCache.get(ln); + + if (dependNode == null) { + Reader dependNodeReader = assetManager.loadAsset(new ShaderDependencyKey(ln)); + dependNode = loadNode(dependNodeReader, ln); + } + + node.addDependency(sb.length(), dependNode); + } + } else if (ln.trim().startsWith("#extension ")) { + sbExt.append(ln).append('\n'); + } else { + sb.append(ln).append('\n'); + } + } + if (!nodeName.equals("[main]")) { + sb.append("// -- end import ").append(nodeName).append(" --\n"); + } + } catch (final IOException ex) { + throw new AssetLoadException("Failed to load shader node: " + nodeName, ex); + } + + node.setSource(sb.toString()); + node.setExtensions(sbExt.toString()); + dependCache.put(nodeName, node); + return node; + } + + private ShaderDependencyNode nextIndependentNode() throws IOException { + Collection allNodes = dependCache.values(); + + if (allNodes == null || allNodes.isEmpty()) { + return null; + } + + for (ShaderDependencyNode node : allNodes) { + if (node.getDependOnMe().isEmpty()) { + return node; + } + } + + // Circular dependency found.. + for (ShaderDependencyNode node : allNodes){ + System.out.println(node.getName()); + } + + throw new IOException("Circular dependency."); + } + + private String resolveDependencies(ShaderDependencyNode node, Set alreadyInjectedSet, StringBuilder extensions) { + if (alreadyInjectedSet.contains(node)) { + return "// " + node.getName() + " was already injected at the top.\n"; + } else { + alreadyInjectedSet.add(node); + } + if (!node.getExtensions().isEmpty()) { + extensions.append(node.getExtensions()); + } + if (node.getDependencies().isEmpty()) { + return node.getSource(); + } else { + StringBuilder sb = new StringBuilder(node.getSource()); + List resolvedShaderNodes = new ArrayList(); + + for (ShaderDependencyNode dependencyNode : node.getDependencies()) { + resolvedShaderNodes.add(resolveDependencies(dependencyNode, alreadyInjectedSet, extensions)); + } + List injectIndices = node.getDependencyInjectIndices(); + for (int i = resolvedShaderNodes.size() - 1; i >= 0; i--) { + // Must insert them backwards .. + sb.insert(injectIndices.get(i), resolvedShaderNodes.get(i)); + } + return sb.toString(); + } + } + + @Override + public Object load(AssetInfo info) throws IOException { + // The input stream provided is for the vertex shader, + // to retrieve the fragment shader, use the content manager + this.assetManager = info.getManager(); + Reader reader = new InputStreamReader(info.openStream()); + if (info.getKey().getExtension().equals("glsllib")) { + // NOTE: Loopback, GLSLLIB is loaded by this loader + // and needs data as InputStream + return reader; + } else { + ShaderDependencyNode rootNode = loadNode(reader, "[main]"); + StringBuilder extensions = new StringBuilder(); + String code = resolveDependencies(rootNode, new HashSet<>(), extensions); + extensions.append(code); + dependCache.clear(); + return extensions.toString(); + } + } +} diff --git a/src/main/java/com/jme3/util/SafeArrayList.java b/src/main/java/com/jme3/util/SafeArrayList.java index 6bee76e7..0085b20d 100644 --- a/src/main/java/com/jme3/util/SafeArrayList.java +++ b/src/main/java/com/jme3/util/SafeArrayList.java @@ -99,13 +99,7 @@ public SafeArrayList(final Class elementType, final int capacity) { public SafeArrayList(final Class elementType, final Collection collection) { this.elementType = elementType; - - if (collection instanceof SafeArrayList) { - this.buffer = Arrays.asList(((SafeArrayList) collection).getArray()); - } else { - this.buffer = new ArrayList<>(collection); - } - + this.buffer = new ArrayList<>(collection); this.size = buffer.size(); } diff --git a/src/main/java/com/ss/editor/Editor.java b/src/main/java/com/ss/editor/Editor.java index 90429654..e4ba6693 100644 --- a/src/main/java/com/ss/editor/Editor.java +++ b/src/main/java/com/ss/editor/Editor.java @@ -30,6 +30,8 @@ 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; import com.ss.editor.config.Config; import com.ss.editor.config.EditorConfig; import com.ss.editor.executor.impl.JMEThreadExecutor; @@ -77,12 +79,12 @@ public void done(final LightProbe result) { private static final Editor EDITOR = new Editor(); /** - * Gets instance. + * Gets the jME part of this editor. * - * @return the instance + * @return the jME part. */ - @NotNull - public static Editor getInstance() { + @FromAnyThread + public static @NotNull Editor getInstance() { return EDITOR; } @@ -91,8 +93,8 @@ public static Editor getInstance() { * * @return the editor */ - @NotNull - static Editor prepareToStart() { + @JMEThread + static @NotNull Editor prepareToStart() { if (Config.DEV_DEBUG) { System.err.println("config is loaded."); @@ -117,6 +119,7 @@ static Editor prepareToStart() { return EDITOR; } + @JMEThread private static void configureLogger() { // disable the standard logger @@ -223,6 +226,7 @@ private Editor() { * * @return the long */ + @FromAnyThread public final long asyncLock() { return lock.readLock(); } @@ -232,11 +236,13 @@ public final long asyncLock() { * * @param stamp the stamp */ + @FromAnyThread public final void asyncUnlock(final long stamp) { lock.unlockRead(stamp); } @Override + @JMEThread public void destroy() { super.destroy(); @@ -247,12 +253,13 @@ public void destroy() { } @Override - @NotNull - public Camera getCamera() { + @FromAnyThread + public @NotNull Camera getCamera() { return super.getCamera(); } @Override + @JMEThread public void simpleInitApp() { super.simpleInitApp(); @@ -274,7 +281,7 @@ public void simpleInitApp() { audioRenderer.setEnvironment(new Environment(Environment.Garage)); viewPort.setBackgroundColor(new ColorRGBA(50 / 255F, 50 / 255F, 50 / 255F, 1F)); - cam.setFrustumPerspective(55, (float) cam.getWidth() / cam.getHeight(), 1f, 10000); + cam.setFrustumPerspective(55, (float) cam.getWidth() / cam.getHeight(), 1f, Integer.MAX_VALUE); defaultMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); @@ -333,14 +340,20 @@ public void simpleInitApp() { /** * Lock the render thread for doing actions with game scene. + * + * @return the lock stamp. */ + @FromAnyThread public long syncLock() { return lock.writeLock(); } /** * Unlock the render thread. + * + * @param stamp the stamp of the lock. */ + @FromAnyThread public void syncUnlock(final long stamp) { lock.unlockWrite(stamp); } @@ -350,11 +363,13 @@ public void syncUnlock(final long stamp) { * * @return the long */ + @FromAnyThread public long trySyncLock() { return lock.tryWriteLock(); } @Override + @JMEThread public void loseFocus() { super.loseFocus(); @@ -366,6 +381,7 @@ public void loseFocus() { } @Override + @JMEThread public void gainFocus() { super.gainFocus(); @@ -377,6 +393,7 @@ public void gainFocus() { } @Override + @JMEThread public void simpleUpdate(final float tpf) { super.simpleUpdate(tpf); @@ -385,6 +402,7 @@ public void simpleUpdate(final float tpf) { } @Override + @JMEThread public void update() { final long stamp = syncLock(); try { @@ -409,6 +427,7 @@ public void update() { listener.setRotation(cam.getRotation()); } + @JMEThread private void finishWorkOnError(@NotNull final Throwable e) { GAnalytics.sendException(e, true); @@ -425,14 +444,15 @@ private void finishWorkOnError(@NotNull final Throwable e) { * * @return the processor of post effects. */ - @NotNull - public FilterPostProcessor getPostProcessor() { + @JMEThread + public @NotNull FilterPostProcessor getPostProcessor() { return notNull(postProcessor); } /** * Create the light probes for the PBR render. */ + @JMEThread private void createLightProbes() { final EnvironmentCamera environmentCamera = getEnvironmentCamera(); @@ -466,6 +486,7 @@ private void createLightProbes() { * * @param progressAdapter the progress adapter */ + @JMEThread public void updateLightProbe(@NotNull final JobProgressAdapter progressAdapter) { final LightProbe lightProbe = getLightProbe(); @@ -482,6 +503,7 @@ public void updateLightProbe(@NotNull final JobProgressAdapter progr /** * Disable PBR Light probe. */ + @JMEThread public void disableLightProbe() { final LightProbe lightProbe = getLightProbe(); @@ -494,6 +516,7 @@ public void disableLightProbe() { /** * Enable PBR Light probe. */ + @JMEThread public void enableLightProbe() { final LightProbe lightProbe = getLightProbe(); @@ -518,6 +541,7 @@ public void enableLightProbe() { * * @param progressAdapter the progress adapter */ + @JMEThread public void updatePreviewLightProbe(@NotNull final JobProgressAdapter progressAdapter) { final LightProbe lightProbe = getPreviewLightProbe(); @@ -532,83 +556,101 @@ public void updatePreviewLightProbe(@NotNull final JobProgressAdapter IMAGE_EXTENSIONS = ArrayFactory.asArray( + @NotNull String MODEL_BLENDER = "blend"; + @NotNull String MODEL_FBX = "fbx"; + @NotNull String MODEL_GLTF = "gltf"; + @NotNull String MODEL_OBJ = "obj"; + @NotNull String MODEL_SCENE = "scene"; + @NotNull String MODEL_MESH_XML = "mesh.xml"; + @NotNull String MODEL_XBUF = "xbuf"; + + @NotNull Array IMAGE_EXTENSIONS = ArrayFactory.asArray( IMAGE_PNG, IMAGE_JPG, IMAGE_JPEG, @@ -154,8 +60,7 @@ public interface FileExtensions { IMAGE_GIF, IMAGE_TIFF); - @NotNull - Array TEXTURE_EXTENSIONS = ArrayFactory.asArray( + @NotNull Array TEXTURE_EXTENSIONS = ArrayFactory.asArray( IMAGE_PNG, IMAGE_JPG, IMAGE_JPEG, @@ -170,9 +75,7 @@ public interface FileExtensions { GLSL_GEOM, GLSL_LIB); - @NotNull - Array AUDIO_EXTENSIONS = ArrayFactory.asArray( - AUDIO_MP3, + @NotNull Array AUDIO_EXTENSIONS = ArrayFactory.asArray(AUDIO_MP3, AUDIO_WAV, AUDIO_OGG); } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/FolderAssetLocator.java b/src/main/java/com/ss/editor/FolderAssetLocator.java index 0cc888b5..12836813 100644 --- a/src/main/java/com/ss/editor/FolderAssetLocator.java +++ b/src/main/java/com/ss/editor/FolderAssetLocator.java @@ -4,6 +4,7 @@ import com.jme3.asset.AssetKey; import com.jme3.asset.AssetLocator; import com.jme3.asset.AssetManager; +import com.ss.editor.annotation.JMEThread; import com.ss.editor.config.EditorConfig; import org.jetbrains.annotations.NotNull; @@ -21,11 +22,12 @@ public class FolderAssetLocator implements AssetLocator { @Override + @JMEThread public void setRootPath(@NotNull final String rootPath) { - System.out.println(rootPath); } @Override + @JMEThread public AssetInfo locate(final AssetManager manager, final AssetKey key) { final EditorConfig editorConfig = EditorConfig.getInstance(); @@ -51,6 +53,7 @@ private PathAssetInfo(@NotNull final AssetManager manager, @NotNull final AssetK } @Override + @JMEThread public @NotNull InputStream openStream() { try { return Files.newInputStream(path, StandardOpenOption.READ); diff --git a/src/main/java/com/ss/editor/JFXApplication.java b/src/main/java/com/ss/editor/JFXApplication.java index f9f76aa6..993090e6 100644 --- a/src/main/java/com/ss/editor/JFXApplication.java +++ b/src/main/java/com/ss/editor/JFXApplication.java @@ -13,6 +13,7 @@ import com.ss.editor.analytics.google.GAnalytics; import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.JMEThread; import com.ss.editor.config.CommandLineConfig; import com.ss.editor.config.Config; import com.ss.editor.config.EditorConfig; @@ -69,13 +70,12 @@ public class JFXApplication extends Application { private static JFXApplication instance; /** - * Gets instance. + * Get the JavaFX part of this editor. * - * @return the instance + * @return the JavaFX part of this editor. */ - @NotNull @FromAnyThread - public static JFXApplication getInstance() { + public static @NotNull JFXApplication getInstance() { return notNull(instance); } @@ -84,9 +84,8 @@ public static JFXApplication getInstance() { * * @return the current stage. */ - @Nullable @FromAnyThread - private static Stage getStage() { + private static @Nullable Stage getStage() { final JFXApplication instance = JFXApplication.instance; return instance == null ? null : instance.stage; } @@ -156,6 +155,12 @@ public static void main(final String[] args) throws IOException { () -> startJMEApplication(application), "LWJGL Render").start(); } + /** + * Start the new jME application. + * + * @param application the new jME application. + */ + @JMEThread private static void startJMEApplication(@NotNull final JmeToJFXApplication application) { final PluginManager pluginManager = PluginManager.getInstance(); @@ -181,7 +186,8 @@ public static void start() { launch(); } - private static void printError(final Throwable throwable) { + @FromAnyThread + private static void printError(@NotNull final Throwable throwable) { throwable.printStackTrace(); final String userHome = System.getProperty("user.home"); @@ -227,6 +233,7 @@ public JFXApplication() { * * @param window the new opened window. */ + @FXThread public void addWindow(@NotNull final Window window) { ArrayUtils.runInWriteLock(openedWindows, window, Array::add); } @@ -236,6 +243,7 @@ public void addWindow(@NotNull final Window window) { * * @param window the opened window. */ + @FXThread public void removeWindow(@NotNull final Window window) { ArrayUtils.runInWriteLock(openedWindows, window, Array::slowRemove); } @@ -245,12 +253,13 @@ public void removeWindow(@NotNull final Window window) { * * @return the last opened window. */ - @NotNull - public Window getLastWindow() { + @FXThread + public @NotNull Window getLastWindow() { return notNull(ArrayUtils.getInReadLock(openedWindows, Array::last)); } @Override + @FXThread public void start(final Stage stage) throws Exception { JFXApplication.instance = this; this.stage = stage; @@ -310,6 +319,7 @@ public void start(final Stage stage) throws Exception { } @Override + @FXThread public void stop() throws Exception { super.stop(); onExit(); @@ -390,6 +400,7 @@ private void buildScene() { }); } + @FXThread private void createSceneProcessor(@NotNull final EditorFXScene scene, @NotNull final Editor editor) { final FrameTransferSceneProcessor sceneProcessor = bind(editor, scene.getCanvas(), editor.getViewPort()); @@ -412,9 +423,8 @@ private void createSceneProcessor(@NotNull final EditorFXScene scene, @NotNull f * * @return the JavaFX scene. */ - @NotNull @FromAnyThread - public EditorFXScene getScene() { + public @NotNull EditorFXScene getScene() { return notNull(scene, "Scene can't be null."); } @@ -423,9 +433,8 @@ public EditorFXScene getScene() { * * @return the scene processor. */ - @NotNull @FromAnyThread - public FrameTransferSceneProcessor getSceneProcessor() { + public @NotNull FrameTransferSceneProcessor getSceneProcessor() { return notNull(sceneProcessor, "Scene processor can't be null."); } } diff --git a/src/main/java/com/ss/editor/Messages.java b/src/main/java/com/ss/editor/Messages.java index c15c5fb5..08dd2d7a 100644 --- a/src/main/java/com/ss/editor/Messages.java +++ b/src/main/java/com/ss/editor/Messages.java @@ -9,2399 +9,659 @@ import java.util.Map; import java.util.ResourceBundle; +/** + * The localized messages. + * + * @author JavaSaBr + */ public class Messages { - /** - * The constant BUNDLE_NAME. - */ public static final String BUNDLE_NAME = "messages/messages"; - /** - * The constant EDITOR_MENU_FILE. - */ public static final String EDITOR_MENU_FILE; - /** - * The constant EDITOR_MENU_FILE_EXIT. - */ public static final String EDITOR_MENU_FILE_EXIT; - /** - * The constant EDITOR_MENU_FILE_OPEN_ASSET. - */ public static final String EDITOR_MENU_FILE_OPEN_ASSET; - /** - * The constant EDITOR_MENU_FILE_OPEN_ASSET_DIRECTORY_CHOOSER. - */ public static final String EDITOR_MENU_FILE_OPEN_ASSET_DIRECTORY_CHOOSER; - /** - * The constant EDITOR_MENU_FILE_REOPEN_ASSET_FOLDER. - */ public static final String EDITOR_MENU_FILE_REOPEN_ASSET_FOLDER; - /** - * The constant EDITOR_MENU_OTHER. - */ public static final String EDITOR_MENU_OTHER; - /** - * The constant EDITOR_MENU_OTHER_CLEAR_ASSET_CACHE. - */ public static final String EDITOR_MENU_OTHER_CLEAR_ASSET_CACHE; - /** - * The constant EDITOR_MENU_OTHER_UPDATE_CLASSPATH_AND_ASSET_CACHE. - */ public static final String EDITOR_MENU_OTHER_UPDATE_CLASSPATH_AND_ASSET_CACHE; - /** - * The constant EDITOR_MENU_OTHER_SETTINGS. - */ public static final String EDITOR_MENU_OTHER_SETTINGS; - /** - * The constant EDITOR_MENU_OTHER_PLUGINS. - */ public static final String EDITOR_MENU_OTHER_PLUGINS; - /** - * The constant EDITOR_MENU_HELP. - */ public static final String EDITOR_MENU_HELP; - /** - * The constant EDITOR_MENU_HELP_ABOUT. - */ public static final String EDITOR_MENU_HELP_ABOUT; - /** - * The constant EDITOR_TOOL_ASSET. - */ public static final String EDITOR_TOOL_ASSET; - /** - * The constant EDITOR_AREA_SAVE_FILE_QUESTION. - */ public static final String EDITOR_AREA_SAVE_FILE_QUESTION; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_NEW_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_NEW_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_WITH_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_WITH_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_COPY_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_COPY_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_CUT_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_CUT_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_PASTE_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_PASTE_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE_QUESTION. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE_QUESTION; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILES_QUESTION. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILES_QUESTION; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_CONVERT_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_CONVERT_FILE; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_EXTERNAL_EDITOR. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_EXTERNAL_EDITOR; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_SYSTEM_EXPLORER. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_SYSTEM_EXPLORER; - /** - * The constant ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_RENAME_FILE. - */ public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_RENAME_FILE; - /** - * The constant FILE_EDITOR_ACTION_SAVE. - */ public static final String FILE_EDITOR_ACTION_SAVE; - /** - * The constant SCENE_FILE_EDITOR_ACTION_SELECTION. - */ public static final String SCENE_FILE_EDITOR_ACTION_SELECTION; - /** - * The constant SCENE_FILE_EDITOR_ACTION_GRID. - */ public static final String SCENE_FILE_EDITOR_ACTION_GRID; - /** - * The constant SCENE_FILE_EDITOR_ACTION_STATISTICS. - */ public static final String SCENE_FILE_EDITOR_ACTION_STATISTICS; - /** - * The constant SCENE_FILE_EDITOR_ACTION_MOVE_TOOL. - */ public static final String SCENE_FILE_EDITOR_ACTION_MOVE_TOOL; - /** - * The constant SCENE_FILE_EDITOR_ACTION_SCALE_TOOL. - */ public static final String SCENE_FILE_EDITOR_ACTION_SCALE_TOOL; - /** - * The constant SCENE_FILE_EDITOR_ACTION_ROTATION_TOOL. - */ public static final String SCENE_FILE_EDITOR_ACTION_ROTATION_TOOL; - /** - * The constant SCENE_FILE_EDITOR_ACTION_CAMERA_LIGHT. - */ public static final String SCENE_FILE_EDITOR_ACTION_CAMERA_LIGHT; - /** - * The constant SCENE_FILE_EDITOR_ACTION_PHYSICS. - */ public static final String SCENE_FILE_EDITOR_ACTION_PHYSICS; - /** - * The constant SCENE_FILE_EDITOR_ACTION_DEBUG_PHYSICS. - */ public static final String SCENE_FILE_EDITOR_ACTION_DEBUG_PHYSICS; - /** - * The constant SCENE_FILE_EDITOR_ACTION_SHOW_LIGHTS. - */ public static final String SCENE_FILE_EDITOR_ACTION_SHOW_LIGHTS; - /** - * The constant SCENE_FILE_EDITOR_ACTION_SHOW_AUDIO. - */ public static final String SCENE_FILE_EDITOR_ACTION_SHOW_AUDIO; - /** - * The constant MATERIAL_FILE_EDITOR_ACTION_CUBE. - */ public static final String MATERIAL_FILE_EDITOR_ACTION_CUBE; - /** - * The constant MATERIAL_FILE_EDITOR_ACTION_SPHERE. - */ public static final String MATERIAL_FILE_EDITOR_ACTION_SPHERE; - /** - * The constant MATERIAL_FILE_EDITOR_ACTION_PLANE. - */ public static final String MATERIAL_FILE_EDITOR_ACTION_PLANE; - /** - * The constant MATERIAL_FILE_EDITOR_ACTION_LIGHT. - */ public static final String MATERIAL_FILE_EDITOR_ACTION_LIGHT; - /** - * The constant ASSET_EDITOR_DIALOG_TITLE. - */ public static final String ASSET_EDITOR_DIALOG_TITLE; - /** - * The constant ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE. - */ public static final String ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE; - /** - * The constant SAVE_AS_EDITOR_DIALOG_TITLE. - */ public static final String SAVE_AS_EDITOR_DIALOG_TITLE; - /** - * The constant SAVE_AS_EDITOR_DIALOG_FIELD_FILENAME. - */ public static final String SAVE_AS_EDITOR_DIALOG_FIELD_FILENAME; - /** - * The constant PARTICLE_ASSET_EDITOR_DIALOG_TEXTURE_PARAM_LABEL. - */ public static final String PARTICLE_ASSET_EDITOR_DIALOG_TEXTURE_PARAM_LABEL; - /** - * The constant PARTICLE_ASSET_EDITOR_DIALOG_LIGHTING_TRANSFORM_LABEL. - */ public static final String PARTICLE_ASSET_EDITOR_DIALOG_LIGHTING_TRANSFORM_LABEL; - /** - * The constant MATERIAL_EDITOR_MATERIAL_TYPE_LABEL. - */ public static final String MATERIAL_EDITOR_MATERIAL_TYPE_LABEL; - /** - * The constant MATERIAL_FILE_EDITOR_BUCKET_TYPE_LABEL. - */ public static final String MATERIAL_FILE_EDITOR_BUCKET_TYPE_LABEL; - /** - * The constant TEXTURE_2D_MATERIAL_PARAM_CONTROL_REPEAT. - */ public static final String TEXTURE_2D_MATERIAL_PARAM_CONTROL_REPEAT; - /** - * The constant TEXTURE_2D_MATERIAL_PARAM_CONTROL_FLIP. - */ public static final String TEXTURE_2D_MATERIAL_PARAM_CONTROL_FLIP; - /** - * The constant TEXTURE_2D_MATERIAL_PARAM_CONTROL_ADD. - */ public static final String TEXTURE_2D_MATERIAL_PARAM_CONTROL_ADD; - /** - * The constant TEXTURE_2D_MATERIAL_PARAM_CONTROL_REMOVE. - */ public static final String TEXTURE_2D_MATERIAL_PARAM_CONTROL_REMOVE; - /** - * The constant COLOR_MATERIAL_PARAM_CONTROL_REMOVE. - */ public static final String COLOR_MATERIAL_PARAM_CONTROL_REMOVE; - /** - * The constant MATERIAL_SETTINGS_MAIN. - */ public static final String MATERIAL_SETTINGS_MAIN; - /** - * The constant MATERIAL_SETTINGS_TEXTURES. - */ public static final String MATERIAL_SETTINGS_TEXTURES; - /** - * The constant MATERIAL_SETTINGS_COLORS. - */ public static final String MATERIAL_SETTINGS_COLORS; - /** - * The constant MATERIAL_SETTINGS_RENDER. - */ public static final String MATERIAL_SETTINGS_RENDER; - /** - * The constant MATERIAL_SETTINGS_OTHER. - */ public static final String MATERIAL_SETTINGS_OTHER; - /** - * The constant MATERIAL_RENDER_STATE_FACE_CULL_MODE. - */ public static final String MATERIAL_RENDER_STATE_FACE_CULL_MODE; - /** - * The constant MATERIAL_RENDER_STATE_BLEND_MODE. - */ public static final String MATERIAL_RENDER_STATE_BLEND_MODE; - /** - * The constant MATERIAL_RENDER_STATE_BLEND_EQUATION. - */ public static final String MATERIAL_RENDER_STATE_BLEND_EQUATION; - /** - * The constant MATERIAL_RENDER_STATE_BLEND_EQUATION_ALPHA. - */ public static final String MATERIAL_RENDER_STATE_BLEND_EQUATION_ALPHA; - /** - * The constant MATERIAL_RENDER_STATE_POLY_OFFSET_FACTOR. - */ public static final String MATERIAL_RENDER_STATE_POLY_OFFSET_FACTOR; - /** - * The constant MATERIAL_RENDER_STATE_POLY_OFFSET_UNITS. - */ public static final String MATERIAL_RENDER_STATE_POLY_OFFSET_UNITS; - /** - * The constant MATERIAL_RENDER_STATE_DEPTH_WRITE. - */ public static final String MATERIAL_RENDER_STATE_DEPTH_WRITE; - /** - * The constant MATERIAL_RENDER_STATE_COLOR_WRITE. - */ public static final String MATERIAL_RENDER_STATE_COLOR_WRITE; - /** - * The constant MATERIAL_RENDER_STATE_DEPTH_TEST. - */ public static final String MATERIAL_RENDER_STATE_DEPTH_TEST; - /** - * The constant MATERIAL_RENDER_STATE_WIREFRAME. - */ public static final String MATERIAL_RENDER_STATE_WIREFRAME; - /** - * The constant TEXT_FILE_EDITOR_NAME. - */ public static final String TEXT_FILE_EDITOR_NAME; - /** - * The constant MATERIAL_EDITOR_NAME. - */ public static final String MATERIAL_EDITOR_NAME; - /** - * The constant FILE_CREATOR_FILE_NAME_LABEL. - */ public static final String FILE_CREATOR_FILE_NAME_LABEL; - /** - * The constant MATERIAL_FILE_CREATOR_TITLE. - */ public static final String MATERIAL_FILE_CREATOR_TITLE; - /** - * The constant MATERIAL_FILE_CREATOR_MATERIAL_TYPE_LABEL. - */ public static final String MATERIAL_FILE_CREATOR_MATERIAL_TYPE_LABEL; - /** - * The constant MATERIAL_FILE_CREATOR_FILE_DESCRIPTION. - */ public static final String MATERIAL_FILE_CREATOR_FILE_DESCRIPTION; - /** - * The constant MATERIAL_DEFINITION_FILE_CREATOR_FILE_DESCRIPTION. - */ public static final String MATERIAL_DEFINITION_FILE_CREATOR_FILE_DESCRIPTION; - /** - * The constant MATERIAL_DEFINITION_FILE_CREATOR_TITLE. - */ public static final String MATERIAL_DEFINITION_FILE_CREATOR_TITLE; - /** - * The constant MATERIAL_DEFINITION_FILE_CREATOR_GLSL_LABEL. - */ public static final String MATERIAL_DEFINITION_FILE_CREATOR_GLSL_LABEL; - /** - * The constant SINGLE_COLOR_TEXTURE_FILE_CREATOR_TITLE. - */ public static final String SINGLE_COLOR_TEXTURE_FILE_CREATOR_TITLE; - /** - * The constant SINGLE_COLOR_TEXTURE_FILE_CREATOR_WIDTH. - */ public static final String SINGLE_COLOR_TEXTURE_FILE_CREATOR_WIDTH; - /** - * The constant SINGLE_COLOR_TEXTURE_FILE_CREATOR_HEIGHT. - */ public static final String SINGLE_COLOR_TEXTURE_FILE_CREATOR_HEIGHT; - /** - * The constant SINGLE_COLOR_TEXTURE_FILE_CREATOR_COLOR. - */ public static final String SINGLE_COLOR_TEXTURE_FILE_CREATOR_COLOR; - /** - * The constant SINGLE_COLOR_TEXTURE_FILE_CREATOR_DESCRIPTION. - */ public static final String SINGLE_COLOR_TEXTURE_FILE_CREATOR_DESCRIPTION; - /** - * The constant SETTINGS_DIALOG_TITLE. - */ public static final String SETTINGS_DIALOG_TITLE; - /** - * The constant SETTINGS_DIALOG_FXAA. - */ public static final String SETTINGS_DIALOG_FXAA; - /** - * The constant SETTINGS_DIALOG_NATIVE_FILE_CHOOSER. - */ public static final String SETTINGS_DIALOG_NATIVE_FILE_CHOOSER; - /** - * The constant SETTINGS_DIALOG_STOP_RENDER_ON_LOST_FOCUS. - */ public static final String SETTINGS_DIALOG_STOP_RENDER_ON_LOST_FOCUS; - /** - * The constant SETTINGS_DIALOG_FRAME_RATE. - */ public static final String SETTINGS_DIALOG_FRAME_RATE; - /** - * The constant SETTINGS_DIALOG_GAMMA_CORRECTION. - */ public static final String SETTINGS_DIALOG_GAMMA_CORRECTION; - /** - * The constant SETTINGS_DIALOG_TONEMAP_FILTER. - */ public static final String SETTINGS_DIALOG_TONEMAP_FILTER; - /** - * The constant SETTINGS_DIALOG_TONEMAP_FILTER_WHITE_POINT. - */ public static final String SETTINGS_DIALOG_TONEMAP_FILTER_WHITE_POINT; - /** - * The constant SETTINGS_DIALOG_ANISOTROPY. - */ public static final String SETTINGS_DIALOG_ANISOTROPY; - /** - * The constant SETTINGS_DIALOG_MESSAGE. - */ public static final String SETTINGS_DIALOG_MESSAGE; - /** - * The constant SETTINGS_DIALOG_GOOGLE_ANALYTICS. - */ public static final String SETTINGS_DIALOG_GOOGLE_ANALYTICS; - /** - * The constant SETTINGS_DIALOG_CAMERA_ANGLE. - */ public static final String SETTINGS_DIALOG_CAMERA_ANGLE; - /** - * The constant SETTINGS_DIALOG_AUTO_TANGENT_GENERATING. - */ public static final String SETTINGS_DIALOG_AUTO_TANGENT_GENERATING; - /** - * The constant SETTINGS_DIALOG_DEFAULT_FLIPPED_TEXTURE. - */ public static final String SETTINGS_DIALOG_DEFAULT_FLIPPED_TEXTURE; - /** - * The constant SETTINGS_DIALOG_DEFAULT_EDITOR_CAMERA_LAMP_ENABLED. - */ public static final String SETTINGS_DIALOG_DEFAULT_EDITOR_CAMERA_LAMP_ENABLED; - /** - * The constant SETTINGS_DIALOG_TAB_GRAPHICS. - */ public static final String SETTINGS_DIALOG_TAB_GRAPHICS; - /** - * The constant SETTINGS_DIALOG_TAB_OTHER. - */ public static final String SETTINGS_DIALOG_TAB_OTHER; - /** - * The constant SETTINGS_DIALOG_USER_LIBRARIES_FOLDER_LABEL. - */ public static final String SETTINGS_DIALOG_USER_LIBRARIES_FOLDER_LABEL; - /** - * The constant SETTINGS_DIALOG_USER_CLASSES_FOLDER_LABEL. - */ public static final String SETTINGS_DIALOG_USER_CLASSES_FOLDER_LABEL; - /** - * The constant SETTINGS_DIALOG_THEME_LABEL. - */ public static final String SETTINGS_DIALOG_THEME_LABEL; - /** - * The constant SETTINGS_DIALOG_OPEN_GL_LABEL. - */ public static final String SETTINGS_DIALOG_OPEN_GL_LABEL; - /** - * The constant SETTINGS_DIALOG_CLASSES_FOLDER_CHOOSER_TITLE. - */ public static final String SETTINGS_DIALOG_CLASSES_FOLDER_CHOOSER_TITLE; - /** - * The constant SETTINGS_DIALOG_LIBRARIES_FOLDER_CHOOSER_TITLE. - */ public static final String SETTINGS_DIALOG_LIBRARIES_FOLDER_CHOOSER_TITLE; - /** - * The constant SETTINGS_DIALOG_ENVS_FOLDER_LABEL. - */ public static final String SETTINGS_DIALOG_ENVS_FOLDER_LABEL; - /** - * The constant SETTINGS_DIALOG_ENVS_FOLDER_CHOOSER_TITLE. - */ public static final String SETTINGS_DIALOG_ENVS_FOLDER_CHOOSER_TITLE; - /** - * The constant BLEND_TO_J3O_FILE_CONVERTER_DESCRIPTION. - */ public static final String BLEND_TO_J3O_FILE_CONVERTER_DESCRIPTION; - /** - * The constant GLTF_TO_J3O_FILE_CONVERTER_DESCRIPTION. - */ public static final String GLTF_TO_J3O_FILE_CONVERTER_DESCRIPTION; - /** - * The constant FBX_TO_J3O_FILE_CONVERTER_DESCRIPTION. - */ public static final String FBX_TO_J3O_FILE_CONVERTER_DESCRIPTION; - /** - * The constant OBJ_TO_J3O_FILE_CONVERTER_DESCRIPTION. - */ public static final String OBJ_TO_J3O_FILE_CONVERTER_DESCRIPTION; - /** - * The constant XBUF_TO_J3O_FILE_CONVERTER_DESCRIPTION. - */ public static final String XBUF_TO_J3O_FILE_CONVERTER_DESCRIPTION; - /** - * The constant SCENE_TO_J3O_FILE_CONVERTER_DESCRIPTION. - */ public static final String SCENE_TO_J3O_FILE_CONVERTER_DESCRIPTION; - /** - * The constant MESH_XML_TO_J3O_FILE_CONVERTER_DESCRIPTION. - */ public static final String MESH_XML_TO_J3O_FILE_CONVERTER_DESCRIPTION; - /** - * The constant MODEL_FILE_EDITOR_NAME. - */ public static final String MODEL_FILE_EDITOR_NAME; - /** - * The constant MODEL_FILE_EDITOR_NO_SKY. - */ public static final String MODEL_FILE_EDITOR_NO_SKY; - /** - * The constant MODEL_FILE_EDITOR_FAST_SKY. - */ public static final String MODEL_FILE_EDITOR_FAST_SKY; - /** - * The constant MODEL_FILE_EDITOR_TRANSFORM_MODE. - */ public static final String MODEL_FILE_EDITOR_TRANSFORM_MODE; - /** - * The constant MODEL_FILE_EDITOR_NODE_MESH. - */ public static final String MODEL_FILE_EDITOR_NODE_MESH; - /** - * The constant MODEL_FILE_EDITOR_NODE_MATERIAL. - */ public static final String MODEL_FILE_EDITOR_NODE_MATERIAL; - /** - * The constant MODEL_FILE_EDITOR_NODE_AMBIENT_LIGHT. - */ public static final String MODEL_FILE_EDITOR_NODE_AMBIENT_LIGHT; - /** - * The constant MODEL_FILE_EDITOR_NODE_DIRECTION_LIGHT. - */ public static final String MODEL_FILE_EDITOR_NODE_DIRECTION_LIGHT; - /** - * The constant MODEL_FILE_EDITOR_NODE_POINT_LIGHT. - */ public static final String MODEL_FILE_EDITOR_NODE_POINT_LIGHT; - /** - * The constant MODEL_FILE_EDITOR_NODE_SPOT_LIGHT. - */ public static final String MODEL_FILE_EDITOR_NODE_SPOT_LIGHT; - /** - * The constant MODEL_FILE_EDITOR_NODE_LIGHT_PROBE. - */ public static final String MODEL_FILE_EDITOR_NODE_LIGHT_PROBE; - /** - * The constant MODEL_FILE_EDITOR_NODE_ANIM_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_ANIM_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCERS. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCERS; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_EMPTY. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_EMPTY; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_DEFAULT. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_DEFAULT; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_RADIAL. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_RADIAL; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_BOX. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_BOX; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_SPHERE. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_SPHERE; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_POINT. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_POINT; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_VERTEX. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_VERTEX; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_FACE. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_FACE; - /** - * The constant MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_CONVEX_HULL. - */ public static final String MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_CONVEX_HULL; - /** - * The constant MODEL_FILE_EDITOR_NODE_STATIC_RIGID_BODY_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_STATIC_RIGID_BODY_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_RIGID_BODY_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_RIGID_BODY_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_CHARACTER_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_CHARACTER_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_SKELETON_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_SKELETON_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_VEHICLE_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_VEHICLE_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_RAGDOLL_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_RAGDOLL_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_BOX_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_BOX_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_CAPSULE_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_CAPSULE_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_CHILD_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_CHILD_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_COMPUTED_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_COMPUTED_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_CONE_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_CONE_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_CYLINDER_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_CYLINDER_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_GIMPACT_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_GIMPACT_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_HEIGHT_FIELD_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_HEIGHT_FIELD_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_HULL_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_HULL_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_MESH_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_MESH_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_PLANE_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_PLANE_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_SPHERE_COLLISION_SHAPE. - */ public static final String MODEL_FILE_EDITOR_NODE_SPHERE_COLLISION_SHAPE; - /** - * The constant MODEL_FILE_EDITOR_NODE_WHEEL. - */ public static final String MODEL_FILE_EDITOR_NODE_WHEEL; - /** - * The constant MODEL_FILE_EDITOR_NODE_MOTION_CONTROL. - */ public static final String MODEL_FILE_EDITOR_NODE_MOTION_CONTROL; - /** - * The constant MODEL_FILE_EDITOR_NODE_MOTION_PATH. - */ public static final String MODEL_FILE_EDITOR_NODE_MOTION_PATH; - /** - * The constant MODEL_FILE_EDITOR_NODE_WAY_POINT. - */ public static final String MODEL_FILE_EDITOR_NODE_WAY_POINT; - /** - * The constant MODEL_FILE_EDITOR_NODE_VERTEX_BUFFER. - */ public static final String MODEL_FILE_EDITOR_NODE_VERTEX_BUFFER; - /** - * The constant SCENE_FILE_EDITOR_NAME. - */ public static final String SCENE_FILE_EDITOR_NAME; - /** - * The constant SCENE_FILE_EDITOR_TOOL_OBJECTS. - */ public static final String SCENE_FILE_EDITOR_TOOL_OBJECTS; - /** - * The constant SCENE_FILE_EDITOR_TOOL_EDITING. - */ public static final String SCENE_FILE_EDITOR_TOOL_EDITING; - /** - * The constant SCENE_FILE_EDITOR_TOOL_SCRIPTING. - */ public static final String SCENE_FILE_EDITOR_TOOL_SCRIPTING; - /** - * The constant SCENE_FILE_EDITOR_TOOL_APP_STATES. - */ public static final String SCENE_FILE_EDITOR_TOOL_APP_STATES; - /** - * The constant SCENE_FILE_EDITOR_TOOL_FILTERS. - */ public static final String SCENE_FILE_EDITOR_TOOL_FILTERS; - /** - * The constant SCENE_FILE_EDITOR_TOOL_LAYERS. - */ public static final String SCENE_FILE_EDITOR_TOOL_LAYERS; - /** - * The constant MODEL_NODE_TREE_ACTION_REMOVE. - */ public static final String MODEL_NODE_TREE_ACTION_REMOVE; - /** - * The constant MODEL_NODE_TREE_ACTION_RENAME. - */ public static final String MODEL_NODE_TREE_ACTION_RENAME; - /** - * The constant MODEL_NODE_TREE_ACTION_OPTIMIZE_GEOMETRY. - */ public static final String MODEL_NODE_TREE_ACTION_OPTIMIZE_GEOMETRY; - /** - * The constant MODEL_NODE_TREE_ACTION_TOOLS. - */ public static final String MODEL_NODE_TREE_ACTION_TOOLS; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_NODE. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_NODE; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_SKY. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_SKY; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_EDITABLE_SKY. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_EDITABLE_SKY; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_BOX. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_BOX; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_SPHERE. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_SPHERE; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_QUAD. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_QUAD; - /** - * The constant MODEL_NODE_TREE_ACTION_LOAD_MODEL. - */ public static final String MODEL_NODE_TREE_ACTION_LOAD_MODEL; - /** - * The constant MODEL_NODE_TREE_ACTION_SAVE_AS. - */ public static final String MODEL_NODE_TREE_ACTION_SAVE_AS; - /** - * The constant MODEL_NODE_TREE_ACTION_MAKE_EMBEDDED. - */ public static final String MODEL_NODE_TREE_ACTION_MAKE_EMBEDDED; - /** - * The constant MODEL_NODE_TREE_ACTION_LINK_MODEL. - */ public static final String MODEL_NODE_TREE_ACTION_LINK_MODEL; - /** - * The constant MODEL_NODE_TREE_ACTION_TANGENT_GENERATOR. - */ public static final String MODEL_NODE_TREE_ACTION_TANGENT_GENERATOR; - /** - * The constant MODEL_NODE_TREE_ACTION_LOD_GENERATOR. - */ public static final String MODEL_NODE_TREE_ACTION_LOD_GENERATOR; - /** - * The constant MODEL_NODE_TREE_ACTION_LIGHT. - */ public static final String MODEL_NODE_TREE_ACTION_LIGHT; - /** - * The constant MODEL_NODE_TREE_ACTION_AMBIENT_LIGHT. - */ public static final String MODEL_NODE_TREE_ACTION_AMBIENT_LIGHT; - /** - * The constant MODEL_NODE_TREE_ACTION_DIRECTION_LIGHT. - */ public static final String MODEL_NODE_TREE_ACTION_DIRECTION_LIGHT; - /** - * The constant MODEL_NODE_TREE_ACTION_POINT_LIGHT. - */ public static final String MODEL_NODE_TREE_ACTION_POINT_LIGHT; - /** - * The constant MODEL_NODE_TREE_ACTION_SPOT_LIGHT. - */ public static final String MODEL_NODE_TREE_ACTION_SPOT_LIGHT; - /** - * The constant MODEL_NODE_TREE_ACTION_ANIMATION_PLAY. - */ public static final String MODEL_NODE_TREE_ACTION_ANIMATION_PLAY; - /** - * The constant MODEL_NODE_TREE_ACTION_ANIMATION_PLAY_SETTINGS. - */ public static final String MODEL_NODE_TREE_ACTION_ANIMATION_PLAY_SETTINGS; - /** - * The constant MODEL_NODE_TREE_ACTION_ANIMATION_STOP. - */ public static final String MODEL_NODE_TREE_ACTION_ANIMATION_STOP; - /** - * The constant MODEL_NODE_TREE_ACTION_ANIMATION_MANUAL_EXTRAXT_SUB_ANIMATION. - */ + public static final String MODEL_NODE_TREE_ACTION_ANIMATION_PAUSE; public static final String MODEL_NODE_TREE_ACTION_ANIMATION_MANUAL_EXTRAXT_SUB_ANIMATION; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_AUDIO_NODE. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_AUDIO_NODE; - /** - * The constant MODEL_NODE_TREE_ACTION_AUDIO_PLAY. - */ public static final String MODEL_NODE_TREE_ACTION_AUDIO_PLAY; - /** - * The constant MODEL_NODE_TREE_ACTION_AUDIO_STOP. - */ public static final String MODEL_NODE_TREE_ACTION_AUDIO_STOP; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_TONEG0D_PARTICLE_EMITTER. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_TONEG0D_PARTICLE_EMITTER; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_SOFT_TONEG0D_PARTICLE_EMITTER. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_SOFT_TONEG0D_PARTICLE_EMITTER; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_DEFAULT_PARTICLE_EMITTER. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_DEFAULT_PARTICLE_EMITTER; - /** - * The constant MODEL_NODE_TREE_ACTION_RESET_PARTICLE_EMITTERS. - */ public static final String MODEL_NODE_TREE_ACTION_RESET_PARTICLE_EMITTERS; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_TRIANGLE_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_TRIANGLE_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CHANGE_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CHANGE_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CHANGE_INFLUENCER. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CHANGE_INFLUENCER; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_DEFAULT. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_DEFAULT; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_EMPTY. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_EMPTY; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_RADIAL. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_RADIAL; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_POINT_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_POINT_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_BOX_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_BOX_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_SPHERE_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_SPHERE_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_VERTEX_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_VERTEX_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_FACE_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_FACE_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_CONVEX_HULL_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_CONVEX_HULL_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CYLINDER_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CYLINDER_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_DOME_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_DOME_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_QUAD_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_QUAD_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_TORUS_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_TORUS_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MODEL_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MODEL_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CHANGE_PARTICLES_MESH. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CHANGE_PARTICLES_MESH; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_QUAD. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_QUAD; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_POINT. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_POINT; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_IMPOSTOR. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_IMPOSTOR; - /** - * The constant MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_MODEL. - */ public static final String MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_PARTICLES_MESH_MODEL; - /** - * The constant MODEL_NODE_TREE_ACTION_CREATE_LAYER. - */ public static final String MODEL_NODE_TREE_ACTION_CREATE_LAYER; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_USER_DATA. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_USER_DATA; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL_RIGID_BODY. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL_RIGID_BODY; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL_STATIC_RIGID_BODY. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL_STATIC_RIGID_BODY; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL_NOTION. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL_NOTION; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL_CHARACTER. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL_CHARACTER; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL_CUSTOM. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL_CUSTOM; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL_VEHICLE. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL_VEHICLE; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_CONTROL_KINEMATIC_RAGDOLL. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_CONTROL_KINEMATIC_RAGDOLL; - /** - * The constant MODEL_NODE_TREE_ACTION_REACTIVATE. - */ public static final String MODEL_NODE_TREE_ACTION_REACTIVATE; - /** - * The constant MODEL_NODE_TREE_ACTION_CHANGE_COLLISION_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_CHANGE_COLLISION_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_GENERATE_COLLISION_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_GENERATE_COLLISION_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_BOX_COLLISION_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_BOX_COLLISION_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_CAPSULE_COLLISION_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_CAPSULE_COLLISION_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_CONE_COLLISION_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_CONE_COLLISION_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_CYLINDER_COLLISION_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_CYLINDER_COLLISION_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_SPHERE_COLLISION_SHAPE. - */ public static final String MODEL_NODE_TREE_ACTION_SPHERE_COLLISION_SHAPE; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_WHEEL. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_WHEEL; - /** - * The constant MODEL_NODE_TREE_ACTION_ADD_TERRAIN. - */ public static final String MODEL_NODE_TREE_ACTION_ADD_TERRAIN; - /** - * The constant MODEL_PROPERTY_CULL_HINT. - */ public static final String MODEL_PROPERTY_CULL_HINT; - /** - * The constant MODEL_PROPERTY_SHADOW_MODE. - */ public static final String MODEL_PROPERTY_SHADOW_MODE; - /** - * The constant MODEL_PROPERTY_QUEUE_BUCKET. - */ public static final String MODEL_PROPERTY_QUEUE_BUCKET; - /** - * The constant MODEL_PROPERTY_LOCATION. - */ public static final String MODEL_PROPERTY_LOCATION; - /** - * The constant MODEL_PROPERTY_SCALE. - */ public static final String MODEL_PROPERTY_SCALE; - /** - * The constant MODEL_PROPERTY_ROTATION. - */ public static final String MODEL_PROPERTY_ROTATION; - /** - * The constant MODEL_PROPERTY_MATERIAL. - */ public static final String MODEL_PROPERTY_MATERIAL; - /** - * The constant MODEL_PROPERTY_DIRECTION. - */ public static final String MODEL_PROPERTY_DIRECTION; - /** - * The constant MODEL_PROPERTY_RADIUS. - */ public static final String MODEL_PROPERTY_RADIUS; - /** - * The constant MODEL_PROPERTY_COLOR. - */ public static final String MODEL_PROPERTY_COLOR; - /** - * The constant MODEL_PROPERTY_INNER_ANGLE. - */ public static final String MODEL_PROPERTY_INNER_ANGLE; - /** - * The constant MODEL_PROPERTY_OUTER_ANGLE. - */ public static final String MODEL_PROPERTY_OUTER_ANGLE; - /** - * The constant MODEL_PROPERTY_MIN. - */ public static final String MODEL_PROPERTY_MIN; - /** - * The constant MODEL_PROPERTY_MAX. - */ public static final String MODEL_PROPERTY_MAX; - /** - * The constant MODEL_PROPERTY_IS_LOOPING. - */ public static final String MODEL_PROPERTY_IS_LOOPING; - /** - * The constant MODEL_PROPERTY_IS_REVERB. - */ public static final String MODEL_PROPERTY_IS_REVERB; - /** - * The constant MODEL_PROPERTY_IS_DIRECTIONAL. - */ public static final String MODEL_PROPERTY_IS_DIRECTIONAL; - /** - * The constant MODEL_PROPERTY_IS_POSITIONAL. - */ public static final String MODEL_PROPERTY_IS_POSITIONAL; - /** - * The constant MODEL_PROPERTY_AUDIO_PITCH. - */ public static final String MODEL_PROPERTY_AUDIO_PITCH; - /** - * The constant MODEL_PROPERTY_AUDIO_VOLUME. - */ public static final String MODEL_PROPERTY_AUDIO_VOLUME; - /** - * The constant MODEL_PROPERTY_TIME_OFFSET. - */ public static final String MODEL_PROPERTY_TIME_OFFSET; - /** - * The constant MODEL_PROPERTY_MAX_DISTANCE. - */ public static final String MODEL_PROPERTY_MAX_DISTANCE; - /** - * The constant MODEL_PROPERTY_REF_DISTANCE. - */ public static final String MODEL_PROPERTY_REF_DISTANCE; - /** - * The constant MODEL_PROPERTY_AUDIO_DATA. - */ public static final String MODEL_PROPERTY_AUDIO_DATA; - /** - * The constant MODEL_PROPERTY_VELOCITY. - */ public static final String MODEL_PROPERTY_VELOCITY; - /** - * The constant MODEL_PROPERTY_LOD. - */ public static final String MODEL_PROPERTY_LOD; - /** - * The constant MODEL_PROPERTY_TRIANGLE_COUNT. - */ public static final String MODEL_PROPERTY_TRIANGLE_COUNT; - /** - * The constant MODEL_PROPERTY_LEVEL. - */ public static final String MODEL_PROPERTY_LEVEL; - /** - * The constant MODEL_PROPERTY_LAYER. - */ public static final String MODEL_PROPERTY_LAYER; - /** - * The constant MODEL_PROPERTY_VALUE. - */ public static final String MODEL_PROPERTY_VALUE; - /** - * The constant MODEL_PROPERTY_ID. - */ public static final String MODEL_PROPERTY_ID; - /** - * The constant MODEL_PROPERTY_INSTANCE_COUNT. - */ public static final String MODEL_PROPERTY_INSTANCE_COUNT; - /** - * The constant MODEL_PROPERTY_VERTEX_COUNT. - */ public static final String MODEL_PROPERTY_VERTEX_COUNT; - /** - * The constant MODEL_PROPERTY_NUM_LOD_LEVELS. - */ public static final String MODEL_PROPERTY_NUM_LOD_LEVELS; - /** - * The constant MODEL_PROPERTY_MODE. - */ public static final String MODEL_PROPERTY_MODE; - /** - * The constant MODEL_PROPERTY_TYPE. - */ public static final String MODEL_PROPERTY_TYPE; - /** - * The constant MODEL_PROPERTY_FORMAT. - */ public static final String MODEL_PROPERTY_FORMAT; - /** - * The constant MODEL_PROPERTY_USAGE. - */ public static final String MODEL_PROPERTY_USAGE; - /** - * The constant MODEL_PROPERTY_UNIQ_ID. - */ public static final String MODEL_PROPERTY_UNIQ_ID; - /** - * The constant MODEL_PROPERTY_BASE_INSTANCE_COUNT. - */ public static final String MODEL_PROPERTY_BASE_INSTANCE_COUNT; - /** - * The constant MODEL_PROPERTY_INSTANCE_SPAN. - */ public static final String MODEL_PROPERTY_INSTANCE_SPAN; - /** - * The constant MODEL_PROPERTY_NUM_COMPONENTS. - */ public static final String MODEL_PROPERTY_NUM_COMPONENTS; - /** - * The constant MODEL_PROPERTY_NUM_ELEMENTS. - */ public static final String MODEL_PROPERTY_NUM_ELEMENTS; - /** - * The constant MODEL_PROPERTY_OFFSET. - */ public static final String MODEL_PROPERTY_OFFSET; - /** - * The constant MODEL_PROPERTY_STRIDE. - */ public static final String MODEL_PROPERTY_STRIDE; - /** - * The constant MODEL_PROPERTY_CAPACITY. - */ public static final String MODEL_PROPERTY_CAPACITY; - /** - * The constant MODEL_PROPERTY_IS_ENABLED. - */ public static final String MODEL_PROPERTY_IS_ENABLED; - /** - * The constant MODEL_PROPERTY_IS_HARDWARE_SKINNING_PREFERRED. - */ public static final String MODEL_PROPERTY_IS_HARDWARE_SKINNING_PREFERRED; - /** - * The constant MODEL_PROPERTY_VIEW_DIRECTION. - */ public static final String MODEL_PROPERTY_VIEW_DIRECTION; - /** - * The constant MODEL_PROPERTY_WALK_DIRECTION. - */ public static final String MODEL_PROPERTY_WALK_DIRECTION; - /** - * The constant MODEL_PROPERTY_FALL_SPEED. - */ public static final String MODEL_PROPERTY_FALL_SPEED; - /** - * The constant MODEL_PROPERTY_GRAVITY. - */ public static final String MODEL_PROPERTY_GRAVITY; - /** - * The constant MODEL_PROPERTY_JUMP_SPEED. - */ public static final String MODEL_PROPERTY_JUMP_SPEED; - /** - * The constant MODEL_PROPERTY_MAX_SLOPE. - */ public static final String MODEL_PROPERTY_MAX_SLOPE; - /** - * The constant MODEL_PROPERTY_IS_APPLY_PHYSICS_LOCAL. - */ public static final String MODEL_PROPERTY_IS_APPLY_PHYSICS_LOCAL; - /** - * The constant MODEL_PROPERTY_IS_USE_VIEW_DIRECTION. - */ public static final String MODEL_PROPERTY_IS_USE_VIEW_DIRECTION; - /** - * The constant MODEL_PROPERTY_IS_KINEMATIC_SPATIAL. - */ public static final String MODEL_PROPERTY_IS_KINEMATIC_SPATIAL; - /** - * The constant MODEL_PROPERTY_IS_KINEMATIC. - */ public static final String MODEL_PROPERTY_IS_KINEMATIC; - /** - * The constant MODEL_PROPERTY_ANGULAR_VELOCITY. - */ public static final String MODEL_PROPERTY_ANGULAR_VELOCITY; - /** - * The constant MODEL_PROPERTY_LINEAR_FACTOR. - */ public static final String MODEL_PROPERTY_LINEAR_FACTOR; - /** - * The constant MODEL_PROPERTY_ANGULAR_DAMPING. - */ public static final String MODEL_PROPERTY_ANGULAR_DAMPING; - /** - * The constant MODEL_PROPERTY_ANGULAR_FACTOR. - */ public static final String MODEL_PROPERTY_ANGULAR_FACTOR; - /** - * The constant MODEL_PROPERTY_FRICTION. - */ public static final String MODEL_PROPERTY_FRICTION; - /** - * The constant MODEL_PROPERTY_LINEAR_DAMPING. - */ public static final String MODEL_PROPERTY_LINEAR_DAMPING; - /** - * The constant MODEL_PROPERTY_MASS. - */ public static final String MODEL_PROPERTY_MASS; - /** - * The constant MODEL_PROPERTY_RESTITUTION. - */ public static final String MODEL_PROPERTY_RESTITUTION; - /** - * The constant MODEL_PROPERTY_CURRENT_VALUE. - */ public static final String MODEL_PROPERTY_CURRENT_VALUE; - /** - * The constant MODEL_PROPERTY_CURRENT_WAY_POINT. - */ public static final String MODEL_PROPERTY_CURRENT_WAY_POINT; - /** - * The constant MODEL_PROPERTY_DIRECTION_TYPE. - */ public static final String MODEL_PROPERTY_DIRECTION_TYPE; - /** - * The constant MODEL_PROPERTY_ANGULAR_SLEEPING_THRESHOLD. - */ public static final String MODEL_PROPERTY_ANGULAR_SLEEPING_THRESHOLD; - /** - * The constant MODEL_PROPERTY_LOOP_MODE. - */ public static final String MODEL_PROPERTY_LOOP_MODE; - /** - * The constant MODEL_PROPERTY_INITIAL_DURATION. - */ public static final String MODEL_PROPERTY_INITIAL_DURATION; - /** - * The constant MODEL_PROPERTY_SPEED. - */ public static final String MODEL_PROPERTY_SPEED; - /** - * The constant MODEL_PROPERTY_TIME. - */ public static final String MODEL_PROPERTY_TIME; - /** - * The constant MODEL_PROPERTY_MARGIN. - */ public static final String MODEL_PROPERTY_MARGIN; - /** - * The constant MODEL_PROPERTY_HALF_EXTENTS. - */ public static final String MODEL_PROPERTY_HALF_EXTENTS; - /** - * The constant MODEL_PROPERTY_HEIGHT. - */ public static final String MODEL_PROPERTY_HEIGHT; - /** - * The constant MODEL_PROPERTY_AXIS. - */ public static final String MODEL_PROPERTY_AXIS; - /** - * The constant MODEL_PROPERTY_OBJECT_ID. - */ public static final String MODEL_PROPERTY_OBJECT_ID; - /** - * The constant MODEL_PROPERTY_AXLE. - */ public static final String MODEL_PROPERTY_AXLE; - /** - * The constant MODEL_PROPERTY_REST_LENGTH. - */ public static final String MODEL_PROPERTY_REST_LENGTH; - /** - * The constant MODEL_PROPERTY_IS_FRONT. - */ public static final String MODEL_PROPERTY_IS_FRONT; - /** - * The constant MODEL_PROPERTY_DAMPING_COMPRESSION. - */ public static final String MODEL_PROPERTY_DAMPING_COMPRESSION; - /** - * The constant MODEL_PROPERTY_FRICTION_SLIP. - */ public static final String MODEL_PROPERTY_FRICTION_SLIP; - /** - * The constant MODEL_PROPERTY_MAX_SUSPENSION_FORCE. - */ public static final String MODEL_PROPERTY_MAX_SUSPENSION_FORCE; - /** - * The constant MODEL_PROPERTY_MAX_SUSPENSION_TRAVEL_CM. - */ public static final String MODEL_PROPERTY_MAX_SUSPENSION_TRAVEL_CM; - /** - * The constant MODEL_PROPERTY_DAMPING_RELAXATION. - */ public static final String MODEL_PROPERTY_DAMPING_RELAXATION; - /** - * The constant MODEL_PROPERTY_SUSPENSION_STIFFNESS. - */ public static final String MODEL_PROPERTY_SUSPENSION_STIFFNESS; - /** - * The constant MODEL_PROPERTY_ROLL_INFLUENCE. - */ public static final String MODEL_PROPERTY_ROLL_INFLUENCE; - /** - * The constant MODEL_PROPERTY_WHEEL_SPATIAL. - */ public static final String MODEL_PROPERTY_WHEEL_SPATIAL; - /** - * The constant MODEL_PROPERTY_LENGTH. - */ public static final String MODEL_PROPERTY_LENGTH; - /** - * The constant MODEL_PROPERTY_CURRENT_TIME. - */ public static final String MODEL_PROPERTY_CURRENT_TIME; - /** - * The constant MODEL_PROPERTY_POINT. - */ public static final String MODEL_PROPERTY_POINT; - /** - * The constant MODEL_PROPERTY_CENTER. - */ public static final String MODEL_PROPERTY_CENTER; - /** - * The constant MODEL_PROPERTY_VELOCITY_VARIATION. - */ public static final String MODEL_PROPERTY_VELOCITY_VARIATION; - /** - * The constant MODEL_PROPERTY_INITIAL_VELOCITY. - */ public static final String MODEL_PROPERTY_INITIAL_VELOCITY; - /** - * The constant MODEL_PROPERTY_ORIGIN. - */ public static final String MODEL_PROPERTY_ORIGIN; - /** - * The constant MODEL_PROPERTY_RADIAL_VELOCITY. - */ public static final String MODEL_PROPERTY_RADIAL_VELOCITY; - /** - * The constant MODEL_PROPERTY_IS_HORIZONTAL. - */ public static final String MODEL_PROPERTY_IS_HORIZONTAL; - /** - * The constant MODEL_PROPERTY_IS_TEST_MODE. - */ public static final String MODEL_PROPERTY_IS_TEST_MODE; - /** - * The constant MODEL_PROPERTY_IS_FACING_VELOCITY. - */ public static final String MODEL_PROPERTY_IS_FACING_VELOCITY; - /** - * The constant MODEL_PROPERTY_IS_IN_WORLD_SPACE. - */ public static final String MODEL_PROPERTY_IS_IN_WORLD_SPACE; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_ANGLE. - */ public static final String MODEL_PROPERTY_IS_RANDOM_ANGLE; - /** - * The constant MODEL_PROPERTY_IS_SELECT_RANDOM_IMAGE. - */ public static final String MODEL_PROPERTY_IS_SELECT_RANDOM_IMAGE; - /** - * The constant MODEL_PROPERTY_SIZE. - */ public static final String MODEL_PROPERTY_SIZE; - /** - * The constant MODEL_PROPERTY_ROTATE_SPEED. - */ public static final String MODEL_PROPERTY_ROTATE_SPEED; - /** - * The constant MODEL_PROPERTY_START_COLOR. - */ public static final String MODEL_PROPERTY_START_COLOR; - /** - * The constant MODEL_PROPERTY_END_COLOR. - */ public static final String MODEL_PROPERTY_END_COLOR; - /** - * The constant MODEL_PROPERTY_MESH_TYPE. - */ public static final String MODEL_PROPERTY_MESH_TYPE; - /** - * The constant MODEL_PROPERTY_FACE_NORMAL. - */ public static final String MODEL_PROPERTY_FACE_NORMAL; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_POINT. - */ public static final String MODEL_PROPERTY_IS_RANDOM_POINT; - /** - * The constant MODEL_PROPERTY_IS_SEQUENTIAL_FACE. - */ public static final String MODEL_PROPERTY_IS_SEQUENTIAL_FACE; - /** - * The constant MODEL_PROPERTY_IS_SKIP_PATTERN. - */ public static final String MODEL_PROPERTY_IS_SKIP_PATTERN; - /** - * The constant MODEL_PROPERTY_EMISSION_POINT. - */ public static final String MODEL_PROPERTY_EMISSION_POINT; - /** - * The constant MODEL_PROPERTY_MAX_PARTICLES. - */ public static final String MODEL_PROPERTY_MAX_PARTICLES; - /** - * The constant MODEL_PROPERTY_EMISSION_PER_SECOND. - */ public static final String MODEL_PROPERTY_EMISSION_PER_SECOND; - /** - * The constant MODEL_PROPERTY_PARTICLES_PER_SECOND. - */ public static final String MODEL_PROPERTY_PARTICLES_PER_SECOND; - /** - * The constant MODEL_PROPERTY_EMITTER_LIFE. - */ public static final String MODEL_PROPERTY_EMITTER_LIFE; - /** - * The constant MODEL_PROPERTY_EMITTER_DELAY. - */ public static final String MODEL_PROPERTY_EMITTER_DELAY; - /** - * The constant MODEL_PROPERTY_IS_TEST_PARTICLES. - */ public static final String MODEL_PROPERTY_IS_TEST_PARTICLES; - /** - * The constant MODEL_PROPERTY_IS_FOLLOW_EMITTER. - */ public static final String MODEL_PROPERTY_IS_FOLLOW_EMITTER; - /** - * The constant MODEL_PROPERTY_STRETCHING. - */ public static final String MODEL_PROPERTY_STRETCHING; - /** - * The constant MODEL_PROPERTY_MAGNITUDE. - */ public static final String MODEL_PROPERTY_MAGNITUDE; - /** - * The constant MODEL_PROPERTY_BILLBOARD. - */ public static final String MODEL_PROPERTY_BILLBOARD; - /** - * The constant MODEL_PROPERTY_INITIAL_FORCE. - */ public static final String MODEL_PROPERTY_INITIAL_FORCE; - /** - * The constant MODEL_PROPERTY_LIFE. - */ public static final String MODEL_PROPERTY_LIFE; - /** - * The constant MODEL_PROPERTY_COLUMNS. - */ public static final String MODEL_PROPERTY_COLUMNS; - /** - * The constant MODEL_PROPERTY_ROWS. - */ public static final String MODEL_PROPERTY_ROWS; - /** - * The constant MODEL_PROPERTY_SPRITE_COUNT. - */ public static final String MODEL_PROPERTY_SPRITE_COUNT; - /** - * The constant MODEL_PROPERTY_FIXED_DURATION. - */ public static final String MODEL_PROPERTY_FIXED_DURATION; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_START_COLOR. - */ public static final String MODEL_PROPERTY_IS_RANDOM_START_COLOR; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_START_SIZE. - */ public static final String MODEL_PROPERTY_IS_RANDOM_START_SIZE; - /** - * The constant MODEL_PROPERTY_SIZE_VARIATION_FACTOR. - */ public static final String MODEL_PROPERTY_SIZE_VARIATION_FACTOR; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_START_DESTINATION. - */ public static final String MODEL_PROPERTY_IS_RANDOM_START_DESTINATION; - /** - * The constant MODEL_PROPERTY_CHANCE. - */ public static final String MODEL_PROPERTY_CHANCE; - /** - * The constant MODEL_PROPERTY_STRENGTH. - */ public static final String MODEL_PROPERTY_STRENGTH; - /** - * The constant MODEL_PROPERTY_ALIGNMENT. - */ public static final String MODEL_PROPERTY_ALIGNMENT; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_DIRECTION. - */ public static final String MODEL_PROPERTY_IS_RANDOM_DIRECTION; - /** - * The constant MODEL_PROPERTY_PULL_CENTER. - */ public static final String MODEL_PROPERTY_PULL_CENTER; - /** - * The constant MODEL_PROPERTY_PULL_ALIGNMENT. - */ public static final String MODEL_PROPERTY_PULL_ALIGNMENT; - /** - * The constant MODEL_PROPERTY_UP_ALIGNMENT. - */ public static final String MODEL_PROPERTY_UP_ALIGNMENT; - /** - * The constant MODEL_PROPERTY_RADIAL_PULL. - */ public static final String MODEL_PROPERTY_RADIAL_PULL; - /** - * The constant MODEL_PROPERTY_TANGENT_FORCE. - */ public static final String MODEL_PROPERTY_TANGENT_FORCE; - /** - * The constant MODEL_PROPERTY_ALPHA_INTERPOLATION. - */ public static final String MODEL_PROPERTY_ALPHA_INTERPOLATION; - /** - * The constant MODEL_PROPERTY_COLOR_INTERPOLATION. - */ public static final String MODEL_PROPERTY_COLOR_INTERPOLATION; - /** - * The constant MODEL_PROPERTY_DESTINATION_INTERPOLATION. - */ public static final String MODEL_PROPERTY_DESTINATION_INTERPOLATION; - /** - * The constant MODEL_PROPERTY_ROTATION_INTERPOLATION. - */ public static final String MODEL_PROPERTY_ROTATION_INTERPOLATION; - /** - * The constant MODEL_PROPERTY_SIZE_INTERPOLATION. - */ public static final String MODEL_PROPERTY_SIZE_INTERPOLATION; - /** - * The constant MODEL_PROPERTY_ALPHA. - */ public static final String MODEL_PROPERTY_ALPHA; - /** - * The constant MODEL_PROPERTY_FRAME_SEQUENCE. - */ public static final String MODEL_PROPERTY_FRAME_SEQUENCE; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_START_IMAGE. - */ public static final String MODEL_PROPERTY_IS_RANDOM_START_IMAGE; - /** - * The constant MODEL_PROPERTY_IS_ANIMATE. - */ public static final String MODEL_PROPERTY_IS_ANIMATE; - /** - * The constant MODEL_PROPERTY_REACTION. - */ public static final String MODEL_PROPERTY_REACTION; - /** - * The constant MODEL_PROPERTY_IS_RANDOM_SPEED. - */ public static final String MODEL_PROPERTY_IS_RANDOM_SPEED; - /** - * The constant MODEL_PROPERTY_IS_START_RANDOM_ROTATION_X. - */ public static final String MODEL_PROPERTY_IS_START_RANDOM_ROTATION_X; - /** - * The constant MODEL_PROPERTY_INTERPOLATION. - */ public static final String MODEL_PROPERTY_INTERPOLATION; - /** - * The constant MODEL_PROPERTY_GEOMETRY_LIST. - */ public static final String MODEL_PROPERTY_GEOMETRY_LIST; - /** - * The constant MODEL_PROPERTY_GEOMETRY. - */ public static final String MODEL_PROPERTY_GEOMETRY; - /** - * The constant MODEL_PROPERTY_AXIS_SAMPLES. - */ public static final String MODEL_PROPERTY_AXIS_SAMPLES; - /** - * The constant MODEL_PROPERTY_RADIAL_SAMPLES. - */ public static final String MODEL_PROPERTY_RADIAL_SAMPLES; - /** - * The constant MODEL_PROPERTY_PLANES. - */ public static final String MODEL_PROPERTY_PLANES; - /** - * The constant MODEL_PROPERTY_WIDTH. - */ public static final String MODEL_PROPERTY_WIDTH; - /** - * The constant MODEL_PROPERTY_FLIP_COORDS. - */ public static final String MODEL_PROPERTY_FLIP_COORDS; - /** - * The constant MODEL_PROPERTY_Z_SAMPLES. - */ public static final String MODEL_PROPERTY_Z_SAMPLES; - /** - * The constant MODEL_PROPERTY_CIRCLE_SAMPLES. - */ public static final String MODEL_PROPERTY_CIRCLE_SAMPLES; - /** - * The constant MODEL_PROPERTY_INNER_RADIUS. - */ public static final String MODEL_PROPERTY_INNER_RADIUS; - /** - * The constant MODEL_PROPERTY_OUTER_RADIUS. - */ public static final String MODEL_PROPERTY_OUTER_RADIUS; - /** - * The constant MODEL_PROPERTY_NAME. - */ public static final String MODEL_PROPERTY_NAME; - /** - * The constant MODEL_PROPERTY_DATA_TYPE. - */ public static final String MODEL_PROPERTY_DATA_TYPE; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_NO_TEXTURE. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_NO_TEXTURE; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_TEXTURE_SETTINGS. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_TEXTURE_SETTINGS; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_NO_MATERIAL. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_NO_MATERIAL; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_FLIP_Y. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_FLIP_Y; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_S. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_S; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_T. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_T; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_MAG_FILTER. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_MAG_FILTER; - /** - * The constant MATERIAL_MODEL_PROPERTY_CONTROL_MIN_FILTER. - */ public static final String MATERIAL_MODEL_PROPERTY_CONTROL_MIN_FILTER; - /** - * The constant ABSTRACT_ELEMENT_PROPERTY_CONTROL_NO_ELEMENT. - */ public static final String ABSTRACT_ELEMENT_PROPERTY_CONTROL_NO_ELEMENT; - /** - * The constant LAYER_PROPERTY_CONTROL_NO_LAYER. - */ public static final String LAYER_PROPERTY_CONTROL_NO_LAYER; - /** - * The constant AUDIO_KEY_PROPERTY_CONTROL_NO_AUDIO. - */ public static final String AUDIO_KEY_PROPERTY_CONTROL_NO_AUDIO; - /** - * The constant CHOOSE_FOLDER_CONTROL_NO_FOLDER. - */ public static final String CHOOSE_FOLDER_CONTROL_NO_FOLDER; - /** - * The constant RENAME_DIALOG_TITLE. - */ public static final String RENAME_DIALOG_TITLE; - /** - * The constant RENAME_DIALOG_NEW_NAME_LABEL. - */ public static final String RENAME_DIALOG_NEW_NAME_LABEL; - /** - * The constant RENAME_DIALOG_BUTTON_OK. - */ public static final String RENAME_DIALOG_BUTTON_OK; - /** - * The constant PLAY_ANIMATION_SETTINGS_DIALOG_TITLE. - */ public static final String PLAY_ANIMATION_SETTINGS_DIALOG_TITLE; - /** - * The constant MANUAL_EXTRACT_ANIMATION_DIALOG_TITLE. - */ public static final String MANUAL_EXTRACT_ANIMATION_DIALOG_TITLE; - /** - * The constant MANUAL_EXTRACT_ANIMATION_DIALOG_NAME. - */ public static final String MANUAL_EXTRACT_ANIMATION_DIALOG_NAME; - /** - * The constant MANUAL_EXTRACT_ANIMATION_DIALOG_NAME_EXAMPLE. - */ public static final String MANUAL_EXTRACT_ANIMATION_DIALOG_NAME_EXAMPLE; - /** - * The constant MANUAL_EXTRACT_ANIMATION_DIALOG_START_FRAME. - */ public static final String MANUAL_EXTRACT_ANIMATION_DIALOG_START_FRAME; - /** - * The constant MANUAL_EXTRACT_ANIMATION_DIALOG_END_FRAME. - */ public static final String MANUAL_EXTRACT_ANIMATION_DIALOG_END_FRAME; - /** - * The constant MANUAL_EXTRACT_ANIMATION_DIALOG_BUTTON_OK. - */ public static final String MANUAL_EXTRACT_ANIMATION_DIALOG_BUTTON_OK; - /** - * The constant QUESTION_DIALOG_TITLE. - */ public static final String QUESTION_DIALOG_TITLE; - /** - * The constant FOLDER_CREATOR_DESCRIPTION. - */ public static final String FOLDER_CREATOR_DESCRIPTION; - /** - * The constant FOLDER_CREATOR_TITLE. - */ public static final String FOLDER_CREATOR_TITLE; - /** - * The constant FOLDER_CREATOR_FILE_NAME_LABEL. - */ public static final String FOLDER_CREATOR_FILE_NAME_LABEL; - /** - * The constant EMPTY_FILE_CREATOR_DESCRIPTION. - */ public static final String EMPTY_FILE_CREATOR_DESCRIPTION; - /** - * The constant EMPTY_FILE_CREATOR_TITLE. - */ public static final String EMPTY_FILE_CREATOR_TITLE; - /** - * The constant IMAGE_VIEWER_EDITOR_NAME. - */ public static final String IMAGE_VIEWER_EDITOR_NAME; - /** - * The constant AUDIO_VIEWER_EDITOR_NAME. - */ public static final String AUDIO_VIEWER_EDITOR_NAME; - /** - * The constant AUDIO_VIEWER_EDITOR_DURATION_LABEL. - */ public static final String AUDIO_VIEWER_EDITOR_DURATION_LABEL; - /** - * The constant AUDIO_VIEWER_EDITOR_BITS_PER_SAMPLE_LABEL. - */ public static final String AUDIO_VIEWER_EDITOR_BITS_PER_SAMPLE_LABEL; - /** - * The constant AUDIO_VIEWER_EDITOR_CHANNELS_LABEL. - */ public static final String AUDIO_VIEWER_EDITOR_CHANNELS_LABEL; - /** - * The constant AUDIO_VIEWER_EDITOR_DATA_TYPE_LABEL. - */ public static final String AUDIO_VIEWER_EDITOR_DATA_TYPE_LABEL; - /** - * The constant AUDIO_VIEWER_EDITOR_SAMPLE_RATE_LABEL. - */ public static final String AUDIO_VIEWER_EDITOR_SAMPLE_RATE_LABEL; - /** - * The constant CREATE_SKY_DIALOG_TITLE. - */ public static final String CREATE_SKY_DIALOG_TITLE; - /** - * The constant CREATE_SKY_DIALOG_SKY_TYPE_SINGLE. - */ public static final String CREATE_SKY_DIALOG_SKY_TYPE_SINGLE; - /** - * The constant CREATE_SKY_DIALOG_SKY_TYPE_MULTIPLE. - */ public static final String CREATE_SKY_DIALOG_SKY_TYPE_MULTIPLE; - /** - * The constant CREATE_SKY_DIALOG_SKY_TYPE. - */ public static final String CREATE_SKY_DIALOG_SKY_TYPE; - /** - * The constant CREATE_SKY_DIALOG_NORMAL_SCALE. - */ public static final String CREATE_SKY_DIALOG_NORMAL_SCALE; - /** - * The constant CREATE_SKY_DIALOG_MATERIAL_FOLDER. - */ public static final String CREATE_SKY_DIALOG_MATERIAL_FOLDER; - /** - * The constant CREATE_SKY_DIALOG_MATERIAL_NAME. - */ public static final String CREATE_SKY_DIALOG_MATERIAL_NAME; - /** - * The constant CREATE_SKY_DIALOG_TEXTURE. - */ public static final String CREATE_SKY_DIALOG_TEXTURE; - /** - * The constant CREATE_SKY_DIALOG_TEXTURE_TYPE. - */ public static final String CREATE_SKY_DIALOG_TEXTURE_TYPE; - /** - * The constant CREATE_SKY_DIALOG_FLIP_Y. - */ public static final String CREATE_SKY_DIALOG_FLIP_Y; - /** - * The constant CREATE_SKY_DIALOG_NORTH. - */ public static final String CREATE_SKY_DIALOG_NORTH; - /** - * The constant CREATE_SKY_DIALOG_SOUTH. - */ public static final String CREATE_SKY_DIALOG_SOUTH; - /** - * The constant CREATE_SKY_DIALOG_EAST. - */ public static final String CREATE_SKY_DIALOG_EAST; - /** - * The constant CREATE_SKY_DIALOG_WEST. - */ public static final String CREATE_SKY_DIALOG_WEST; - /** - * The constant CREATE_SKY_DIALOG_TOP. - */ public static final String CREATE_SKY_DIALOG_TOP; - /** - * The constant CREATE_SKY_DIALOG_BOTTOM. - */ public static final String CREATE_SKY_DIALOG_BOTTOM; - /** - * The constant SIMPLE_DIALOG_BUTTON_OK. - */ public static final String SIMPLE_DIALOG_BUTTON_OK; - /** - * The constant SIMPLE_DIALOG_BUTTON_SELECT. - */ public static final String SIMPLE_DIALOG_BUTTON_SELECT; - /** - * The constant SIMPLE_DIALOG_BUTTON_ADD. - */ public static final String SIMPLE_DIALOG_BUTTON_ADD; - /** - * The constant SIMPLE_DIALOG_BUTTON_SAVE. - */ public static final String SIMPLE_DIALOG_BUTTON_SAVE; - /** - * The constant SIMPLE_DIALOG_BUTTON_GENERATE. - */ public static final String SIMPLE_DIALOG_BUTTON_GENERATE; - /** - * The constant SIMPLE_DIALOG_BUTTON_CREATE. - */ public static final String SIMPLE_DIALOG_BUTTON_CREATE; - /** - * The constant SIMPLE_DIALOG_BUTTON_APPLY. - */ public static final String SIMPLE_DIALOG_BUTTON_APPLY; - /** - * The constant SIMPLE_DIALOG_BUTTON_CANCEL. - */ public static final String SIMPLE_DIALOG_BUTTON_CANCEL; - /** - * The constant SIMPLE_DIALOG_BUTTON_CLOSE. - */ public static final String SIMPLE_DIALOG_BUTTON_CLOSE; - /** - * The constant SIMPLE_DIALOG_BUTTON_YES. - */ public static final String SIMPLE_DIALOG_BUTTON_YES; - /** - * The constant SIMPLE_DIALOG_BUTTON_NO. - */ public static final String SIMPLE_DIALOG_BUTTON_NO; - /** - * The constant EMPTY_MODEL_CREATOR_DESCRIPTION. - */ public static final String EMPTY_MODEL_CREATOR_DESCRIPTION; - /** - * The constant EMPTY_MODEL_CREATOR_TITLE. - */ public static final String EMPTY_MODEL_CREATOR_TITLE; - /** - * The constant EMPTY_SCENE_CREATOR_DESCRIPTION. - */ public static final String EMPTY_SCENE_CREATOR_DESCRIPTION; - /** - * The constant DEFAULT_SCENE_CREATOR_DESCRIPTION. - */ public static final String DEFAULT_SCENE_CREATOR_DESCRIPTION; - /** - * The constant EMPTY_SCENE_CREATOR_TITLE. - */ public static final String EMPTY_SCENE_CREATOR_TITLE; - /** - * The constant DEFAULT_SCENE_CREATOR_TITLE. - */ public static final String DEFAULT_SCENE_CREATOR_TITLE; - /** - * The constant GLSL_FILE_EDITOR_NAME. - */ public static final String GLSL_FILE_EDITOR_NAME; - /** - * The constant MATERIAL_DEFINITION_FILE_EDITOR_NAME. - */ public static final String MATERIAL_DEFINITION_FILE_EDITOR_NAME; - /** - * The constant GENERATE_TANGENTS_DIALOG_SPLIT_MIRRORED. - */ public static final String GENERATE_TANGENTS_DIALOG_SPLIT_MIRRORED; - /** - * The constant GENERATE_TANGENTS_DIALOG_ALGORITHM_LABEL. - */ public static final String GENERATE_TANGENTS_DIALOG_ALGORITHM_LABEL; - /** - * The constant GENERATE_TANGENTS_DIALOG_TITLE. - */ public static final String GENERATE_TANGENTS_DIALOG_TITLE; - /** - * The constant GENERATE_LOD_DIALOG_TITLE. - */ public static final String GENERATE_LOD_DIALOG_TITLE; - /** - * The constant GENERATE_LOD_DIALOG_METHOD. - */ public static final String GENERATE_LOD_DIALOG_METHOD; - /** - * The constant BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_NAME. - */ public static final String BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_NAME; - /** - * The constant BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_SPHERE. - */ public static final String BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_SPHERE; - /** - * The constant BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_SPHERE_RADIUS. - */ public static final String BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_SPHERE_RADIUS; - /** - * The constant BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_BOX. - */ public static final String BOUNDING_VOLUME_MODEL_PROPERTY_CONTROL_BOX; - /** - * The constant NODE_SELECTOR_DIALOG_TITLE. - */ public static final String NODE_SELECTOR_DIALOG_TITLE; - /** - * The constant GEOMETRY_SELECTOR_DIALOG_TITLE. - */ public static final String GEOMETRY_SELECTOR_DIALOG_TITLE; - /** - * The constant LIGHT_SELECTOR_DIALOG_TITLE. - */ public static final String LIGHT_SELECTOR_DIALOG_TITLE; - /** - * The constant LOG_VIEW_TITLE. - */ public static final String LOG_VIEW_TITLE; - /** - * The constant CREATE_SCENE_APP_STATE_DIALOG_TITLE. - */ public static final String CREATE_SCENE_APP_STATE_DIALOG_TITLE; - /** - * The constant CREATE_SCENE_APP_STATE_DIALOG_BUILT_IN. - */ public static final String CREATE_SCENE_APP_STATE_DIALOG_BUILT_IN; - /** - * The constant CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_BOX. - */ public static final String CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_BOX; - /** - * The constant CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_FIELD. - */ public static final String CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_FIELD; - /** - * The constant CREATE_SCENE_FILTER_DIALOG_TITLE. - */ public static final String CREATE_SCENE_FILTER_DIALOG_TITLE; - /** - * The constant CREATE_SCENE_FILTER_DIALOG_BUILT_IN. - */ public static final String CREATE_SCENE_FILTER_DIALOG_BUILT_IN; - /** - * The constant CREATE_SCENE_FILTER_DIALOG_CUSTOM_BOX. - */ public static final String CREATE_SCENE_FILTER_DIALOG_CUSTOM_BOX; - /** - * The constant CREATE_SCENE_FILTER_DIALOG_CUSTOM_FIELD. - */ public static final String CREATE_SCENE_FILTER_DIALOG_CUSTOM_FIELD; - /** - * The constant ADD_USER_DATA_DIALOG_TITLE. - */ public static final String ADD_USER_DATA_DIALOG_TITLE; - /** - * The constant CREATE_CUSTOM_CONTROL_DIALOG_TITLE. - */ public static final String CREATE_CUSTOM_CONTROL_DIALOG_TITLE; - /** - * The constant CREATE_CUSTOM_CONTROL_DIALOG_BUILT_IN. - */ public static final String CREATE_CUSTOM_CONTROL_DIALOG_BUILT_IN; - /** - * The constant CREATE_CUSTOM_CONTROL_DIALOG_CUSTOM_BOX. - */ public static final String CREATE_CUSTOM_CONTROL_DIALOG_CUSTOM_BOX; - /** - * The constant CREATE_CUSTOM_CONTROL_DIALOG_CUSTOM_FIELD. - */ public static final String CREATE_CUSTOM_CONTROL_DIALOG_CUSTOM_FIELD; - /** - * The constant ANALYTICS_CONFIRM_DIALOG_MESSAGE. - */ public static final String ANALYTICS_CONFIRM_DIALOG_MESSAGE; - /** - * The constant CREATE_BOX_COLLISION_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_BOX_COLLISION_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_SPHERE_COLLISION_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_SPHERE_COLLISION_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_CYLINDER_COLLISION_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_CYLINDER_COLLISION_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_CONE_COLLISION_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_CONE_COLLISION_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_CAPSULE_COLLISION_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_CAPSULE_COLLISION_SHAPE_DIALOG_TITLE; - /** - * The constant ADD_VEHICLE_WHEEL_DIALOG_TITLE. - */ public static final String ADD_VEHICLE_WHEEL_DIALOG_TITLE; - /** - * The constant CREATE_TERRAIN_DIALOG_TITLE. - */ public static final String CREATE_TERRAIN_DIALOG_TITLE; - /** - * The constant CREATE_TERRAIN_DIALOG_BASE_TEXTURE. - */ public static final String CREATE_TERRAIN_DIALOG_BASE_TEXTURE; - /** - * The constant CREATE_TERRAIN_DIALOG_FOLDER_ALPHA_TEXTURE. - */ public static final String CREATE_TERRAIN_DIALOG_FOLDER_ALPHA_TEXTURE; - /** - * The constant CREATE_TERRAIN_DIALOG_TOTAL_SIZE. - */ public static final String CREATE_TERRAIN_DIALOG_TOTAL_SIZE; - /** - * The constant CREATE_TERRAIN_DIALOG_PATCH_SIZE. - */ public static final String CREATE_TERRAIN_DIALOG_PATCH_SIZE; - /** - * The constant CREATE_TERRAIN_DIALOG_ALPHA_BLEND_TEXTURE_SIZE. - */ public static final String CREATE_TERRAIN_DIALOG_ALPHA_BLEND_TEXTURE_SIZE; - /** - * The constant CREATE_TERRAIN_DIALOG_TERRAIN_TYPE. - */ public static final String CREATE_TERRAIN_DIALOG_TERRAIN_TYPE; - /** - * The constant CREATE_TERRAIN_DIALOG_TERRAIN_TYPE_FLAT. - */ public static final String CREATE_TERRAIN_DIALOG_TERRAIN_TYPE_FLAT; - /** - * The constant CREATE_TERRAIN_DIALOG_TERRAIN_TYPE_IMAGE_BASED. - */ public static final String CREATE_TERRAIN_DIALOG_TERRAIN_TYPE_IMAGE_BASED; - /** - * The constant CREATE_TERRAIN_DIALOG_TERRAIN_TYPE_HILL. - */ public static final String CREATE_TERRAIN_DIALOG_TERRAIN_TYPE_HILL; - /** - * The constant CREATE_TERRAIN_DIALOG_HEIGHT_MAP_IMAGE. - */ public static final String CREATE_TERRAIN_DIALOG_HEIGHT_MAP_IMAGE; - /** - * The constant CREATE_TERRAIN_DIALOG_HEIGHT_SMOOTH. - */ public static final String CREATE_TERRAIN_DIALOG_HEIGHT_SMOOTH; - /** - * The constant CREATE_TERRAIN_DIALOG_HEIGHT_SCALE. - */ public static final String CREATE_TERRAIN_DIALOG_HEIGHT_SCALE; - /** - * The constant CREATE_TERRAIN_DIALOG_ITERATIONS. - */ public static final String CREATE_TERRAIN_DIALOG_ITERATIONS; - /** - * The constant CREATE_TERRAIN_DIALOG_FLATTENING. - */ public static final String CREATE_TERRAIN_DIALOG_FLATTENING; - /** - * The constant CREATE_TERRAIN_DIALOG_MIN_RADIUS. - */ public static final String CREATE_TERRAIN_DIALOG_MIN_RADIUS; - /** - * The constant CREATE_TERRAIN_DIALOG_MAX_RADIUS. - */ public static final String CREATE_TERRAIN_DIALOG_MAX_RADIUS; - /** - * The constant CREATE_PARTICLE_EMITTER_POINT_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_POINT_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_PARTICLE_EMITTER_BOX_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_BOX_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_PARTICLE_EMITTER_SPHERE_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_SPHERE_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_PARTICLE_EMITTER_CYLINDER_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_CYLINDER_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_PARTICLE_EMITTER_DOME_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_DOME_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_PARTICLE_EMITTER_QUAD_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_QUAD_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_PARTICLE_EMITTER_TORUS_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_TORUS_SHAPE_DIALOG_TITLE; - /** - * The constant CREATE_PARTICLE_EMITTER_TRIANGLE_SHAPE_DIALOG_TITLE. - */ public static final String CREATE_PARTICLE_EMITTER_TRIANGLE_SHAPE_DIALOG_TITLE; - /** - * The constant EDITING_COMPONENT_BRUSH_SIZE. - */ public static final String EDITING_COMPONENT_BRUSH_SIZE; - /** - * The constant EDITING_COMPONENT_BRUSH_POWER. - */ public static final String EDITING_COMPONENT_BRUSH_POWER; - /** - * The constant EDITING_COMPONENT_SMOOTHLY. - */ public static final String EDITING_COMPONENT_SMOOTHLY; - /** - * The constant EDITING_COMPONENT_LIMITED. - */ public static final String EDITING_COMPONENT_LIMITED; - /** - * The constant EDITING_COMPONENT_USE_MARKER. - */ public static final String EDITING_COMPONENT_USE_MARKER; - /** - * The constant EDITING_COMPONENT_LEVEL. - */ public static final String EDITING_COMPONENT_LEVEL; - /** - * The constant EDITING_COMPONENT_ROUGHNESS. - */ public static final String EDITING_COMPONENT_ROUGHNESS; - /** - * The constant EDITING_COMPONENT_FREQUENCY. - */ public static final String EDITING_COMPONENT_FREQUENCY; - /** - * The constant EDITING_COMPONENT_LACUNARITY. - */ public static final String EDITING_COMPONENT_LACUNARITY; - /** - * The constant EDITING_COMPONENT_OCTAVES. - */ public static final String EDITING_COMPONENT_OCTAVES; - /** - * The constant EDITING_COMPONENT_SCALE. - */ public static final String EDITING_COMPONENT_SCALE; - /** - * The constant EDITING_COMPONENT_TRI_PLANAR. - */ public static final String EDITING_COMPONENT_TRI_PLANAR; - /** - * The constant EDITING_COMPONENT_SHININESS. - */ public static final String EDITING_COMPONENT_SHININESS; - /** - * The constant EDITING_COMPONENT_LAYER. - */ public static final String EDITING_COMPONENT_LAYER; - /** - * The constant MODEL_CONVERTER_DIALOG_TITLE. - */ public static final String MODEL_CONVERTER_DIALOG_TITLE; - /** - * The constant MODEL_CONVERTER_DIALOG_RESULT_NAME. - */ public static final String MODEL_CONVERTER_DIALOG_RESULT_NAME; - /** - * The constant MODEL_CONVERTER_DIALOG_DESTINATION_FOLDER. - */ public static final String MODEL_CONVERTER_DIALOG_DESTINATION_FOLDER; - /** - * The constant MODEL_CONVERTER_DIALOG_EXPORT_MATERIALS. - */ public static final String MODEL_CONVERTER_DIALOG_EXPORT_MATERIALS; - /** - * The constant MODEL_CONVERTER_DIALOG_MATERIAL_FOLDER. - */ public static final String MODEL_CONVERTER_DIALOG_MATERIAL_FOLDER; - /** - * The constant MODEL_CONVERTER_DIALOG_OVERWRITE_MATERIALS. - */ public static final String MODEL_CONVERTER_DIALOG_OVERWRITE_MATERIALS; - /** - * The constant MODEL_CONVERTER_DIALOG_BUTTON_OK. - */ public static final String MODEL_CONVERTER_DIALOG_BUTTON_OK; - /** - * The constant FILE_DELETE_HANDLER_DELETE_MATERIALS. - */ public static final String FILE_DELETE_HANDLER_DELETE_MATERIALS; - /** - * The constant CHECK_NEW_VERSION_DIALOG_TITLE. - */ public static final String CHECK_NEW_VERSION_DIALOG_TITLE; - /** - * The constant CHECK_NEW_VERSION_DIALOG_HYPERLINK. - */ public static final String CHECK_NEW_VERSION_DIALOG_HYPERLINK; - /** - * The constant CHECK_NEW_VERSION_DIALOG_HEADER_TEXT. - */ public static final String CHECK_NEW_VERSION_DIALOG_HEADER_TEXT; - /** - * The constant EDITOR_SCRIPTING_COMPONENT_HEADERS. - */ public static final String EDITOR_SCRIPTING_COMPONENT_HEADERS; - /** - * The constant EDITOR_SCRIPTING_COMPONENT_BODY. - */ public static final String EDITOR_SCRIPTING_COMPONENT_BODY; - /** - * The constant EDITOR_SCRIPTING_COMPONENT_RUN. - */ public static final String EDITOR_SCRIPTING_COMPONENT_RUN; - /** - * The constant ABOUT_DIALOG_TITLE. - */ public static final String ABOUT_DIALOG_TITLE; - /** - * The constant ABOUT_DIALOG_VERSION. - */ public static final String ABOUT_DIALOG_VERSION; - /** - * The constant ABOUT_DIALOG_PROJECT_HOME. - */ public static final String ABOUT_DIALOG_PROJECT_HOME; - /** - * The constant ABOUT_DIALOG_FORUM_THREAD. - */ public static final String ABOUT_DIALOG_FORUM_THREAD; - /** - * The constant ABOUT_DIALOG_USED_LIBRARIES. - */ public static final String ABOUT_DIALOG_USED_LIBRARIES; - /** - * The constant ABOUT_DIALOG_USED_ICONS. - */ public static final String ABOUT_DIALOG_USED_ICONS; - /** - * The constant RESOURCE_PROPERTY_EDIT_CONTROL_NOTHING_IS_SELECTED. - */ public static final String RESOURCE_PROPERTY_EDIT_CONTROL_NOTHING_IS_SELECTED; - /** - * The constant PLUGINS_DIALOG_TITLE. - */ public static final String PLUGINS_DIALOG_TITLE; - /** - * The constant PLUGINS_DIALOG_FILE_CHOOSER_TITLE. - */ public static final String PLUGINS_DIALOG_FILE_CHOOSER_TITLE; - /** - * The constant PLUGINS_DIALOG_FILE_CHOOSER_FILTER. - */ public static final String PLUGINS_DIALOG_FILE_CHOOSER_FILTER; - /** - * The constant PLUGINS_DIALOG_QUESTION. - */ public static final String PLUGINS_DIALOG_QUESTION; static { @@ -2639,6 +899,7 @@ public class Messages { MODEL_NODE_TREE_ACTION_ANIMATION_PLAY = bundle.getString("ModelNodeTreeActionAnimationPlay"); MODEL_NODE_TREE_ACTION_ANIMATION_PLAY_SETTINGS = bundle.getString("ModelNodeTreeActionAnimationPlaySettings"); MODEL_NODE_TREE_ACTION_ANIMATION_STOP = bundle.getString("ModelNodeTreeActionAnimationStop"); + MODEL_NODE_TREE_ACTION_ANIMATION_PAUSE = bundle.getString("ModelNodeTreeActionAnimationPause"); MODEL_NODE_TREE_ACTION_ANIMATION_MANUAL_EXTRAXT_SUB_ANIMATION = bundle.getString("ModelNodeTreeActionAnimationManualExtractSubAnimation"); MODEL_NODE_TREE_ACTION_CREATE_AUDIO_NODE = bundle.getString("ModelNodeTreeActionCreateAudioNode"); MODEL_NODE_TREE_ACTION_AUDIO_PLAY = bundle.getString("ModelNodeTreeActionAudioPlay"); diff --git a/src/main/java/com/ss/editor/UpdateBSS.java b/src/main/java/com/ss/editor/UpdateBSS.java deleted file mode 100644 index 63e13b82..00000000 --- a/src/main/java/com/ss/editor/UpdateBSS.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ss.editor; - -import com.sun.javafx.css.Stylesheet; - -import java.io.File; -import java.io.IOException; - -/** - * The class to update bss files. - */ -public class UpdateBSS { - - /** - * The entry point of application. - * - * @param args the input arguments - * @throws IOException the io exception - */ - public static void main(String[] args) throws IOException { - Stylesheet.convertToBinary(new File("./src/main/resources/ui/css/base.css"), new File("./src/main/resources/ui/css/base.bss")); - Stylesheet.convertToBinary(new File("./src/main/resources/ui/css/shadow-color.css"), new File("./src/main/resources/ui/css/shadow-color.bss")); - Stylesheet.convertToBinary(new File("./src/main/resources/ui/css/dark-color.css"), new File("./src/main/resources/ui/css/dark-color.bss")); - Stylesheet.convertToBinary(new File("./src/main/resources/ui/css/light-color.css"), new File("./src/main/resources/ui/css/light-color.bss")); - Stylesheet.convertToBinary(new File("./src/main/resources/ui/css/external.css"), new File("./src/main/resources/ui/css/external.bss")); - Stylesheet.convertToBinary(new File("./src/main/resources/ui/css/custom_ids.css"), new File("./src/main/resources/ui/css/custom_ids.bss")); - Stylesheet.convertToBinary(new File("./src/main/resources/ui/css/custom_classes.css"), new File("./src/main/resources/ui/css/custom_classes.bss")); - } -} diff --git a/src/main/java/com/ss/editor/config/Config.java b/src/main/java/com/ss/editor/config/Config.java index 80e52acc..c76e27f7 100644 --- a/src/main/java/com/ss/editor/config/Config.java +++ b/src/main/java/com/ss/editor/config/Config.java @@ -18,28 +18,34 @@ * * @author JavaSaBr */ -public abstract class Config { +public final class Config { + /** + * The path to config file in classpath. + */ @NotNull private static final String CONFIG_RESOURCE_PATH = "/app-config.xml"; + /** + * The name of editor's folder in user home folder. + */ @NotNull private static final String SS_FOLDER_IN_USER_HOME = ".jme3-spaceshift-editor"; /** - * The constant TITLE. + * The editor's title. */ @NotNull public static final String TITLE = "jME3 SpaceShift Editor"; /** - * The constant APP_VERSION. + * The editor's version. */ @NotNull - public static final Version APP_VERSION = new Version("1.1.0"); + public static final Version APP_VERSION = new Version("1.2.0"); /** - * The constant STRING_VERSION. + * The string version. */ @NotNull public static final String STRING_VERSION = APP_VERSION.toString(); @@ -63,31 +69,37 @@ public abstract class Config { public static final OperatingSystem OPERATING_SYSTEM; /** - * Flag is for showing debug. + * The flat to enable debug mode. */ public static final boolean DEV_DEBUG; + /** - * The flag to enable debug of camera moving. + * The flat to enable camera debug mode. */ public static final boolean DEV_CAMERA_DEBUG; + /** - * The flag to enable debug of transforms controls. + * The flat to enable transformations debug mode. */ public static final boolean DEV_TRANSFORMS_DEBUG; + /** - * Flag is for showing debug of the JavaFX. + * The flat to enable JavaFX debug mode. */ public static final boolean DEV_DEBUG_JFX; + /** - * The flag to enable debug of mouse input from javaFX to jME. + * The flat to enable JavaFX mouse input debug mode. */ public static final boolean DEV_DEBUG_JFX_MOUSE_INPUT; + /** - * The flag to enable debug of key input from javaFX to jME. + * The flat to enable javaFX key input debug mode. */ public static final boolean DEV_DEBUG_JFX_KEY_INPUT; + /** - * Flag is for activating the PBR. + * The flat to enable PBR render. */ public static final boolean ENABLE_PBR; @@ -117,8 +129,7 @@ public abstract class Config { * * @return the path to the folder for writing log files. */ - @NotNull - public static Path getFolderForLog() { + public static @NotNull Path getFolderForLog() { return getAppFolderInUserHome().resolve("log"); } @@ -127,8 +138,7 @@ public static Path getFolderForLog() { * * @return the app folder in user home */ - @NotNull - public static Path getAppFolderInUserHome() { + public static @NotNull Path getAppFolderInUserHome() { final String userHome = System.getProperty("user.home"); return Paths.get(userHome, SS_FOLDER_IN_USER_HOME); } 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 da875108..c1b27973 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 @@ -119,6 +119,7 @@ public void convert(@NotNull final Path source, @NotNull final Path destination) * @param source the source file. * @param destination the target file. * @param overwrite is need to overwrite. + * @throws IOException if was problem with writing to the destination or reading from the source file. */ protected void convertImpl(@NotNull final Path source, @NotNull final Path destination, final boolean overwrite) throws IOException { 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 b60e5b41..d35185b2 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 @@ -84,7 +84,7 @@ private void convertImpl(@NotNull final Path source, @NotNull final ModelConvert final boolean isOverwrite = Files.exists(destination); final Path assetFile = notNull(getAssetFile(source), "Not found asset file for " + source); - final ModelKey modelKey = new ModelKey(assetFile.toString()); + final ModelKey modelKey = new ModelKey(toAssetPath(assetFile)); final AssetManager assetManager = EDITOR.getAssetManager(); final Spatial model = assetManager.loadAsset(modelKey); diff --git a/src/main/java/com/ss/editor/manager/ClasspathManager.java b/src/main/java/com/ss/editor/manager/ClasspathManager.java index 84dfa2fa..941dd31f 100644 --- a/src/main/java/com/ss/editor/manager/ClasspathManager.java +++ b/src/main/java/com/ss/editor/manager/ClasspathManager.java @@ -264,6 +264,8 @@ private void setClassesLoader(@Nullable final URLClassLoader classesLoader) { /** * Find all implementations of the interface class. * + * @param the type of an interface. + * @param interfaceClass the interface class. * @return the list of all available implementations. */ public @NotNull Array> findImplements(@NotNull final Class interfaceClass) { diff --git a/src/main/java/com/ss/editor/manager/FileIconManager.java b/src/main/java/com/ss/editor/manager/FileIconManager.java index 4a2bb1a1..555c3a3e 100644 --- a/src/main/java/com/ss/editor/manager/FileIconManager.java +++ b/src/main/java/com/ss/editor/manager/FileIconManager.java @@ -75,6 +75,7 @@ public class FileIconManager { EXTENSION_TO_CONTENT_TYPE.put("java", "application-x-java"); EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_OBJECT, "jme3"); + EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_SHADER_NODE, "vector"); EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_SCENE, "sse"); EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_MATERIAL, "parquet"); EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_MATERIAL_DEFINITION, "text"); @@ -107,9 +108,6 @@ public class FileIconManager { MIME_TYPES_FOLDERS.add(Paths.get("/ui/icons/filetypes/")); } - private static boolean supportedRepaint = true; - - @Nullable private static FileIconManager instance; @@ -118,8 +116,8 @@ public class FileIconManager { * * @return the instance */ - @NotNull - public static FileIconManager getInstance() { + @FromAnyThread + public static @NotNull FileIconManager getInstance() { if (instance == null) instance = new FileIconManager(); return instance; } @@ -174,90 +172,115 @@ public void register(@NotNull final BiFunction iconFinder) * @param size the icon size. * @return the icon. */ - @NotNull @FXThread - public Image getIcon(@NotNull final Path path, int size) { + public @NotNull Image getIcon(@NotNull final Path path, int size) { + return getIcon(path, Files.isDirectory(path), true, size); + } - final String extension = FileUtils.getExtension(path); + /** + * Get an icon to a file. + * + * @param path the file. + * @param directory the directory. + * @param tryToGetContentType true of we can try to get content type of the file. + * @param size the icon size. + * @return the icon. + */ + @FXThread + public @NotNull Image getIcon(@NotNull final Path path, final boolean directory, final boolean tryToGetContentType, + int size) { + + final String extension = directory ? "folder" : FileUtils.getExtension(path); final Array> iconFinders = getIconFinders(); + String url = extensionToUrl.get(extension); + + if (url != null) { + return getImage(url, size); + } + if (!iconFinders.isEmpty()) { for (final BiFunction iconFinder : iconFinders) { + url = iconFinder.apply(path, extension); - final String url = iconFinder.apply(path, extension); final ClassLoader classLoader = iconFinder.getClass().getClassLoader(); - if (url == null || !EditorUtil.checkExists(url, classLoader)) { continue; } - return buildImage(url, EditorUtil.getInputStream(url, classLoader), size); + extensionToUrl.put(extension, url); + + return getImage(url, classLoader, size); } } - String contentType = EXTENSION_TO_CONTENT_TYPE.get(extension); + String contentType; - if (contentType == null) { - try { - contentType = Files.probeContentType(path); - } catch (IOException e) { - LOGGER.warning(e); + if (directory) { + contentType = "folder"; + } else { + + contentType = EXTENSION_TO_CONTENT_TYPE.get(extension); + + if (contentType == null && tryToGetContentType) { + try { + contentType = Files.probeContentType(path); + } catch (final IOException e) { + LOGGER.warning(e); + } } } - if (Files.isDirectory(path)) contentType = "folder"; - if (contentType != null) contentType = contentType.replace("/", "-"); + if (contentType != null) { + contentType = contentType.replace("/", "-"); + } if (contentType == null) { LOGGER.debug("not found content type for " + path); contentType = "none"; } - String url = extensionToUrl.get(extension); + for (final Path mimeTypes : MIME_TYPES_FOLDERS) { - if (url == null) { - for (final Path mimeTypes : MIME_TYPES_FOLDERS) { + Path iconPath = mimeTypes.resolve(contentType + ".svg"); + url = toAssetPath(iconPath); - Path iconPath = mimeTypes.resolve(contentType + ".svg"); + if (!EditorUtil.checkExists(url)) { + contentType = EXTENSION_TO_CONTENT_TYPE.get(extension); + iconPath = mimeTypes.resolve(contentType + ".svg"); url = toAssetPath(iconPath); + } - if (!EditorUtil.checkExists(url)) { - contentType = EXTENSION_TO_CONTENT_TYPE.get(extension); - iconPath = mimeTypes.resolve(contentType + ".svg"); - url = toAssetPath(iconPath); - } - - if (!EditorUtil.checkExists(url)) { - contentType = EXTENSION_TO_CONTENT_TYPE.get(extension); - iconPath = mimeTypes.resolve(contentType + ".png"); - url = toAssetPath(iconPath); - } - - if (EditorUtil.checkExists(url)) { - break; - } + if (!EditorUtil.checkExists(url)) { + contentType = EXTENSION_TO_CONTENT_TYPE.get(extension); + iconPath = mimeTypes.resolve(contentType + ".png"); + url = toAssetPath(iconPath); } - if (url == null || !EditorUtil.checkExists(url)) { - LOGGER.warning("not found image for contentType " + contentType + " and path " + path); - url = "/ui/icons/svg/document.svg"; + if (EditorUtil.checkExists(url)) { + break; } + } - extensionToUrl.put(extension, url); + if (url == null || !EditorUtil.checkExists(url)) { + LOGGER.warning("not found image for contentType " + contentType + " and path " + path); + url = "/ui/icons/svg/document.svg"; } + extensionToUrl.put(extension, url); + return getImage(url, size); } + /** * Get an image by an URL. * * @param url the url. * @return the image. */ - @NotNull @FXThread - public Image getImage(@NotNull final String url) { + public @NotNull Image getImage(@NotNull final String url) { return getImage(url, 16); } @@ -268,12 +291,24 @@ public Image getImage(@NotNull final String url) { * @param size the size. * @return the image. */ - @NotNull @FXThread - public Image getImage(@NotNull final String url, final int size) { + public @NotNull Image getImage(@NotNull final String url, final int size) { return getImage(url, size, true); } + /** + * Get an image by an URL. + * + * @param url the url. + * @param classLoader the class loader. + * @param size the size. + * @return the image. + */ + @FXThread + public @NotNull Image getImage(@NotNull final String url, @NotNull final ClassLoader classLoader, final int size) { + return getImage(url, classLoader, size, true); + } + /** * Get an image by an URL. * @@ -282,22 +317,39 @@ public Image getImage(@NotNull final String url, final int size) { * @param useCache true if need to use cache. * @return the image. */ - @NotNull @FXThread - public Image getImage(@NotNull final String url, final int size, final boolean useCache) { - if (!useCache) return buildImage(url, size); + public @NotNull Image getImage(@NotNull final String url, final int size, final boolean useCache) { + return getImage(url, getClass().getClassLoader(), size, useCache); + } + + /** + * Get an image by an URL. + * + * @param url the url. + * @param classLoader the class loader. + * @param size the size. + * @param useCache true if need to use cache. + * @return the image. + */ + @FXThread + public @NotNull Image getImage(@NotNull final String url, @NotNull final ClassLoader classLoader, final int size, + final boolean useCache) { + + if (!useCache) return buildImage(url, classLoader, size); + final ObjectDictionary cache = imageCache.get(size, DictionaryFactory::newObjectDictionary); - final Image image = cache.get(url, () -> buildImage(url, size)); + final Image image = cache.get(url, () -> buildImage(url, classLoader, size)); + return notNull(image); } - @NotNull - private Image buildImage(@NotNull final String url, final int size) { - return buildImage(url, null, size); + private @NotNull Image buildImage(@NotNull final String url, @NotNull final ClassLoader classLoader, + final int size) { + final InputStream in = EditorUtil.getInputStream(url, classLoader); + return buildImage(url, in, size); } - @NotNull - private Image buildImage(@NotNull final String url, @Nullable final InputStream in, final int size) { + private @NotNull Image buildImage(@NotNull final String url, @Nullable final InputStream in, final int size) { final Image image; @@ -315,7 +367,7 @@ private Image buildImage(@NotNull final String url, @Nullable final InputStream final EditorConfig config = EditorConfig.getInstance(); final CssColorTheme theme = config.getTheme(); - if (theme.needRepaintIcons() && supportedRepaint) { + if (theme.needRepaintIcons()) { try { final Color iconColor = theme.getIconColor(); @@ -338,8 +390,7 @@ private Image buildImage(@NotNull final String url, @Nullable final InputStream return coloredImage; } catch (final Throwable e) { - e.printStackTrace(); - supportedRepaint = false; + LOGGER.warning(e); } } @@ -354,16 +405,16 @@ private Image buildImage(@NotNull final String url, @Nullable final InputStream * @param image the image. * @return the original image. */ - @NotNull - public Image getOriginal(@NotNull final Image image) { + @FromAnyThread + public @NotNull Image getOriginal(@NotNull final Image image) { return notNull(originalImageCache.get(image), "not found original for " + image.impl_getUrl()); } /** * @return the list of icon finders. */ - @NotNull - private Array> getIconFinders() { + @FromAnyThread + private @NotNull Array> getIconFinders() { return iconFinders; } } diff --git a/src/main/java/com/ss/editor/manager/JMEFilePreviewManager.java b/src/main/java/com/ss/editor/manager/JMEFilePreviewManager.java index 5c8b220b..75e11298 100644 --- a/src/main/java/com/ss/editor/manager/JMEFilePreviewManager.java +++ b/src/main/java/com/ss/editor/manager/JMEFilePreviewManager.java @@ -38,6 +38,7 @@ 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 javafx.scene.image.ImageView; @@ -92,8 +93,8 @@ public class JMEFilePreviewManager extends AbstractControl { * * @return the instance */ - @NotNull - public static JMEFilePreviewManager getInstance() { + @FromAnyThread + public static @NotNull JMEFilePreviewManager getInstance() { if (instance == null) { synchronized (JMEFilePreviewManager.class) { if (instance == null) { @@ -105,11 +106,12 @@ public static JMEFilePreviewManager getInstance() { } /** - * Is jme file boolean. + * Check the file. * * @param file the file * @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); @@ -117,17 +119,44 @@ public static boolean isJmeFile(@Nullable final Path file) { } /** - * Is audio file boolean. + * Check the file by the asset path. * - * @param file the file + * @param assetPath the asset path. * @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); + } + + /** + * Check the file. + * + * @param file the file + * @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); } + /** + * Check the asset path. + * + * @param assetPath the asset path + * @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); + } + @NotNull private final JobProgressAdapter probeHandler = new JobProgressAdapter() { @@ -188,6 +217,7 @@ private JMEFilePreviewManager() { } @Override + @JMEThread protected void controlUpdate(final float tpf) { if (frame == 2) { @@ -206,6 +236,7 @@ private void notifyProbeComplete() { } @Override + @JMEThread protected void controlRender(@NotNull final RenderManager renderManager, @NotNull final ViewPort viewPort) { } @@ -223,8 +254,18 @@ public void show(@NotNull final Path file, final int fitWidth, final int fitHeig final Path assetFile = notNull(getAssetFile(file), "File can't be null."); final String path = toAssetPath(assetFile); - final String extension = getExtension(assetFile); + showPreview(path, getExtension(assetFile)); + } + + /** + * Show a preview of the file by the asset path. + * + * @param path the asset path. + * @param extension the extension. + */ + @FromAnyThread + private void showPreview(@NotNull final String path, @NotNull final String extension) { if (FileExtensions.JME_MATERIAL.equals(extension)) { EDITOR_THREAD_EXECUTOR.addToExecute(() -> showMaterial(path)); } else if (FileExtensions.JME_OBJECT.equals(extension)) { @@ -234,6 +275,20 @@ public void show(@NotNull final Path file, final int fitWidth, final int fitHeig } } + /** + * Show a file. + * + * @param assetPath the asset path. + * @param fitWidth the target width of preview. + * @param fitHeight the target height of preview. + */ + @FromAnyThread + public void show(@NotNull final String assetPath, final int fitWidth, final int fitHeight) { + imageView.setFitHeight(fitHeight); + imageView.setFitWidth(fitWidth); + showPreview(assetPath, getExtension(assetPath)); + } + /** * Show a j3o object. * diff --git a/src/main/java/com/ss/editor/manager/JavaFXImageManager.java b/src/main/java/com/ss/editor/manager/JavaFXImageManager.java index fac48ffd..66250759 100644 --- a/src/main/java/com/ss/editor/manager/JavaFXImageManager.java +++ b/src/main/java/com/ss/editor/manager/JavaFXImageManager.java @@ -1,5 +1,6 @@ package com.ss.editor.manager; +import static com.ss.rlib.util.FileUtils.getExtension; import static com.ss.rlib.util.array.ArrayFactory.asArray; import static java.awt.Image.SCALE_DEFAULT; import static java.nio.file.StandardOpenOption.*; @@ -41,7 +42,6 @@ import java.io.IOException; import java.io.OutputStream; import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileTime; @@ -94,30 +94,43 @@ public class JavaFXImageManager { } /** - * Is image boolean. + * Check the file. * * @param file the file * @return true if the file is image. */ + @FromAnyThread public static boolean isImage(@Nullable final Path file) { if (file == null) return false; - final String extension = FileUtils.getExtension(file); + final String extension = getExtension(file); return IMAGE_FORMATS.contains(extension); } - @Nullable - private static JavaFXImageManager instance; - /** - * Gets instance. + * Check the file by the asset path. * - * @return the instance + * @param assetPath the asset path + * @return true if the file is image. */ + @FromAnyThread + public static boolean isImage(@Nullable final String assetPath) { + if (assetPath == null) return false; + final String extension = getExtension(assetPath); + return IMAGE_FORMATS.contains(extension); + } + + @Nullable + private static JavaFXImageManager instance; + + @FromAnyThread public static @NotNull JavaFXImageManager getInstance() { if (instance == null) instance = new JavaFXImageManager(); return instance; } + /** + * The cache of small images. + */ @NotNull private IntegerDictionary>> smallImageCache; @@ -238,41 +251,18 @@ private void putImageToCache(@NotNull final String path, @NotNull final Image im if (image != null) return image; } - final Array<@NotNull ClassLoader> classLoaders = ArrayFactory.newArray(ClassLoader.class); - classLoaders.add(getClass().getClassLoader()); + final ResourceManager resourceManager = ResourceManager.getInstance(); + URL url = resourceManager.tryToFindResource(resourcePath); - final ClasspathManager classpathManager = ClasspathManager.getInstance(); - final URLClassLoader classesLoader = classpathManager.getClassesLoader(); - final URLClassLoader librariesLoader = classpathManager.getLibrariesLoader(); - - if (classesLoader != null) { - classLoaders.add(classesLoader); - } - - if (librariesLoader != null) { - classLoaders.add(librariesLoader); - } - - final PluginManager pluginManager = PluginManager.getInstance(); - pluginManager.handlePlugins(plugin -> classLoaders.add(plugin.getClassLoader())); - - final String altResourcePath = "/" + resourcePath; + if (url == null) { - URL url = null; + final Path realFile = EditorUtil.getRealFile(resourcePath); - for (final ClassLoader classLoader : classLoaders) { - url = classLoader.getResource(resourcePath); - if (url != null) break; - url = classLoader.getResource(altResourcePath); - if (url != null) break; - } - - if (url == null) { - url = getClass().getResource("/" + resourcePath); - } + if (realFile == null || !Files.exists(realFile)) { + return Icons.IMAGE_512; + } - if (url == null) { - return Icons.IMAGE_512; + url = FileUtils.toUrl(realFile); } final Image image = getImagePreview(url, null, width, height); @@ -307,7 +297,7 @@ private void putImageToCache(@NotNull final String path, @NotNull final Image im Utils.run(cacheFile, first -> Files.createDirectories(first.getParent())); - final String extension = FileUtils.getExtension(externalForm); + final String extension = getExtension(externalForm); if (FX_FORMATS.contains(extension)) { return readFXImage(width, height, externalForm, cacheFile); diff --git a/src/main/java/com/ss/editor/manager/ResourceManager.java b/src/main/java/com/ss/editor/manager/ResourceManager.java index 7d1d9298..e6a6f0a2 100644 --- a/src/main/java/com/ss/editor/manager/ResourceManager.java +++ b/src/main/java/com/ss/editor/manager/ResourceManager.java @@ -3,7 +3,6 @@ import static com.ss.editor.FileExtensions.*; import static com.ss.editor.util.EditorUtil.*; import static com.ss.rlib.util.ArrayUtils.contains; -import static com.ss.rlib.util.ArrayUtils.move; import static com.ss.rlib.util.FileUtils.getFiles; import static com.ss.rlib.util.FileUtils.toUrl; import static com.ss.rlib.util.ObjectUtils.notNull; @@ -83,13 +82,8 @@ public class ResourceManager extends EditorThread implements AssetEventListener @Nullable private static ResourceManager instance; - /** - * Gets instance. - * - * @return the instance - */ - @NotNull - public static ResourceManager getInstance() { + @FromAnyThread + public static @NotNull ResourceManager getInstance() { if (instance == null) instance = new ResourceManager(); return instance; } @@ -101,34 +95,34 @@ public static ResourceManager getInstance() { private final ObjectDictionary assetCacheTable; /** - * The list of additional ENVs. + * The table with interested resources. */ @NotNull - private final Array additionalEnvs; + private final ObjectDictionary> interestedResources; /** - * The list of an additional classpath. + * The table with interested resources in the classpath. */ @NotNull - private final Array classLoaders; + private final ObjectDictionary> interestedResourcesInClasspath; /** - * The list of resources in the classpath. + * The list of additional ENVs. */ @NotNull - private final Array resourcesInClasspath; + private final Array additionalEnvs; /** - * The list of material definitions in the classpath. + * The list of an additional classpath. */ @NotNull - private final Array materialDefinitionsInClasspath; + private final Array classLoaders; /** - * The list of available material definitions in the classpath. + * The list of resources in the classpath. */ @NotNull - private final Array materialDefinitions; + private final Array resourcesInClasspath; /** * The list of keys for watching to folders. @@ -149,13 +143,12 @@ private ResourceManager() { this.watchKeys = ArrayFactory.newArray(WatchKey.class); this.classLoaders = ArrayFactory.newArray(URLClassLoader.class); this.resourcesInClasspath = classpathManager.getAllResources(); - this.materialDefinitionsInClasspath = ArrayFactory.newArray(String.class); - this.materialDefinitions = ArrayFactory.newArray(String.class); - - prepareClasspathResources(); + this.interestedResources = DictionaryFactory.newObjectDictionary(); + this.interestedResourcesInClasspath = DictionaryFactory.newObjectDictionary(); final ExecutorManager executorManager = ExecutorManager.getInstance(); executorManager.addFXTask(() -> { + prepareClasspathResources(); final FXEventManager fxEventManager = FXEventManager.getInstance(); fxEventManager.addEventHandler(ChangedCurrentAssetFolderEvent.EVENT_TYPE, event -> processChangeAsset()); fxEventManager.addEventHandler(RequestedRefreshAssetEvent.EVENT_TYPE, event -> processRefreshAsset()); @@ -169,13 +162,99 @@ private ResourceManager() { assetManager.addAssetEventListener(this); }); + registerInterestedFileType(FileExtensions.JME_MATERIAL_DEFINITION); + registerInterestedFileType(FileExtensions.JME_SHADER_NODE); updateAdditionalEnvs(); start(); } + /** + * Try to find a resource by the resource path. + * + * @param resourcePath the resource path. + * @return the URL or null. + */ + @FromAnyThread + public @Nullable URL tryToFindResource(@NotNull final String resourcePath) { + + final Array<@NotNull ClassLoader> classLoaders = ArrayFactory.newArray(ClassLoader.class); + classLoaders.add(getClass().getClassLoader()); + + final ClasspathManager classpathManager = ClasspathManager.getInstance(); + final URLClassLoader classesLoader = classpathManager.getClassesLoader(); + final URLClassLoader librariesLoader = classpathManager.getLibrariesLoader(); + + if (classesLoader != null) { + classLoaders.add(classesLoader); + } + + if (librariesLoader != null) { + classLoaders.add(librariesLoader); + } + + final PluginManager pluginManager = PluginManager.getInstance(); + pluginManager.handlePlugins(plugin -> classLoaders.add(plugin.getClassLoader())); + + final String altResourcePath = "/" + resourcePath; + + URL url = null; + + for (final ClassLoader classLoader : classLoaders) { + url = classLoader.getResource(resourcePath); + if (url != null) break; + url = classLoader.getResource(altResourcePath); + if (url != null) break; + } + + if (url == null) { + url = getClass().getResource("/" + resourcePath); + } + + return url; + } + + /** + * @return the table with interested resources. + */ + @FromAnyThread + private @NotNull ObjectDictionary> getInterestedResources() { + return interestedResources; + } + + /** + * @return the table with interested resources in the classpath. + */ + @FromAnyThread + private @NotNull ObjectDictionary> getInterestedResourcesInClasspath() { + return interestedResourcesInClasspath; + } + + /** + * Register the file type of interested resources. + * + * @param fileExtension the file type. + */ + public synchronized void registerInterestedFileType(@NotNull final String fileExtension) { + + ObjectDictionary> resources = getInterestedResources(); + + if(!resources.containsKey(fileExtension)) { + resources.put(fileExtension, ArrayFactory.newArray(String.class)); + } + + resources = getInterestedResourcesInClasspath(); + + if(!resources.containsKey(fileExtension)) { + resources.put(fileExtension, ArrayFactory.newArray(String.class)); + } + } + @Override @FromAnyThread public synchronized void assetLoaded(@NotNull final AssetKey key) { + if (key.getCacheType() == null) { + return; + } final String extension = key.getExtension(); if (StringUtils.isEmpty(extension)) return; @@ -188,6 +267,9 @@ public synchronized void assetLoaded(@NotNull final AssetKey key) { @Override @FromAnyThread public synchronized void assetRequested(@NotNull final AssetKey key) { + if (key.getCacheType() == null) { + return; + } final String extension = key.getExtension(); if (StringUtils.isEmpty(extension)) return; @@ -242,16 +324,16 @@ public synchronized void updateAdditionalEnvs() { * * @return the list. */ - @NotNull - public Array getAdditionalEnvs() { + @FromAnyThread + public @NotNull Array getAdditionalEnvs() { return additionalEnvs; } /** * @return the table with last modify dates. */ - @NotNull - private ObjectDictionary getAssetCacheTable() { + @FromAnyThread + private @NotNull ObjectDictionary getAssetCacheTable() { return assetCacheTable; } @@ -265,13 +347,17 @@ private synchronized void processEvent(@NotNull final DeletedFileEvent event) { final Path file = event.getFile(); final String extension = FileUtils.getExtension(file); + final ObjectDictionary> interestedResources = getInterestedResources(); + final Array resources = interestedResources.get(extension); + final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file); final String assetPath = toAssetPath(assetFile); - if (extension.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) { - final Array materialDefinitions = getMaterialDefinitions(); - materialDefinitions.fastRemove(assetPath); - } else if (extension.endsWith(FileExtensions.JAVA_LIBRARY)) { + if (resources != null) { + resources.fastRemove(assetPath); + } + + if (extension.endsWith(FileExtensions.JAVA_LIBRARY)) { final Editor editor = Editor.getInstance(); final AssetManager assetManager = editor.getAssetManager(); @@ -297,82 +383,79 @@ private synchronized void processEvent(@NotNull final CreatedFileEvent event) { handleFile(event.getFile()); } - /** - * @return the list of material definitions in the classpath. - */ - @NotNull - private Array getMaterialDefinitionsInClasspath() { - return materialDefinitionsInClasspath; - } - /** * @return the list of resources in the classpath. */ - @NotNull - private Array getResourcesInClasspath() { + @FromAnyThread + private @NotNull Array getResourcesInClasspath() { return resourcesInClasspath; } /** * Prepare classpath resources. */ + @FromAnyThread private void prepareClasspathResources() { - final Array materialDefinitionsInClasspath = getMaterialDefinitionsInClasspath(); + + final ObjectDictionary> resources = getInterestedResourcesInClasspath(); final Array resourcesInClasspath = getResourcesInClasspath(); resourcesInClasspath.forEach(resource -> { - if (resource.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) { - materialDefinitionsInClasspath.add(resource); + final String extension = FileUtils.getExtension(resource); + final Array toStore = resources.get(extension); + if (toStore != null) { + toStore.add(resource); } }); } - /** - * @return the list of available material definitions in the classpath. - */ - @NotNull - private Array getMaterialDefinitions() { - return materialDefinitions; - } - /** * Gets class loaders. * * @return the list of an additional classpath. */ - @NotNull - public Array getClassLoaders() { + @FromAnyThread + public @NotNull Array getClassLoaders() { return classLoaders; } /** - * Gets available material definitions. + * Get available resources by the file extension. * + * @param extension the interested extension. * @return the list of all available material definitions. */ - @NotNull @FromAnyThread - public synchronized Array getAvailableMaterialDefinitions() { + public synchronized @NotNull Array getAvailableResources(@NotNull final String extension) { final Array result = ArrayFactory.newArray(String.class); - addAvailableMaterialDefinitionsTo(result); + addAvailableResources(result, extension); return result; } /** - * Add available material definitions to the result array. + * Add available interested resources to the result array by the file extension. * - * @param result the result + * @param result the array to store result. + * @param extension the interested extension. */ @FromAnyThread - public synchronized void addAvailableMaterialDefinitionsTo(@NotNull final Array result) { + public synchronized void addAvailableResources(@NotNull final Array result, + @NotNull final String extension) { - final Array materialDefinitions = getMaterialDefinitions(); + final ObjectDictionary> resourcesInClasspath = getInterestedResourcesInClasspath(); + final ObjectDictionary> resources = getInterestedResources(); - move(materialDefinitions, result, false); + final Array inAsset = resources.get(extension); + final Array inClassPath = resourcesInClasspath.get(extension); - final Array materialDefinitionsInClasspath = getMaterialDefinitionsInClasspath(); - materialDefinitionsInClasspath.forEach(result, (resource, container) -> { - if (!container.contains(resource)) container.add(resource); - }); + if (inAsset != null) { + result.addAll(inAsset); + } + + if (inClassPath != null) { + inClassPath.forEach(result, + (resource, toStore) -> !toStore.contains(resource), + (resource, toStore) -> toStore.add(resource)); + } result.sort(STRING_ARRAY_COMPARATOR); } @@ -399,8 +482,8 @@ public synchronized void reload() { assetManager.clearCache(); - final Array materialDefinitions = getMaterialDefinitions(); - materialDefinitions.clear(); + final ObjectDictionary> interestedResources = getInterestedResources(); + interestedResources.forEach((extension, resources) -> resources.clear()); final EditorConfig editorConfig = EditorConfig.getInstance(); final Path currentAsset = editorConfig.getCurrentAsset(); @@ -420,6 +503,7 @@ public synchronized void reload() { } } + @FromAnyThread private static void registerFiles(@NotNull final Array watchKeys, @NotNull final Path file) { watchKeys.add(get(file, toRegister -> toRegister.register(WATCH_SERVICE, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY))); } @@ -433,11 +517,15 @@ private synchronized void handleFile(@NotNull final Path file) { final String extension = FileUtils.getExtension(file); - if (extension.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) { + final ObjectDictionary> interestedResources = getInterestedResources(); + final Array toStore = interestedResources.get(extension); + + if (toStore != null) { final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file); - final Array materialDefinitions = getMaterialDefinitions(); - materialDefinitions.add(toAssetPath(assetFile)); - } else if (extension.endsWith(FileExtensions.JAVA_LIBRARY)) { + toStore.add(toAssetPath(assetFile)); + } + + if (extension.endsWith(FileExtensions.JAVA_LIBRARY)) { final Editor editor = Editor.getInstance(); final AssetManager assetManager = editor.getAssetManager(); @@ -526,9 +614,8 @@ public void run() { * @param path the file. * @return the watch key or null. */ - @Nullable @FromAnyThread - private synchronized WatchKey findWatchKey(@NotNull final Path path) { + private synchronized @Nullable WatchKey findWatchKey(@NotNull final Path path) { final Array watchKeys = getWatchKeys(); return watchKeys.search(path, (watchKey, toCheck) -> watchKey.watchable().equals(toCheck)); } @@ -562,6 +649,7 @@ private synchronized void registerWatchKey(@NotNull final Path path) { /** * Handle refreshing asset folder. */ + @FromAnyThread private void processRefreshAsset() { EXECUTOR_MANAGER.addBackgroundTask(this::reload); } @@ -569,6 +657,7 @@ private void processRefreshAsset() { /** * Handle changing asset folder. */ + @FromAnyThread private void processChangeAsset() { EXECUTOR_MANAGER.addBackgroundTask(this::reload); } @@ -576,8 +665,8 @@ private void processChangeAsset() { /** * @return the list of keys for watching to folders. */ - @NotNull - private Array getWatchKeys() { + @FromAnyThread + private @NotNull Array getWatchKeys() { return watchKeys; } } diff --git a/src/main/java/com/ss/editor/manager/WorkspaceManager.java b/src/main/java/com/ss/editor/manager/WorkspaceManager.java index 8e10998f..56df742b 100644 --- a/src/main/java/com/ss/editor/manager/WorkspaceManager.java +++ b/src/main/java/com/ss/editor/manager/WorkspaceManager.java @@ -42,8 +42,7 @@ public class WorkspaceManager { * * @return the instance */ - @NotNull - public static WorkspaceManager getInstance() { + public static @NotNull WorkspaceManager getInstance() { if (instance == null) instance = new WorkspaceManager(); return instance; } @@ -62,8 +61,7 @@ private WorkspaceManager() { /** * @return the table of workspaces. */ - @NotNull - private ObjectDictionary getWorkspaces() { + private @NotNull ObjectDictionary getWorkspaces() { return workspaces; } @@ -72,9 +70,8 @@ private ObjectDictionary getWorkspaces() { * * @return the current workspace or null. */ - @Nullable @FromAnyThread - public Workspace getCurrentWorkspace() { + public @Nullable Workspace getCurrentWorkspace() { final EditorConfig editorConfig = EditorConfig.getInstance(); final Path currentAsset = editorConfig.getCurrentAsset(); @@ -88,9 +85,8 @@ public Workspace getCurrentWorkspace() { * * @return the workspace. */ - @NotNull @FromAnyThread - private synchronized Workspace getWorkspace(@NotNull final Path assetFolder) { + private synchronized @NotNull Workspace getWorkspace(@NotNull final Path assetFolder) { final ObjectDictionary workspaces = getWorkspaces(); final Workspace exists = workspaces.get(assetFolder); diff --git a/src/main/java/com/ss/editor/model/undo/editor/MaterialChangeConsumer.java b/src/main/java/com/ss/editor/model/undo/editor/MaterialChangeConsumer.java deleted file mode 100644 index 5a58e738..00000000 --- a/src/main/java/com/ss/editor/model/undo/editor/MaterialChangeConsumer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ss.editor.model.undo.editor; - -import com.jme3.material.Material; -import com.ss.editor.annotation.FromAnyThread; -import org.jetbrains.annotations.NotNull; - -/** - * The interface to notify about any changes of materials. - * - * @author JavaSaBr - */ -public interface MaterialChangeConsumer extends ChangeConsumer{ - - /** - * Gets current material. - * - * @return the current material. - */ - @FromAnyThread - @NotNull Material getCurrentMaterial(); -} 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 bd072391..20f6ad80 100644 --- a/src/main/java/com/ss/editor/model/workspace/Workspace.java +++ b/src/main/java/com/ss/editor/model/workspace/Workspace.java @@ -4,6 +4,7 @@ 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 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; @@ -19,12 +20,9 @@ import java.io.IOException; import java.io.Serializable; -import java.nio.ByteBuffer; -import java.nio.channels.SeekableByteChannel; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; -import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -93,7 +91,8 @@ public Workspace() { /** * Notify about finished restoring this workspace. */ - public void notifyRestored() { + @FromAnyThread + public synchronized void notifyRestored() { if (openedFiles == null) { openedFiles = new HashMap<>(); @@ -116,7 +115,8 @@ public void notifyRestored() { * * @return the current edited file. */ - public @Nullable String getCurrentEditedFile() { + @FromAnyThread + public synchronized @Nullable String getCurrentEditedFile() { return currentEditedFile; } @@ -125,6 +125,7 @@ public void notifyRestored() { * * @param file the current edited file. */ + @FromAnyThread public synchronized void updateCurrentEditedFile(@Nullable final Path file) { if (file == null) { @@ -139,14 +140,16 @@ public synchronized void updateCurrentEditedFile(@Nullable final Path file) { /** * @return the table with states of editors. */ - private @NotNull Map getEditorStateMap() { + @FromAnyThread + private synchronized @NotNull Map getEditorStateMap() { return notNull(editorStateMap); } /** * @return the list of expanded folders. */ - private @NotNull List getExpandedFolders() { + @FromAnyThread + private synchronized @NotNull List getExpandedFolders() { return notNull(expandedFolders); } @@ -155,6 +158,7 @@ public synchronized void updateCurrentEditedFile(@Nullable final Path file) { * * @return the list of expanded absolute folders. */ + @FromAnyThread public synchronized @NotNull Array getExpandedAbsoluteFolders() { final Array result = ArrayFactory.newArray(Path.class); @@ -171,6 +175,7 @@ public synchronized void updateCurrentEditedFile(@Nullable final Path file) { * * @param folders the folders */ + @FromAnyThread public synchronized void updateExpandedFolders(@NotNull final Array folders) { final List expandedFolders = getExpandedFolders(); @@ -190,6 +195,7 @@ public synchronized void updateExpandedFolders(@NotNull final Array folder * @param stateFactory the state factory. * @return the state of the editor. */ + @FromAnyThread public synchronized @NotNull T getEditorState(@NotNull final Path file, @NotNull final Supplier stateFactory) { @@ -213,6 +219,7 @@ public synchronized void updateExpandedFolders(@NotNull final Array folder * * @param file the file. */ + @FromAnyThread public synchronized void removeEditorState(@NotNull final Path file) { final Path assetFile = getAssetFile(getAssetFolder(), file); @@ -229,7 +236,8 @@ public synchronized void removeEditorState(@NotNull final Path file) { * * @param assetFolder the asset folder of this workspace. */ - public void setAssetFolder(@NotNull final Path assetFolder) { + @FromAnyThread + public synchronized void setAssetFolder(@NotNull final Path assetFolder) { this.assetFolder = assetFolder; } @@ -238,7 +246,8 @@ public void setAssetFolder(@NotNull final Path assetFolder) { * * @return the table of opened files. */ - public @NotNull Map getOpenedFiles() { + @FromAnyThread + public synchronized @NotNull Map getOpenedFiles() { return notNull(openedFiles); } @@ -248,6 +257,7 @@ public void setAssetFolder(@NotNull final Path assetFolder) { * @param file the opened file. * @param fileEditor the editor. */ + @FromAnyThread public synchronized void addOpenedFile(@NotNull final Path file, @NotNull final FileEditor fileEditor) { final Path assetFile = getAssetFile(getAssetFolder(), file); @@ -267,6 +277,7 @@ public synchronized void addOpenedFile(@NotNull final Path file, @NotNull final * * @param file the removed file. */ + @FromAnyThread public synchronized void removeOpenedFile(@NotNull final Path file) { final Path assetFile = getAssetFile(getAssetFolder(), file); @@ -283,13 +294,15 @@ public synchronized void removeOpenedFile(@NotNull final Path file) { * * @return the asset folder of this workspace. */ - public @NotNull Path getAssetFolder() { + @FromAnyThread + public synchronized @NotNull Path getAssetFolder() { return notNull(assetFolder); } /** * Increase a counter of changes. */ + @FromAnyThread private void incrementChanges() { changes.incrementAndGet(); } @@ -297,7 +310,8 @@ private void incrementChanges() { /** * Clear this workspace. */ - public void clear() { + @FromAnyThread + public synchronized void clear() { getOpenedFiles().clear(); } @@ -306,7 +320,8 @@ public void clear() { * * @param force the force */ - public void save(final boolean force) { + @FromAnyThread + public synchronized void save(final boolean force) { if (!force && changes.get() == 0) return; final Path assetFolder = getAssetFolder(); @@ -342,16 +357,8 @@ public void save(final boolean force) { changes.set(0); - final byte[] serialize = EditorUtil.serialize(this); - - try (final SeekableByteChannel channel = Files.newByteChannel(workspaceFile, StandardOpenOption.WRITE)) { - - final ByteBuffer buffer = ByteBuffer.wrap(serialize); - buffer.position(serialize.length); - buffer.flip(); - - channel.write(buffer); - + try { + Files.write(workspaceFile, EditorUtil.serialize(this)); } catch (final IOException e) { LOGGER.warning(e); } 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 3f4f482d..1e38ee68 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 @@ -3,6 +3,8 @@ import static com.ss.editor.plugin.api.property.control.PropertyEditorControlFactory.build; import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.editor.plugin.api.property.control.PropertyEditorControl; @@ -86,6 +88,7 @@ public GenericFactoryDialog(@NotNull final Array definitions * * @param title the new title. */ + @FXThread public void setTitle(@NotNull final String title) { getDialog().setTitle(title); } @@ -95,6 +98,7 @@ public void setTitle(@NotNull final String title) { * * @param text the new text. */ + @FXThread public void setButtonOkText(@NotNull final String text) { getOkButton().setText(text); } @@ -104,16 +108,19 @@ public void setButtonOkText(@NotNull final String text) { * * @param text the new text. */ + @FXThread public void setButtonCloseText(@NotNull final String text) { getCloseButton().setText(text); } @Override + @FromAnyThread protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_CREATE; } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); this.root = root; @@ -124,6 +131,7 @@ protected void createContent(@NotNull final VBox root) { * * @return the root. */ + @FXThread private @NotNull VBox getRoot() { return notNull(root); } @@ -131,6 +139,7 @@ protected void createContent(@NotNull final VBox root) { /** * Create controls. */ + @FXThread private void createControls() { final ObservableList children = getRoot().getChildren(); @@ -144,6 +153,7 @@ private void createControls() { } @Override + @FromAnyThread protected @NotNull Point getSize() { return DIALOG_SIZE; } @@ -151,6 +161,7 @@ private void createControls() { /** * @return the list of all definitions. */ + @FXThread private @NotNull Array getDefinitions() { return definitions; } @@ -158,11 +169,13 @@ private void createControls() { /** * Validate current values. */ + @FXThread protected void validate() { getOkButton().setDisable(!validator.test(vars)); } @Override + @FXThread protected void processOk() { super.processOk(); handler.accept(vars); 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 1a26ae87..908ae1f6 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 @@ -51,15 +51,7 @@ public abstract class Advanced3DFileEditorWithRightTool editor3DArea.requestFocus()); - editor3DArea.setOnKeyReleased(Event::consume); - editor3DArea.setOnKeyPressed(Event::consume); + createEditorAreaPane(); mainSplitContainer = new EditorToolSplitPane(JFX_APPLICATION.getScene(), root); @@ -74,11 +66,28 @@ protected void createContent(@NotNull final StackPane root) { if (editorState != null) editorState.setOpenedTool(newValue.intValue()); }); - mainSplitContainer.initFor(editorToolComponent, editorAreaPane); + mainSplitContainer.initFor(editorToolComponent, getEditorAreaPane()); FXUtils.addToPane(mainSplitContainer, root); - FXUtils.addToPane(editor3DArea, editorAreaPane); FXUtils.addClassTo(mainSplitContainer, CSSClasses.FILE_EDITOR_MAIN_SPLIT_PANE); + } + + /** + * Create editor area pane. + */ + @FXThread + protected void createEditorAreaPane() { + + editorAreaPane = new StackPane(); + editorAreaPane.setOnDragOver(this::handleDragOverEvent); + editorAreaPane.setOnDragDropped(this::handleDragDroppedEvent); + + editor3DArea = new BorderPane(); + editor3DArea.setOnMousePressed(event -> editor3DArea.requestFocus()); + editor3DArea.setOnKeyReleased(Event::consume); + editor3DArea.setOnKeyPressed(Event::consume); + + FXUtils.addToPane(editor3DArea, editorAreaPane); FXUtils.addClassTo(editorAreaPane, CSSClasses.FILE_EDITOR_EDITOR_AREA); } @@ -124,20 +133,27 @@ protected void loadState() { * Create and add tool components to the container. * * @param container the tool container. - * @param container the root. + * @param root the root. */ + @FXThread protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { } /** - * Handle drag objects. + * Handle drag over events. + * + * @param dragEvent the drag event. */ - protected void dragOver(@NotNull final DragEvent dragEvent) { + @FXThread + protected void handleDragOverEvent(@NotNull final DragEvent dragEvent) { } /** - * Handle dropped texture. + * Handle dropped events. + * + * @param dragEvent the drop event. */ - protected void dragDropped(@NotNull final DragEvent dragEvent) { + @FXThread + protected void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { } } diff --git a/src/main/java/com/ss/editor/plugin/api/editor/Base3DFileEditor.java b/src/main/java/com/ss/editor/plugin/api/editor/Base3DFileEditor.java index 2ab0c995..8ee35f04 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/Base3DFileEditor.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/Base3DFileEditor.java @@ -3,10 +3,6 @@ import com.jme3.math.Vector3f; import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.model.undo.EditorOperation; -import com.ss.editor.model.undo.EditorOperationControl; -import com.ss.editor.model.undo.UndoableEditor; -import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.state.editor.impl.AbstractEditor3DState; import com.ss.editor.ui.component.editor.state.impl.Editor3DEditorState; import javafx.event.Event; @@ -17,7 +13,6 @@ import org.jetbrains.annotations.NotNull; import java.nio.file.Path; -import java.util.concurrent.atomic.AtomicInteger; /** * The base implementation of {@link com.ss.editor.ui.component.editor.FileEditor} with 3D scene. @@ -25,13 +20,7 @@ * @author JavaSaBr */ public abstract class Base3DFileEditor extends - BaseFileEditor implements UndoableEditor, ChangeConsumer { - - /** - * The operation control. - */ - @NotNull - private final EditorOperationControl operationControl; + BaseFileEditor { /** * The 3D part of this editor. @@ -39,16 +28,9 @@ public abstract class Base3DFileEditor extends AbstractFileEditor { +public abstract class BaseFileEditor extends AbstractFileEditor implements + UndoableEditor, ChangeConsumer { + + /** + * The operation control. + */ + @NotNull + private final EditorOperationControl operationControl; + + /** + * The changes counter. + */ + @NotNull + private final AtomicInteger changeCounter; + /** * The state of this editor. */ @@ -33,11 +54,94 @@ public abstract class BaseFileEditor extends AbstractFile */ private boolean ignoreListeners; + protected BaseFileEditor() { + this.operationControl = createOperationControl(); + this.changeCounter = new AtomicInteger(); + } + + /** + * Create an editor operation control. + * + * @return the editor operation control. + */ + @FXThread + protected @NotNull EditorOperationControl createOperationControl() { + return new EditorOperationControl(this); + } + + @Override + @FromAnyThread + public void execute(@NotNull final EditorOperation operation) { + operationControl.execute(operation); + } + + @FXThread + @Override + protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed, + final boolean isControlDown, final boolean isShiftDown, + final boolean isButtonMiddleDown) { + + if (isPressed && isControlDown && keyCode == KeyCode.Z) { + undo(); + return true; + } else if (isPressed && isControlDown && isShiftDown && keyCode == KeyCode.Z) { + redo(); + return true; + } else if (isPressed && isControlDown && keyCode == KeyCode.Y) { + redo(); + return true; + } + + return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isShiftDown, isButtonMiddleDown); + } + + @Override + @FXThread + public void incrementChange() { + final int result = changeCounter.incrementAndGet(); + setDirty(result != 0); + } + + @Override + @FXThread + public void decrementChange() { + final int result = changeCounter.decrementAndGet(); + setDirty(result != 0); + } + + @Override + @FromAnyThread + public void redo() { + operationControl.redo(); + } + + @Override + @FromAnyThread + public void undo() { + operationControl.undo(); + } + + /** + * Get the editor operation control. + * + * @return the editor operation control. + */ + @FromAnyThread + protected @NotNull EditorOperationControl getOperationControl() { + return operationControl; + } + @Override @FXThread public void openFile(@NotNull final Path file) { super.openFile(file); - doOpenFile(file); + + try { + doOpenFile(file); + } catch (final IOException e) { + throw new RuntimeException(e); + } + EXECUTOR_MANAGER.addFXTask(this::loadState); } @@ -63,6 +167,7 @@ protected void loadState() { * * @return the factory to make an editor state. */ + @FXThread protected @Nullable Supplier getEditorStateFactory() { return null; } @@ -71,9 +176,10 @@ protected void loadState() { * Do main activities to open the file. * * @param file the file to open. + * @throws IOException if was some problem with writing to the file. */ @FXThread - protected void doOpenFile(@NotNull final Path file) { + protected void doOpenFile(@NotNull final Path file) throws IOException { } /** @@ -114,8 +220,8 @@ protected boolean isIgnoreListeners() { return editorState; } - @FXThread @Override + @FXThread public boolean isInside(final double sceneX, final double sceneY, @NotNull final Class eventType) { return false; } 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 new file mode 100644 index 00000000..94b9afb5 --- /dev/null +++ b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithRightTool.java @@ -0,0 +1,137 @@ +package com.ss.editor.plugin.api.editor; + +import static com.ss.rlib.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; +import com.ss.editor.ui.component.tab.EditorToolComponent; +import com.ss.editor.ui.component.tab.ScrollableEditorToolComponent; +import com.ss.editor.ui.css.CSSClasses; +import com.ss.rlib.ui.util.FXUtils; +import javafx.scene.input.DragEvent; +import javafx.scene.layout.StackPane; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The base implementation of a file editor without 3D part and with right tool panel. + * + * @author JavaSaBr + */ +public abstract class BaseFileEditorWithRightTool extends BaseFileEditor { + + /** + * The main split container. + */ + @Nullable + private EditorToolSplitPane mainSplitContainer; + + /** + * Editor tool component. + */ + @Nullable + private ScrollableEditorToolComponent editorToolComponent; + + /** + * The pane of editor area. + */ + @Nullable + private StackPane editorAreaPane; + + @Override + @FXThread + protected void createContent(@NotNull final StackPane root) { + createEditorAreaPane(); + + mainSplitContainer = new EditorToolSplitPane(JFX_APPLICATION.getScene(), root); + + editorToolComponent = new ScrollableEditorToolComponent(mainSplitContainer, 1); + editorToolComponent.prefHeightProperty().bind(root.heightProperty()); + + createToolComponents(editorToolComponent, root); + + editorToolComponent.addChangeListener((observable, oldValue, newValue) -> processChangeTool(oldValue, newValue)); + editorToolComponent.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue) -> { + final S editorState = getEditorState(); + if (editorState != null) editorState.setOpenedTool(newValue.intValue()); + }); + + mainSplitContainer.initFor(editorToolComponent, getEditorAreaPane()); + + FXUtils.addToPane(mainSplitContainer, root); + FXUtils.addClassTo(mainSplitContainer, CSSClasses.FILE_EDITOR_MAIN_SPLIT_PANE); + } + + /** + * Create editor area pane. + */ + @FXThread + protected void createEditorAreaPane() { + + editorAreaPane = new StackPane(); + editorAreaPane.setOnDragOver(this::handleDragOverEvent); + editorAreaPane.setOnDragDropped(this::handleDragDroppedEvent); + + FXUtils.addClassTo(editorAreaPane, CSSClasses.FILE_EDITOR_EDITOR_AREA); + } + + /** + * Process change tool. + * + * @param oldValue the old value + * @param newValue the new value + */ + @FXThread + protected void processChangeTool(@Nullable final Number oldValue, @NotNull final Number newValue) { + } + + @Override + @FXThread + protected void loadState() { + super.loadState(); + + final S editorState = getEditorState(); + if (editorState == null) { + return; + } + + editorToolComponent.getSelectionModel().select(editorState.getOpenedTool()); + mainSplitContainer.updateFor(editorState); + } + + /** + * @return the pane of editor area. + */ + @FXThread + protected @NotNull StackPane getEditorAreaPane() { + return notNull(editorAreaPane); + } + + /** + * Create and add tool components to the container. + * + * @param container the tool container. + * @param root the root. + */ + @FXThread + protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { + } + + /** + * Handle drag over events. + * + * @param dragEvent the drag event. + */ + @FXThread + protected void handleDragOverEvent(@NotNull final DragEvent dragEvent) { + } + + /** + * Handle dropped events. + * + * @param dragEvent the drop event. + */ + @FXThread + protected void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { + } +} 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 new file mode 100644 index 00000000..ffbc0422 --- /dev/null +++ b/src/main/java/com/ss/editor/plugin/api/editor/BaseFileEditorWithSplitRightTool.java @@ -0,0 +1,53 @@ +package com.ss.editor.plugin.api.editor; + +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 javafx.scene.Node; +import javafx.scene.control.SplitPane; +import javafx.scene.layout.Region; +import javafx.scene.layout.StackPane; +import org.jetbrains.annotations.NotNull; + +/** + * The base implementation of a file editor without 3D part and with right split tool panel. + * + * @author JavaSaBr + */ +public abstract class BaseFileEditorWithSplitRightTool extends + BaseFileEditorWithRightTool { + + /** + * Build split component. + * + * @param first the first component. + * @param second the second component. + * @param root the root. + * @return the result component. + */ + @FXThread + protected Region buildSplitComponent(@NotNull final Node first, @NotNull final Node second, + @NotNull final StackPane root) { + + final SplitPane splitPane = new SplitPane(first, second); + splitPane.prefHeightProperty().bind(root.heightProperty()); + splitPane.prefWidthProperty().bind(root.widthProperty()); + + root.heightProperty().addListener((observableValue, oldValue, newValue) -> calcVSplitSize(splitPane)); + + FXUtils.addClassTo(splitPane, CSSClasses.FILE_EDITOR_TOOL_SPLIT_PANE); + + return splitPane; + } + + /** + * Calc height of vertical split pane. + * + * @param splitPane the split pane + */ + @FXThread + protected void calcVSplitSize(@NotNull final SplitPane splitPane) { + splitPane.setDividerPosition(0, 0.3); + } +} diff --git a/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialEditor3DState.java b/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialEditor3DState.java new file mode 100644 index 00000000..2db742b5 --- /dev/null +++ b/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialEditor3DState.java @@ -0,0 +1,411 @@ +package com.ss.editor.plugin.api.editor.material; + +import static com.ss.rlib.util.ObjectUtils.notNull; +import com.jme3.app.Application; +import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetNotFoundException; +import com.jme3.input.InputManager; +import com.jme3.input.KeyInput; +import com.jme3.input.controls.KeyTrigger; +import com.jme3.light.DirectionalLight; +import com.jme3.material.Material; +import com.jme3.math.Vector3f; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.RendererException; +import com.jme3.renderer.queue.RenderQueue.Bucket; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.shape.Box; +import com.jme3.scene.shape.Quad; +import com.jme3.scene.shape.Sphere; +import com.ss.editor.EditorThread; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.JMEThread; +import com.ss.editor.model.EditorCamera; +import com.ss.editor.model.tool.TangentGenerator; +import com.ss.editor.plugin.api.editor.part3d.AdvancedPBRWithStudioSky3DEditorState; +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 javafx.scene.input.KeyCode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The implementation the 3D part of the {@link MaterialFileEditor}. + * + * @author JavaSaBr + */ +public class BaseMaterialEditor3DState extends AdvancedPBRWithStudioSky3DEditorState { + + @NotNull + private static final Vector3f QUAD_OFFSET = new Vector3f(0, -2, 2); + + @NotNull + private static final Vector3f LIGHT_DIRECTION = new Vector3f(0.007654993F, 0.39636374F, 0.9180617F).negate(); + + private static final float H_ROTATION = AngleUtils.degreeToRadians(75); + private static final float V_ROTATION = AngleUtils.degreeToRadians(25); + + @NotNull + private static final String KEY_C = "SSEditor.materialEditorState.C"; + + @NotNull + private static final String KEY_S = "SSEditor.materialEditorState.S"; + + @NotNull + private static final String KEY_P = "SSEditor.materialEditorState.P"; + + @NotNull + private static final String KEY_L = "SSEditor.materialEditorState.L"; + + static { + TRIGGERS.put(KEY_C, new KeyTrigger(KeyInput.KEY_C)); + TRIGGERS.put(KEY_S, new KeyTrigger(KeyInput.KEY_S)); + TRIGGERS.put(KEY_P, new KeyTrigger(KeyInput.KEY_P)); + TRIGGERS.put(KEY_L, new KeyTrigger(KeyInput.KEY_L)); + } + + /** + * The test box. + */ + @NotNull + private final Geometry testBox; + + /** + * The test sphere. + */ + @NotNull + private final Geometry testSphere; + + /** + * The test quad. + */ + @NotNull + private final Geometry testQuad; + + /** + * The current model mode. + */ + @Nullable + private ModelType currentModelType; + + /** + * The flag of enabling light. + */ + private boolean lightEnabled; + + public BaseMaterialEditor3DState(@NotNull final T fileEditor) { + super(fileEditor); + this.testBox = new Geometry("Box", new Box(2, 2, 2)); + this.testSphere = new Geometry("Sphere", new Sphere(30, 30, 2)); + this.testQuad = new Geometry("Quad", new Quad(4, 4)); + this.testQuad.setLocalTranslation(QUAD_OFFSET); + this.lightEnabled = MaterialFileEditor.DEFAULT_LIGHT_ENABLED; + + TangentGenerator.useMikktspaceGenerator(testBox); + TangentGenerator.useMikktspaceGenerator(testSphere); + TangentGenerator.useMikktspaceGenerator(testQuad); + + final DirectionalLight light = notNull(getLightForCamera()); + light.setDirection(LIGHT_DIRECTION); + + final EditorCamera editorCamera = notNull(getEditorCamera()); + editorCamera.setDefaultHorizontalRotation(H_ROTATION); + editorCamera.setDefaultVerticalRotation(V_ROTATION); + + getModelNode().attachChild(getNodeForCamera()); + } + + @Override + @JMEThread + protected void registerActionHandlers(@NotNull final ObjectDictionary actionHandlers) { + super.registerActionHandlers(actionHandlers); + + final T fileEditor = getFileEditor(); + + actionHandlers.put(KEY_S, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.S, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); + + actionHandlers.put(KEY_C, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.C, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); + + actionHandlers.put(KEY_P, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.P, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); + + actionHandlers.put(KEY_L, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.L, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); + } + + @Override + @JMEThread + protected void registerActionListener(@NotNull final InputManager inputManager) { + super.registerActionListener(inputManager); + inputManager.addListener(actionListener, KEY_S, KEY_C, KEY_P, KEY_L); + } + + /** + * @return the test box. + */ + @JMEThread + protected @NotNull Geometry getTestBox() { + return testBox; + } + + /** + * @return the test quad. + */ + @JMEThread + protected @NotNull Geometry getTestQuad() { + return testQuad; + } + + /** + * @return the test sphere. + */ + @JMEThread + protected @NotNull Geometry getTestSphere() { + return testSphere; + } + + /** + * Update the {@link Material}. + * + * @param material the material + */ + @FromAnyThread + public void updateMaterial(@NotNull final Material material) { + EXECUTOR_MANAGER.addJMETask(() -> updateMaterialImpl(material)); + } + + /** + * Update the {@link Material} in the {@link EditorThread}. + * + * @param material the new material. + */ + @JMEThread + protected void updateMaterialImpl(@NotNull final Material material) { + + final Geometry testBox = getTestBox(); + testBox.setMaterial(material); + + final Geometry testQuad = getTestQuad(); + testQuad.setMaterial(material); + + final Geometry testSphere = getTestSphere(); + testSphere.setMaterial(material); + + final RenderManager renderManager = EDITOR.getRenderManager(); + try { + renderManager.preloadScene(testBox); + } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) { + handleMaterialException(e); + testBox.setMaterial(EDITOR.getDefaultMaterial()); + testQuad.setMaterial(EDITOR.getDefaultMaterial()); + testSphere.setMaterial(EDITOR.getDefaultMaterial()); + } + } + + /** + * Handle the material exception. + * + * @param exception the exception. + */ + @JMEThread + protected void handleMaterialException(@NotNull final RuntimeException exception) { + EditorUtil.handleException(LOGGER, this, exception); + } + + /** + * Change the {@link ModelType}. + * + * @param modelType the model type + */ + @FromAnyThread + public void changeMode(@NotNull final ModelType modelType) { + EXECUTOR_MANAGER.addJMETask(() -> changeModeImpl(modelType)); + } + + /** + * Change the {@link ModelType} in the {@link EditorThread}. + * + * @param modelType the new model type. + */ + @JMEThread + protected void changeModeImpl(@NotNull final ModelType modelType) { + + final Node modelNode = getModelNode(); + modelNode.detachAllChildren(); + + switch (modelType) { + case BOX: { + modelNode.attachChild(getTestBox()); + break; + } + case QUAD: { + modelNode.attachChild(getTestQuad()); + break; + } + case SPHERE: { + modelNode.attachChild(getTestSphere()); + break; + } + } + + setCurrentModelType(modelType); + } + + /** + * Change the {@link Bucket}. + * + * @param bucket the bucket + */ + @FromAnyThread + public void changeBucketType(@NotNull final Bucket bucket) { + EXECUTOR_MANAGER.addJMETask(() -> changeBucketTypeImpl(bucket)); + } + + /** + * Change the {@link Bucket} in the {@link EditorThread}. + * + * @param bucket the new bucket. + */ + @JMEThread + protected void changeBucketTypeImpl(@NotNull final Bucket bucket) { + + final Geometry testQuad = getTestQuad(); + testQuad.setQueueBucket(bucket); + + final Geometry testSphere = getTestSphere(); + testSphere.setQueueBucket(bucket); + + final Geometry testBox = getTestBox(); + testBox.setQueueBucket(bucket); + } + + @Override + @JMEThread + public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { + super.initialize(stateManager, application); + changeModeImpl(getCurrentModelType()); + } + + @Override + @JMEThread + protected boolean needMovableCamera() { + return false; + } + + @Override + @JMEThread + protected boolean needEditorCamera() { + return true; + } + + @Override + @JMEThread + protected boolean needLightForCamera() { + return true; + } + + /** + * @return the current model mode. + */ + @JMEThread + protected @NotNull ModelType getCurrentModelType() { + return notNull(currentModelType); + } + + /** + * @param currentModelType the current model mode. + */ + @JMEThread + protected void setCurrentModelType(@NotNull final ModelType currentModelType) { + this.currentModelType = currentModelType; + } + + /** + * @return true if the light is enabled. + */ + @JMEThread + protected boolean isLightEnabled() { + return lightEnabled; + } + + /** + * @param lightEnabled true if the light is enabled. + */ + @JMEThread + protected void setLightEnabled(final boolean lightEnabled) { + this.lightEnabled = lightEnabled; + } + + /** + * Update the light in the scene. + * + * @param enabled the enabled + */ + @FromAnyThread + public void updateLightEnabled(final boolean enabled) { + EXECUTOR_MANAGER.addJMETask(() -> updateLightEnabledImpl(enabled)); + } + + /** + * Update the light in the scene in the {@link EditorThread}. + * + * @param enabled true if light should be enabled. + */ + @JMEThread + protected void updateLightEnabledImpl(final boolean enabled) { + if (enabled == isLightEnabled()) return; + + final DirectionalLight light = getLightForCamera(); + final Node stateNode = getStateNode(); + + if (enabled) { + stateNode.addLight(light); + } else { + stateNode.removeLight(light); + } + + setLightEnabled(enabled); + } + + @Override + @JMEThread + protected boolean needUpdateCameraLight() { + return false; + } + + /** + * The enum Model type. + */ + public enum ModelType { + /** + * Sphere model type. + */ + SPHERE, + /** + * Box model type. + */ + BOX, + /** + * Quad model type. + */ + QUAD; + + private static final ModelType[] VALUES = values(); + + /** + * Value of model type. + * + * @param index the index + * @return the model type + */ + public static ModelType valueOf(final int index) { + return VALUES[index]; + } + } +} 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 new file mode 100644 index 00000000..484e5d4e --- /dev/null +++ b/src/main/java/com/ss/editor/plugin/api/editor/material/BaseMaterialFileEditor.java @@ -0,0 +1,419 @@ +package com.ss.editor.plugin.api.editor.material; + +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 javafx.collections.FXCollections.observableArrayList; +import com.jme3.material.Material; +import com.jme3.renderer.queue.RenderQueue; +import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.plugin.api.editor.Advanced3DFileEditorWithSplitRightTool; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState.ModelType; +import com.ss.editor.ui.Icons; +import com.ss.editor.ui.component.editor.state.EditorState; +import com.ss.editor.ui.component.editor.state.impl.EditorMaterialEditorState; +import com.ss.editor.ui.component.tab.EditorToolComponent; +import com.ss.editor.ui.control.property.PropertyEditor; +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.editor.ui.util.DynamicIconSupport; +import com.ss.rlib.ui.util.FXUtils; +import javafx.collections.ObservableList; +import javafx.scene.control.*; +import javafx.scene.image.ImageView; +import javafx.scene.input.KeyCode; +import javafx.scene.layout.HBox; +import javafx.scene.layout.StackPane; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Supplier; + +/** + * The implementation of the Editor to edit materials. + * + * @author JavaSaBr + */ +public abstract class BaseMaterialFileEditor extends + Advanced3DFileEditorWithSplitRightTool { + + /** + * The default state of editor light. + */ + public static final boolean DEFAULT_LIGHT_ENABLED = true; + + /** + * The list of available bucket types. + */ + @NotNull + protected static final ObservableList BUCKETS = observableArrayList(values()); + + /** + * The settings tree. + */ + @Nullable + private NodeTree settingsTree; + + /** + * The property editor. + */ + @Nullable + private PropertyEditor propertyEditor; + + /** + * The button to use a cube. + */ + @Nullable + private ToggleButton cubeButton; + + /** + * The button to use a sphere. + */ + @Nullable + private ToggleButton sphereButton; + + /** + * The button to use a plane. + */ + @Nullable + private ToggleButton planeButton; + + /** + * The button to use a light. + */ + @Nullable + private ToggleButton lightButton; + + /** + * The list of RenderQueue.Bucket. + */ + @Nullable + private ComboBox bucketComboBox; + + protected BaseMaterialFileEditor() { + super(); + } + + /** + * Get the change consumer. + * + * @return the change consumer. + */ + @FromAnyThread + protected C getChangeConsumer() { + return unsafeCast(this); + } + + @Override + @FXThread + protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed, + final boolean isControlDown, final boolean isShiftDown, + final boolean isButtonMiddleDown) { + + if (isPressed && keyCode == KeyCode.C && !isControlDown && !isButtonMiddleDown) { + final ToggleButton cubeButton = getCubeButton(); + cubeButton.setSelected(true); + return true; + } else if (isPressed && keyCode == KeyCode.S && !isControlDown && !isButtonMiddleDown) { + final ToggleButton sphereButton = getSphereButton(); + sphereButton.setSelected(true); + return true; + } else if (isPressed && keyCode == KeyCode.P && !isControlDown && !isButtonMiddleDown) { + final ToggleButton planeButton = getPlaneButton(); + planeButton.setSelected(true); + return true; + } else if (isPressed && keyCode == KeyCode.L && !isControlDown && !isButtonMiddleDown) { + final ToggleButton lightButton = getLightButton(); + lightButton.setSelected(!lightButton.isSelected()); + return true; + } + + return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isShiftDown, isButtonMiddleDown); + } + + @Override + @FXThread + protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { + super.createToolComponents(container, root); + + settingsTree = new NodeTree<>(this::selectedFromTree, getChangeConsumer()); + propertyEditor = new PropertyEditor<>(getChangeConsumer()); + propertyEditor.prefHeightProperty().bind(root.heightProperty()); + + container.addComponent(buildSplitComponent(settingsTree, propertyEditor, root), getSettingsTreeToolName()); + + FXUtils.addClassTo(settingsTree.getTreeView(), CSSClasses.TRANSPARENT_TREE_VIEW); + } + + /** + * Get the settings tree tool name. + * + * @return the settings tree tool name. + */ + @FromAnyThread + protected @NotNull String getSettingsTreeToolName() { + return Messages.MATERIAL_SETTINGS_MAIN; + } + + /** + * @return the settings tree. + */ + @FromAnyThread + protected @NotNull NodeTree getSettingsTree() { + return notNull(settingsTree); + } + + /** + * @return the property editor. + */ + @FromAnyThread + protected @NotNull PropertyEditor getPropertyEditor() { + return notNull(propertyEditor); + } + + /** + * Handle selected object from tree. + * + * @param object the selected object. + */ + @FXThread + private void selectedFromTree(@Nullable final Object object) { + + Object parent = null; + Object element; + + if (object instanceof TreeNode) { + final TreeNode treeNode = (TreeNode) object; + final TreeNode parentNode = treeNode.getParent(); + parent = parentNode == null ? null : parentNode.getElement(); + element = treeNode.getElement(); + } else { + element = object; + } + + getPropertyEditor().buildFor(element, parent); + } + + @Override + @FXThread + protected void loadState() { + super.loadState(); + + switch (ModelType.valueOf(editorState.getModelType())) { + case BOX: + getCubeButton().setSelected(true); + break; + case SPHERE: + getSphereButton().setSelected(true); + break; + case QUAD: + getPlaneButton().setSelected(true); + break; + } + + getBucketComboBox().getSelectionModel().select(editorState.getBucketType()); + getLightButton().setSelected(editorState.isLightEnable()); + } + + @Override + @FXThread + protected @Nullable Supplier getEditorStateFactory() { + return EditorMaterialEditorState::new; + } + + @Override + @FXThread + protected void calcVSplitSize(@NotNull final SplitPane splitPane) { + splitPane.setDividerPosition(0, 0.2); + } + + @Override + @FXThread + protected boolean needToolbar() { + return true; + } + + @Override + @FXThread + protected void createToolbar(@NotNull final HBox container) { + super.createToolbar(container); + createActions(container); + + final Label bucketLabel = new Label(Messages.MATERIAL_FILE_EDITOR_BUCKET_TYPE_LABEL + ":"); + + bucketComboBox = new ComboBox<>(BUCKETS); + bucketComboBox.getSelectionModel().select(Inherit); + bucketComboBox.getSelectionModel() + .selectedItemProperty() + .addListener((observable, oldValue, newValue) -> changeBucketType(newValue)); + + FXUtils.addToPane(bucketLabel, container); + FXUtils.addToPane(bucketComboBox, container); + } + + /** + * Create actions on toolbar. + * + * @param container the container. + */ + @FXThread + protected void createActions(@NotNull final HBox container) { + + cubeButton = new ToggleButton(); + cubeButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_CUBE + " (C)")); + cubeButton.setGraphic(new ImageView(Icons.CUBE_16)); + cubeButton.selectedProperty().addListener((observable, oldValue, newValue) -> + changeModelType(ModelType.BOX, newValue)); + + sphereButton = new ToggleButton(); + sphereButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_SPHERE + " (S)")); + sphereButton.setGraphic(new ImageView(Icons.SPHERE_16)); + sphereButton.selectedProperty().addListener((observable, oldValue, newValue) -> + changeModelType(ModelType.SPHERE, newValue)); + + planeButton = new ToggleButton(); + planeButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_PLANE + " (P)")); + planeButton.setGraphic(new ImageView(Icons.PLANE_16)); + planeButton.selectedProperty().addListener((observable, oldValue, newValue) -> + changeModelType(ModelType.QUAD, newValue)); + + lightButton = new ToggleButton(); + lightButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_LIGHT + " (L)")); + lightButton.setGraphic(new ImageView(Icons.LIGHT_16)); + lightButton.setSelected(DEFAULT_LIGHT_ENABLED); + lightButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeLight(newValue)); + + FXUtils.addToPane(createSaveAction(), container); + FXUtils.addToPane(cubeButton, container); + FXUtils.addToPane(sphereButton, container); + FXUtils.addToPane(planeButton, container); + FXUtils.addToPane(lightButton, container); + + DynamicIconSupport.addSupport(cubeButton, sphereButton, planeButton, lightButton); + FXUtils.addClassTo(cubeButton, sphereButton, planeButton, lightButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON); + } + + /** + * Handle changing the bucket type. + */ + @FXThread + private void changeBucketType(@NotNull final RenderQueue.Bucket newValue) { + + final T editor3DState = getEditor3DState(); + editor3DState.changeBucketType(newValue); + + final EditorMaterialEditorState editorState = getEditorState(); + if (editorState != null) editorState.setBucketType(newValue); + } + + /** + * Handle changing the light enabling. + */ + @FXThread + private void changeLight(@NotNull final Boolean newValue) { + + final T editor3DState = getEditor3DState(); + editor3DState.updateLightEnabled(newValue); + + final EditorMaterialEditorState editorState = getEditorState(); + if (editorState != null) editorState.setLightEnable(newValue); + } + + /** + * @return the button to use a cube. + */ + @FromAnyThread + private @NotNull ToggleButton getCubeButton() { + return notNull(cubeButton); + } + + /** + * @return the button to use a plane. + */ + @FromAnyThread + private @NotNull ToggleButton getPlaneButton() { + return notNull(planeButton); + } + + /** + * @return the button to use a sphere. + */ + @FromAnyThread + private @NotNull ToggleButton getSphereButton() { + return notNull(sphereButton); + } + + /** + * @return the button to use a light. + */ + @FromAnyThread + private @NotNull ToggleButton getLightButton() { + return notNull(lightButton); + } + + /** + * @return the list of RenderQueue.Bucket. + */ + @FromAnyThread + private @NotNull ComboBox getBucketComboBox() { + return notNull(bucketComboBox); + } + + /** + * Handle the changed model type. + */ + @FXThread + private void changeModelType(@NotNull final ModelType modelType, @NotNull final Boolean newValue) { + if (newValue == Boolean.FALSE) return; + + final T editor3DState = getEditor3DState(); + + final ToggleButton cubeButton = getCubeButton(); + final ToggleButton sphereButton = getSphereButton(); + final ToggleButton planeButton = getPlaneButton(); + + if (modelType == ModelType.BOX) { + cubeButton.setMouseTransparent(true); + sphereButton.setMouseTransparent(false); + planeButton.setMouseTransparent(false); + cubeButton.setSelected(true); + sphereButton.setSelected(false); + planeButton.setSelected(false); + editor3DState.changeMode(modelType); + } else if (modelType == ModelType.SPHERE) { + cubeButton.setMouseTransparent(false); + sphereButton.setMouseTransparent(true); + planeButton.setMouseTransparent(false); + cubeButton.setSelected(false); + sphereButton.setSelected(true); + planeButton.setSelected(false); + editor3DState.changeMode(modelType); + } else if (modelType == ModelType.QUAD) { + cubeButton.setMouseTransparent(false); + sphereButton.setMouseTransparent(false); + planeButton.setMouseTransparent(true); + sphereButton.setSelected(false); + cubeButton.setSelected(false); + planeButton.setSelected(true); + editor3DState.changeMode(modelType); + } + + final EditorMaterialEditorState editorState = getEditorState(); + if (editorState != null) editorState.setModelType(modelType); + } + + @Override + @FXThread + public void notifyFXChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { + if (object instanceof Material) { + getPropertyEditor().refresh(); + } else { + getPropertyEditor().syncFor(object); + } + } +} diff --git a/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorState.java b/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorState.java index dce55ad1..53778734 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorState.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/part3d/Advanced3DEditorState.java @@ -41,7 +41,7 @@ public Advanced3DEditorState(@NotNull final T fileEditor) { * @return the node on which the camera is looking. */ @FromAnyThread - protected @NotNull Node getCameraNode() { + protected @NotNull Node getCameraNode() { return notNull(cameraNode); } @@ -60,6 +60,7 @@ protected void redo() { } @Override + @JMEThread protected void notifyChangedCameraSettings(@NotNull final Vector3f cameraLocation, final float hRotation, final float vRotation, final float targetDistance, final float cameraSpeed) { super.notifyChangedCameraSettings(cameraLocation, hRotation, vRotation, targetDistance, cameraSpeed); diff --git a/src/main/java/com/ss/editor/plugin/api/editor/part3d/AdvancedPBR3DEditorState.java b/src/main/java/com/ss/editor/plugin/api/editor/part3d/AdvancedPBR3DEditorState.java index a4e27386..d145e39c 100644 --- a/src/main/java/com/ss/editor/plugin/api/editor/part3d/AdvancedPBR3DEditorState.java +++ b/src/main/java/com/ss/editor/plugin/api/editor/part3d/AdvancedPBR3DEditorState.java @@ -5,6 +5,7 @@ import com.jme3.environment.generation.JobProgressAdapter; import com.jme3.light.LightProbe; import com.jme3.scene.Node; +import com.ss.editor.annotation.JMEThread; import com.ss.editor.plugin.api.editor.Advanced3DFileEditor; import org.jetbrains.annotations.NotNull; @@ -42,12 +43,14 @@ public AdvancedPBR3DEditorState(@NotNull final T fileEditor) { } @Override + @JMEThread public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { super.initialize(stateManager, application); frame = 0; } @Override + @JMEThread public void cleanup() { super.cleanup(); @@ -61,6 +64,7 @@ public void cleanup() { /** * Attach model node to state node. */ + @JMEThread private void attachModelNode() { final Node stateNode = getStateNode(); stateNode.attachChild(modelNode); @@ -69,11 +73,13 @@ private void attachModelNode() { /** * @return the model node. */ + @JMEThread protected @NotNull Node getModelNode() { return modelNode; } @Override + @JMEThread public void update(final float tpf) { super.update(tpf); 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 e7e298e4..846f3d2b 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 @@ -88,6 +88,7 @@ protected void validateFileName() { * Validate variables. * * @param vars the variables. + * @return true if the all variables are valid. */ @FXThread protected boolean validate(@NotNull final VarTable vars) { @@ -105,6 +106,7 @@ protected void writeData(@NotNull final Path resultFile) throws IOException { * * @param vars the available variables. * @param resultFile the result file. + * @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 { 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 f6e7c33e..f135e437 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 @@ -1,5 +1,6 @@ package com.ss.editor.plugin.api.property; +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; @@ -46,6 +47,12 @@ public final class PropertyDefinition { @NotNull private final Array options; + /** + * The file extension to filter files/resources. + */ + @Nullable + private final String extension; + /** * The min value. */ @@ -65,11 +72,25 @@ public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @Not this.max = Float.NaN; this.min = Float.NaN; this.options = EMPTY_OPTIONS; + this.extension = null; } public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, - @NotNull final String id, @Nullable final Object defaultValue, - @NotNull final Array options) { + @NotNull final String id, @Nullable final Object defaultValue, + @Nullable final String extension) { + this.propertyType = propertyType; + this.name = name; + this.id = id; + this.defaultValue = defaultValue; + this.max = Float.NaN; + this.min = Float.NaN; + this.options = EMPTY_OPTIONS; + this.extension = extension; + } + + public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, + @NotNull final String id, @Nullable final Object defaultValue, + @NotNull final Array options) { this.propertyType = propertyType; this.name = name; this.id = id; @@ -77,6 +98,7 @@ public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @Not this.options = options; this.max = Float.NaN; this.min = Float.NaN; + this.extension = null; } public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @NotNull final String name, @@ -89,43 +111,45 @@ public PropertyDefinition(@NotNull final EditablePropertyType propertyType, @Not this.min = min; this.max = max; this.options = EMPTY_OPTIONS; + this.extension = null; } /** * @return the type of the property. */ - @NotNull - public EditablePropertyType getPropertyType() { + @FromAnyThread + public @NotNull EditablePropertyType getPropertyType() { return propertyType; } /** * @return the name of the property. */ - @Nullable - public Object getDefaultValue() { + @FromAnyThread + public @Nullable Object getDefaultValue() { return defaultValue; } /** * @return the id of the property. */ - @NotNull - public String getId() { + @FromAnyThread + public @NotNull String getId() { return id; } /** * @return the default value of the property. */ - @NotNull - public String getName() { + @FromAnyThread + public @NotNull String getName() { return name; } /** * @return the max value. */ + @FromAnyThread public float getMax() { return max; } @@ -133,6 +157,7 @@ public float getMax() { /** * @return the min value. */ + @FromAnyThread public float getMin() { return min; } @@ -140,15 +165,25 @@ public float getMin() { /** * @return the options. */ - @NotNull - public Array getOptions() { + @FromAnyThread + public @NotNull Array getOptions() { return options; } + /** + * Get the file extension to filter files/resources. + * + * @return the file extension to filter files/resources. + */ + @FromAnyThread + public @Nullable String getExtension() { + return extension; + } + @Override public String toString() { return "PropertyDefinition{" + "propertyType=" + propertyType + ", name='" + name + '\'' + ", id='" + id + - '\'' + ", defaultValue=" + defaultValue + ", options=" + options + ", min=" + min + ", max=" + max + - '}'; + '\'' + ", defaultValue=" + defaultValue + ", options=" + options + ", extension='" + extension + '\'' + + ", min=" + min + ", max=" + max + '}'; } } 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 bf7af3e9..f57ad9bd 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,5 +1,7 @@ package com.ss.editor.plugin.api.property.control; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.util.UIUtils; import com.ss.rlib.util.VarTable; @@ -34,8 +36,8 @@ protected AssetResourcePropertyEditorControl(@NotNull final VarTable vars, * * @return the action tester. */ - @NotNull - protected Predicate> getActionTester() { + @FromAnyThread + protected @NotNull Predicate> getActionTester() { return DEFAULT_ACTION_TESTER; } @@ -44,12 +46,13 @@ protected Predicate> getActionTester() { * * @return the list with available extensions. */ - @NotNull - protected Array getExtensions() { + @FromAnyThread + protected @NotNull Array getExtensions() { return DEFAULT_EXTENSIONS; } @Override + @FXThread protected void processSelect() { super.processSelect(); UIUtils.openFileAssetDialog(this::processSelect, getExtensions(), getActionTester()); @@ -60,6 +63,7 @@ protected void processSelect() { * * @param file the selected file. */ + @FXThread protected void processSelect(@NotNull final 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 a9e0a947..a30e9b9f 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,6 +1,7 @@ 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; @@ -34,12 +35,12 @@ public class AwtFontPropertyEditorControl extends PropertyEditorControl { private static final StringConverter STRING_CONVERTER = new StringConverter() { @Override - public String toString(@Nullable final Font font) { + public @NotNull String toString(@Nullable final Font font) { return font == null ? StringUtils.EMPTY : font.getFontName(); } @Override - public Font fromString(@NotNull final String fontName) { + public @Nullable Font fromString(@NotNull final String fontName) { return Arrays.stream(FONTS) .filter(font -> font.getFontName().equals(fontName)) .findAny().orElse(null); @@ -58,19 +59,24 @@ protected AwtFontPropertyEditorControl(@NotNull final VarTable vars, @NotNull fi } @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.getItems().addAll(FONTS); comboBox.setVisibleRowCount(20); comboBox.setConverter(STRING_CONVERTER); comboBox.setEditable(true); - new AutoCompletionTextFieldBinding<>(comboBox.getEditor(), - SuggestionProvider.create(comboBox.getItems()), STRING_CONVERTER); + final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); + selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) -> change()); + + final AutoCompletionTextFieldBinding binding = + new AutoCompletionTextFieldBinding<>(comboBox.getEditor(), + SuggestionProvider.create(comboBox.getItems()), STRING_CONVERTER); + binding.setOnAutoCompleted(event -> selectionModel.select(event.getCompletion())); FXUtils.addClassesTo(comboBox.getEditor(), CSSClasses.TRANSPARENT_TEXT_FIELD, CSSClasses.TEXT_FIELD_IN_COMBO_BOX); FXUtils.addClassTo(comboBox, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); @@ -80,12 +86,13 @@ protected void createComponents() { /** * @return The list of available options of the string value. */ - @NotNull - private ComboBox getComboBox() { + @FXThread + private @NotNull ComboBox getComboBox() { return notNull(comboBox); } @Override + @FXThread protected void reload() { super.reload(); final Font value = getPropertyValue(); @@ -94,6 +101,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { final ComboBox comboBox = getComboBox(); final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); 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 1c42ee86..53d1dbf5 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,6 +1,7 @@ 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.ui.css.CSSClasses; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.rlib.ui.util.FXUtils; @@ -28,6 +29,7 @@ protected BooleanPropertyEditorControl(@NotNull final VarTable vars, @NotNull fi } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -39,12 +41,16 @@ protected void createComponents() { FXUtils.addClassTo(checkBox, CSSClasses.ABSTRACT_PARAM_CONTROL_CHECK_BOX); } - @NotNull - private CheckBox getCheckBox() { + /** + * @return the CheckBox with current value. + */ + @FXThread + private @NotNull CheckBox getCheckBox() { return notNull(checkBox); } @Override + @FXThread protected void reload() { super.reload(); final Boolean value = getPropertyValue(); @@ -52,6 +58,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { setPropertyValue(getCheckBox().isSelected()); super.changeImpl(); 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 1ed70974..cf023799 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 @@ -2,6 +2,7 @@ import static com.ss.rlib.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; @@ -30,6 +31,7 @@ protected ColorPropertyEditorControl(@NotNull final VarTable vars, @NotNull fina } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -44,12 +46,13 @@ protected void createComponents() { /** * @return the color picker. */ - @NotNull - private ColorPicker getColorPicker() { + @FXThread + private @NotNull ColorPicker getColorPicker() { return notNull(colorPicker); } @Override + @FXThread protected void reload() { super.reload(); final ColorPicker colorPicker = getColorPicker(); @@ -57,6 +60,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { final ColorPicker colorPicker = getColorPicker(); setPropertyValue(UIUtils.from(colorPicker.getValue())); 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 27ca9537..7045a3bb 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 @@ -2,6 +2,7 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; 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; @@ -36,6 +37,7 @@ protected EnumPropertyEditorControl(@NotNull final VarTable vars, @NotNull final } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -51,12 +53,13 @@ protected void createComponents() { /** * @return the list of available options of the {@link Enum} value. */ - @NotNull - private ComboBox getEnumComboBox() { + @FXThread + private @NotNull ComboBox getEnumComboBox() { return notNull(enumComboBox); } @Override + @FXThread protected void reload() { super.reload(); final T value = getPropertyValue(); @@ -65,6 +68,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { final ComboBox enumComboBox = getEnumComboBox(); final SingleSelectionModel selectionModel = enumComboBox.getSelectionModel(); 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 new file mode 100644 index 00000000..113882a8 --- /dev/null +++ b/src/main/java/com/ss/editor/plugin/api/property/control/FileAssetResourcePropertyControl.java @@ -0,0 +1,71 @@ +package com.ss.editor.plugin.api.property.control; + +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 com.ss.editor.annotation.FromAnyThread; +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 org.jetbrains.annotations.NotNull; + +import java.nio.file.Path; +import java.util.function.Predicate; + +/** + * The control to edit file values from asset folder. + * + * @author JavaSaBr + */ +public class FileAssetResourcePropertyControl extends AssetResourcePropertyEditorControl { + + @NotNull + private static final Predicate> ACTION_TESTER = type -> type == NewFileAction.class; + + /** + * The list of target extensions. + */ + @NotNull + private final Array extensions; + + public FileAssetResourcePropertyControl(@NotNull final VarTable vars, @NotNull final PropertyDefinition definition, + @NotNull final Runnable validationCallback) { + super(vars, definition, validationCallback); + this.extensions = ArrayFactory.asArray(notNull(definition.getExtension())); + } + + @Override + @FromAnyThread + public @NotNull Predicate> getActionTester() { + return ACTION_TESTER; + } + + @Override + @FromAnyThread + protected @NotNull Array getExtensions() { + return extensions; + } + + @Override + @FXThread + protected void processSelect(@NotNull final Path file) { + setPropertyValue(notNull(getAssetFile(file))); + super.processSelect(file); + } + + @Override + @FXThread + protected void reload() { + + final Path file = getPropertyValue(); + + final Label 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 935d3aef..1f101a02 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,6 +1,7 @@ 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; @@ -28,6 +29,7 @@ protected FloatPropertyEditorControl(@NotNull final VarTable vars, @NotNull fina } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -39,8 +41,11 @@ protected void createComponents() { FXUtils.addToPane(valueField, this); } - @NotNull - private FloatTextField getValueField() { + /** + * @return the value field. + */ + @FXThread + private @NotNull FloatTextField getValueField() { return notNull(valueField); } @@ -50,12 +55,14 @@ private FloatTextField getValueField() { * @param min the min value. * @param max the max value. */ + @FXThread public void setMinMax(final float min, final float max) { if (Float.isNaN(min) || Float.isNaN(max)) return; getValueField().setMinMax(min, max); } @Override + @FXThread protected void reload() { super.reload(); final Float value = getPropertyValue(); @@ -63,6 +70,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { setPropertyValue(getValueField().getValue()); super.changeImpl(); 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 55113cd6..f5ad8ff8 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 @@ -4,6 +4,7 @@ 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; @@ -18,14 +19,14 @@ public class GeometryAssetResourcePropertyControl extends SpatialAssetResourcePropertyControl { public GeometryAssetResourcePropertyControl(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + @NotNull final PropertyDefinition definition, + @NotNull final Runnable validationCallback) { super(vars, definition, validationCallback); } - @Nullable @Override - protected Geometry findResource(@NotNull final AssetManager assetManager, @NotNull final ModelKey modelKey) { + @FXThread + protected @Nullable Geometry findResource(@NotNull final AssetManager assetManager, @NotNull final ModelKey modelKey) { final Spatial spatial = assetManager.loadModel(modelKey); return NodeUtils.findGeometry(spatial); } 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 400103c9..0773c49d 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,6 +1,7 @@ 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.IntegerTextField; @@ -28,6 +29,7 @@ protected IntegerPropertyEditorControl(@NotNull final VarTable vars, @NotNull fi } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -45,17 +47,22 @@ protected void createComponents() { * @param min the min value. * @param max the max value. */ + @FXThread public void setMinMax(final float min, final float max) { if (Float.isNaN(min) || Float.isNaN(max)) return; getValueField().setMinMax((int) min, (int) max); } - @NotNull - private IntegerTextField getValueField() { + /** + * @return the value field. + */ + @FXThread + private @NotNull IntegerTextField getValueField() { return notNull(valueField); } @Override + @FXThread protected void reload() { super.reload(); final Integer value = getPropertyValue(); @@ -63,6 +70,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { setPropertyValue(getValueField().getValue()); super.changeImpl(); 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 a0e69beb..5dc6fc9e 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 @@ -1,6 +1,8 @@ package com.ss.editor.plugin.api.property.control; import com.ss.editor.Editor; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.css.CSSClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; @@ -30,6 +32,9 @@ public class PropertyEditorControl extends HBox { */ public static final double DEFAULT_FIELD_W_PERCENT = AbstractSimpleEditorDialog.DEFAULT_FIELD_W_PERCENT; + /** + * The editor. + */ @NotNull protected static final Editor EDITOR = Editor.getInstance(); @@ -94,18 +99,22 @@ protected PropertyEditorControl(@NotNull final VarTable vars, @NotNull final Pro FXUtils.addClassTo(this, CSSClasses.ABSTRACT_PARAM_EDITOR_CONTROL); } + @FXThread protected void reload() { } + @FXThread protected void change() { if (isIgnoreListener()) return; changeImpl(); } + @FXThread protected void changeImpl() { validationCallback.run(); } + @FXThread protected void createComponents() { setAlignment(Pos.CENTER_RIGHT); @@ -121,8 +130,8 @@ protected void createComponents() { * * @return the name of the property. */ - @NotNull - protected String getName() { + @FromAnyThread + protected @NotNull String getName() { return name; } @@ -131,8 +140,8 @@ protected String getName() { * * @return the current property value. */ - @Nullable - protected T getPropertyValue() { + @FromAnyThread + protected @Nullable T getPropertyValue() { if (!vars.has(id)) return null; return vars.get(id); } @@ -142,7 +151,7 @@ protected T getPropertyValue() { * * @param propertyValue the new current property value. */ - @Nullable + @FXThread protected void setPropertyValue(@Nullable final T propertyValue) { if (propertyValue == null) { vars.clear(id); @@ -156,6 +165,7 @@ protected void setPropertyValue(@Nullable final T propertyValue) { * * @param ignoreListener the flag for ignoring listeners. */ + @FXThread protected void setIgnoreListener(final boolean ignoreListener) { this.ignoreListener = ignoreListener; } @@ -165,6 +175,7 @@ protected void setIgnoreListener(final boolean ignoreListener) { * * @return true if need to ignore listeners. */ + @FXThread protected boolean isIgnoreListener() { return ignoreListener; } 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 9e97aae0..323bcd7d 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 @@ -1,5 +1,6 @@ package com.ss.editor.plugin.api.property.control; +import com.ss.editor.annotation.FXThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.rlib.util.VarTable; import org.jetbrains.annotations.NotNull; @@ -11,10 +12,18 @@ */ public class PropertyEditorControlFactory { - @NotNull - public static PropertyEditorControl build(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validation) { + /** + * Build the property control for the property definition. + * + * @param vars the variables table. + * @param definition the definition. + * @param validation the validator. + * @return the new property control. + */ + @FXThread + public static @NotNull PropertyEditorControl build(@NotNull final VarTable vars, + @NotNull final PropertyDefinition definition, + @NotNull final Runnable validation) { switch (definition.getPropertyType()) { case FLOAT: { @@ -22,20 +31,31 @@ public static PropertyEditorControl build(@NotNull final VarTable vars, control.setMinMax(definition.getMin(), definition.getMax()); return control; } - case COLOR: return new ColorPropertyEditorControl(vars, definition, validation); - case BOOLEAN: return new BooleanPropertyEditorControl(vars, definition, validation); + case COLOR: + return new ColorPropertyEditorControl(vars, definition, validation); + case BOOLEAN: + return new BooleanPropertyEditorControl(vars, definition, validation); case INTEGER: { final IntegerPropertyEditorControl control = new IntegerPropertyEditorControl(vars, definition, validation); control.setMinMax(definition.getMin(), definition.getMax()); return control; } - case VECTOR_3F: return new Vector3fPropertyEditorControl(vars, definition, validation); - case ENUM: return new EnumPropertyEditorControl<>(vars, definition, validation); - case STRING: return new StringPropertyEditorControl(vars, definition, validation); - case GEOMETRY_FROM_ASSET_FOLDER: return new GeometryAssetResourcePropertyControl(vars, definition, validation); - case STRING_FROM_LIST: return new StringFromListPropertyEditorControl(vars, definition, validation, definition.getOptions()); - case AWT_FONT: return new AwtFontPropertyEditorControl(vars, definition, validation); - default: throw new IllegalArgumentException("Unknown the type " + definition.getPropertyType()); + case VECTOR_3F: + return new Vector3fPropertyEditorControl(vars, definition, validation); + case ENUM: + return new EnumPropertyEditorControl<>(vars, definition, validation); + case STRING: + return new StringPropertyEditorControl(vars, definition, validation); + case GEOMETRY_FROM_ASSET_FOLDER: + return new GeometryAssetResourcePropertyControl(vars, definition, validation); + case FILE_FROM_ASSET_FOLDER: + return new FileAssetResourcePropertyControl(vars, definition, validation); + case STRING_FROM_LIST: + return new StringFromListPropertyEditorControl(vars, definition, validation, definition.getOptions()); + case AWT_FONT: + return new AwtFontPropertyEditorControl(vars, definition, validation); + default: + throw new IllegalArgumentException("Unknown the type " + definition.getPropertyType()); } } } 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 cdcb2e42..fca48260 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 @@ -3,6 +3,7 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.css.CSSClasses; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -53,6 +54,7 @@ protected ResourcePropertyEditorControl(@NotNull final VarTable vars, @NotNull f } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -62,9 +64,10 @@ protected void createComponents() { changeButton.setGraphic(new ImageView(Icons.ADD_16)); changeButton.setOnAction(event -> processSelect()); - resourceLabel.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); - final HBox container = new HBox(resourceLabel, changeButton); + container.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); + + resourceLabel.prefWidthProperty().bind(container.widthProperty()); FXUtils.addToPane(container, this); @@ -78,6 +81,7 @@ protected void createComponents() { /** * Process select a resource. */ + @FXThread protected void processSelect() { } @@ -85,12 +89,14 @@ protected void processSelect() { /** * Handle grad exiting. */ + @FXThread private void dragExited(@NotNull final DragEvent dragEvent) { } /** * Handle dropped files to editor. */ + @FXThread private void dragDropped(@NotNull final DragEvent dragEvent) { final Dragboard dragboard = dragEvent.getDragboard(); @@ -111,12 +117,14 @@ private void dragDropped(@NotNull final DragEvent dragEvent) { * * @param file the dropped file. */ + @FXThread protected void handleFile(@NotNull final File file) { } /** * Handle drag over. */ + @FXThread private void dragOver(@NotNull final DragEvent dragEvent) { final Dragboard dragboard = dragEvent.getDragboard(); @@ -136,6 +144,7 @@ private void dragOver(@NotNull final DragEvent dragEvent) { dragEvent.consume(); } + @FXThread protected boolean canAccept(@NotNull final File file) { return false; } @@ -143,8 +152,8 @@ protected boolean canAccept(@NotNull final File file) { /** * @return the label with name of the resource. */ - @NotNull - protected Label getResourceLabel() { + @FXThread + protected @NotNull Label getResourceLabel() { return notNull(resourceLabel); } } 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 7ed8ff37..2c2f641b 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 @@ -10,6 +10,8 @@ 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.plugin.api.property.PropertyDefinition; import com.ss.rlib.util.VarTable; import com.ss.rlib.util.array.Array; @@ -35,18 +37,19 @@ public class SpatialAssetResourcePropertyControl extends Asse } public SpatialAssetResourcePropertyControl(@NotNull final VarTable vars, - @NotNull final PropertyDefinition definition, - @NotNull final Runnable validationCallback) { + @NotNull final PropertyDefinition definition, + @NotNull final Runnable validationCallback) { super(vars, definition, validationCallback); } - @NotNull @Override - protected Array getExtensions() { + @FromAnyThread + protected @NotNull Array getExtensions() { return EXTENSIONS; } @Override + @FXThread protected void processSelect(@NotNull final Path file) { final AssetManager assetManager = EDITOR.getAssetManager(); @@ -67,12 +70,13 @@ protected void processSelect(@NotNull final Path file) { * @param modelKey the model key. * @return the target resource. */ - @Nullable - protected T findResource(@NotNull final AssetManager assetManager, @NotNull final ModelKey modelKey) { + @FXThread + protected @Nullable T findResource(@NotNull final AssetManager assetManager, @NotNull final ModelKey modelKey) { return unsafeCast(assetManager.loadModel(modelKey)); } @Override + @FXThread protected void reload() { final T model = getPropertyValue(); 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 e423cd70..166c4608 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,6 +1,7 @@ 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; @@ -8,7 +9,6 @@ import com.ss.rlib.util.array.Array; import javafx.scene.control.ComboBox; import javafx.scene.control.SingleSelectionModel; -import org.controlsfx.control.textfield.TextFields; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,10 +35,17 @@ protected StringFromListPropertyEditorControl(@NotNull final VarTable vars, @Not if (options.size() > comboBox.getVisibleRowCount()) { setIgnoreListener(true); try { - comboBox.setEditable(true); - TextFields.bindAutoCompletion(comboBox.getEditor(), comboBox.getItems()); - FXUtils.addClassesTo(comboBox.getEditor(), CSSClasses.TRANSPARENT_TEXT_FIELD, CSSClasses.TEXT_FIELD_IN_COMBO_BOX); - reload(); + + //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()); + //binding.setOnAutoCompleted(event -> selectionModel.select(event.getCompletion())); + + //FXUtils.addClassesTo(editor, CSSClasses.TRANSPARENT_TEXT_FIELD, CSSClasses.TEXT_FIELD_IN_COMBO_BOX); + //reload(); } finally { setIgnoreListener(false); } @@ -46,6 +53,7 @@ protected StringFromListPropertyEditorControl(@NotNull final VarTable vars, @Not } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -61,12 +69,13 @@ protected void createComponents() { /** * @return The list of available options of the string value. */ - @NotNull - private ComboBox getComboBox() { + @FXThread + private @NotNull ComboBox getComboBox() { return notNull(comboBox); } @Override + @FXThread protected void reload() { super.reload(); final String value = getPropertyValue(); @@ -75,6 +84,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { final ComboBox comboBox = getComboBox(); final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); 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 8f9317d5..9fbb4de1 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,6 +1,7 @@ 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; @@ -28,6 +29,7 @@ protected StringPropertyEditorControl(@NotNull final VarTable vars, @NotNull fin } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -39,12 +41,16 @@ protected void createComponents() { FXUtils.addToPane(valueField, this); } - @NotNull - private TextField getValueField() { + /** + * @return the value field. + */ + @FXThread + private @NotNull TextField getValueField() { return notNull(valueField); } @Override + @FXThread protected void reload() { super.reload(); final String value = getPropertyValue(); @@ -52,6 +58,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { setPropertyValue(getValueField().getText()); super.changeImpl(); 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 b07f803e..17364ada 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,6 +1,7 @@ package com.ss.editor.plugin.api.property.control; 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.util.UIUtils; @@ -42,6 +43,7 @@ protected Vector3fPropertyEditorControl(@NotNull final VarTable vars, @NotNull f } @Override + @FXThread protected void createComponents() { super.createComponents(); @@ -75,28 +77,29 @@ protected void createComponents() { /** * @return the field X. */ - @NotNull - private FloatTextField getXField() { + @FXThread + private @NotNull FloatTextField getXField() { return xField; } /** * @return the field Y. */ - @NotNull - private FloatTextField getYField() { + @FXThread + private @NotNull FloatTextField getYField() { return yField; } /** * @return the field Z. */ - @NotNull - private FloatTextField getZField() { + @FXThread + private @NotNull FloatTextField getZField() { return zField; } @Override + @FXThread protected void reload() { super.reload(); @@ -113,6 +116,7 @@ protected void reload() { } @Override + @FXThread protected void changeImpl() { final FloatTextField xField = getXField(); final FloatTextField yField = getYField(); diff --git a/src/main/java/com/ss/editor/state/editor/impl/AdvancedAbstractEditor3DState.java b/src/main/java/com/ss/editor/state/editor/impl/AdvancedAbstractEditor3DState.java index 43a3d13d..380fd19b 100644 --- a/src/main/java/com/ss/editor/state/editor/impl/AdvancedAbstractEditor3DState.java +++ b/src/main/java/com/ss/editor/state/editor/impl/AdvancedAbstractEditor3DState.java @@ -483,6 +483,7 @@ protected void registerActionHandlers(@NotNull final ObjectDictionary analogHandlers) { analogHandlers.put(MOUSE_X_AXIS, (value, tpf) -> moveXMouse(value)); analogHandlers.put(MOUSE_X_AXIS_NEGATIVE, (value, tpf) -> moveXMouse(-value)); @@ -493,6 +494,7 @@ protected void registerAnalogHandlers(@NotNull final ObjectDictionary getFileEditor().notifyChangedStatus(Status.Stopped)); } @Override + @JMEThread public void update(final float tpf) { super.update(tpf); @@ -193,14 +201,15 @@ public void update(final float tpf) { /** * @return the audio node. */ - @Nullable - private AudioNode getAudioNode() { + @JMEThread + private @Nullable AudioNode getAudioNode() { return audioNode; } /** * @param audioNode the audio node. */ + @JMEThread private void setAudioNode(@Nullable final AudioNode audioNode) { this.audioNode = audioNode; } @@ -208,14 +217,15 @@ private void setAudioNode(@Nullable final AudioNode audioNode) { /** * @return the audio data. */ - @NotNull - private AudioData getAudioData() { + @JMEThread + private @NotNull AudioData getAudioData() { return notNull(audioData); } /** * @param audioData the audio data. */ + @JMEThread private void setAudioData(@NotNull final AudioData audioData) { this.audioData = audioData; } @@ -223,14 +233,15 @@ private void setAudioData(@NotNull final AudioData audioData) { /** * @return the audio key. */ - @NotNull - private AudioKey getAudioKey() { + @JMEThread + private @NotNull AudioKey getAudioKey() { return notNull(audioKey); } /** * @param audioKey the audio key. */ + @JMEThread private void setAudioKey(@NotNull final AudioKey audioKey) { this.audioKey = audioKey; } @@ -240,15 +251,15 @@ private void setAudioKey(@NotNull final AudioKey audioKey) { * * @return the previous status. */ - @Nullable @FromAnyThread - public Status getPrevStatus() { + public @Nullable Status getPrevStatus() { return prevStatus; } /** * @param prevStatus the previous status. */ + @JMEThread private void setPrevStatus(@Nullable final Status prevStatus) { this.prevStatus = prevStatus; } diff --git a/src/main/java/com/ss/editor/state/editor/impl/material/MaterialEditor3DState.java b/src/main/java/com/ss/editor/state/editor/impl/material/MaterialEditor3DState.java index d3308ae0..a2b01caf 100644 --- a/src/main/java/com/ss/editor/state/editor/impl/material/MaterialEditor3DState.java +++ b/src/main/java/com/ss/editor/state/editor/impl/material/MaterialEditor3DState.java @@ -1,368 +1,17 @@ package com.ss.editor.state.editor.impl.material; -import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.app.Application; -import com.jme3.app.state.AppStateManager; -import com.jme3.asset.AssetNotFoundException; -import com.jme3.input.InputManager; -import com.jme3.input.KeyInput; -import com.jme3.input.controls.KeyTrigger; -import com.jme3.light.DirectionalLight; -import com.jme3.material.Material; -import com.jme3.math.Vector3f; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.RendererException; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.scene.Geometry; -import com.jme3.scene.Node; -import com.jme3.scene.shape.Box; -import com.jme3.scene.shape.Quad; -import com.jme3.scene.shape.Sphere; -import com.ss.editor.EditorThread; -import com.ss.editor.model.EditorCamera; -import com.ss.editor.model.tool.TangentGenerator; -import com.ss.editor.plugin.api.editor.Advanced3DFileEditor; -import com.ss.editor.plugin.api.editor.part3d.AdvancedPBRWithStudioSky3DEditorState; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState; 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 javafx.scene.input.KeyCode; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * The implementation the 3D part of the {@link MaterialFileEditor} but it can be reused in other cases. * * @author JavaSaBr */ -public class MaterialEditor3DState extends AdvancedPBRWithStudioSky3DEditorState { +public class MaterialEditor3DState extends BaseMaterialEditor3DState { - @NotNull - private static final Vector3f QUAD_OFFSET = new Vector3f(0, -2, 2); - - @NotNull - private static final Vector3f LIGHT_DIRECTION = new Vector3f(0.007654993F, 0.39636374F, 0.9180617F).negate(); - - private static final float H_ROTATION = AngleUtils.degreeToRadians(75); - private static final float V_ROTATION = AngleUtils.degreeToRadians(25); - - @NotNull - private static final String KEY_C = "SSEditor.materialEditorState.C"; - - @NotNull - private static final String KEY_S = "SSEditor.materialEditorState.S"; - - @NotNull - private static final String KEY_P = "SSEditor.materialEditorState.P"; - - @NotNull - private static final String KEY_L = "SSEditor.materialEditorState.L"; - - static { - TRIGGERS.put(KEY_C, new KeyTrigger(KeyInput.KEY_C)); - TRIGGERS.put(KEY_S, new KeyTrigger(KeyInput.KEY_S)); - TRIGGERS.put(KEY_P, new KeyTrigger(KeyInput.KEY_P)); - TRIGGERS.put(KEY_L, new KeyTrigger(KeyInput.KEY_L)); - } - - /** - * The test box. - */ - @NotNull - private final Geometry testBox; - - /** - * The test sphere. - */ - @NotNull - private final Geometry testSphere; - - /** - * The test quad. - */ - @NotNull - private final Geometry testQuad; - - /** - * The current model mode. - */ - @Nullable - private ModelType currentModelType; - - /** - * The flag of enabling light. - */ - private boolean lightEnabled; - - /** - * Instantiates a new Material editor app state. - * - * @param fileEditor the file editor - */ - public MaterialEditor3DState(@NotNull final T fileEditor) { + public MaterialEditor3DState(@NotNull final MaterialFileEditor fileEditor) { super(fileEditor); - this.testBox = new Geometry("Box", new Box(2, 2, 2)); - this.testSphere = new Geometry("Sphere", new Sphere(30, 30, 2)); - this.testQuad = new Geometry("Quad", new Quad(4, 4)); - this.testQuad.setLocalTranslation(QUAD_OFFSET); - this.lightEnabled = MaterialFileEditor.DEFAULT_LIGHT_ENABLED; - - TangentGenerator.useMikktspaceGenerator(testBox); - TangentGenerator.useMikktspaceGenerator(testSphere); - TangentGenerator.useMikktspaceGenerator(testQuad); - - final DirectionalLight light = notNull(getLightForCamera()); - light.setDirection(LIGHT_DIRECTION); - - final EditorCamera editorCamera = notNull(getEditorCamera()); - editorCamera.setDefaultHorizontalRotation(H_ROTATION); - editorCamera.setDefaultVerticalRotation(V_ROTATION); - - getModelNode().attachChild(getNodeForCamera()); - } - - @Override - protected void registerActionHandlers(@NotNull final ObjectDictionary actionHandlers) { - super.registerActionHandlers(actionHandlers); - - final T fileEditor = getFileEditor(); - - actionHandlers.put(KEY_S, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.S, isPressed, isControlDown(), isButtonMiddleDown())); - actionHandlers.put(KEY_C, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.C, isPressed, isControlDown(), isButtonMiddleDown())); - actionHandlers.put(KEY_P, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.P, isPressed, isControlDown(), isButtonMiddleDown())); - actionHandlers.put(KEY_L, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.L, isPressed, isControlDown(), isButtonMiddleDown())); - } - - @Override - protected void registerActionListener(@NotNull final InputManager inputManager) { - super.registerActionListener(inputManager); - inputManager.addListener(actionListener, KEY_S, KEY_C, KEY_P, KEY_L); - } - - /** - * @return the test box. - */ - protected @NotNull Geometry getTestBox() { - return testBox; - } - - /** - * @return the test quad. - */ - protected @NotNull Geometry getTestQuad() { - return testQuad; - } - - /** - * @return the test sphere. - */ - protected @NotNull Geometry getTestSphere() { - return testSphere; - } - - /** - * Update the {@link Material}. - * - * @param material the material - */ - public void updateMaterial(@NotNull final Material material) { - EXECUTOR_MANAGER.addJMETask(() -> updateMaterialImpl(material)); - } - - /** - * Update the {@link Material} in the {@link EditorThread}. - */ - protected void updateMaterialImpl(@NotNull final Material material) { - - final Geometry testBox = getTestBox(); - testBox.setMaterial(material); - - final Geometry testQuad = getTestQuad(); - testQuad.setMaterial(material); - - final Geometry testSphere = getTestSphere(); - testSphere.setMaterial(material); - - final RenderManager renderManager = EDITOR.getRenderManager(); - try { - renderManager.preloadScene(testBox); - } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) { - EditorUtil.handleException(LOGGER, this, e); - testBox.setMaterial(EDITOR.getDefaultMaterial()); - testQuad.setMaterial(EDITOR.getDefaultMaterial()); - testSphere.setMaterial(EDITOR.getDefaultMaterial()); - } - } - - /** - * Change the {@link ModelType}. - * - * @param modelType the model type - */ - public void changeMode(@NotNull final ModelType modelType) { - EXECUTOR_MANAGER.addJMETask(() -> changeModeImpl(modelType)); - } - - /** - * Change the {@link ModelType} in the {@link EditorThread}. - */ - protected void changeModeImpl(@NotNull final ModelType modelType) { - - final Node modelNode = getModelNode(); - modelNode.detachAllChildren(); - - switch (modelType) { - case BOX: { - modelNode.attachChild(getTestBox()); - break; - } - case QUAD: { - modelNode.attachChild(getTestQuad()); - break; - } - case SPHERE: { - modelNode.attachChild(getTestSphere()); - break; - } - } - - setCurrentModelType(modelType); - } - - /** - * Change the {@link Bucket}. - * - * @param bucket the bucket - */ - public void changeBucketType(@NotNull final Bucket bucket) { - EXECUTOR_MANAGER.addJMETask(() -> changeBucketTypeImpl(bucket)); - } - - /** - * Change the {@link Bucket} in the {@link EditorThread}. - */ - protected void changeBucketTypeImpl(@NotNull final Bucket bucket) { - - final Geometry testQuad = getTestQuad(); - testQuad.setQueueBucket(bucket); - - final Geometry testSphere = getTestSphere(); - testSphere.setQueueBucket(bucket); - - final Geometry testBox = getTestBox(); - testBox.setQueueBucket(bucket); - } - - @Override - public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { - super.initialize(stateManager, application); - changeModeImpl(getCurrentModelType()); - } - - @Override - protected boolean needMovableCamera() { - return false; - } - - @Override - protected boolean needEditorCamera() { - return true; - } - - @Override - protected boolean needLightForCamera() { - return true; - } - - /** - * @return the current model mode. - */ - protected @NotNull ModelType getCurrentModelType() { - return notNull(currentModelType); - } - - /** - * @param currentModelType the current model mode. - */ - protected void setCurrentModelType(@NotNull final ModelType currentModelType) { - this.currentModelType = currentModelType; - } - - /** - * @return true if the light is enabled. - */ - protected boolean isLightEnabled() { - return lightEnabled; - } - - /** - * @param lightEnabled true if the light is enabled. - */ - protected void setLightEnabled(final boolean lightEnabled) { - this.lightEnabled = lightEnabled; - } - - /** - * Update the light in the scene. - * - * @param enabled the enabled - */ - public void updateLightEnabled(final boolean enabled) { - EXECUTOR_MANAGER.addJMETask(() -> updateLightEnabledImpl(enabled)); - } - - /** - * Update the light in the scene in the {@link EditorThread}. - */ - protected void updateLightEnabledImpl(boolean enabled) { - if (enabled == isLightEnabled()) return; - - final DirectionalLight light = getLightForCamera(); - final Node stateNode = getStateNode(); - - if (enabled) { - stateNode.addLight(light); - } else { - stateNode.removeLight(light); - } - - setLightEnabled(enabled); - } - - @Override - protected boolean needUpdateCameraLight() { - return false; - } - - /** - * The enum Model type. - */ - public enum ModelType { - /** - * Sphere model type. - */ - SPHERE, - /** - * Box model type. - */ - BOX, - /** - * Quad model type. - */ - QUAD; - - private static final ModelType[] VALUES = values(); - - /** - * Value of model type. - * - * @param index the index - * @return the model type - */ - public static ModelType valueOf(final int index) { - return VALUES[index]; - } } } diff --git a/src/main/java/com/ss/editor/state/editor/impl/model/ModelEditor3DState.java b/src/main/java/com/ss/editor/state/editor/impl/model/ModelEditor3DState.java index 7afa3ead..2f20a9da 100644 --- a/src/main/java/com/ss/editor/state/editor/impl/model/ModelEditor3DState.java +++ b/src/main/java/com/ss/editor/state/editor/impl/model/ModelEditor3DState.java @@ -7,14 +7,14 @@ import com.jme3.light.LightProbe; import com.jme3.scene.Node; import com.jme3.scene.Spatial; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.JMEThread; import com.ss.editor.state.editor.impl.scene.AbstractSceneEditor3DState; import com.ss.editor.ui.component.editor.impl.model.ModelFileEditor; - -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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import tonegod.emitter.filter.TonegodTranslucentBucketFilter; /** @@ -62,11 +62,6 @@ public void done(final LightProbe result) { */ private int frame; - /** - * Instantiates a new Model editor app state. - * - * @param fileEditor the file editor - */ public ModelEditor3DState(final ModelFileEditor fileEditor) { super(fileEditor); this.customSkyNode = new Node("Custom Sky"); @@ -81,22 +76,23 @@ public ModelEditor3DState(final ModelFileEditor fileEditor) { /** * @return the node for the placement of custom sky. */ - @NotNull - private Node getCustomSkyNode() { + @JMEThread + private @NotNull Node getCustomSkyNode() { return customSkyNode; } /** * @return the array of custom skies. */ - @NotNull - private Array getCustomSky() { + @JMEThread + private @NotNull Array getCustomSky() { return customSky; } /** * Activate the node with models. */ + @JMEThread private void notifyProbeComplete() { final Node stateNode = getStateNode(); @@ -113,6 +109,7 @@ private void notifyProbeComplete() { /** * @param currentFastSky the current fast sky. */ + @JMEThread private void setCurrentFastSky(@Nullable final Spatial currentFastSky) { this.currentFastSky = currentFastSky; } @@ -120,14 +117,15 @@ private void setCurrentFastSky(@Nullable final Spatial currentFastSky) { /** * @return the current fast sky. */ - @Nullable - private Spatial getCurrentFastSky() { + @JMEThread + private @Nullable Spatial getCurrentFastSky() { return currentFastSky; } /** * @return true if the light of the camera is enabled. */ + @JMEThread private boolean isLightEnabled() { return lightEnabled; } @@ -135,17 +133,20 @@ private boolean isLightEnabled() { /** * @param lightEnabled the flag of activity light of the camera. */ + @JMEThread private void setLightEnabled(final boolean lightEnabled) { this.lightEnabled = lightEnabled; } @Override + @JMEThread public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { super.initialize(stateManager, application); frame = 0; } @Override + @JMEThread public void cleanup() { super.cleanup(); @@ -155,6 +156,7 @@ public void cleanup() { } @Override + @JMEThread public void update(final float tpf) { super.update(tpf); @@ -172,11 +174,13 @@ public void update(final float tpf) { } @Override + @JMEThread protected boolean needUpdateCameraLight() { return true; } @Override + @JMEThread protected boolean needLightForCamera() { return true; } @@ -186,6 +190,7 @@ protected boolean needLightForCamera() { * * @param enabled the enabled */ + @FromAnyThread public void updateLightEnabled(final boolean enabled) { EXECUTOR_MANAGER.addJMETask(() -> updateLightEnabledImpl(enabled)); } @@ -193,6 +198,7 @@ public void updateLightEnabled(final boolean enabled) { /** * The process of updating the light. */ + @JMEThread private void updateLightEnabledImpl(boolean enabled) { if (enabled == isLightEnabled()) return; @@ -213,6 +219,7 @@ private void updateLightEnabledImpl(boolean enabled) { * * @param fastSky the fast sky */ + @FromAnyThread public void changeFastSky(@Nullable final Spatial fastSky) { EXECUTOR_MANAGER.addJMETask(() -> changeFastSkyImpl(fastSky)); } @@ -220,6 +227,7 @@ public void changeFastSky(@Nullable final Spatial fastSky) { /** * The process of changing the fast sky. */ + @JMEThread private void changeFastSkyImpl(@Nullable final Spatial fastSky) { final Node stateNode = getStateNode(); @@ -246,6 +254,7 @@ private void changeFastSkyImpl(@Nullable final Spatial fastSky) { * * @param sky the sky */ + @FromAnyThread public void addCustomSky(@NotNull final Spatial sky) { EXECUTOR_MANAGER.addJMETask(() -> addCustomSkyImpl(sky)); } @@ -253,6 +262,7 @@ public void addCustomSky(@NotNull final Spatial sky) { /** * The process of adding the custom sky. */ + @JMEThread private void addCustomSkyImpl(@NotNull final Spatial sky) { final Array customSky = getCustomSky(); customSky.add(sky); @@ -263,6 +273,7 @@ private void addCustomSkyImpl(@NotNull final Spatial sky) { * * @param sky the sky */ + @FromAnyThread public void removeCustomSky(@NotNull final Spatial sky) { EXECUTOR_MANAGER.addJMETask(() -> removeCustomSkyImpl(sky)); } @@ -270,6 +281,7 @@ public void removeCustomSky(@NotNull final Spatial sky) { /** * The process of removing the custom sky. */ + @JMEThread private void removeCustomSkyImpl(@NotNull final Spatial sky) { final Array customSky = getCustomSky(); customSky.slowRemove(sky); @@ -278,6 +290,7 @@ private void removeCustomSkyImpl(@NotNull final Spatial sky) { /** * Update the light probe. */ + @FromAnyThread public void updateLightProbe() { EXECUTOR_MANAGER.addJMETask(() -> { diff --git a/src/main/java/com/ss/editor/state/editor/impl/scene/AbstractSceneEditor3DState.java b/src/main/java/com/ss/editor/state/editor/impl/scene/AbstractSceneEditor3DState.java index 20083c60..16de3bd9 100644 --- a/src/main/java/com/ss/editor/state/editor/impl/scene/AbstractSceneEditor3DState.java +++ b/src/main/java/com/ss/editor/state/editor/impl/scene/AbstractSceneEditor3DState.java @@ -355,10 +355,17 @@ protected void registerActionHandlers(@NotNull final ObjectDictionary fileEditor.handleKeyAction(KeyCode.S, isPressed, isControlDown(), isButtonMiddleDown())); - actionHandlers.put(KEY_G, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.G, isPressed, isControlDown(), isButtonMiddleDown())); - actionHandlers.put(KEY_R, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.R, isPressed, isControlDown(), isButtonMiddleDown())); - actionHandlers.put(KEY_DEL, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.DELETE, isPressed, isControlDown(), isButtonMiddleDown())); + actionHandlers.put(KEY_S, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.S, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); + + actionHandlers.put(KEY_G, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.G, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); + + actionHandlers.put(KEY_R, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.R, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); + + actionHandlers.put(KEY_DEL, (isPressed, tpf) -> + fileEditor.handleKeyAction(KeyCode.DELETE, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); } @Override diff --git a/src/main/java/com/ss/editor/state/editor/impl/scene/SceneEditor3DState.java b/src/main/java/com/ss/editor/state/editor/impl/scene/SceneEditor3DState.java index f1463f3e..e0899b36 100644 --- a/src/main/java/com/ss/editor/state/editor/impl/scene/SceneEditor3DState.java +++ b/src/main/java/com/ss/editor/state/editor/impl/scene/SceneEditor3DState.java @@ -7,6 +7,7 @@ import com.jme3.post.filters.ToneMapFilter; import com.jme3.scene.Node; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.JMEThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.extension.scene.app.state.SceneAppState; @@ -32,11 +33,6 @@ public class SceneEditor3DState extends AbstractSceneEditor3DState addAppStateImpl(appState)); } + @JMEThread private void addAppStateImpl(@NotNull final SceneAppState appState) { final AppStateManager stateManager = EDITOR.getStateManager(); stateManager.attach(appState); @@ -122,6 +124,7 @@ public void removeAppState(@NotNull final SceneAppState appState) { EXECUTOR_MANAGER.addJMETask(() -> removeAppStateImpl(appState)); } + @JMEThread private void removeAppStateImpl(@NotNull final SceneAppState appState) { final AppStateManager stateManager = EDITOR.getStateManager(); stateManager.detach(appState); @@ -137,6 +140,7 @@ public void addFilter(@NotNull final SceneFilter sceneFilter) { EXECUTOR_MANAGER.addJMETask(() -> addFilterImpl(sceneFilter)); } + @JMEThread private void addFilterImpl(@NotNull final SceneFilter sceneFilter) { final FilterPostProcessor postProcessor = EDITOR.getPostProcessor(); postProcessor.addFilter(sceneFilter.get()); @@ -152,6 +156,7 @@ public void removeFilter(@NotNull final SceneFilter sceneFilter) { EXECUTOR_MANAGER.addJMETask(() -> removeFilterImpl(sceneFilter)); } + @JMEThread private void removeFilterImpl(@NotNull final SceneFilter sceneFilter) { final FilterPostProcessor postProcessor = EDITOR.getPostProcessor(); postProcessor.removeFilter(sceneFilter.get()); @@ -160,6 +165,7 @@ private void removeFilterImpl(@NotNull final SceneFilter sceneFilter) { /** * @return true if need to show light models. */ + @JMEThread private boolean isLightShowed() { return lightShowed; } @@ -167,6 +173,7 @@ private boolean isLightShowed() { /** * @param lightShowed true if need to show light models. */ + @JMEThread private void setLightShowed(final boolean lightShowed) { this.lightShowed = lightShowed; } @@ -174,6 +181,7 @@ private void setLightShowed(final boolean lightShowed) { /** * @return true if need to show audio models. */ + @JMEThread private boolean isAudioShowed() { return audioShowed; } @@ -181,6 +189,7 @@ private boolean isAudioShowed() { /** * @param audioShowed true if need to show audio models. */ + @JMEThread private void setAudioShowed(final boolean audioShowed) { this.audioShowed = audioShowed; } @@ -190,6 +199,7 @@ private void setAudioShowed(final boolean audioShowed) { * * @param showed the showed */ + @FromAnyThread public void updateLightShowed(final boolean showed) { EXECUTOR_MANAGER.addJMETask(() -> updateLightShowedImpl(showed)); } @@ -197,6 +207,7 @@ public void updateLightShowed(final boolean showed) { /** * The process to change light showing. */ + @JMEThread private void updateLightShowedImpl(final boolean showed) { if (showed == isLightShowed()) return; @@ -217,6 +228,7 @@ private void updateLightShowedImpl(final boolean showed) { * * @param showed the showed */ + @FromAnyThread public void updateAudioShowed(final boolean showed) { EXECUTOR_MANAGER.addJMETask(() -> updateAudioShowedImpl(showed)); } @@ -224,6 +236,7 @@ public void updateAudioShowed(final boolean showed) { /** * The process to change audio showing. */ + @JMEThread private void updateAudioShowedImpl(final boolean showed) { if (showed == isAudioShowed()) return; diff --git a/src/main/java/com/ss/editor/ui/Icons.java b/src/main/java/com/ss/editor/ui/Icons.java index 0d8ee850..728cccaa 100644 --- a/src/main/java/com/ss/editor/ui/Icons.java +++ b/src/main/java/com/ss/editor/ui/Icons.java @@ -11,384 +11,105 @@ */ public interface Icons { - /** - * The constant ICON_MANAGER. - */ - @NotNull - FileIconManager ICON_MANAGER = FileIconManager.getInstance(); + @NotNull FileIconManager ICON_MANAGER = FileIconManager.getInstance(); - /** - * The constant REMOVE_12. - */ - Image REMOVE_12 = ICON_MANAGER.getImage("/ui/icons/svg/horizontal-line-remove-button.svg", 12, false); - /** - * The constant ADD_12. - */ - Image ADD_12 = ICON_MANAGER.getImage("/ui/icons/svg/add-plus-button.svg", 12, false); + @NotNull Image REMOVE_12 = ICON_MANAGER.getImage("/ui/icons/svg/horizontal-line-remove-button.svg", 12, false); + @NotNull Image ADD_12 = ICON_MANAGER.getImage("/ui/icons/svg/add-plus-button.svg", 12, false); - /** - * The constant SAVE_16. - */ - Image SAVE_16 = ICON_MANAGER.getImage("/ui/icons/svg/save-disk.svg", 16); - /** - * The constant SCALE_16. - */ - Image SCALE_16 = ICON_MANAGER.getImage("/ui/icons/svg/resize.svg", 16); - /** - * The constant ROTATION_16. - */ - Image ROTATION_16 = ICON_MANAGER.getImage("/ui/icons/svg/eliptical-arrows.svg", 16); - /** - * The constant CUBE_16. - */ - Image CUBE_16 = ICON_MANAGER.getImage("/ui/icons/svg/hollow-cube.svg"); - /** - * The constant MOVE_16. - */ - Image MOVE_16 = ICON_MANAGER.getImage("/ui/icons/svg/move-arrows.svg", 16); - /** - * The constant LIGHT_16. - */ - Image LIGHT_16 = ICON_MANAGER.getImage("/ui/icons/svg/idea.svg"); - /** - * The constant INFLUENCER_16. - */ - Image INFLUENCER_16 = ICON_MANAGER.getImage("/ui/icons/svg/enhance-effect.svg", 16); - /** - * The constant SPHERE_16. - */ - Image SPHERE_16 = ICON_MANAGER.getImage("/ui/icons/svg/planet-sphere.svg"); - /** - * The constant PLANE_16. - */ - Image PLANE_16 = ICON_MANAGER.getImage("/ui/icons/svg/table.svg", 16); - /** - * The constant NODE_16. - */ - Image NODE_16 = ICON_MANAGER.getImage("/ui/icons/svg/family-tree.svg"); - /** - * The constant PARTICLES_16. - */ - Image PARTICLES_16 = ICON_MANAGER.getImage("/ui/icons/svg/molecule_2.svg", 16); - /** - * The DEBUG_16 PARTICLES_16. - */ - Image DEBUG_16 = ICON_MANAGER.getImage("/ui/icons/svg/debug.svg", 16); - /** - * The constant GEOMETRY_16. - */ - Image GEOMETRY_16 = ICON_MANAGER.getImage("/ui/icons/svg/cube-divisions.svg"); - /** - * The constant MESH_16. - */ - Image MESH_16 = ICON_MANAGER.getImage("/ui/icons/svg/grid.svg"); - /** - * The constant MESH_16. - */ - Image MATERIAL_16 = ICON_MANAGER.getImage("/ui/icons/svg/draws.svg"); - /** - * The constant EDIT_16. - */ - Image EDIT_16 = ICON_MANAGER.getImage("/ui/icons/svg/pencil-edit-button.svg"); - /** - * The constant AMBIENT_16. - */ - Image AMBIENT_16 = ICON_MANAGER.getImage("/ui/icons/svg/brightness.svg"); - /** - * The constant LAMP_16. - */ - Image LAMP_16 = ICON_MANAGER.getImage("/ui/icons/svg/lantern.svg"); - /** - * The constant POINT_LIGHT_16. - */ - Image POINT_LIGHT_16 = ICON_MANAGER.getImage("/ui/icons/svg/light-bulb.svg"); - /** - * The constant SUN_16. - */ - Image SUN_16 = ICON_MANAGER.getImage("/ui/icons/svg/sunny-day.svg"); - /** - * The constant PLAY_16. - */ - Image PLAY_16 = ICON_MANAGER.getImage("/ui/icons/svg/play-button.svg"); - /** - * The constant STOP_16. - */ - Image STOP_16 = ICON_MANAGER.getImage("/ui/icons/svg/stop.svg"); - /** - * The constant PAUSE_16. - */ - Image PAUSE_16 = ICON_MANAGER.getImage("/ui/icons/svg/pause.svg"); - /** - * The constant ANIMATION_16. - */ - Image ANIMATION_16 = ICON_MANAGER.getImage("/ui/icons/svg/movie-symbol-of-video-camera.svg", 16); - /** - * The constant GEAR_16. - */ - Image GEAR_16 = ICON_MANAGER.getImage("/ui/icons/svg/settings.svg", 16); - /** - * The constant EXPORT_16. - */ - Image EXPORT_16 = ICON_MANAGER.getImage("/ui/icons/svg/scale-symbol.svg", 16); - /** - * The constant EXPORT_16. - */ - Image EXPLORER_16 = ICON_MANAGER.getImage("/ui/icons/svg/inbox.svg", 16); - /** - * The constant EXPORT_16. - */ - Image EDIT_2_16 = ICON_MANAGER.getImage("/ui/icons/svg/font-selection-editor.svg", 16); - /** - * The constant BONE_16. - */ - Image BONE_16 = ICON_MANAGER.getImage("/ui/icons/svg/bone.svg", 16); - /** - * The constant AUDIO_16. - */ - Image AUDIO_16 = ICON_MANAGER.getImage("/ui/icons/svg/audio-volume.svg"); - /** - * The constant SETTINGS_16. - */ - Image SETTINGS_16 = ICON_MANAGER.getImage("/ui/icons/svg/settings.svg"); - /** - * The constant PASTE_16. - */ - Image PASTE_16 = ICON_MANAGER.getImage("/ui/icons/svg/clipboard-paste-option.svg"); - /** - * The constant NEW_FILE_16. - */ - Image NEW_FILE_16 = ICON_MANAGER.getImage("/ui/icons/svg/add-new-file.svg", 16); - /** - * The constant CUT_16. - */ - Image CUT_16 = ICON_MANAGER.getImage("/ui/icons/svg/cut-content-button.svg", 16); - /** - * The constant COPY_16. - */ - Image COPY_16 = ICON_MANAGER.getImage("/ui/icons/svg/copy-file.svg", 16); - /** - * The constant TRANSFORMATION_16. - */ - Image TRANSFORMATION_16 = ICON_MANAGER.getImage("/ui/icons/svg/transformation-of-geometric-shapes-from-cube-to-cone-outlines.svg"); - /** - * The constant EXTRACT_16. - */ - Image EXTRACT_16 = ICON_MANAGER.getImage("/ui/icons/svg/extract-image.svg", 16); - /** - * The constant SCENE_16. - */ - Image SCENE_16 = ICON_MANAGER.getImage("/ui/icons/svg/line-segment.svg"); - /** - * The constant LAYERS_16. - */ - Image LAYERS_16 = ICON_MANAGER.getImage("/ui/icons/svg/layers.svg", 16); - /** - * The constant OPEN_FILE_16. - */ - Image OPEN_FILE_16 = ICON_MANAGER.getImage("/ui/icons/svg/open-folder-with-document.svg"); - /** - * The constant EMITTER_16. - */ - Image EMITTER_16 = ICON_MANAGER.getImage("/ui/icons/svg/atom-symbol.svg", 16); - /** - * The constant SKY_16. - */ - Image SKY_16 = ICON_MANAGER.getImage("/ui/icons/svg/cloudy-day-outlined-weather-interface-symbol.svg"); - /** - * The constant INVISIBLE_16. - */ - Image INVISIBLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/invisible.svg", 16); - /** - * The constant VISIBLE_16. - */ - Image VISIBLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/eye-view-interface-symbol.svg"); - /** - * The constant STATIC_RIGID_BODY_16. - */ - Image STATIC_RIGID_BODY_16 = ICON_MANAGER.getImage("/ui/icons/svg/brickwall-.svg"); - /** - * The constant RIGID_BODY_16. - */ - Image RIGID_BODY_16 = ICON_MANAGER.getImage("/ui/icons/svg/soccer-ball.svg"); - /** - * The constant REPLAY_16. - */ - Image REPLAY_16 = ICON_MANAGER.getImage("/ui/icons/svg/replay.svg"); - /** - * The constant CHARACTER_16. - */ - Image CHARACTER_16 = ICON_MANAGER.getImage("/ui/icons/svg/user-silhouette.svg", 16); - /** - * The constant SKELETON_16. - */ - Image SKELETON_16 = ICON_MANAGER.getImage("/ui/icons/svg/bones.svg"); - /** - * The constant VEHICLE_16. - */ - Image VEHICLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/sports-car.svg"); - /** - * The constant ATOM_16. - */ - Image ATOM_16 = ICON_MANAGER.getImage("/ui/icons/svg/molecule.svg", 16); - /** - * The constant PHYSICS_16. - */ - Image PHYSICS_16 = ICON_MANAGER.getImage("/ui/icons/svg/black-hole.svg", 16); - /** - * The constant DOLL_16. - */ - Image DOLL_16 = ICON_MANAGER.getImage("/ui/icons/svg/doll.svg", 16); - /** - * The constant CAPSULE_16. - */ - Image CAPSULE_16 = ICON_MANAGER.getImage("/ui/icons/svg/capsule-black-and-white-variant.svg", 16); - /** - * The constant CONE_16. - */ - Image CONE_16 = ICON_MANAGER.getImage("/ui/icons/svg/cone-geometrical-shape.svg", 16); - /** - * The constant CYLINDER_16. - */ - Image CYLINDER_16 = ICON_MANAGER.getImage("/ui/icons/svg/cylinder.svg"); - /** - * The constant TERRAIN_16. - */ - Image TERRAIN_16 = ICON_MANAGER.getImage("/ui/icons/svg/terrain.svg"); - /** - * The constant WHEEL_16. - */ - Image WHEEL_16 = ICON_MANAGER.getImage("/ui/icons/svg/wheel.svg"); - /** - * The constant TRIANGLE_16. - */ - Image TRIANGLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/triangle.svg"); - /** - * The constant DOME_16. - */ - Image DOME_16 = ICON_MANAGER.getImage("/ui/icons/svg/reichstag-dome.svg"); - /** - * The constant QUAD_16. - */ - Image QUAD_16 = ICON_MANAGER.getImage("/ui/icons/svg/basic-square.svg"); - /** - * The constant RHOMB_16. - */ - Image RHOMB_16 = ICON_MANAGER.getImage("/ui/icons/svg/rhombus.svg"); - /** - * The constant TORUS_16. - */ - Image TORUS_16 = ICON_MANAGER.getImage("/ui/icons/svg/circle.svg"); - /** - * The constant POINTS_16. - */ - Image POINTS_16 = ICON_MANAGER.getImage("/ui/icons/svg/because-mathematical-symbol.svg"); - /** - * The constant IMPOSTOR_16. - */ - Image IMPOSTOR_16 = ICON_MANAGER.getImage("/ui/icons/svg/plus.svg"); - /** - * The constant REMOVE_16. - */ - Image REMOVE_16 = ICON_MANAGER.getImage("/ui/icons/svg/horizontal-line-remove-button.svg", 16, false); - /** - * The constant ADD_16. - */ - Image ADD_16 = ICON_MANAGER.getImage("/ui/icons/svg/add-plus-button.svg", 16, false); - /** - * The constant MOTION_16. - */ - Image MOTION_16 = ICON_MANAGER.getImage("/ui/icons/svg/horse-in-running-motion-silhouette.svg", 16, false); - /** - * The constant PATH_16. - */ - Image PATH_16 = ICON_MANAGER.getImage("/ui/icons/svg/map-location.svg", 16, false); - /** - * The constant WAY_POINT_16. - */ - Image WAY_POINT_16 = ICON_MANAGER.getImage("/ui/icons/svg/placeholder.svg", 16, false); - /** - * The constant VERTEX_16. - */ - Image VERTEX_16 = ICON_MANAGER.getImage("/ui/icons/svg/graphene.svg", 16, false); - /** - * The constant DATA_16. - */ - Image DATA_16 = ICON_MANAGER.getImage("/ui/icons/svg/database.svg", 16, false); - /** - * The constant LINKED_NODE_16. - */ - Image LINKED_NODE_16 = ICON_MANAGER.getImage("/ui/icons/svg/link.svg"); - /** - * The constant LINK_FILE_16. - */ - Image LINK_FILE_16 = ICON_MANAGER.getImage("/ui/icons/svg/link-folder-with-document.svg"); - /** - * The constant STATISTICS_16. - */ - Image STATISTICS_16 = ICON_MANAGER.getImage("/ui/icons/svg/bar-chart.svg"); - /** - * The constant STATISTICS_16. - */ - Image DOR_IN_CIRCLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/dot-and-circle.svg"); - /** - * The constant PLUGIN_16. - */ - Image PLUGIN_16 = ICON_MANAGER.getImage("/ui/icons/svg/plug-silhouette.svg"); + @NotNull Image SAVE_16 = ICON_MANAGER.getImage("/ui/icons/svg/save-disk.svg", 16); + @NotNull Image SCALE_16 = ICON_MANAGER.getImage("/ui/icons/svg/resize.svg", 16); + @NotNull Image ROTATION_16 = ICON_MANAGER.getImage("/ui/icons/svg/eliptical-arrows.svg", 16); + @NotNull Image CUBE_16 = ICON_MANAGER.getImage("/ui/icons/svg/hollow-cube.svg"); + @NotNull Image MOVE_16 = ICON_MANAGER.getImage("/ui/icons/svg/move-arrows.svg", 16); + @NotNull Image LIGHT_16 = ICON_MANAGER.getImage("/ui/icons/svg/idea.svg"); + @NotNull Image INFLUENCER_16 = ICON_MANAGER.getImage("/ui/icons/svg/enhance-effect.svg", 16); + @NotNull Image SPHERE_16 = ICON_MANAGER.getImage("/ui/icons/svg/planet-sphere.svg"); + @NotNull Image PLANE_16 = ICON_MANAGER.getImage("/ui/icons/svg/table.svg", 16); + @NotNull Image NODE_16 = ICON_MANAGER.getImage("/ui/icons/svg/family-tree.svg"); + @NotNull Image PARTICLES_16 = ICON_MANAGER.getImage("/ui/icons/svg/molecule_2.svg", 16); + @NotNull Image DEBUG_16 = ICON_MANAGER.getImage("/ui/icons/svg/debug.svg", 16); + @NotNull Image GEOMETRY_16 = ICON_MANAGER.getImage("/ui/icons/svg/cube-divisions.svg"); + @NotNull Image MESH_16 = ICON_MANAGER.getImage("/ui/icons/svg/grid.svg"); + @NotNull Image MATERIAL_16 = ICON_MANAGER.getImage("/ui/icons/svg/draws.svg"); + @NotNull Image EDIT_16 = ICON_MANAGER.getImage("/ui/icons/svg/pencil-edit-button.svg"); + @NotNull Image AMBIENT_16 = ICON_MANAGER.getImage("/ui/icons/svg/brightness.svg"); + @NotNull Image LAMP_16 = ICON_MANAGER.getImage("/ui/icons/svg/lantern.svg"); + @NotNull Image POINT_LIGHT_16 = ICON_MANAGER.getImage("/ui/icons/svg/light-bulb.svg"); + @NotNull Image SUN_16 = ICON_MANAGER.getImage("/ui/icons/svg/sunny-day.svg"); + @NotNull Image PLAY_16 = ICON_MANAGER.getImage("/ui/icons/svg/play-button.svg"); + @NotNull Image STOP_16 = ICON_MANAGER.getImage("/ui/icons/svg/stop.svg"); + @NotNull Image PAUSE_16 = ICON_MANAGER.getImage("/ui/icons/svg/pause.svg"); + @NotNull Image ANIMATION_16 = ICON_MANAGER.getImage("/ui/icons/svg/movie-symbol-of-video-camera.svg", 16); + @NotNull Image GEAR_16 = ICON_MANAGER.getImage("/ui/icons/svg/settings.svg", 16); + @NotNull Image EXPORT_16 = ICON_MANAGER.getImage("/ui/icons/svg/scale-symbol.svg", 16); + @NotNull Image IMPORT_16 = ICON_MANAGER.getImage("/ui/icons/svg/import.svg", 16); + @NotNull Image EXPLORER_16 = ICON_MANAGER.getImage("/ui/icons/svg/inbox.svg", 16); + @NotNull Image EDIT_2_16 = ICON_MANAGER.getImage("/ui/icons/svg/font-selection-editor.svg", 16); + @NotNull Image BONE_16 = ICON_MANAGER.getImage("/ui/icons/svg/bone.svg", 16); + @NotNull Image AUDIO_16 = ICON_MANAGER.getImage("/ui/icons/svg/audio-volume.svg"); + @NotNull Image SETTINGS_16 = ICON_MANAGER.getImage("/ui/icons/svg/settings.svg"); + @NotNull Image PASTE_16 = ICON_MANAGER.getImage("/ui/icons/svg/clipboard-paste-option.svg"); + @NotNull Image NEW_FILE_16 = ICON_MANAGER.getImage("/ui/icons/svg/add-new-file.svg", 16); + @NotNull Image CUT_16 = ICON_MANAGER.getImage("/ui/icons/svg/cut-content-button.svg", 16); + @NotNull Image COPY_16 = ICON_MANAGER.getImage("/ui/icons/svg/copy-file.svg", 16); + @NotNull Image TRANSFORMATION_16 = ICON_MANAGER.getImage("/ui/icons/svg/transformation-of-geometric-shapes-from-cube-to-cone-outlines.svg"); + @NotNull Image EXTRACT_16 = ICON_MANAGER.getImage("/ui/icons/svg/extract-image.svg", 16); + @NotNull Image SCENE_16 = ICON_MANAGER.getImage("/ui/icons/svg/line-segment.svg"); + @NotNull Image LAYERS_16 = ICON_MANAGER.getImage("/ui/icons/svg/layers.svg", 16); + @NotNull Image OPEN_FILE_16 = ICON_MANAGER.getImage("/ui/icons/svg/open-folder-with-document.svg"); + @NotNull Image EMITTER_16 = ICON_MANAGER.getImage("/ui/icons/svg/atom-symbol.svg", 16); + @NotNull Image SKY_16 = ICON_MANAGER.getImage("/ui/icons/svg/cloudy-day-outlined-weather-interface-symbol.svg"); + @NotNull Image INVISIBLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/invisible.svg", 16); + @NotNull Image VISIBLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/eye-view-interface-symbol.svg"); + @NotNull Image STATIC_RIGID_BODY_16 = ICON_MANAGER.getImage("/ui/icons/svg/brickwall-.svg"); + @NotNull Image RIGID_BODY_16 = ICON_MANAGER.getImage("/ui/icons/svg/soccer-ball.svg"); + @NotNull Image REPLAY_16 = ICON_MANAGER.getImage("/ui/icons/svg/replay.svg"); + @NotNull Image CHARACTER_16 = ICON_MANAGER.getImage("/ui/icons/svg/user-silhouette.svg", 16); + @NotNull Image SKELETON_16 = ICON_MANAGER.getImage("/ui/icons/svg/bones.svg"); + @NotNull Image VEHICLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/sports-car.svg"); + @NotNull Image ATOM_16 = ICON_MANAGER.getImage("/ui/icons/svg/molecule.svg", 16); + @NotNull Image PHYSICS_16 = ICON_MANAGER.getImage("/ui/icons/svg/black-hole.svg", 16); + @NotNull Image DOLL_16 = ICON_MANAGER.getImage("/ui/icons/svg/doll.svg", 16); + @NotNull Image CAPSULE_16 = ICON_MANAGER.getImage("/ui/icons/svg/capsule-black-and-white-variant.svg", 16); + @NotNull Image CONE_16 = ICON_MANAGER.getImage("/ui/icons/svg/cone-geometrical-shape.svg", 16); + @NotNull Image CYLINDER_16 = ICON_MANAGER.getImage("/ui/icons/svg/cylinder.svg"); + @NotNull Image TERRAIN_16 = ICON_MANAGER.getImage("/ui/icons/svg/terrain.svg"); + @NotNull Image WHEEL_16 = ICON_MANAGER.getImage("/ui/icons/svg/wheel.svg"); + @NotNull Image TRIANGLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/triangle.svg"); + @NotNull Image DOME_16 = ICON_MANAGER.getImage("/ui/icons/svg/reichstag-dome.svg"); + @NotNull Image QUAD_16 = ICON_MANAGER.getImage("/ui/icons/svg/basic-square.svg"); + @NotNull Image RHOMB_16 = ICON_MANAGER.getImage("/ui/icons/svg/rhombus.svg"); + @NotNull Image TORUS_16 = ICON_MANAGER.getImage("/ui/icons/svg/circle.svg"); + @NotNull Image POINTS_16 = ICON_MANAGER.getImage("/ui/icons/svg/because-mathematical-symbol.svg"); + @NotNull Image IMPOSTOR_16 = ICON_MANAGER.getImage("/ui/icons/svg/plus.svg"); + @NotNull Image REMOVE_16 = ICON_MANAGER.getImage("/ui/icons/svg/horizontal-line-remove-button.svg", 16, false); + @NotNull Image ADD_16 = ICON_MANAGER.getImage("/ui/icons/svg/add-plus-button.svg", 16, false); + @NotNull Image MOTION_16 = ICON_MANAGER.getImage("/ui/icons/svg/horse-in-running-motion-silhouette.svg", 16, false); + @NotNull Image PATH_16 = ICON_MANAGER.getImage("/ui/icons/svg/map-location.svg", 16, false); + @NotNull Image WAY_POINT_16 = ICON_MANAGER.getImage("/ui/icons/svg/placeholder.svg", 16, false); + @NotNull Image VERTEX_16 = ICON_MANAGER.getImage("/ui/icons/svg/graphene.svg", 16, false); + @NotNull Image DATA_16 = ICON_MANAGER.getImage("/ui/icons/svg/database.svg", 16, false); + @NotNull Image LINKED_NODE_16 = ICON_MANAGER.getImage("/ui/icons/svg/link.svg"); + @NotNull Image LINK_FILE_16 = ICON_MANAGER.getImage("/ui/icons/svg/link-folder-with-document.svg"); + @NotNull Image STATISTICS_16 = ICON_MANAGER.getImage("/ui/icons/svg/bar-chart.svg"); + @NotNull Image DOR_IN_CIRCLE_16 = ICON_MANAGER.getImage("/ui/icons/svg/dot-and-circle.svg"); + @NotNull Image PLUGIN_16 = ICON_MANAGER.getImage("/ui/icons/svg/plug-silhouette.svg"); - /** - * The constant REFRESH_18. - */ - Image REFRESH_18 = ICON_MANAGER.getImage("/ui/icons/svg/refresh-button.svg", 18); - /** - * The constant WARNING_24. - */ - Image WARNING_24 = ICON_MANAGER.getImage("/ui/icons/svg/warning.svg", 24); + @NotNull Image REFRESH_18 = ICON_MANAGER.getImage("/ui/icons/svg/refresh-button.svg", 18); + @NotNull Image WARNING_24 = ICON_MANAGER.getImage("/ui/icons/svg/warning.svg", 24); - /** - * The constant TERRAIN_LEVEL_32. - */ - Image TERRAIN_LEVEL_32 = ICON_MANAGER.getImage("/ui/icons/svg/level_terrain.svg", 32); - /** - * The constant TERRAIN_PAINT_32. - */ - Image TERRAIN_PAINT_32 = ICON_MANAGER.getImage("/ui/icons/svg/paint_terrain.svg", 32); - /** - * The constant TERRAIN_ROUGH_32. - */ - Image TERRAIN_ROUGH_32 = ICON_MANAGER.getImage("/ui/icons/svg/rough_terrain.svg", 32); - /** - * The constant TERRAIN_SLOPE_32. - */ - Image TERRAIN_SLOPE_32 = ICON_MANAGER.getImage("/ui/icons/svg/slope_terrain.svg", 32); - /** - * The constant TERRAIN_SMOOTH_32. - */ - Image TERRAIN_SMOOTH_32 = ICON_MANAGER.getImage("/ui/icons/svg/smooth_terrain.svg", 32); - /** - * The constant TERRAIN_UP_32. - */ - Image TERRAIN_UP_32 = ICON_MANAGER.getImage("/ui/icons/svg/raise_terrain.svg", 32); + @NotNull Image TERRAIN_LEVEL_32 = ICON_MANAGER.getImage("/ui/icons/svg/level_terrain.svg", 32); + @NotNull Image TERRAIN_PAINT_32 = ICON_MANAGER.getImage("/ui/icons/svg/paint_terrain.svg", 32); + @NotNull Image TERRAIN_ROUGH_32 = ICON_MANAGER.getImage("/ui/icons/svg/rough_terrain.svg", 32); + @NotNull Image TERRAIN_SLOPE_32 = ICON_MANAGER.getImage("/ui/icons/svg/slope_terrain.svg", 32); + @NotNull Image TERRAIN_SMOOTH_32 = ICON_MANAGER.getImage("/ui/icons/svg/smooth_terrain.svg", 32); + @NotNull Image TERRAIN_UP_32 = ICON_MANAGER.getImage("/ui/icons/svg/raise_terrain.svg", 32); - /** - * The constant APPLICATION_64. - */ - Image APPLICATION_64 = ICON_MANAGER.getImage("/ui/icons/app/SSEd64.png", 64); + @NotNull Image APPLICATION_64 = ICON_MANAGER.getImage("/ui/icons/app/SSEd64.png", 64); - /** - * The constant PLAY_128. - */ - Image PLAY_128 = ICON_MANAGER.getImage("/ui/icons/svg/play-button.svg", 128); - /** - * The constant PAUSE_128. - */ - Image PAUSE_128 = ICON_MANAGER.getImage("/ui/icons/svg/pause.svg", 128); - /** - * The constant STOP_128. - */ - Image STOP_128 = ICON_MANAGER.getImage("/ui/icons/svg/stop.svg", 128); + @NotNull Image PLAY_128 = ICON_MANAGER.getImage("/ui/icons/svg/play-button.svg", 128); + @NotNull Image PAUSE_128 = ICON_MANAGER.getImage("/ui/icons/svg/pause.svg", 128); + @NotNull Image STOP_128 = ICON_MANAGER.getImage("/ui/icons/svg/stop.svg", 128); - /** - * The constant IMAGE_512. - */ - Image IMAGE_512 = ICON_MANAGER.getImage("/ui/icons/svg/picture.svg", 512); + @NotNull Image IMAGE_512 = ICON_MANAGER.getImage("/ui/icons/svg/picture.svg", 512); } 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 a274eb9b..283e4c99 100644 --- a/src/main/java/com/ss/editor/ui/builder/EditorFXSceneBuilder.java +++ b/src/main/java/com/ss/editor/ui/builder/EditorFXSceneBuilder.java @@ -45,31 +45,31 @@ public class EditorFXSceneBuilder { * The path to the base CSS styles. */ @NotNull - public static final String CSS_FILE_BASE = "/ui/css/base.css"; + 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"; + 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"; + 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"; + public static final String CSS_FILE_CUSTOM_CLASSES = "ui/css/custom_classes.css"; static { - CSS_REGISTRY.register(CSS_FILE_BASE); - CSS_REGISTRY.register(CSS_FILE_EXTERNAL); - CSS_REGISTRY.register(CSS_FILE_CUSTOM_IDS); - CSS_REGISTRY.register(CSS_FILE_CUSTOM_CLASSES); + CSS_REGISTRY.register(CSS_FILE_BASE, EditorFXSceneBuilder.class.getClassLoader()); + CSS_REGISTRY.register(CSS_FILE_EXTERNAL, EditorFXSceneBuilder.class.getClassLoader()); + CSS_REGISTRY.register(CSS_FILE_CUSTOM_IDS, EditorFXSceneBuilder.class.getClassLoader()); + CSS_REGISTRY.register(CSS_FILE_CUSTOM_CLASSES, EditorFXSceneBuilder.class.getClassLoader()); } /** 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 00ca1662..b0e642bb 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,6 +1,8 @@ package com.ss.editor.ui.component.asset; import static com.ss.rlib.util.ObjectUtils.notNull; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.manager.WorkspaceManager; @@ -35,9 +37,15 @@ 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(); @@ -83,14 +91,15 @@ public AssetComponent() { * * @return the list of waited files to select. */ - @NotNull - private Array getWaitedFilesToSelect() { + @FromAnyThread + private @NotNull Array getWaitedFilesToSelect() { return waitedFilesToSelect; } /** * Handle request for selection a file. */ + @FXThread private void processEvent(@NotNull final RequestSelectFileEvent event) { final Path file = event.getFile(); @@ -110,6 +119,7 @@ private void processEvent(@NotNull final RequestSelectFileEvent event) { /** * Handle a created file. */ + @FXThread private void processEvent(@NotNull final CreatedFileEvent event) { final Path file = event.getFile(); @@ -127,6 +137,7 @@ private void processEvent(@NotNull final CreatedFileEvent event) { /** * Handle a deleted file. */ + @FXThread private void processEvent(@NotNull final DeletedFileEvent event) { final Path file = event.getFile(); @@ -143,19 +154,15 @@ private void processEvent(@NotNull final DeletedFileEvent event) { /** * Handle changing an asset folder. */ + @FXThread private void processChangeAsset() { - - final EditorConfig editorConfig = EditorConfig.getInstance(); - final Path currentAsset = editorConfig.getCurrentAsset(); - if (currentAsset == null) return; - - final ResourceTree resourceTree = getResourceTree(); - resourceTree.fill(currentAsset); + loadAssetFolder(); } /** * Handle refreshing. */ + @FXThread private void processRefresh() { final ResourceTree resourceTree = getResourceTree(); resourceTree.refresh(); @@ -164,6 +171,7 @@ private void processRefresh() { /** * Create components. */ + @FXThread private void createComponents() { setIgnoreExpanded(true); @@ -184,6 +192,7 @@ private void createComponents() { /** * Handle changing loading state of the tree. */ + @FXThread private void handleTreeLoading(@NotNull final Boolean finished) { final WorkspaceManager workspaceManager = WorkspaceManager.getInstance(); @@ -206,6 +215,7 @@ private void handleTreeLoading(@NotNull final Boolean finished) { * * @return true if the expand listener is ignored. */ + @FromAnyThread private boolean isIgnoreExpanded() { return ignoreExpanded; } @@ -215,6 +225,7 @@ private boolean isIgnoreExpanded() { * * @param ignoreExpanded the flag for ignoring expand changes. */ + @FromAnyThread private void setIgnoreExpanded(final boolean ignoreExpanded) { this.ignoreExpanded = ignoreExpanded; } @@ -222,6 +233,7 @@ 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; @@ -244,26 +256,33 @@ private void updateExpanded(final int count, final ResourceTree tree) { /** * @return the toolbar of this component. */ - @NotNull - private AssetBarComponent getBarComponent() { + @FXThread + private @NotNull AssetBarComponent getBarComponent() { return notNull(barComponent); } /** * @return the resource tree. */ - @NotNull - private ResourceTree getResourceTree() { + @FXThread + private @NotNull ResourceTree getResourceTree() { return notNull(resourceTree); } @Override + @FromAnyThread public String getComponentId() { return COMPONENT_ID; } @Override + @FXThread public void notifyFinishBuild() { + loadAssetFolder(); + } + + @FXThread + private void loadAssetFolder() { final EditorConfig editorConfig = EditorConfig.getInstance(); final Path currentAsset = editorConfig.getCurrentAsset(); 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 efc93d00..c845a7d6 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 @@ -24,9 +24,15 @@ public static AssetTreeContextMenuFillerRegistry getInstance() { return INSTANCE; } + /** + * The list of single fillers. + */ @NotNull private final Array singleFillers; + /** + * The list of multi fillers. + */ @NotNull private final Array multiFillers; 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 09411f57..5a47e596 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 @@ -6,6 +6,7 @@ import static com.ss.rlib.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.config.EditorConfig; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.ui.FXConstants; @@ -44,13 +45,22 @@ * @author JavaSaBr */ 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) -> { @@ -68,28 +78,31 @@ public class ResourceTree extends TreeView { return StringUtils.compareIgnoreCase(firstName, secondName); }; + /** + * 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(); - - final int firstLevel = getLevel(firstElement); - final int secondLevel = getLevel(secondElement); - - if (firstLevel != secondLevel) return firstLevel - secondLevel; - return NAME_COMPARATOR.compare(firstElement, secondElement); }; + /** + * The context menu filler registry. + */ @NotNull 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; } + /** + * The default open function. + */ @NotNull private static final Consumer DEFAULT_OPEN_FUNCTION = element -> { final OpenFileAction action = new OpenFileAction(element); @@ -186,6 +199,7 @@ public ResourceTree(@Nullable final Consumer openFunction, fina /** * @param lazyMode true if need to use lazy mode. */ + @FromAnyThread public void setLazyMode(final boolean lazyMode) { this.lazyMode = lazyMode; } @@ -193,6 +207,7 @@ public void setLazyMode(final boolean lazyMode) { /** * @return true if need to use lazy mode. */ + @FromAnyThread private boolean isLazyMode() { return lazyMode; } @@ -200,6 +215,7 @@ private boolean isLazyMode() { /** * @param needCleanup true of need to cleanup this tree. */ + @FromAnyThread public void setNeedCleanup(final boolean needCleanup) { this.needCleanup = needCleanup; } @@ -207,6 +223,7 @@ public void setNeedCleanup(final boolean needCleanup) { /** * @return true of need to cleanup this tree. */ + @FromAnyThread private boolean isNeedCleanup() { return needCleanup; } @@ -214,6 +231,7 @@ private boolean isNeedCleanup() { /** * Handle changed count of expanded elements. */ + @FXThread private void processChangedExpands(@NotNull final Number newValue) { if (isLazyMode()) { @@ -296,6 +314,7 @@ private void lazyLoadChildren(@NotNull final TreeItem treeItem, * * @param expandHandler the handler for listening expand items. */ + @FromAnyThread public void setExpandHandler(@Nullable final IntObjectConsumer expandHandler) { this.expandHandler = expandHandler; } @@ -305,6 +324,7 @@ public void setExpandHandler(@Nullable final IntObjectConsumer exp * * @param actionTester the action tester. */ + @FromAnyThread public void setActionTester(@NotNull final Predicate> actionTester) { this.actionTester = actionTester; } @@ -312,6 +332,7 @@ public void setActionTester(@NotNull final Predicate> actionTester) { /** * @return the handler for listening expand items. */ + @FromAnyThread private @Nullable IntObjectConsumer getExpandHandler() { return expandHandler; } @@ -321,6 +342,7 @@ public void setActionTester(@NotNull final Predicate> actionTester) { * * @param extensionFilter the list of filtered extensions. */ + @FromAnyThread public void setExtensionFilter(@NotNull final Array extensionFilter) { this.extensionFilter = extensionFilter; } @@ -328,6 +350,7 @@ public void setExtensionFilter(@NotNull final Array extensionFilter) { /** * @return the list of filtered extensions. */ + @FromAnyThread private @NotNull Array getExtensionFilter() { return extensionFilter; } @@ -337,6 +360,7 @@ public void setExtensionFilter(@NotNull final Array extensionFilter) { * * @param onLoadHandler the post loading handler. */ + @FromAnyThread public void setOnLoadHandler(@Nullable final Consumer onLoadHandler) { this.onLoadHandler = onLoadHandler; } @@ -344,6 +368,7 @@ public void setOnLoadHandler(@Nullable final Consumer onLoadHandler) { /** * @return the post loading handler. */ + @FromAnyThread private @Nullable Consumer getOnLoadHandler() { return onLoadHandler; } @@ -351,6 +376,7 @@ public void setOnLoadHandler(@Nullable final Consumer onLoadHandler) { /** * @return the flag of read only mode. */ + @FromAnyThread private boolean isReadOnly() { return readOnly; } @@ -358,6 +384,7 @@ private boolean isReadOnly() { /** * @return the action tester. */ + @FromAnyThread private @NotNull Predicate> getActionTester() { return actionTester; } @@ -368,6 +395,7 @@ private boolean isReadOnly() { * @param element the element * @return the context menu for the element. */ + @FXThread protected @Nullable ContextMenu getContextMenu(@NotNull final ResourceElement element) { if (isReadOnly()) return null; @@ -414,6 +442,7 @@ private boolean isReadOnly() { * * @param assetFolder the asset folder. */ + @FXThread public void fill(@NotNull final Path assetFolder) { final Consumer onLoadHandler = getOnLoadHandler(); @@ -430,6 +459,7 @@ public void fill(@NotNull final Path assetFolder) { /** * @return the list of expanded elements. */ + @FromAnyThread private @NotNull ConcurrentArray getExpandedElements() { return expandedElements; } @@ -437,6 +467,7 @@ public void fill(@NotNull final Path assetFolder) { /** * @return the list of selected elements. */ + @FromAnyThread private @NotNull ConcurrentArray getSelectedElements() { return selectedElements; } @@ -444,6 +475,7 @@ public void fill(@NotNull final Path assetFolder) { /** * Refresh this tree. */ + @FXThread public void refresh() { final EditorConfig config = EditorConfig.getInstance(); @@ -469,6 +501,7 @@ public void refresh() { /** * Update the list of expanded elements. */ + @FXThread private void updateExpandedElements() { final ConcurrentArray expandedElements = getExpandedElements(); @@ -491,6 +524,7 @@ private void updateExpandedElements() { /** * Update the list of selected elements. */ + @FXThread private void updateSelectedElements() { final ConcurrentArray selectedElements = getSelectedElements(); @@ -511,6 +545,7 @@ private void updateSelectedElements() { /** * Show the process of loading. */ + @FXThread private void showLoading() { setRoot(new TreeItem<>(LoadingResourceElement.getInstance())); } @@ -518,6 +553,7 @@ private void showLoading() { /** * Start the background process of filling. */ + @BackgroundThread private void startBackgroundFill(@NotNull final Path assetFolder) { final ResourceElement rootElement = createFor(assetFolder); @@ -541,6 +577,7 @@ private void startBackgroundFill(@NotNull final Path assetFolder) { /** * Start the background process of loading. */ + @BackgroundThread private void startBackgroundRefresh(@NotNull final Path assetFolder) { final ResourceElement rootElement = createFor(assetFolder); @@ -580,6 +617,7 @@ private void startBackgroundRefresh(@NotNull final Path assetFolder) { /** * Restore selection. */ + @FromAnyThread private void restoreSelection() { EXECUTOR_MANAGER.addFXTask(() -> { @@ -606,6 +644,7 @@ private void restoreSelection() { /** * Fill the node. */ + @FXThread private void fill(@NotNull final TreeItem treeItem) { final ResourceElement element = treeItem.getValue(); @@ -631,6 +670,7 @@ private void fill(@NotNull final TreeItem treeItem) { * * @param file the created file. */ + @FXThread public void notifyCreated(@NotNull final Path file) { final EditorConfig editorConfig = EditorConfig.getInstance(); @@ -664,6 +704,7 @@ public void notifyCreated(@NotNull final Path file) { * * @param file the file */ + @FXThread public void notifyDeleted(@NotNull final Path file) { final ResourceElement element = createFor(file); @@ -683,6 +724,7 @@ public void notifyDeleted(@NotNull final Path file) { * @param prevFile the prev version. * @param newFile the new version. */ + @FXThread public void notifyMoved(@NotNull final Path prevFile, @NotNull final Path newFile) { final ResourceElement prevElement = createFor(prevFile); @@ -710,6 +752,7 @@ public void notifyMoved(@NotNull final Path prevFile, @NotNull final Path newFil 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) { @@ -729,6 +772,7 @@ private void fillChildren(@NotNull final Path prevFile, @NotNull final Path newF * @param prevFile the prev version. * @param newFile the new version. */ + @FXThread public void notifyRenamed(@NotNull final Path prevFile, @NotNull final Path newFile) { final ResourceElement prevElement = createFor(prevFile); @@ -746,6 +790,7 @@ public void notifyRenamed(@NotNull final Path prevFile, @NotNull final Path newF /** * Handle hotkeys. */ + @FXThread private void processKey(@NotNull final KeyEvent event) { if (isReadOnly()) return; @@ -819,6 +864,7 @@ private void processKey(@NotNull final KeyEvent event) { * * @return the open resource function. */ + @FromAnyThread protected @Nullable Consumer getOpenFunction() { return openFunction; } @@ -826,6 +872,7 @@ private void processKey(@NotNull final KeyEvent event) { /** * Cleanup the tree. */ + @FXThread private void cleanup(@NotNull final TreeItem treeItem) { final ResourceElement element = treeItem.getValue(); @@ -850,6 +897,7 @@ private void cleanup(@NotNull final TreeItem treeItem) { * @param treeItem the tree item * @param needSelect the need select */ + @FXThread public void expandTo(@NotNull final TreeItem treeItem, final boolean needSelect) { TreeItem parent = treeItem; @@ -869,6 +917,7 @@ public void expandTo(@NotNull final TreeItem treeItem, final bo * * @param file the file */ + @FXThread public void markExpand(@NotNull final Path file) { final ResourceElement element = createFor(file); @@ -883,6 +932,7 @@ public void markExpand(@NotNull final Path file) { * * @param onlyFolders true if need to show only folders. */ + @FromAnyThread public void setOnlyFolders(final boolean onlyFolders) { this.onlyFolders = onlyFolders; } @@ -890,6 +940,7 @@ public void setOnlyFolders(final boolean onlyFolders) { /** * @return true if need to show only folders. */ + @FromAnyThread public boolean isOnlyFolders() { return onlyFolders; } @@ -952,6 +1003,7 @@ public void expandTo(@NotNull final Path file, final boolean needSelect) { } } + @FromAnyThread private void scrollToAndSelect(@NotNull final TreeItem treeItem) { EXECUTOR_MANAGER.addFXTask(() -> { final MultipleSelectionModel> selectionModel = getSelectionModel(); 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 364311f2..b6fbb54c 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 @@ -2,6 +2,7 @@ import static com.ss.editor.manager.FileIconManager.DEFAULT_FILE_ICON_SIZE; 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.component.asset.tree.resource.FolderResourceElement; @@ -27,6 +28,9 @@ */ public class ResourceTreeCell extends TreeCell { + /** + * The file icon manager. + */ @NotNull private static final FileIconManager ICON_MANAGER = FileIconManager.getInstance(); @@ -46,25 +50,31 @@ public class ResourceTreeCell extends TreeCell { * Instantiates a new Resource tree cell. */ protected ResourceTreeCell() { - setOnMouseClicked(this::processClick); - setOnDragDetected(this::startDrag); - setOnDragDone(this::stopDrag); + setOnMouseClicked(this::handleMouseClickedEvent); + setOnDragDetected(this::handleStartDragEvent); + setOnDragDone(this::handleStopDragEvent); this.icon = new ImageView(); this.tooltip = new Tooltip(); } /** - * Handle stopping dragging. + * Handle stop drag events. + * + * @param event the stop drag event. */ - private void stopDrag(@NotNull final DragEvent event) { + @FXThread + private void handleStopDragEvent(@NotNull final DragEvent event) { setCursor(Cursor.DEFAULT); event.consume(); } /** - * Handle starting dragging. + * Handle start drag events. + * + * @param mouseEvent the mouse event. */ - private void startDrag(@NotNull final MouseEvent mouseEvent) { + @FXThread + private void handleStartDragEvent(@NotNull final MouseEvent mouseEvent) { startFullDrag(); final ResourceElement item = getItem(); @@ -84,9 +94,12 @@ private void startDrag(@NotNull final MouseEvent mouseEvent) { } /** - * Handle a click. + * Handle mouse clicked events. + * + * @param event the mouse clicked event. */ - private void processClick(@NotNull final MouseEvent event) { + @FXThread + private void handleMouseClickedEvent(@NotNull final MouseEvent event) { final ResourceElement item = getItem(); if (item == null) return; @@ -106,6 +119,7 @@ private void processClick(@NotNull final MouseEvent event) { } @Override + @FXThread protected void updateItem(@Nullable final ResourceElement item, boolean empty) { super.updateItem(item, empty); @@ -123,14 +137,16 @@ protected void updateItem(@Nullable final ResourceElement item, boolean empty) { final Path file = item.getFile(); final Path fileName = file.getFileName(); + final boolean folder = item instanceof FolderResourceElement; - icon.setImage(ICON_MANAGER.getIcon(file, DEFAULT_FILE_ICON_SIZE)); + icon.setImage(ICON_MANAGER.getIcon(file, folder, true, DEFAULT_FILE_ICON_SIZE)); setText(fileName.toString()); setGraphic(icon); createToolTip(); } + @FXThread private @NotNull ProgressIndicator createIndicator() { final ProgressIndicator indicator = new ProgressIndicator(); indicator.setMaxHeight(FXConstants.RESOURCE_TREE_CELL_HEIGHT - 2); @@ -138,12 +154,14 @@ protected void updateItem(@Nullable final ResourceElement item, boolean empty) { return indicator; } + @FXThread private void removeToolTip() { if (tooltip == null) return; Tooltip.uninstall(this, tooltip); tooltip = null; } + @FXThread private void createToolTip() { tooltip = getItem().createToolTip(); if (tooltip == null) return; 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 44b36744..d97310b6 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 @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.asset.tree.context.menu.filler; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import com.ss.rlib.util.array.Array; import javafx.scene.control.MenuItem; @@ -23,6 +24,7 @@ public interface AssetTreeMultiContextMenuFiller { * @param items the container of items of a context menu. * @param actionTester the action tester. */ + @FXThread void fill(@NotNull final Array elements, @NotNull final List items, @NotNull final Predicate> actionTester); } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeSingleContextMenuFiller.java b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeSingleContextMenuFiller.java index 0c2e8c89..8f477f6d 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeSingleContextMenuFiller.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/context/menu/filler/AssetTreeSingleContextMenuFiller.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.asset.tree.context.menu.filler; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import javafx.scene.control.MenuItem; import org.jetbrains.annotations.NotNull; @@ -22,6 +23,7 @@ public interface AssetTreeSingleContextMenuFiller { * @param items the container of items of a context menu. * @param actionTester the action tester. */ + @FXThread void fill(@NotNull final ResourceElement element, @NotNull final List items, @NotNull final Predicate> actionTester); } \ No newline at end of file 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 65df836a..4c964007 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 @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.asset.tree.context.menu.filler.impl; +import com.ss.editor.annotation.FXThread; import com.ss.editor.file.converter.FileConverterDescription; import com.ss.editor.file.converter.FileConverterRegistry; import com.ss.editor.ui.component.asset.tree.context.menu.action.ConvertFileAction; @@ -30,6 +31,7 @@ public class FileAssetTreeSingleContextMenuFiller implements AssetTreeSingleCont private static final FileConverterRegistry FILE_CONVERTER_REGISTRY = FileConverterRegistry.getInstance(); @Override + @FXThread public void fill(@NotNull final ResourceElement element, @NotNull final List items, @NotNull final Predicate> actionTester) { @@ -60,6 +62,7 @@ public void fill(@NotNull final ResourceElement element, @NotNull final List elements, @NotNull final List items, @NotNull final Predicate> actionTester) { } 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 08a048fc..ffbc10d1 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 @@ -1,6 +1,7 @@ package com.ss.editor.ui.component.asset.tree.context.menu.filler.impl; import static com.ss.editor.util.EditorUtil.hasFileInClipboard; +import com.ss.editor.annotation.FXThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.ui.component.asset.tree.context.menu.action.*; import com.ss.editor.ui.component.asset.tree.context.menu.filler.AssetTreeMultiContextMenuFiller; @@ -26,6 +27,7 @@ public class ResourceAssetTreeSingleContextMenuFiller implements AssetTreeSingle AssetTreeMultiContextMenuFiller { @Override + @FXThread public void fill(@NotNull final ResourceElement element, @NotNull final List items, @NotNull final Predicate> actionTester) { @@ -57,6 +59,7 @@ public void fill(@NotNull final ResourceElement element, @NotNull final List elements, @NotNull final List items, @NotNull final Predicate> actionTester) { diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FileResourceElement.java b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FileResourceElement.java index 41054f3f..21206a5c 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FileResourceElement.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/FileResourceElement.java @@ -11,12 +11,7 @@ */ public class FileResourceElement extends ResourceElement { - /** - * Instantiates a new File element. - * - * @param file the file - */ - FileResourceElement(@NotNull final Path file) { + public FileResourceElement(@NotNull final Path file) { super(file); } } 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 5471de02..c2b394e7 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 @@ -1,10 +1,12 @@ package com.ss.editor.ui.component.asset.tree.resource; 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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.nio.file.AccessDeniedException; @@ -19,17 +21,13 @@ */ public class FolderResourceElement extends ResourceElement { - /** - * Instantiates a new Folder element. - * - * @param file the file - */ - FolderResourceElement(@NotNull final Path file) { + public FolderResourceElement(@NotNull final Path file) { super(file); } @Override - public Array getChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { + @FromAnyThread + public @Nullable Array getChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { if (!Files.isDirectory(file)) return null; final Array elements = ArrayFactory.newArray(ResourceElement.class); @@ -63,6 +61,7 @@ public Array getChildren(@NotNull final Array extension } @Override + @FromAnyThread public boolean hasChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { if (!Files.isDirectory(file)) return false; diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ImageResourceElement.java b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ImageResourceElement.java index 1d0a041f..bfb72f96 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ImageResourceElement.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ImageResourceElement.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.asset.tree.resource; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.tooltip.ImagePreview; import javafx.scene.control.Tooltip; import org.jetbrains.annotations.NotNull; @@ -14,16 +15,12 @@ */ public class ImageResourceElement extends FileResourceElement { - /** - * Instantiates a new ImageResourceElement. - * - * @param file the file - */ - ImageResourceElement(@NotNull final Path file) { + public ImageResourceElement(@NotNull final Path file) { super(file); } @Override + @FXThread public @Nullable Tooltip createToolTip() { return new ImagePreview(getFile()); } 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 974cab5e..a8d14148 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,5 +1,7 @@ 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; @@ -17,7 +19,7 @@ public abstract class ResourceElement implements Comparable { /** - * The constant LOGGER. + * The logger. */ @NotNull protected static final Logger LOGGER = LoggerManager.getLogger(ResourceElement.class); @@ -28,11 +30,6 @@ public abstract class ResourceElement implements Comparable { @NotNull protected final Path file; - /** - * Instantiates a new Resource element. - * - * @param file the file - */ public ResourceElement(@NotNull final Path file) { this.file = file; } @@ -42,8 +39,8 @@ public ResourceElement(@NotNull final Path file) { * * @return the tooltip. */ - @Nullable - public Tooltip createToolTip() { + @FXThread + public @Nullable Tooltip createToolTip() { return null; } @@ -52,8 +49,8 @@ public Tooltip createToolTip() { * * @return the reference to the file. */ - @NotNull - public Path getFile() { + @FromAnyThread + public @NotNull Path getFile() { return file; } @@ -64,7 +61,8 @@ public Path getFile() { * @param onlyFolders the only folders * @return list of children resource elements. */ - public Array getChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { + @FromAnyThread + public @Nullable Array getChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { return null; } @@ -75,6 +73,7 @@ public Array getChildren(@NotNull final Array extension * @param onlyFolders the only folders * @return true if this element has children. */ + @FromAnyThread public boolean hasChildren(@NotNull final Array extensionFilter, final boolean onlyFolders) { return false; } diff --git a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElementFactory.java b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElementFactory.java index 43f71296..a2e00582 100644 --- a/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElementFactory.java +++ b/src/main/java/com/ss/editor/ui/component/asset/tree/resource/ResourceElementFactory.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.asset.tree.resource; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.JavaFXImageManager; import org.jetbrains.annotations.NotNull; @@ -14,13 +15,13 @@ public class ResourceElementFactory { /** - * Create for resource element. + * Create a resource element for the file. * - * @param file the file - * @return the resource element + * @param file the file. + * @return the created resource element. */ - @NotNull - public static ResourceElement createFor(@NotNull final Path file) { + @FromAnyThread + public static @NotNull ResourceElement createFor(@NotNull final Path file) { if (Files.isDirectory(file)) { return new FolderResourceElement(file); } else if (JavaFXImageManager.isImage(file)) { 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 3f4babd4..f4ceba14 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 @@ -238,7 +238,7 @@ protected void processOk() { notifyFileCreated(fileToCreate, true); - } catch (final IOException e) { + } catch (final Exception e) { Utils.run(tempFile, Files::delete); EditorUtil.handleException(LOGGER, this, e); } @@ -251,6 +251,7 @@ protected void processOk() { * Write created data to the created file. * * @param resultFile the result file. + * @throws IOException if was some problem with writing to the result file. */ @BackgroundThread protected void writeData(@NotNull final Path resultFile) throws IOException { diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/DefaultSceneCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/DefaultSceneCreator.java index 1a817140..03c4a2da 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/DefaultSceneCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/DefaultSceneCreator.java @@ -3,6 +3,7 @@ import com.jme3.renderer.queue.RenderQueue; import com.jme3.shadow.EdgeFilteringMode; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.extension.scene.app.state.impl.EditableLightingSceneAppState; import com.ss.editor.extension.scene.app.state.impl.EditableSkySceneAppState; @@ -29,14 +30,14 @@ public class DefaultSceneCreator extends EmptySceneCreator { DESCRIPTION.setConstructor(DefaultSceneCreator::new); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.DEFAULT_SCENE_CREATOR_TITLE; } - @NotNull @Override + @NotNull protected SceneNode createScene() { final EditableLightingStateShadowFilter shadowFilter = new EditableLightingStateShadowFilter(); 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 e6ac6d18..a6994462 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 @@ -1,6 +1,7 @@ package com.ss.editor.ui.component.creator.impl; 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 org.jetbrains.annotations.NotNull; @@ -23,15 +24,16 @@ public class EmptyFileCreator extends AbstractFileCreator { DESCRIPTION.setConstructor(EmptyFileCreator::new); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.EMPTY_FILE_CREATOR_TITLE; } - @NotNull + @Override - protected String getFileExtension() { + @FromAnyThread + protected @NotNull String getFileExtension() { return StringUtils.EMPTY; } } diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyModelCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyModelCreator.java index abac50e2..d216070a 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyModelCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/EmptyModelCreator.java @@ -8,6 +8,7 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.BackgroundThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.creator.FileCreatorDescription; import org.jetbrains.annotations.NotNull; @@ -34,15 +35,15 @@ public class EmptyModelCreator extends AbstractFileCreator { DESCRIPTION.setConstructor(EmptyModelCreator::new); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.EMPTY_MODEL_CREATOR_TITLE; } - @NotNull @Override - protected String getFileExtension() { + @FromAnyThread + protected @NotNull String getFileExtension() { return FileExtensions.JME_OBJECT; } diff --git a/src/main/java/com/ss/editor/ui/component/creator/impl/EmptySceneCreator.java b/src/main/java/com/ss/editor/ui/component/creator/impl/EmptySceneCreator.java index 90e012a5..646fec83 100644 --- a/src/main/java/com/ss/editor/ui/component/creator/impl/EmptySceneCreator.java +++ b/src/main/java/com/ss/editor/ui/component/creator/impl/EmptySceneCreator.java @@ -7,6 +7,8 @@ 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.extension.scene.SceneLayer; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.ui.component.creator.FileCreatorDescription; @@ -35,15 +37,15 @@ public class EmptySceneCreator extends AbstractFileCreator { DESCRIPTION.setConstructor(EmptySceneCreator::new); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.EMPTY_SCENE_CREATOR_TITLE; } - @NotNull @Override - protected String getFileExtension() { + @FromAnyThread + protected @NotNull String getFileExtension() { return FileExtensions.JME_SCENE; } @@ -65,8 +67,8 @@ protected void writeData(@NotNull final Path resultFile) throws IOException { * * @return the scene node */ - @NotNull - protected SceneNode createScene() { + @FXThread + protected @NotNull SceneNode createScene() { final SceneNode newNode = new SceneNode(); newNode.addLayer(new SceneLayer("Default", true)); newNode.addLayer(new SceneLayer("TransparentFX", true)); 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 16a70cf5..3a0c4634 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 @@ -2,6 +2,7 @@ import static com.ss.rlib.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; @@ -30,29 +31,26 @@ public class FolderCreator extends AbstractFileCreator { DESCRIPTION.setConstructor(FolderCreator::new); } - private FolderCreator() { - } - - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.FOLDER_CREATOR_TITLE; } - @NotNull @Override - protected String getFileExtension() { + @FromAnyThread + protected @NotNull String getFileExtension() { return StringUtils.EMPTY; } - @NotNull @Override @FromAnyThread - protected String getFileNameLabelText() { + protected @NotNull String getFileNameLabelText() { return Messages.FOLDER_CREATOR_FILE_NAME_LABEL; } @Override + @FXThread protected void processOk() { super.hide(); 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 c72cfe70..022df0d2 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 @@ -5,6 +5,7 @@ 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; @@ -63,24 +64,23 @@ public class MaterialFileCreator extends GenericFileCreator { @Nullable private Array definitions; - private MaterialFileCreator() { - super(); - } - @Override + @FromAnyThread protected @NotNull String getTitleText() { return Messages.MATERIAL_FILE_CREATOR_TITLE; } @Override + @FromAnyThread protected @NotNull String getFileExtension() { return JME_MATERIAL; } @Override + @FromAnyThread protected @NotNull Array getPropertyDefinitions() { - definitions = RESOURCE_MANAGER.getAvailableMaterialDefinitions(); + definitions = RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION); final String def; 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 37c50c91..f9909794 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 @@ -11,6 +11,8 @@ import com.jme3.renderer.Renderer; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.extension.property.EditablePropertyType; import com.ss.editor.plugin.api.file.creator.GenericFileCreator; @@ -86,23 +88,20 @@ public class MaterialDefinitionFileCreator extends GenericFileCreator { VERT_TEMPLATE = FileUtils.read(vertResource); } - public MaterialDefinitionFileCreator() { - super(); - } - - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.MATERIAL_DEFINITION_FILE_CREATOR_TITLE; } - @NotNull @Override - protected String getFileExtension() { + @FromAnyThread + protected @NotNull String getFileExtension() { return JME_MATERIAL_DEFINITION; } @Override + @FXThread protected boolean validate(@NotNull final VarTable vars) { final String glslVersion = vars.get(PROP_GLSL_VERSION, String.class, StringUtils.EMPTY); @@ -114,9 +113,9 @@ protected boolean validate(@NotNull final VarTable vars) { return super.validate(vars); } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FromAnyThread + protected @NotNull Array getPropertyDefinitions() { final Array result = ArrayFactory.newArray(PropertyDefinition.class); result.add(new PropertyDefinition(EditablePropertyType.STRING_FROM_LIST, @@ -126,6 +125,7 @@ protected Array getPropertyDefinitions() { } @Override + @FXThread protected void processOk() { super.hide(); 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 8562a8c4..44c0a587 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 @@ -71,10 +71,6 @@ public class SingleColorTextureFileCreator extends GenericFileCreator { @Nullable private ImageView imageView; - public SingleColorTextureFileCreator() { - super(); - } - @Override @FXThread protected void createPreview(@NotNull final BorderPane container) { @@ -86,8 +82,8 @@ protected void createPreview(@NotNull final BorderPane container) { /** * @return the image view to show preview of texture. */ - @NotNull - private ImageView getImageView() { + @FXThread + private @NotNull ImageView getImageView() { return notNull(imageView); } @@ -97,22 +93,21 @@ protected boolean needPreview() { return true; } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.SINGLE_COLOR_TEXTURE_FILE_CREATOR_TITLE; } - @NotNull @Override - protected String getFileExtension() { + @FromAnyThread + protected @NotNull String getFileExtension() { return FileExtensions.IMAGE_PNG; } - @NotNull @Override @FromAnyThread - protected Array getPropertyDefinitions() { + protected @NotNull Array getPropertyDefinitions() { return DEFINITIONS; } diff --git a/src/main/java/com/ss/editor/ui/component/editing/terrain/TerrainEditingStateWithEditorTool.java b/src/main/java/com/ss/editor/ui/component/editing/terrain/TerrainEditingStateWithEditorTool.java index 6d77c254..f0be389e 100644 --- a/src/main/java/com/ss/editor/ui/component/editing/terrain/TerrainEditingStateWithEditorTool.java +++ b/src/main/java/com/ss/editor/ui/component/editing/terrain/TerrainEditingStateWithEditorTool.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.component.editing.terrain; import static java.lang.Math.abs; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.editor.state.impl.AbstractEditorState; import com.ss.editor.ui.component.editor.state.impl.AdditionalEditorState; @@ -45,120 +46,144 @@ public TerrainEditingStateWithEditorTool() { this.slopeSmoothly = true; } + @FXThread public float getBrushSize() { return brushSize; } + @FXThread public void setBrushSize(final float brushSize) { final boolean changed = abs(getBrushSize() - brushSize) > 0.001f; this.brushSize = brushSize; if (changed) notifyChange(); } + @FXThread public float getBrushPower() { return brushPower; } + @FXThread public void setBrushPower(final float brushPower) { final boolean changed = abs(getBrushPower() - brushPower) > 0.001f; this.brushPower = brushPower; if (changed) notifyChange(); } + @FXThread public float getLevelValue() { return levelValue; } + @FXThread public void setLevelValue(final float levelValue) { final boolean changed = abs(getLevelValue() - levelValue) > 0.001f; this.levelValue = levelValue; if (changed) notifyChange(); } + @FXThread public float getRoughtFrequency() { return roughtFrequency; } + @FXThread public void setRoughtFrequency(final float roughtFrequency) { final boolean changed = abs(getRoughtFrequency() - roughtFrequency) > 0.001f; this.roughtFrequency = roughtFrequency; if (changed) notifyChange(); } + @FXThread public float getRoughtLacunarity() { return roughtLacunarity; } + @FXThread public void setRoughtLacunarity(final float roughtLacunarity) { final boolean changed = abs(getRoughtLacunarity() - roughtLacunarity) > 0.001f; this.roughtLacunarity = roughtLacunarity; if (changed) notifyChange(); } + @FXThread public float getRoughtOctaves() { return roughtOctaves; } + @FXThread public void setRoughtOctaves(final float roughtOctaves) { final boolean changed = abs(getRoughtOctaves() - roughtOctaves) > 0.001f; this.roughtOctaves = roughtOctaves; if (changed) notifyChange(); } + @FXThread public float getRoughtRoughness() { return roughtRoughness; } + @FXThread public void setRoughtRoughness(final float roughtRoughness) { final boolean changed = abs(getRoughtRoughness() - roughtRoughness) > 0.001f; this.roughtRoughness = roughtRoughness; if (changed) notifyChange(); } + @FXThread public float getRoughtScale() { return roughtScale; } + @FXThread public void setRoughtScale(final float roughtScale) { final boolean changed = abs(getRoughtScale() - roughtScale) > 0.001f; this.roughtScale = roughtScale; if (changed) notifyChange(); } + @FXThread public boolean isLevelUseMarker() { return levelUseMarker; } + @FXThread public void setLevelUseMarker(final boolean levelUseMarker) { final boolean changed = isLevelUseMarker() != levelUseMarker; this.levelUseMarker = levelUseMarker; if (changed) notifyChange(); } + @FXThread public boolean isLevelSmoothly() { return levelSmoothly; } + @FXThread public void setLevelSmoothly(final boolean levelSmoothly) { final boolean changed = isLevelSmoothly() != levelSmoothly; this.levelSmoothly = levelSmoothly; if (changed) notifyChange(); } + @FXThread public boolean isSlopeLimited() { return slopeLimited; } + @FXThread public void setSlopeLimited(final boolean slopeLimited) { final boolean changed = isSlopeLimited() != slopeLimited; this.slopeLimited = slopeLimited; if (changed) notifyChange(); } + @FXThread public boolean isSlopeSmoothly() { return slopeSmoothly; } + @FXThread public void setSlopeSmoothly(final boolean slopeSmoothly) { final boolean changed = isSlopeSmoothly() != slopeSmoothly; this.slopeSmoothly = slopeSmoothly; 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 854189db..47ad0381 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 @@ -465,10 +465,17 @@ private void processOpenFileImpl(@NotNull final RequestedOpenFileEvent event, @N editor.openFile(file); } catch (final Throwable e) { EditorUtil.handleException(null, this, new Exception(e)); + + final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); + if (workspace != null) { + workspace.removeOpenedFile(file); + } + EXECUTOR_MANAGER.addFXTask(() -> { EditorUtil.decrementLoading(); resultEditor.notifyClosed(); }); + return; } finally { EDITOR.asyncUnlock(stamp); 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 9bce566f..a531441c 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,8 +1,7 @@ package com.ss.editor.ui.component.editor.impl; import static com.ss.rlib.util.ObjectUtils.notNull; -import static java.nio.file.StandardCopyOption.ATOMIC_MOVE; -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; import com.jme3.math.Vector3f; import com.ss.editor.Editor; import com.ss.editor.JFXApplication; @@ -47,7 +46,9 @@ import org.jetbrains.annotations.Nullable; import java.io.IOException; -import java.nio.file.*; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; import java.time.Duration; import java.time.LocalTime; import java.util.function.Consumer; @@ -265,7 +266,7 @@ protected void processKeyReleased(@NotNull final KeyEvent event) { final KeyCode code = event.getCode(); - if (handleKeyActionImpl(code, true, event.isControlDown(), false)) { + if (handleKeyActionImpl(code, false, event.isControlDown(), event.isShiftDown(), false)) { event.consume(); } } @@ -276,12 +277,13 @@ protected void processKeyReleased(@NotNull final KeyEvent event) { * @param keyCode the key code. * @param isPressed true if key is pressed. * @param isControlDown true if control is down. + * @param isShiftDown true if shift is down. * @param isButtonMiddleDown true if mouse middle button is pressed. */ @FromAnyThread public void handleKeyAction(@NotNull final KeyCode keyCode, final boolean isPressed, final boolean isControlDown, - final boolean isButtonMiddleDown) { - EXECUTOR_MANAGER.addFXTask(() -> handleKeyActionImpl(keyCode, isPressed, isControlDown, isButtonMiddleDown)); + final boolean isShiftDown, final boolean isButtonMiddleDown) { + EXECUTOR_MANAGER.addFXTask(() -> handleKeyActionImpl(keyCode, isPressed, isControlDown, isShiftDown, isButtonMiddleDown)); } /** @@ -290,12 +292,14 @@ public void handleKeyAction(@NotNull final KeyCode keyCode, final boolean isPres * @param keyCode the key code. * @param isPressed true if key is pressed. * @param isControlDown true if control is down. + * @param isShiftDown true if shift is down. * @param isButtonMiddleDown true if mouse middle button is pressed. - * @return true if can consume an event. + * @return true if need to consume an event. */ @FXThread protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed, - final boolean isControlDown, final boolean isButtonMiddleDown) { + final boolean isControlDown, final boolean isShiftDown, + final boolean isButtonMiddleDown) { return false; } @@ -311,7 +315,7 @@ protected void processKeyPressed(@NotNull final KeyEvent event) { if (code == KeyCode.S && event.isControlDown() && isDirty()) { save(); - } else if (handleKeyActionImpl(code, true, event.isControlDown(), false)) { + } else if (handleKeyActionImpl(code, true, event.isControlDown(), event.isShiftDown(), false)) { event.consume(); } } @@ -366,17 +370,13 @@ public void save(@Nullable final Consumer<@NotNull FileEditor> callback) { final Path editFile = getEditFile(); doSave(tempFile); - try { - Files.move(tempFile, editFile, REPLACE_EXISTING, ATOMIC_MOVE); - } catch (final AtomicMoveNotSupportedException e) { - Files.move(tempFile, editFile, REPLACE_EXISTING); - } catch (final AccessDeniedException e) { - Files.copy(tempFile, editFile, StandardCopyOption.REPLACE_EXISTING); + try (final OutputStream out = Files.newOutputStream(editFile, TRUNCATE_EXISTING)) { + Files.copy(tempFile, out); + } finally { FileUtils.delete(tempFile); } } catch (final IOException e) { - FileUtils.delete(tempFile); LOGGER.warning(this, e); EXECUTOR_MANAGER.addFXTask(this::notifyFinishSaving); } finally { @@ -391,6 +391,7 @@ public void save(@Nullable final Consumer<@NotNull FileEditor> callback) { * Save new changes. * * @param toStore the file to store. + * @throws IOException if was some problem with writing to the to store file. */ @BackgroundThread protected void doSave(@NotNull final Path toStore) throws IOException { 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 9b9e2c0a..dcf98ff3 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 @@ -103,14 +103,14 @@ private AudioViewerEditor() { addEditorState(editorAppState); } - @NotNull @Override - protected VBox createRoot() { + @FXThread + protected @NotNull VBox createRoot() { return new VBox(); } - @Override + @FXThread protected void createContent(@NotNull final VBox root) { final Label durationLabel = new Label(Messages.AUDIO_VIEWER_EDITOR_DURATION_LABEL + ":"); @@ -174,6 +174,7 @@ protected void createContent(@NotNull final VBox root) { /** * Stop of plying. */ + @FXThread private void processStop() { getEditorAppState().stop(); } @@ -181,6 +182,7 @@ private void processStop() { /** * Play the audio. */ + @FXThread private void processPlay() { final AudioViewer3DState appState = getEditorAppState(); if (appState.getPrevStatus() == Playing) { @@ -190,8 +192,8 @@ private void processPlay() { } } - @FXThread @Override + @FXThread public void openFile(@NotNull final Path file) { super.openFile(file); @@ -218,18 +220,17 @@ public void openFile(@NotNull final Path file) { getBitsPerSampleField().setText(String.valueOf(bitsPerSample)); } - @NotNull @Override - public EditorDescription getDescription() { + @FromAnyThread + public @NotNull EditorDescription getDescription() { return DESCRIPTION; } /** * @return the editor app state. */ - @NotNull @FromAnyThread - private AudioViewer3DState getEditorAppState() { + private @NotNull AudioViewer3DState getEditorAppState() { return editorAppState; } @@ -268,56 +269,56 @@ public void notifyChangedStatus(final AudioSource.Status status) { /** * @return the play button. */ - @NotNull - private Button getPlayButton() { + @FXThread + private @NotNull Button getPlayButton() { return notNull(playButton); } /** * @return the stop button. */ - @NotNull - private Button getStopButton() { + @FXThread + private @NotNull Button getStopButton() { return notNull(stopButton); } /** * @return the channels field. */ - @NotNull - private TextField getChannelsField() { + @FXThread + private @NotNull TextField getChannelsField() { return notNull(channelsField); } /** * @return the duration field. */ - @NotNull - private TextField getDurationField() { + @FXThread + private @NotNull TextField getDurationField() { return notNull(durationField); } /** * @return the data type field. */ - @NotNull - private TextField getDataTypeField() { + @FXThread + private @NotNull TextField getDataTypeField() { return notNull(dataTypeField); } /** * @return the sample rate field. */ - @NotNull - private TextField getSampleRateField() { + @FXThread + private @NotNull TextField getSampleRateField() { return notNull(sampleRateField); } /** * @return the bits per sample field. */ - @NotNull - private TextField getBitsPerSampleField() { + @FXThread + private @NotNull TextField getBitsPerSampleField() { return notNull(bitsPerSampleField); } 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 6eb713ed..6e271bd8 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 @@ -3,14 +3,13 @@ import static com.ss.rlib.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 javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import org.fxmisc.richtext.CodeArea; -import org.fxmisc.richtext.model.StyleSpans; -import org.fxmisc.undo.UndoManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,7 +17,6 @@ import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collection; /** * The implementation of editor to edit files with code. @@ -37,19 +35,19 @@ public abstract class CodeAreaFileEditor extends AbstractFileEditor { * The code area. */ @Nullable - private CodeArea codeArea; + private BaseCodeArea codeArea; @Override + @FXThread protected @NotNull VBox createRoot() { return new VBox(); } @Override + @FXThread protected void createContent(@NotNull final VBox root) { - codeArea = new CodeArea(); - codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) - .subscribe(change -> codeArea.setStyleSpans(0, getStyleSpans(codeArea.getText()))); + codeArea = createCodeArea(); codeArea.textProperty().addListener((observable, oldValue, newValue) -> updateDirty(newValue)); codeArea.prefHeightProperty().bind(root.heightProperty()); codeArea.prefWidthProperty().bind(root.widthProperty()); @@ -59,28 +57,31 @@ protected void createContent(@NotNull final VBox root) { } /** - * Gets style spans. + * Create the code area. * - * @param text the text - * @return the style spans + * @return the code area. */ - protected @NotNull StyleSpans> getStyleSpans(@NotNull final String text) { - throw new RuntimeException("unsupported"); + @FXThread + protected @NotNull BaseCodeArea createCodeArea() { + throw new RuntimeException(); } /** * Update dirty state. */ + @FXThread private void updateDirty(final String newContent) { setDirty(!getOriginalContent().equals(newContent)); } @Override + @FXThread protected boolean needToolbar() { return true; } @Override + @FXThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); FXUtils.addToPane(createSaveAction(), container); @@ -89,7 +90,8 @@ protected void createToolbar(@NotNull final HBox container) { /** * @return the code area. */ - private @NotNull CodeArea getCodeArea() { + @FXThread + private @NotNull BaseCodeArea getCodeArea() { return notNull(codeArea); } @@ -100,11 +102,8 @@ public void openFile(@NotNull final Path file) { setOriginalContent(FileUtils.read(file)); - final CodeArea codeArea = getCodeArea(); - codeArea.appendText(getOriginalContent()); - - final UndoManager undoManager = codeArea.getUndoManager(); - undoManager.forgetHistory(); + final BaseCodeArea codeArea = getCodeArea(); + codeArea.loadContent(getOriginalContent()); setOriginalContent(codeArea.getText()); updateDirty(getOriginalContent()); @@ -113,6 +112,7 @@ public void openFile(@NotNull final Path file) { /** * @return the original content of the opened file. */ + @FXThread private @NotNull String getOriginalContent() { return notNull(originalContent); } @@ -120,6 +120,7 @@ public void openFile(@NotNull final Path file) { /** * @param originalContent the original content of the opened file. */ + @FXThread private void setOriginalContent(@NotNull final String originalContent) { this.originalContent = originalContent; } @@ -150,14 +151,15 @@ protected void postSave() { } @Override + @FXThread protected void handleExternalChanges() { super.handleExternalChanges(); final String newContent = FileUtils.read(getEditFile()); - final CodeArea codeArea = getCodeArea(); + final BaseCodeArea codeArea = getCodeArea(); final String currentContent = codeArea.getText(); - codeArea.replaceText(0, currentContent.length(), newContent); + codeArea.reloadContent(newContent); setOriginalContent(currentContent); updateDirty(newContent); diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/GLSLFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/GLSLFileEditor.java index 4bc992ee..2f616435 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/GLSLFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/GLSLFileEditor.java @@ -1,17 +1,14 @@ package com.ss.editor.ui.component.editor.impl; -import static java.util.Collections.singleton; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.editor.EditorDescription; -import org.fxmisc.richtext.model.StyleSpans; -import org.fxmisc.richtext.model.StyleSpansBuilder; +import com.ss.editor.ui.control.code.BaseCodeArea; +import com.ss.editor.ui.control.code.GLSLCodeArea; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * The implementation of editor to edit GLSL files. * @@ -32,106 +29,15 @@ public class GLSLFileEditor extends CodeAreaFileEditor { DESCRIPTION.setExtensions(FileExtensions.SHADER_EXTENSIONS); } - @NotNull - private static final String[] KEYWORDS = { - "define", "undef", "if", "ifdef", "ifndef", - "else", "elif", "endif", "error", "pragma", - "extension", "version", "line", "attribute", "const", - "uniform", "varying", "layout", "centroid", "flat", - "smooth", "noperspective", "patch", "sample", "break", - "continue", "do", "for", "while", "switch", - "case", "default", "if", "subroutine", "in", "out", "inout", - "void", "true", "false", "invariant", "discard", "return", "struct" - }; - - @NotNull - private static final String[] VALUE_TYPES = { - "float", "double", "int", "bool", "mat2", "mat3", "mat4", "uint", "uvec2", "uvec3", "uvec4", - "sampler1D", "sampler2D", "sampler3D", "samplerCube", "vec2", "vec3", "vec4" - }; - - private static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b"; - private static final String VALUE_TYPE_PATTERN = "\\b(" + String.join("|", VALUE_TYPES) + ")\\b"; - private static final String PAREN_PATTERN = "\\(|\\)"; - private static final String BRACE_PATTERN = "\\{|\\}"; - private static final String BRACKET_PATTERN = "\\[|\\]"; - private static final String SEMICOLON_PATTERN = "\\;"; - private static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\""; - private static final String COMMENT_PATTERN = "//[^\n]*" + "|" + "/\\*(.|\\R)*?\\*/"; - - private static final Pattern PATTERN = Pattern.compile( - "(?" + KEYWORD_PATTERN + ")" - + "|(?" + VALUE_TYPE_PATTERN + ")" - + "|(?" + PAREN_PATTERN + ")" - + "|(?" + BRACE_PATTERN + ")" - + "|(?" + BRACKET_PATTERN + ")" - + "|(?" + SEMICOLON_PATTERN + ")" - + "|(?" + STRING_PATTERN + ")" - + "|(?" + COMMENT_PATTERN + ")" - ); - - @NotNull - private static StyleSpans> computeHighlighting(@NotNull final String text) { - - final Matcher matcher = PATTERN.matcher(text); - final StyleSpansBuilder> spansBuilder = new StyleSpansBuilder<>(); - - int lastKwEnd = 0; - - while (matcher.find()) { - - String styleClass = matcher.group("KEYWORD") != null ? "keyword" : null; - - if (styleClass == null) { - styleClass = matcher.group("VALUETYPE") != null ? "value-type" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("PAREN") != null ? "paren" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("BRACE") != null ? "brace" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("BRACKET") != null ? "bracket" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("SEMICOLON") != null ? "semicolon" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("STRING") != null ? "string" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("COMMENT") != null ? "comment" : null; - } - - assert styleClass != null; - - spansBuilder.add(singleton("plain-code"), matcher.start() - lastKwEnd); - spansBuilder.add(singleton(styleClass), matcher.end() - matcher.start()); - - lastKwEnd = matcher.end(); - } - - spansBuilder.add(singleton("plain-code"), text.length() - lastKwEnd); - - return spansBuilder.create(); - } - - @NotNull @Override - protected StyleSpans> getStyleSpans(@NotNull final String text) { - return computeHighlighting(text); + @FXThread + protected @NotNull BaseCodeArea createCodeArea() { + return new GLSLCodeArea(); } - @NotNull @Override - public EditorDescription getDescription() { + @FromAnyThread + public @NotNull EditorDescription getDescription() { return DESCRIPTION; } } 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 6bc36e0c..ddba00ac 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 @@ -5,11 +5,11 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.JavaFXImageManager; 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.plugin.annotation.PluginDescription; import com.ss.rlib.ui.util.FXUtils; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -32,7 +32,7 @@ public class ImageViewerEditor extends AbstractFileEditor { @NotNull public static final EditorDescription DESCRIPTION = new EditorDescription(); - @PluginDescription + @NotNull private static final JavaFXImageManager JAVA_FX_IMAGE_MANAGER = JavaFXImageManager.getInstance(); private static final int IMAGE_SIZE = 512; @@ -50,13 +50,14 @@ public class ImageViewerEditor extends AbstractFileEditor { @Nullable private ImageView imageView; - @NotNull @Override - protected VBox createRoot() { + @FXThread + protected @NotNull VBox createRoot() { return new VBox(); } @Override + @FXThread protected void createContent(@NotNull final VBox root) { imageView = new ImageView(); @@ -68,34 +69,36 @@ protected void createContent(@NotNull final VBox root) { /** * @return the image view. */ - @NotNull - private ImageView getImageView() { + @FXThread + private @NotNull ImageView getImageView() { return notNull(imageView); } @Override + @FXThread protected void processChangedFile(@NotNull final FileChangedEvent event) { final Path file = event.getFile(); if (!getEditFile().equals(file)) return; EXECUTOR_MANAGER.schedule(() -> EXECUTOR_MANAGER.addFXTask(() -> showImage(file)), 1000); } + @FXThread private void showImage(@NotNull final Path file) { final Image preview = JAVA_FX_IMAGE_MANAGER.getImagePreview(file, IMAGE_SIZE, IMAGE_SIZE); final ImageView imageView = getImageView(); imageView.setImage(preview); } - @FXThread @Override + @FXThread public void openFile(@NotNull final Path file) { super.openFile(file); showImage(file); } - @NotNull @Override - public EditorDescription getDescription() { + @FromAnyThread + public @NotNull EditorDescription getDescription() { return DESCRIPTION; } } diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/MaterialDefinitionFileEditor.java b/src/main/java/com/ss/editor/ui/component/editor/impl/MaterialDefinitionFileEditor.java index 15d48ce4..596e0c90 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/MaterialDefinitionFileEditor.java +++ b/src/main/java/com/ss/editor/ui/component/editor/impl/MaterialDefinitionFileEditor.java @@ -1,17 +1,14 @@ package com.ss.editor.ui.component.editor.impl; -import static java.util.Collections.singleton; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.component.editor.EditorDescription; -import org.fxmisc.richtext.model.StyleSpans; -import org.fxmisc.richtext.model.StyleSpansBuilder; +import com.ss.editor.ui.control.code.BaseCodeArea; +import com.ss.editor.ui.control.code.MaterialDefinitionCodeArea; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * The implementation of editor to edit material definition files. * @@ -32,117 +29,15 @@ public class MaterialDefinitionFileEditor extends CodeAreaFileEditor { DESCRIPTION.addExtension(FileExtensions.JME_MATERIAL_DEFINITION); } - @NotNull - private static final String[] KEYWORDS = { - "MaterialDef", "MaterialParameters", "Technique", "WorldParameters", "Defines", "ForcedRenderState" - }; - - @NotNull - private static final String[] VALUE_TYPES = { - "Texture2D", "Float", "Boolean", "Int", "Color", "Vector3", "TextureCubeMap", "Matrix4", "Vector4", "Vector2", - "VertexShader", "TessellationEvaluationShader ", "TessellationControlShader", "FragmentShader", "LightMode", - "WorldViewProjectionMatrix", "Time", "NormalMatrix", "WorldViewMatrix", - "ViewMatrix", "CameraPosition", "WorldMatrix", "FaceCull", "DepthTest", "DepthWrite", "PolyOffset", - "ColorWrite", "Blend", "Resolution", "FragmentShader", "ViewProjectionMatrix", - "IntArray", "FloatArray", "Vector2Array", "Vector3Array", "Vector4Array", "Matrix3", - "Matrix3Array", "Matrix4Array", "TextureBuffer", "Texture3D", "TextureArray", "GeometryShader" - }; - - @NotNull - private static final String[] VALUE_VALUES = { - "true", "false", "Off", "On", "True", "False", "Disable", "SinglePass", "MultiPass", - "SinglePassAndImageBased", "FixedPipeline", "StaticPass", "InPass", "PostPass", "World", "View", - "Legacy", "GLSL100", "GLSL110", "GLSL120", "GLSL130", "GLSL140", "GLSL150", "GLSL400", "GLSL330", - "GLSL410", "GLSL420", "GLSL430", "GLSL440", "GLSL450", - }; - - private static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b"; - private static final String VALUE_TYPE_PATTERN = "\\b(" + String.join("|", VALUE_TYPES) + ")\\b"; - private static final String VALUE_VALUE_PATTERN = "\\b(" + String.join("|", VALUE_VALUES) + ")\\b"; - private static final String PAREN_PATTERN = "\\(|\\)"; - private static final String BRACE_PATTERN = "\\{|\\}"; - private static final String BRACKET_PATTERN = "\\[|\\]"; - private static final String SEMICOLON_PATTERN = "\\;"; - private static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\""; - private static final String COMMENT_PATTERN = "//[^\n]*" + "|" + "/\\*(.|\\R)*?\\*/"; - - private static final Pattern PATTERN = Pattern.compile( - "(?" + KEYWORD_PATTERN + ")" - + "|(?" + VALUE_TYPE_PATTERN + ")" - + "|(?" + VALUE_VALUE_PATTERN + ")" - + "|(?" + PAREN_PATTERN + ")" - + "|(?" + BRACE_PATTERN + ")" - + "|(?" + BRACKET_PATTERN + ")" - + "|(?" + SEMICOLON_PATTERN + ")" - + "|(?" + STRING_PATTERN + ")" - + "|(?" + COMMENT_PATTERN + ")" - ); - - private static StyleSpans> computeHighlighting(final String text) { - - final Matcher matcher = PATTERN.matcher(text); - final StyleSpansBuilder> spansBuilder = new StyleSpansBuilder<>(); - - int lastKwEnd = 0; - - while (matcher.find()) { - - String styleClass = matcher.group("KEYWORD") != null ? "keyword" : null; - - if (styleClass == null) { - styleClass = matcher.group("VALUETYPE") != null ? "value-type" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("VALUEVALUE") != null ? "value-value" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("PAREN") != null ? "paren" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("BRACE") != null ? "brace" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("BRACKET") != null ? "bracket" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("SEMICOLON") != null ? "semicolon" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("STRING") != null ? "string" : null; - } - - if (styleClass == null) { - styleClass = matcher.group("COMMENT") != null ? "comment" : null; - } - - assert styleClass != null; - - spansBuilder.add(singleton("plain-code"), matcher.start() - lastKwEnd); - spansBuilder.add(singleton(styleClass), matcher.end() - matcher.start()); - - lastKwEnd = matcher.end(); - } - - spansBuilder.add(singleton("plain-code"), text.length() - lastKwEnd); - - return spansBuilder.create(); - } - - @NotNull @Override - protected StyleSpans> getStyleSpans(@NotNull final String text) { - return computeHighlighting(text); + @FXThread + protected @NotNull BaseCodeArea createCodeArea() { + return new MaterialDefinitionCodeArea(); } - @NotNull @Override - public EditorDescription getDescription() { + @FromAnyThread + public @NotNull EditorDescription getDescription() { return DESCRIPTION; } } 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 e8632baf..d5903ac8 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 @@ -4,6 +4,7 @@ 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.ui.component.editor.EditorDescription; import com.ss.editor.ui.component.editor.EditorRegistry; import com.ss.editor.ui.css.CSSClasses; @@ -52,13 +53,14 @@ public class TextFileEditor extends AbstractFileEditor { @Nullable private TextArea textArea; - @NotNull @Override - protected VBox createRoot() { + @FXThread + protected @NotNull VBox createRoot() { return new VBox(); } @Override + @FXThread protected void createContent(@NotNull final VBox root) { textArea = new TextArea(); @@ -73,16 +75,19 @@ protected void createContent(@NotNull final VBox root) { /** * Update dirty state. */ + @FXThread private void updateDirty(final String newContent) { setDirty(!getOriginalContent().equals(newContent)); } @Override + @FXThread protected boolean needToolbar() { return true; } @Override + @FXThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); FXUtils.addToPane(createSaveAction(), container); @@ -91,18 +96,25 @@ protected void createToolbar(@NotNull final HBox container) { /** * @return the text area. */ - @NotNull - private TextArea getTextArea() { + @FXThread + private @NotNull TextArea getTextArea() { return notNull(textArea); } - @FXThread @Override + @FXThread public void openFile(@NotNull final Path file) { super.openFile(file); setOriginalContent(FileUtils.read(file)); + /* TODO added to handle some exceptions + try { + + } catch (final MalformedInputException e) { + throw new RuntimeException("This file isn't a text file.", e); + } */ + final TextArea textArea = getTextArea(); textArea.setText(getOriginalContent()); } @@ -110,14 +122,15 @@ public void openFile(@NotNull final Path file) { /** * @return the original content of the opened file. */ - @NotNull - private String getOriginalContent() { + @FXThread + private @NotNull String getOriginalContent() { return notNull(originalContent); } /** * @param originalContent the original content of the opened file. */ + @FXThread private void setOriginalContent(@NotNull final String originalContent) { this.originalContent = originalContent; } @@ -135,8 +148,8 @@ public void doSave(@NotNull final Path toStore) throws IOException { } } - @FXThread @Override + @FXThread protected void postSave() { super.postSave(); @@ -148,6 +161,7 @@ protected void postSave() { } @Override + @FXThread protected void handleExternalChanges() { super.handleExternalChanges(); @@ -161,9 +175,9 @@ protected void handleExternalChanges() { updateDirty(newContent); } - @NotNull @Override - public EditorDescription getDescription() { + @FromAnyThread + public @NotNull EditorDescription getDescription() { return DESCRIPTION; } } 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 92f065c4..fad33d0f 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 @@ -1,13 +1,10 @@ package com.ss.editor.ui.component.editor.impl.material; -import static com.jme3.renderer.queue.RenderQueue.Bucket.Inherit; -import static com.jme3.renderer.queue.RenderQueue.Bucket.values; import static com.ss.editor.Messages.MATERIAL_EDITOR_NAME; 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 javafx.collections.FXCollections.observableArrayList; import com.jme3.asset.AssetManager; import com.jme3.asset.MaterialKey; import com.jme3.asset.TextureKey; @@ -15,7 +12,6 @@ import com.jme3.material.MatParamTexture; import com.jme3.material.Material; import com.jme3.material.MaterialDef; -import com.jme3.renderer.queue.RenderQueue; import com.jme3.shader.VarType; import com.jme3.texture.Texture; import com.ss.editor.FileExtensions; @@ -28,33 +24,24 @@ import com.ss.editor.model.node.material.RootMaterialSettings; import com.ss.editor.model.undo.EditorOperationControl; import com.ss.editor.model.undo.editor.ChangeConsumer; -import com.ss.editor.model.undo.editor.MaterialChangeConsumer; -import com.ss.editor.plugin.api.editor.Advanced3DFileEditorWithSplitRightTool; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState.ModelType; +import com.ss.editor.plugin.api.editor.material.BaseMaterialFileEditor; import com.ss.editor.serializer.MaterialSerializer; import com.ss.editor.state.editor.impl.material.MaterialEditor3DState; -import com.ss.editor.state.editor.impl.material.MaterialEditor3DState.ModelType; -import com.ss.editor.ui.Icons; import com.ss.editor.ui.component.editor.EditorDescription; import com.ss.editor.ui.component.editor.state.EditorState; import com.ss.editor.ui.component.editor.state.impl.EditorMaterialEditorState; -import com.ss.editor.ui.component.tab.EditorToolComponent; -import com.ss.editor.ui.control.property.PropertyEditor; 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.editor.ui.css.CSSClasses; 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.MaterialUtils; import com.ss.rlib.ui.util.FXUtils; import javafx.collections.ObservableList; -import javafx.scene.control.*; -import javafx.scene.image.ImageView; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; import javafx.scene.input.DragEvent; -import javafx.scene.input.KeyCode; import javafx.scene.layout.HBox; -import javafx.scene.layout.StackPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -73,10 +60,10 @@ * @author JavaSaBr */ public class MaterialFileEditor extends - Advanced3DFileEditorWithSplitRightTool implements MaterialChangeConsumer { + BaseMaterialFileEditor { /** - * The constant DESCRIPTION. + * The description. */ @NotNull public static final EditorDescription DESCRIPTION = new EditorDescription(); @@ -88,28 +75,14 @@ public class MaterialFileEditor extends DESCRIPTION.addExtension(FileExtensions.JME_MATERIAL); } - /** - * The default flag of enabling light. - */ - public static final boolean DEFAULT_LIGHT_ENABLED = true; - @NotNull private static final ResourceManager RESOURCE_MANAGER = ResourceManager.getInstance(); - @NotNull - private static final ObservableList BUCKETS = observableArrayList(values()); - - /** - * The settings tree. - */ - @Nullable - private NodeTree settingsTree; - /** - * The property editor. + * The list of material definitions. */ @Nullable - private PropertyEditor propertyEditor; + private ComboBox materialDefinitionBox; /** * The current editing material. @@ -117,42 +90,6 @@ public class MaterialFileEditor extends @Nullable private Material currentMaterial; - /** - * The button to use a cube. - */ - @Nullable - private ToggleButton cubeButton; - - /** - * The button to use a sphere. - */ - @Nullable - private ToggleButton sphereButton; - - /** - * The button to use a plane. - */ - @Nullable - private ToggleButton planeButton; - - /** - * The button to use a light. - */ - @Nullable - private ToggleButton lightButton; - - /** - * The list of RenderQueue.Bucket. - */ - @Nullable - private ComboBox bucketComboBox; - - /** - * The list of material definitions. - */ - @Nullable - private ComboBox materialDefinitionBox; - private MaterialFileEditor() { super(); } @@ -160,7 +97,7 @@ private MaterialFileEditor() { @Override @FXThread protected @NotNull MaterialEditor3DState create3DEditorState() { - return new MaterialEditor3DState<>(this); + return new MaterialEditor3DState(this); } @Override @@ -209,90 +146,6 @@ protected void handleExternalChanges() { operationControl.clear(); } - @Override - @FXThread - protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed, - final boolean isControlDown, final boolean isButtonMiddleDown) { - - if (isPressed && isControlDown && keyCode == KeyCode.Z) { - undo(); - return true; - } else if (isPressed && isControlDown && keyCode == KeyCode.Y) { - redo(); - return true; - } else if (isPressed && keyCode == KeyCode.C && !isControlDown && !isButtonMiddleDown) { - final ToggleButton cubeButton = getCubeButton(); - cubeButton.setSelected(true); - return true; - } else if (isPressed && keyCode == KeyCode.S && !isControlDown && !isButtonMiddleDown) { - final ToggleButton sphereButton = getSphereButton(); - sphereButton.setSelected(true); - return true; - } else if (isPressed && keyCode == KeyCode.P && !isControlDown && !isButtonMiddleDown) { - final ToggleButton planeButton = getPlaneButton(); - planeButton.setSelected(true); - return true; - } else if (isPressed && keyCode == KeyCode.L && !isControlDown && !isButtonMiddleDown) { - final ToggleButton lightButton = getLightButton(); - lightButton.setSelected(!lightButton.isSelected()); - return true; - } - - return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isButtonMiddleDown); - } - - @Override - @FXThread - protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { - super.createToolComponents(container, root); - - settingsTree = new NodeTree<>(this::selectedFromTree, this); - propertyEditor = new PropertyEditor<>(this); - propertyEditor.prefHeightProperty().bind(root.heightProperty()); - - container.addComponent(buildSplitComponent(settingsTree, propertyEditor, root), Messages.MATERIAL_SETTINGS_MAIN); - - FXUtils.addClassTo(settingsTree.getTreeView(), CSSClasses.TRANSPARENT_TREE_VIEW); - } - - /** - * @return the settings tree. - */ - @FromAnyThread - private @NotNull NodeTree getSettingsTree() { - return notNull(settingsTree); - } - - /** - * @return the property editor. - */ - @FromAnyThread - private @NotNull PropertyEditor getPropertyEditor() { - return notNull(propertyEditor); - } - - /** - * Handle selected object from tree. - * - * @param object the selected object. - */ - private void selectedFromTree(@Nullable final Object object) { - - Object parent = null; - Object element; - - if (object instanceof TreeNode) { - final TreeNode treeNode = (TreeNode) object; - final TreeNode parentNode = treeNode.getParent(); - parent = parentNode == null ? null : parentNode.getElement(); - element = treeNode.getElement(); - } else { - element = object; - } - - getPropertyEditor().buildFor(element, parent); - } - /** * Try to apply dropped texture. * @@ -350,22 +203,24 @@ private void applyTexture(@NotNull final MaterialFileEditor editor, @NotNull fin } @Override - protected void dragDropped(@NotNull final DragEvent dragEvent) { - super.dragDropped(dragEvent); + @FXThread + protected void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { + super.handleDragDroppedEvent(dragEvent); UIUtils.handleDroppedFile(dragEvent, FileExtensions.TEXTURE_EXTENSIONS, this, dragEvent, this::applyTexture); } @Override - protected void dragOver(@NotNull final DragEvent dragEvent) { - super.dragOver(dragEvent); + @FXThread + protected void handleDragOverEvent(@NotNull final DragEvent dragEvent) { + super.handleDragOverEvent(dragEvent); UIUtils.acceptIfHasFile(dragEvent, FileExtensions.TEXTURE_EXTENSIONS); } @Override @FXThread - protected void doOpenFile(@NotNull final Path file) { + protected void doOpenFile(@NotNull final Path file) throws IOException { super.doOpenFile(file); final Path assetFile = notNull(getAssetFile(file)); @@ -380,38 +235,12 @@ protected void doOpenFile(@NotNull final Path file) { reload(material); } - @Override @FXThread - protected void loadState() { - super.loadState(); - - switch (ModelType.valueOf(editorState.getModelType())) { - case BOX: - getCubeButton().setSelected(true); - break; - case SPHERE: - getSphereButton().setSelected(true); - break; - case QUAD: - getPlaneButton().setSelected(true); - break; - } - - getBucketComboBox().getSelectionModel().select(editorState.getBucketType()); - getLightButton().setSelected(editorState.isLightEnable()); - } - @Override protected @Nullable Supplier getEditorStateFactory() { return EditorMaterialEditorState::new; } - @Override - @FXThread - protected void calcVSplitSize(@NotNull final SplitPane splitPane) { - splitPane.setDividerPosition(0, 0.2); - } - /** * Reload the material. */ @@ -429,7 +258,7 @@ private void reload(@NotNull final Material material) { final ComboBox materialDefinitionBox = getMaterialDefinitionBox(); final ObservableList items = materialDefinitionBox.getItems(); items.clear(); - items.addAll(RESOURCE_MANAGER.getAvailableMaterialDefinitions()); + items.addAll(RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION)); final MaterialDef materialDef = material.getMaterialDef(); materialDefinitionBox.getSelectionModel().select(materialDef.getAssetName()); @@ -447,39 +276,10 @@ private void reload(@NotNull final Material material) { return notNull(materialDefinitionBox); } - @Override - @FXThread - protected boolean needToolbar() { - return true; - } - @Override @FXThread protected void createToolbar(@NotNull final HBox container) { - - cubeButton = new ToggleButton(); - cubeButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_CUBE + " (C)")); - cubeButton.setGraphic(new ImageView(Icons.CUBE_16)); - cubeButton.selectedProperty().addListener((observable, oldValue, newValue) -> - changeModelType(ModelType.BOX, newValue)); - - sphereButton = new ToggleButton(); - sphereButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_SPHERE + " (S)")); - sphereButton.setGraphic(new ImageView(Icons.SPHERE_16)); - sphereButton.selectedProperty().addListener((observable, oldValue, newValue) -> - changeModelType(ModelType.SPHERE, newValue)); - - planeButton = new ToggleButton(); - planeButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_PLANE + " (P)")); - planeButton.setGraphic(new ImageView(Icons.PLANE_16)); - planeButton.selectedProperty().addListener((observable, oldValue, newValue) -> - changeModelType(ModelType.QUAD, newValue)); - - lightButton = new ToggleButton(); - lightButton.setTooltip(new Tooltip(Messages.MATERIAL_FILE_EDITOR_ACTION_LIGHT + " (L)")); - lightButton.setGraphic(new ImageView(Icons.LIGHT_16)); - lightButton.setSelected(DEFAULT_LIGHT_ENABLED); - lightButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeLight(newValue)); + super.createToolbar(container); final Label materialDefinitionLabel = new Label(Messages.MATERIAL_EDITOR_MATERIAL_TYPE_LABEL + ":"); @@ -488,42 +288,11 @@ protected void createToolbar(@NotNull final HBox container) { .selectedItemProperty() .addListener((observable, oldValue, newValue) -> changeType(newValue)); - final Label bucketLabel = new Label(Messages.MATERIAL_FILE_EDITOR_BUCKET_TYPE_LABEL + ":"); - - bucketComboBox = new ComboBox<>(BUCKETS); - bucketComboBox.getSelectionModel().select(Inherit); - bucketComboBox.getSelectionModel() - .selectedItemProperty() - .addListener((observable, oldValue, newValue) -> changeBucketType(newValue)); - - FXUtils.addToPane(createSaveAction(), container); - FXUtils.addToPane(cubeButton, container); - FXUtils.addToPane(sphereButton, container); - FXUtils.addToPane(planeButton, container); - FXUtils.addToPane(lightButton, container); FXUtils.addToPane(materialDefinitionLabel, container); FXUtils.addToPane(materialDefinitionBox, container); - FXUtils.addToPane(bucketLabel, container); - FXUtils.addToPane(bucketComboBox, container); - - DynamicIconSupport.addSupport(cubeButton, sphereButton, planeButton, lightButton); - - FXUtils.addClassTo(materialDefinitionLabel, bucketLabel, CSSClasses.FILE_EDITOR_TOOLBAR_LABEL); - FXUtils.addClassTo(materialDefinitionBox, bucketComboBox, CSSClasses.FILE_EDITOR_TOOLBAR_FIELD); - FXUtils.addClassTo(cubeButton, sphereButton, planeButton, lightButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON); - } - - /** - * Handle changing the bucket type. - */ - @FXThread - private void changeBucketType(@NotNull final RenderQueue.Bucket newValue) { - - final MaterialEditor3DState editor3DState = getEditor3DState(); - editor3DState.changeBucketType(newValue); - final EditorMaterialEditorState editorState = getEditorState(); - if (editorState != null) editorState.setBucketType(newValue); + FXUtils.addClassTo(materialDefinitionLabel, CSSClasses.FILE_EDITOR_TOOLBAR_LABEL); + FXUtils.addClassTo(materialDefinitionBox, CSSClasses.FILE_EDITOR_TOOLBAR_FIELD); } /** @@ -554,118 +323,11 @@ private void processChangeTypeImpl(@Nullable final String newType) { reload(newMaterial); } - /** - * Handle changing the light enabling. - */ - @FXThread - private void changeLight(@NotNull final Boolean newValue) { - - final MaterialEditor3DState editor3DState = getEditor3DState(); - editor3DState.updateLightEnabled(newValue); - - final EditorMaterialEditorState editorState = getEditorState(); - if (editorState != null) editorState.setLightEnable(newValue); - } - - /** - * @return the button to use a cube. - */ - @FromAnyThread - private @NotNull ToggleButton getCubeButton() { - return notNull(cubeButton); - } - - /** - * @return the button to use a plane. - */ - @FromAnyThread - private @NotNull ToggleButton getPlaneButton() { - return notNull(planeButton); - } - - /** - * @return the button to use a sphere. - */ - @FromAnyThread - private @NotNull ToggleButton getSphereButton() { - return notNull(sphereButton); - } - - /** - * @return the button to use a light. - */ - @FromAnyThread - private @NotNull ToggleButton getLightButton() { - return notNull(lightButton); - } - - /** - * @return the list of RenderQueue.Bucket. - */ - @FromAnyThread - private @NotNull ComboBox getBucketComboBox() { - return notNull(bucketComboBox); - } - - /** - * Handle the changed model type. - */ - @FXThread - private void changeModelType(@NotNull final ModelType modelType, @NotNull final Boolean newValue) { - if (newValue == Boolean.FALSE) return; - - final MaterialEditor3DState editor3DState = getEditor3DState(); - - final ToggleButton cubeButton = getCubeButton(); - final ToggleButton sphereButton = getSphereButton(); - final ToggleButton planeButton = getPlaneButton(); - - if (modelType == ModelType.BOX) { - cubeButton.setMouseTransparent(true); - sphereButton.setMouseTransparent(false); - planeButton.setMouseTransparent(false); - cubeButton.setSelected(true); - sphereButton.setSelected(false); - planeButton.setSelected(false); - editor3DState.changeMode(modelType); - } else if (modelType == ModelType.SPHERE) { - cubeButton.setMouseTransparent(false); - sphereButton.setMouseTransparent(true); - planeButton.setMouseTransparent(false); - cubeButton.setSelected(false); - sphereButton.setSelected(true); - planeButton.setSelected(false); - editor3DState.changeMode(modelType); - } else if (modelType == ModelType.QUAD) { - cubeButton.setMouseTransparent(false); - sphereButton.setMouseTransparent(false); - planeButton.setMouseTransparent(true); - sphereButton.setSelected(false); - cubeButton.setSelected(false); - planeButton.setSelected(true); - editor3DState.changeMode(modelType); - } - - final EditorMaterialEditorState editorState = getEditorState(); - if (editorState != null) editorState.setModelType(modelType); - } - - @Override @FromAnyThread - public @NotNull Material getCurrentMaterial() { + private @NotNull Material getCurrentMaterial() { return notNull(currentMaterial); } - @Override - @FXThread - public void notifyFXChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { - if (object instanceof Material) { - getPropertyEditor().refresh(); - } else { - getPropertyEditor().syncFor(object); - } - } - /** * @param currentMaterial the current editing material. */ diff --git a/src/main/java/com/ss/editor/ui/component/editor/impl/material/operation/RenderStateOperation.java b/src/main/java/com/ss/editor/ui/component/editor/impl/material/operation/RenderStateOperation.java deleted file mode 100644 index e454bdcd..00000000 --- a/src/main/java/com/ss/editor/ui/component/editor/impl/material/operation/RenderStateOperation.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.ss.editor.ui.component.editor.impl.material.operation; - -import com.jme3.material.Material; -import com.jme3.material.RenderState; -import com.ss.editor.manager.ExecutorManager; -import com.ss.editor.model.undo.editor.MaterialChangeConsumer; -import com.ss.editor.model.undo.impl.AbstractEditorOperation; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.function.BiConsumer; - -/** - * The implementation of an editor operation to edit material render params. - * - * @param the type parameter - * @author JavaSaBr - */ -@SuppressWarnings("Duplicates") -public class RenderStateOperation extends AbstractEditorOperation { - - @NotNull - private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); - - /** - * The apply handler. - */ - @NotNull - private final BiConsumer applyHandler; - - /** - * The new value. - */ - @Nullable - private final T newValue; - - /** - * The old value. - */ - @Nullable - private final T oldValue; - - /** - * Instantiates a new Render state operation. - * - * @param newValue the new value - * @param oldValue the old value - * @param applyHandler the apply handler - */ - public RenderStateOperation(@Nullable final T newValue, @Nullable final T oldValue, - @NotNull final BiConsumer applyHandler) { - this.newValue = newValue; - this.oldValue = oldValue; - this.applyHandler = applyHandler; - } - - @Override - protected void redoImpl(@NotNull final MaterialChangeConsumer editor) { - EXECUTOR_MANAGER.addJMETask(() -> { - final Material currentMaterial = editor.getCurrentMaterial(); - final RenderState renderState = currentMaterial.getAdditionalRenderState(); - applyHandler.accept(renderState, newValue); - EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXChangeProperty(renderState, "RenderState")); - }); - } - - @Override - protected void undoImpl(@NotNull final MaterialChangeConsumer editor) { - EXECUTOR_MANAGER.addJMETask(() -> { - final Material currentMaterial = editor.getCurrentMaterial(); - final RenderState renderState = currentMaterial.getAdditionalRenderState(); - applyHandler.accept(renderState, oldValue); - EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXChangeProperty(renderState, "RenderState")); - }); - } -} 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 99c26f8f..434c19c0 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 @@ -15,6 +15,7 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.ResourceManager; import com.ss.editor.state.editor.impl.model.ModelEditor3DState; import com.ss.editor.state.editor.impl.model.ModelEditorBulletState; @@ -38,6 +39,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.nio.file.Path; import java.util.function.Supplier; @@ -123,6 +125,7 @@ private ModelFileEditor() { /** * @return the list of fast skies. */ + @FXThread private @NotNull ComboBox getFastSkyComboBox() { return notNull(fastSkyComboBox); } @@ -130,6 +133,7 @@ private ModelFileEditor() { /** * @return the light toggle. */ + @FXThread private @NotNull ToggleButton getLightButton() { return notNull(lightButton); } @@ -137,6 +141,7 @@ private ModelFileEditor() { /** * @return the physics toggle. */ + @FXThread private @NotNull ToggleButton getPhysicsButton() { return notNull(physicsButton); } @@ -144,13 +149,14 @@ private ModelFileEditor() { /** * @return the debug physics button. */ + @FXThread private @NotNull ToggleButton getDebugPhysicsButton() { return notNull(debugPhysicsButton); } @Override @FXThread - protected void doOpenFile(@NotNull final Path file) { + protected void doOpenFile(@NotNull final Path file) throws IOException { super.doOpenFile(file); final Path assetFile = notNull(getAssetFile(file), "Asset file for " + file + " can't be null."); @@ -181,6 +187,7 @@ protected void doOpenFile(@NotNull final Path file) { } @Override + @FXThread protected void loadState() { super.loadState(); @@ -200,11 +207,13 @@ protected void loadState() { } @Override + @FXThread protected @Nullable Supplier getEditorStateFactory() { return EditorModelEditorState::new; } @Override + @FXThread protected void handleAddedObject(@NotNull final Spatial model) { super.handleAddedObject(model); @@ -222,8 +231,8 @@ protected void handleAddedObject(@NotNull final Spatial model) { } } - @FXThread @Override + @FXThread protected void handleRemovedObject(@NotNull final Spatial model) { super.handleRemovedObject(model); @@ -242,11 +251,13 @@ protected void handleRemovedObject(@NotNull final Spatial model) { } @Override + @FromAnyThread public @NotNull EditorDescription getDescription() { return DESCRIPTION; } @Override + @FXThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); @@ -269,6 +280,7 @@ protected void createToolbar(@NotNull final HBox container) { } @Override + @FXThread protected void createActions(@NotNull final HBox container) { super.createActions(container); @@ -302,6 +314,7 @@ protected void createActions(@NotNull final HBox container) { /** * Handle changing a sky. */ + @FXThread private void changeFastSky(@NotNull final String newSky) { if (isIgnoreListeners()) return; @@ -335,6 +348,7 @@ private void changeFastSky(@NotNull final String newSky) { /** * @return the bullet state. */ + @FXThread private @NotNull ModelEditorBulletState getBulletState() { return bulletState; } @@ -342,6 +356,7 @@ private void changeFastSky(@NotNull final String newSky) { /** * Handle to change enabling of physics. */ + @FXThread private void changePhysics(@NotNull final Boolean newValue) { if (isIgnoreListeners()) return; @@ -353,6 +368,7 @@ private void changePhysics(@NotNull final Boolean newValue) { /** * Handle to change enabling of physics. */ + @FXThread private void changeDebugPhysics(@NotNull final Boolean newValue) { if (isIgnoreListeners()) return; @@ -364,6 +380,7 @@ private void changeDebugPhysics(@NotNull final Boolean newValue) { /** * Handle changing camera light visibility. */ + @FXThread private void changeLight(@NotNull final Boolean newValue) { if (isIgnoreListeners()) return; @@ -374,6 +391,7 @@ private void changeLight(@NotNull final Boolean newValue) { } @Override + @FXThread public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, final boolean needSelect) { super.notifyFXAddedChild(parent, added, index, needSelect); @@ -395,6 +413,7 @@ public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Obje } @Override + @FXThread public void notifyFXRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { super.notifyFXRemovedChild(parent, removed); 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 1b4f93ce..77add438 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 @@ -459,7 +459,8 @@ protected void loadState() { @Override @FXThread protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed, - final boolean isControlDown, final boolean isButtonMiddleDown) { + final boolean isControlDown, final boolean isShiftDown, + final boolean isButtonMiddleDown) { final MA editor3DState = getEditor3DState(); if (editor3DState.isCameraMoving()) { @@ -508,7 +509,7 @@ protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final bool return true; } - return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isButtonMiddleDown); + return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isShiftDown, isButtonMiddleDown); } /** @@ -972,6 +973,7 @@ protected void createContent(@NotNull final StackPane root) { } @Override + @FXThread protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { super.createToolComponents(container, root); @@ -1041,8 +1043,9 @@ protected void processChangeTool(@Nullable final Number oldValue, @NotNull final } @Override - protected void dragDropped(@NotNull final DragEvent dragEvent) { - super.dragDropped(dragEvent); + @FXThread + protected void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { + super.handleDragDroppedEvent(dragEvent); UIUtils.handleDroppedFile(dragEvent, FileExtensions.JME_OBJECT, this, dragEvent, AbstractSceneFileEditor::addNewModel); @@ -1052,8 +1055,9 @@ protected void dragDropped(@NotNull final DragEvent dragEvent) { } @Override - protected void dragOver(@NotNull final DragEvent dragEvent) { - super.dragOver(dragEvent); + @FXThread + protected void handleDragOverEvent(@NotNull final DragEvent dragEvent) { + super.handleDragOverEvent(dragEvent); UIUtils.acceptIfHasFile(dragEvent, ACCEPTED_FILES); } 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 c146a0f9..1f306b1a 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 @@ -9,6 +9,7 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.extension.scene.SceneLayer; import com.ss.editor.extension.scene.SceneNode; @@ -44,6 +45,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.nio.file.Path; import java.util.Objects; import java.util.function.Supplier; @@ -137,13 +139,14 @@ private SceneFileEditor() { } @Override + @FXThread protected @Nullable Supplier getEditorStateFactory() { return EditorSceneEditorState::new; } @Override @FXThread - protected void doOpenFile(@NotNull final Path file) { + protected void doOpenFile(@NotNull final Path file) throws IOException { super.doOpenFile(file); final Path assetFile = notNull(getAssetFile(file), "Asset file for " + file + " can't be null."); @@ -173,6 +176,7 @@ protected void doOpenFile(@NotNull final Path file) { } @Override + @FXThread protected void refreshTree() { super.refreshTree(); @@ -188,6 +192,7 @@ protected void refreshTree() { layerNodeTree.fill(new LayersRoot(this)); } + @FXThread private void updateVisibility(@NotNull final Spatial spatial) { final SceneLayer layer = SceneLayer.getLayer(spatial); if (layer != null) spatial.setVisible(layer.isShowed()); @@ -196,6 +201,7 @@ private void updateVisibility(@NotNull final Spatial spatial) { /** * @return the list with app states. */ + @FXThread private @NotNull AppStateList getAppStateList() { return notNull(appStateList); } @@ -203,6 +209,7 @@ private void updateVisibility(@NotNull final Spatial spatial) { /** * @return the list with filters. */ + @FXThread private @NotNull FilterList getFilterList() { return notNull(filterList); } @@ -210,6 +217,7 @@ private void updateVisibility(@NotNull final Spatial spatial) { /** * @return the tree with layers. */ + @FXThread private @NotNull LayerNodeTree getLayerNodeTree() { return notNull(layerNodeTree); } @@ -217,6 +225,7 @@ private void updateVisibility(@NotNull final Spatial spatial) { /** * @return the container of property editor in layers tool. */ + @FXThread private @NotNull VBox getPropertyEditorLayersContainer() { return notNull(propertyEditorLayersContainer); } @@ -224,6 +233,7 @@ private void updateVisibility(@NotNull final Spatial spatial) { /** * @return the container of property editor in filters tool. */ + @FXThread private @NotNull VBox getPropertyEditorFiltersContainer() { return notNull(propertyEditorFiltersContainer); } @@ -231,11 +241,13 @@ private void updateVisibility(@NotNull final Spatial spatial) { /** * @return the container of property editor in app states tool. */ + @FXThread private @NotNull VBox getPropertyEditorAppStateContainer() { return notNull(propertyEditorAppStateContainer); } @Override + @FXThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); @@ -262,6 +274,7 @@ protected void createToolbar(@NotNull final HBox container) { /** * Handle changing light models visibility. */ + @FXThread private void changeLight(@NotNull final Boolean newValue) { if (isIgnoreListeners()) return; @@ -274,6 +287,7 @@ private void changeLight(@NotNull final Boolean newValue) { /** * Handle changing audio models visibility. */ + @FXThread private void changeAudio(@NotNull final Boolean newValue) { if (isIgnoreListeners()) return; @@ -284,6 +298,7 @@ private void changeAudio(@NotNull final Boolean newValue) { } @Override + @FXThread protected void createContent(@NotNull final StackPane root) { appStateList = new AppStateList(this::selectAppStateFromList, this); @@ -301,6 +316,7 @@ protected void createContent(@NotNull final StackPane root) { } @Override + @FXThread protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { super.createToolComponents(container, root); @@ -313,6 +329,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container } @Override + @FXThread protected void processChangeTool(@Nullable final Number oldValue, @NotNull final Number newValue) { super.processChangeTool(oldValue, newValue); @@ -346,6 +363,7 @@ protected void processChangeTool(@Nullable final Number oldValue, @NotNull final /** * @return the light toggle. */ + @FXThread private @NotNull ToggleButton getLightButton() { return notNull(lightButton); } @@ -353,11 +371,13 @@ protected void processChangeTool(@Nullable final Number oldValue, @NotNull final /** * @return the audio toggle. */ + @FXThread private @NotNull ToggleButton getAudioButton() { return notNull(audioButton); } @Override + @FXThread protected void loadState() { super.loadState(); @@ -445,6 +465,7 @@ private void selectNodeFromLayersTree(@Nullable final Object object) { } @Override + @FXThread public void selectNodeFromTree(@Nullable final Object object) { if (!isNeedSyncSelection()) return; @@ -468,6 +489,7 @@ public void selectNodeFromTree(@Nullable final Object object) { } @Override + @FromAnyThread public @NotNull EditorDescription getDescription() { return DESCRIPTION; } @@ -475,6 +497,7 @@ public void selectNodeFromTree(@Nullable final Object object) { /** * @param needSyncSelection true if need sync selection. */ + @FXThread private void setNeedSyncSelection(final boolean needSyncSelection) { this.needSyncSelection = needSyncSelection; } @@ -482,11 +505,13 @@ private void setNeedSyncSelection(final boolean needSyncSelection) { /** * @return true if need sync selection. */ + @FXThread private boolean isNeedSyncSelection() { return needSyncSelection; } @Override + @FXThread protected void updateSelection(@Nullable Spatial spatial) { if (spatial instanceof SceneNode || spatial instanceof SceneLayer) { @@ -497,6 +522,7 @@ protected void updateSelection(@Nullable Spatial spatial) { } @Override + @FXThread protected void handleAddedObject(@NotNull final Spatial model) { super.handleAddedObject(model); @@ -516,6 +542,7 @@ protected void handleAddedObject(@NotNull final Spatial model) { } @Override + @FXThread protected void handleRemovedObject(@NotNull final Spatial model) { super.handleRemovedObject(model); @@ -535,6 +562,7 @@ protected void handleRemovedObject(@NotNull final Spatial model) { } @Override + @FXThread public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, final boolean needSelect) { super.notifyFXAddedChild(parent, added, index, needSelect); @@ -551,6 +579,7 @@ public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Obje } @Override + @FXThread public void notifyFXRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { super.notifyFXRemovedChild(parent, removed); @@ -566,6 +595,7 @@ public void notifyFXRemovedChild(@NotNull final Object parent, @NotNull final Ob } @Override + @FXThread public void notifyFXChangeProperty(@Nullable final Object parent, @NotNull final Object object, @NotNull final String propertyName) { super.notifyFXChangeProperty(parent, object, propertyName); @@ -600,6 +630,7 @@ public void notifyFXChangeProperty(@Nullable final Object parent, @NotNull final } @Override + @FXThread public void notifyAddedAppState(@NotNull final SceneAppState appState) { final SceneEditor3DState editor3DState = getEditor3DState(); @@ -613,6 +644,7 @@ public void notifyAddedAppState(@NotNull final SceneAppState appState) { } @Override + @FXThread public void notifyRemovedAppState(@NotNull final SceneAppState appState) { final SceneEditor3DState editor3DState = getEditor3DState(); @@ -626,11 +658,13 @@ public void notifyRemovedAppState(@NotNull final SceneAppState appState) { } @Override + @FXThread public void notifyChangedAppState(@NotNull final SceneAppState appState) { getAppStateList().fill(getCurrentModel()); } @Override + @FXThread public void notifyAddedFilter(@NotNull final SceneFilter sceneFilter) { final SceneEditor3DState editor3DState = getEditor3DState(); @@ -644,6 +678,7 @@ public void notifyAddedFilter(@NotNull final SceneFilter sceneFilter) { } @Override + @FXThread public void notifyRemovedFilter(@NotNull final SceneFilter sceneFilter) { final SceneEditor3DState editor3DState = getEditor3DState(); @@ -657,6 +692,7 @@ public void notifyRemovedFilter(@NotNull final SceneFilter sceneFilter) { } @Override + @FXThread public void notifyChangedFilter(@NotNull final SceneFilter sceneFilter) { getFilterList().fill(getCurrentModel()); } diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/EditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/EditorState.java index 8c7a4c7e..306d314b 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/EditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/EditorState.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.editor.state; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.editor.state.impl.AdditionalEditorState; import org.jetbrains.annotations.NotNull; @@ -18,6 +19,7 @@ public interface EditorState extends Serializable { * * @param handle the change handler. */ + @FXThread void setChangeHandler(@NotNull Runnable handle); /** @@ -28,6 +30,7 @@ public interface EditorState extends Serializable { * @param the type of the state. * @return the additional editor state. */ + @FXThread @NotNull T getOrCreateAdditionalState(@NotNull Class type, @NotNull Supplier factory); } diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/EditorToolConfig.java b/src/main/java/com/ss/editor/ui/component/editor/state/EditorToolConfig.java index f7a311d1..a0000f6b 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/EditorToolConfig.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/EditorToolConfig.java @@ -1,5 +1,7 @@ package com.ss.editor.ui.component.editor.state; +import com.ss.editor.annotation.FXThread; + /** * The interface implementing a state of editor tool. * @@ -12,6 +14,7 @@ public interface EditorToolConfig { * * @return the tool width */ + @FXThread int getToolWidth(); /** @@ -19,6 +22,7 @@ public interface EditorToolConfig { * * @param toolWidth the tool width */ + @FXThread void setToolWidth(final int toolWidth); /** @@ -26,6 +30,7 @@ public interface EditorToolConfig { * * @return the boolean */ + @FXThread boolean isToolCollapsed(); /** @@ -33,5 +38,6 @@ public interface EditorToolConfig { * * @param toolCollapsed the tool collapsed */ + @FXThread void setToolCollapsed(final boolean toolCollapsed); } 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 8dd31128..be2c7130 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,6 +1,7 @@ package com.ss.editor.ui.component.editor.state.impl; import static com.ss.rlib.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; @@ -46,14 +47,12 @@ public abstract class AbstractEditorState implements EditorState { @NotNull private volatile AdditionalEditorState[] additionalStates; - /** - * Instantiates a new Abstract editor state. - */ public AbstractEditorState() { this.additionalStates = EMPTY_ADDITIONAL_STATES; } @Override + @FXThread public void setChangeHandler(@NotNull final Runnable changeHandler) { this.changeHandler = changeHandler; for (final AdditionalEditorState additionalState : additionalStates) { @@ -61,10 +60,10 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { } } - @NotNull @Override - public T getOrCreateAdditionalState(@NotNull final Class type, - @NotNull final Supplier factory) { + @FXThread + public @NotNull T getOrCreateAdditionalState(@NotNull final Class type, + @NotNull final Supplier factory) { for (final AdditionalEditorState additionalState : additionalStates) { if (type.isInstance(additionalState)) { @@ -72,7 +71,7 @@ public T getOrCreateAdditionalState(@NotNull f } } - final AdditionalEditorState newAdditionalState = (AdditionalEditorState) factory.get(); + final AdditionalEditorState newAdditionalState = factory.get(); newAdditionalState.setChangeHandler(notNull(changeHandler)); this.additionalStates = ArrayUtils.addToArray(additionalStates, newAdditionalState, AdditionalEditorState.class); @@ -85,11 +84,12 @@ public T getOrCreateAdditionalState(@NotNull f * * @return the change handler. */ - @Nullable - protected Runnable getChangeHandler() { + @FXThread + protected @Nullable Runnable getChangeHandler() { return changeHandler; } + @FXThread protected void notifyChange() { if (changeHandler != null) { changeHandler.run(); diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/BaseEditorSceneEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/BaseEditorSceneEditorState.java index 4212f15a..d96401a1 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/BaseEditorSceneEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/BaseEditorSceneEditorState.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.editor.state.impl; +import com.ss.editor.annotation.FXThread; import com.ss.editor.control.transform.EditorTransformSupport.TransformType; import com.ss.editor.control.transform.EditorTransformSupport.TransformationMode; import com.ss.editor.ui.component.editor.impl.scene.AbstractSceneFileEditor; @@ -41,9 +42,6 @@ public abstract class BaseEditorSceneEditorState extends Editor3DWithEditorToolE */ private volatile boolean showStatistics; - /** - * Instantiates a new Abstract model file editor state. - */ public BaseEditorSceneEditorState() { this.enableGrid = true; this.enableSelection = true; @@ -56,6 +54,7 @@ public BaseEditorSceneEditorState() { * * @param enableGrid true is the grid is enabled. */ + @FXThread public void setEnableGrid(final boolean enableGrid) { final boolean changed = isEnableGrid() != enableGrid; this.enableGrid = enableGrid; @@ -67,6 +66,7 @@ public void setEnableGrid(final boolean enableGrid) { * * @return true is the grid is enabled. */ + @FXThread public boolean isEnableGrid() { return enableGrid; } @@ -76,6 +76,7 @@ public boolean isEnableGrid() { * * @param enableSelection true if the selection is enabled. */ + @FXThread public void setEnableSelection(final boolean enableSelection) { final boolean changed = isEnableSelection() != enableSelection; this.enableSelection = enableSelection; @@ -87,6 +88,7 @@ public void setEnableSelection(final boolean enableSelection) { * * @return true if the selection is enabled. */ + @FXThread public boolean isEnableSelection() { return enableSelection; } @@ -96,6 +98,7 @@ public boolean isEnableSelection() { * * @return the transformation type. */ + @FXThread public int getTransformationType() { return transformationType; } @@ -105,6 +108,7 @@ public int getTransformationType() { * * @param transformationType the transformation type. */ + @FXThread public void setTransformationType(final int transformationType) { final boolean changed = getTransformationType() != transformationType; this.transformationType = transformationType; @@ -116,6 +120,7 @@ public void setTransformationType(final int transformationType) { * * @return the transformation mode. */ + @FXThread public int getTransformationMode() { return transformationMode; } @@ -125,6 +130,7 @@ public int getTransformationMode() { * * @param transformationMode the transformation mode. */ + @FXThread public void setTransformationMode(final int transformationMode) { final boolean changed = getTransformationMode() != transformationMode; this.transformationMode = transformationMode; @@ -136,6 +142,7 @@ public void setTransformationMode(final int transformationMode) { * * @param showStatistics true if the statistics is need to show. */ + @FXThread public void setShowStatistics(final boolean showStatistics) { final boolean changed = isShowStatistics() != showStatistics; this.showStatistics = showStatistics; @@ -147,6 +154,7 @@ public void setShowStatistics(final boolean showStatistics) { * * @return true if the statistics is need to show. */ + @FXThread public boolean isShowStatistics() { return showStatistics; } 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 6e67f4be..5ab4475f 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 @@ -3,6 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.math.FastMath; import com.jme3.math.Vector3f; +import com.ss.editor.annotation.FXThread; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,9 +47,6 @@ public class Editor3DEditorState extends AbstractEditorState { */ protected volatile float cameraTDistance; - /** - * Instantiates a new Abstract editor state. - */ public Editor3DEditorState() { this.cameraLocation = new Vector3f(); this.cameraVRotation = FastMath.PI / 6; @@ -62,6 +60,7 @@ public Editor3DEditorState() { * * @param cameraHRotation the new horizontal rotation. */ + @FXThread public void setCameraHRotation(final float cameraHRotation) { final boolean changed = getCameraHRotation() != cameraHRotation; this.cameraHRotation = cameraHRotation; @@ -73,6 +72,7 @@ public void setCameraHRotation(final float cameraHRotation) { * * @return the horizontal camera rotation. */ + @FXThread public float getCameraHRotation() { return cameraHRotation; } @@ -82,6 +82,7 @@ public float getCameraHRotation() { * * @param cameraLocation the new camera position. */ + @FXThread public void setCameraLocation(@NotNull final Vector3f cameraLocation) { final boolean changed = Objects.equals(getCameraLocation(), cameraLocation); getCameraLocation().set(cameraLocation); @@ -93,8 +94,8 @@ public void setCameraLocation(@NotNull final Vector3f cameraLocation) { * * @return the camera location. */ - @NotNull - public Vector3f getCameraLocation() { + @FXThread + public @NotNull Vector3f getCameraLocation() { if (cameraLocation == null) cameraLocation = new Vector3f(); return notNull(cameraLocation); } @@ -104,6 +105,7 @@ public Vector3f getCameraLocation() { * * @param cameraTDistance the new camera zoom. */ + @FXThread public void setCameraTDistance(final float cameraTDistance) { final boolean changed = getCameraTDistance() != cameraTDistance; this.cameraTDistance = cameraTDistance; @@ -115,6 +117,7 @@ public void setCameraTDistance(final float cameraTDistance) { * * @return the camera zoom. */ + @FXThread public float getCameraTDistance() { return cameraTDistance; } @@ -124,6 +127,7 @@ public float getCameraTDistance() { * * @param cameraSpeed the camera speed. */ + @FXThread public void setCameraSpeed(final float cameraSpeed) { final boolean changed = getCameraSpeed() != cameraSpeed; this.cameraSpeed = cameraSpeed; @@ -135,6 +139,7 @@ public void setCameraSpeed(final float cameraSpeed) { * * @return the camera speed. */ + @FXThread public float getCameraSpeed() { return cameraSpeed; } @@ -144,6 +149,7 @@ public float getCameraSpeed() { * * @param cameraVRotation the new vertical rotation. */ + @FXThread public void setCameraVRotation(final float cameraVRotation) { final boolean changed = getCameraVRotation() != cameraVRotation; this.cameraVRotation = cameraVRotation; @@ -155,6 +161,7 @@ public void setCameraVRotation(final float cameraVRotation) { * * @return the vertical camera rotation. */ + @FXThread public float getCameraVRotation() { return cameraVRotation; } diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DWithEditorToolEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DWithEditorToolEditorState.java index 5d067c68..b4485e62 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DWithEditorToolEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/Editor3DWithEditorToolEditorState.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.component.editor.state.impl; import static java.lang.Math.abs; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.editor.state.EditorToolConfig; /** @@ -40,11 +41,13 @@ public Editor3DWithEditorToolEditorState() { } @Override + @FXThread public int getToolWidth() { return toolWidth; } @Override + @FXThread public void setToolWidth(final int toolWidth) { final boolean changed = abs(getToolWidth() - toolWidth) > 3; this.toolWidth = toolWidth; @@ -52,11 +55,13 @@ public void setToolWidth(final int toolWidth) { } @Override + @FXThread public boolean isToolCollapsed() { return toolCollapsed; } @Override + @FXThread public void setToolCollapsed(final boolean toolCollapsed) { final boolean changed = isToolCollapsed() != toolCollapsed; this.toolCollapsed = toolCollapsed; diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorMaterialEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorMaterialEditorState.java index 9fe63ae7..2c5c69a5 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorMaterialEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorMaterialEditorState.java @@ -1,7 +1,8 @@ package com.ss.editor.ui.component.editor.state.impl; import com.jme3.renderer.queue.RenderQueue; -import com.ss.editor.state.editor.impl.material.MaterialEditor3DState; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState; import com.ss.editor.ui.component.editor.impl.material.MaterialFileEditor; import org.jetbrains.annotations.NotNull; @@ -36,11 +37,8 @@ public class EditorMaterialEditorState extends Editor3DWithEditorToolEditorState */ private volatile boolean lightEnable; - /** - * Instantiates a new Material file editor state. - */ public EditorMaterialEditorState() { - modelType = MaterialEditor3DState.ModelType.BOX.ordinal(); + modelType = BaseMaterialEditor3DState.ModelType.BOX.ordinal(); bucketTypeId = RenderQueue.Bucket.Inherit.ordinal(); lightEnable = EDITOR_CONFIG.isDefaultEditorCameraEnabled(); } @@ -50,7 +48,8 @@ public EditorMaterialEditorState() { * * @return the bucket type. */ - public RenderQueue.Bucket getBucketType() { + @FXThread + public @NotNull RenderQueue.Bucket getBucketType() { return BUCKETS[bucketTypeId]; } @@ -59,6 +58,7 @@ public RenderQueue.Bucket getBucketType() { * * @param bucketType the bucket type. */ + @FXThread public void setBucketType(@NotNull final RenderQueue.Bucket bucketType) { final boolean changed = getBucketTypeId() != bucketType.ordinal(); this.bucketTypeId = bucketType.ordinal(); @@ -73,6 +73,7 @@ public void setBucketType(@NotNull final RenderQueue.Bucket bucketType) { * * @return the bucket type ordinal. */ + @FXThread public int getBucketTypeId() { return bucketTypeId; } @@ -82,6 +83,7 @@ public int getBucketTypeId() { * * @return the model type. */ + @FXThread public int getModelType() { return modelType; } @@ -91,7 +93,8 @@ public int getModelType() { * * @param modelType the model type. */ - public void setModelType(@NotNull final MaterialEditor3DState.ModelType modelType) { + @FXThread + public void setModelType(@NotNull final BaseMaterialEditor3DState.ModelType modelType) { final boolean changed = getModelType() != modelType.ordinal(); this.modelType = modelType.ordinal(); final Runnable changeHandler = getChangeHandler(); @@ -105,6 +108,7 @@ public void setModelType(@NotNull final MaterialEditor3DState.ModelType modelTyp * * @return true if the light is enabled. */ + @FXThread public boolean isLightEnable() { return lightEnable; } @@ -114,6 +118,7 @@ public boolean isLightEnable() { * * @param lightEnable true if the light is enabled. */ + @FXThread public void setLightEnable(final boolean lightEnable) { final boolean changed = isLightEnable() != lightEnable; this.lightEnable = lightEnable; diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorModelEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorModelEditorState.java index 6b34fe6b..31c18f9f 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorModelEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorModelEditorState.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.editor.state.impl; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.editor.impl.model.ModelFileEditor; /** @@ -46,6 +47,7 @@ public EditorModelEditorState() { * * @return the sky type. */ + @FXThread public int getSkyType() { return skyType; } @@ -55,6 +57,7 @@ public int getSkyType() { * * @param skyType the sky type. */ + @FXThread public void setSkyType(final int skyType) { final boolean changed = getSkyType() != skyType; this.skyType = skyType; @@ -66,6 +69,7 @@ public void setSkyType(final int skyType) { * * @param enableLight true if the light is enabled. */ + @FXThread public void setEnableLight(final boolean enableLight) { final boolean changed = isEnableLight() != enableLight; this.enableLight = enableLight; @@ -77,6 +81,7 @@ public void setEnableLight(final boolean enableLight) { * * @return true if the light is enabled. */ + @FXThread public boolean isEnableLight() { return enableLight; } @@ -84,6 +89,7 @@ public boolean isEnableLight() { /** * @return true if physics is enabled. */ + @FXThread public boolean isEnablePhysics() { return enablePhysics; } @@ -91,6 +97,7 @@ public boolean isEnablePhysics() { /** * @param enablePhysics true if physics is enabled. */ + @FXThread public void setEnablePhysics(final boolean enablePhysics) { final boolean changed = isEnablePhysics() != enablePhysics; this.enablePhysics = enablePhysics; @@ -100,6 +107,7 @@ public void setEnablePhysics(final boolean enablePhysics) { /** * @return true if debug physics is enabled. */ + @FXThread public boolean isEnableDebugPhysics() { return enableDebugPhysics; } @@ -107,6 +115,7 @@ public boolean isEnableDebugPhysics() { /** * @param enableDebugPhysics true if debug physics is enabled. */ + @FXThread public void setEnableDebugPhysics(final boolean enableDebugPhysics) { final boolean changed = isEnableDebugPhysics() != enableDebugPhysics; this.enableDebugPhysics = enableDebugPhysics; diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorSceneEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorSceneEditorState.java index 3cbd745d..0c78c6db 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorSceneEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorSceneEditorState.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.editor.state.impl; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.editor.impl.scene.SceneFileEditor; /** @@ -24,9 +25,6 @@ public class EditorSceneEditorState extends BaseEditorSceneEditorState { */ private volatile boolean showedAudio; - /** - * Instantiates a new Scene file editor state. - */ public EditorSceneEditorState() { this.showedAudio = true; this.showedLight = true; @@ -37,6 +35,7 @@ public EditorSceneEditorState() { * * @param showedLight true if the light is showed. */ + @FXThread public void setShowedLight(final boolean showedLight) { final boolean changed = isShowedLight() != showedLight; this.showedLight = showedLight; @@ -48,6 +47,7 @@ public void setShowedLight(final boolean showedLight) { * * @return true if the light is showed. */ + @FXThread public boolean isShowedLight() { return showedLight; } @@ -57,6 +57,7 @@ public boolean isShowedLight() { * * @param showedAudio true if the audio is showed. */ + @FXThread public void setShowedAudio(final boolean showedAudio) { final boolean changed = isShowedAudio() != showedAudio; this.showedAudio = showedAudio; @@ -68,6 +69,7 @@ public void setShowedAudio(final boolean showedAudio) { * * @return true if the audio is showed. */ + @FXThread public boolean isShowedAudio() { return showedAudio; } diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorWithEditorToolEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorWithEditorToolEditorState.java new file mode 100644 index 00000000..d500a54b --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/EditorWithEditorToolEditorState.java @@ -0,0 +1,93 @@ +package com.ss.editor.ui.component.editor.state.impl; + +import static java.lang.Math.abs; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.ui.component.editor.state.EditorToolConfig; + +/** + * The base implementation of state for {@link com.ss.editor.plugin.api.editor.BaseFileEditorWithRightTool}. + * + * @author JavaSaBr + */ +public class EditorWithEditorToolEditorState extends AbstractEditorState implements EditorToolConfig { + + /** + * The constant serialVersionUID. + */ + public static final long serialVersionUID = 1; + + /** + * The width of tool split panel. + */ + protected volatile int toolWidth; + + /** + * The flag of collapsing split panel. + */ + protected volatile boolean toolCollapsed; + + /** + * Opened editor tool. + */ + private volatile int openedTool; + + /** + * Instantiates a new Abstract editor state. + */ + public EditorWithEditorToolEditorState() { + this.toolWidth = 250; + this.toolCollapsed = false; + openedTool = 0; + } + + @Override + @FXThread + public int getToolWidth() { + return toolWidth; + } + + @Override + @FXThread + public void setToolWidth(final int toolWidth) { + final boolean changed = abs(getToolWidth() - toolWidth) > 3; + this.toolWidth = toolWidth; + if (changed) notifyChange(); + } + + @Override + @FXThread + public boolean isToolCollapsed() { + return toolCollapsed; + } + + @Override + @FXThread + public void setToolCollapsed(final boolean toolCollapsed) { + final boolean changed = isToolCollapsed() != toolCollapsed; + this.toolCollapsed = toolCollapsed; + if (changed) notifyChange(); + } + + /** + * Gets opened tool. + * + * @return the opened tool. + */ + public int getOpenedTool() { + return openedTool; + } + + /** + * Sets opened tool. + * + * @param openedTool the opened tool. + */ + public void setOpenedTool(final int openedTool) { + final boolean changed = getOpenedTool() != openedTool; + this.openedTool = openedTool; + final Runnable changeHandler = getChangeHandler(); + if (changed && changeHandler != null) { + changeHandler.run(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/ss/editor/ui/component/editor/state/impl/VoidEditorState.java b/src/main/java/com/ss/editor/ui/component/editor/state/impl/VoidEditorState.java index 27a6e8b3..89612a4a 100644 --- a/src/main/java/com/ss/editor/ui/component/editor/state/impl/VoidEditorState.java +++ b/src/main/java/com/ss/editor/ui/component/editor/state/impl/VoidEditorState.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.editor.state.impl; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.editor.state.EditorState; import org.jetbrains.annotations.NotNull; @@ -21,10 +22,12 @@ private VoidEditorState() { throw new RuntimeException(); } + @FXThread @Override public void setChangeHandler(@NotNull final Runnable handle) { } + @FXThread @Override public @NotNull T getOrCreateAdditionalState(@NotNull final Class type, @NotNull final Supplier factory) { 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 b2e649f7..17d01dbf 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 @@ -1,5 +1,6 @@ package com.ss.editor.ui.component.split.pane; +import com.ss.editor.annotation.FXThread; 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; @@ -23,70 +24,75 @@ public class EditorToolSplitPane extends TabToolSplitPane { @NotNull private final Region root; - /** - * Instantiates a new Editor tool split pane. - * - * @param scene the scene - * @param root the root - */ public EditorToolSplitPane(@NotNull final Scene scene, @NotNull final 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())); } @Override + @FXThread protected void handleSceneChanged(@NotNull final Number newSize) { super.handleSceneChanged(newSize); Platform.runLater(this::requestLayout); } @Override + @FXThread protected void bindToScene() { } @Override + @FXThread protected void addElements(@NotNull final TabToolComponent toolComponent, @NotNull final Node other) { getItems().setAll(other, toolComponent); } @Override + @FXThread protected boolean loadCollapsed() { return getConfig().isToolCollapsed(); } @Override + @FXThread protected int loadSize() { return getConfig().getToolWidth(); } @Override + @FXThread protected void saveCollapsed(final boolean collapsed) { getConfig().setToolCollapsed(collapsed); } @Override + @FXThread protected void saveSize(final int size) { getConfig().setToolWidth(size); } @Override + @FXThread protected double getCollapsedPosition() { return 1; } @Override + @FXThread protected double getSceneSize() { final double width = root.getWidth(); return width == 0 ? scene.getWidth() : width; } @Override + @FXThread protected double getExpandPosition(final double toolSize, final double sceneSize) { return 1D - super.getExpandPosition(toolSize, sceneSize); } 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 new file mode 100644 index 00000000..7f927914 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTree.java @@ -0,0 +1,237 @@ +package com.ss.editor.ui.component.virtual.tree; + +import static com.ss.rlib.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.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 javafx.collections.ObservableList; +import javafx.scene.control.SelectionMode; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeView; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * THe implementation of a tree with resources of an asset folder. + * + * @author JavaSaBr + */ +public class VirtualResourceTree extends TreeView> { + + @NotNull + private static final ArrayComparator> NAME_COMPARATOR = (first, second) -> { + + final int firstLevel = getLevel(first); + final int secondLevel = getLevel(second); + + if (firstLevel != secondLevel) return firstLevel - secondLevel; + + final String firstName = notNull(first).getName(); + final String secondName = notNull(second).getName(); + + return StringUtils.compareIgnoreCase(firstName, secondName); + }; + + private static int getLevel(@Nullable final VirtualResourceElement element) { + if (element instanceof FolderVirtualResourceElement) return 1; + return 2; + } + + /** + * The target objects type. + */ + @NotNull + private final Class objectsType; + + /** + * The open resource function. + */ + @Nullable + private Consumer> openFunction; + + /** + * The function to get an asset path of the resource element. + */ + @Nullable + private Function pathFunction; + + /** + * The function to get a name of the resource element. + */ + @Nullable + private Function nameFunction; + + public VirtualResourceTree(@NotNull final Class objectsType) { + this.objectsType = objectsType; + + getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + setFixedCellSize(FXConstants.RESOURCE_TREE_CELL_HEIGHT); + setCellFactory(param -> new VirtualResourceTreeCell()); + setShowRoot(false); + setFocusTraversable(true); + } + + /** + * The type of target objects. + * + * @return the target type. + */ + @FromAnyThread + private @NotNull Class getObjectsType() { + return objectsType; + } + + /** + * Get the function to get an asset path of the resource element. + * + * @return the function to get an asset path of the resource element. + */ + @FromAnyThread + private @Nullable Function getPathFunction() { + return pathFunction; + } + + /** + * Set the function to get an asset path of the resource element. + * + * @param pathFunction the function to get an asset path of the resource element. + */ + @FromAnyThread + public void setPathFunction(final Function pathFunction) { + this.pathFunction = pathFunction; + } + + /** + * Get the function to get a name of the resource element. + * + * @return the function to get a name of the resource element. + */ + @FromAnyThread + private @Nullable Function getNameFunction() { + return nameFunction; + } + + /** + * Get the path of the object. + * + * @param object the object. + * @return the path. + */ + @FromAnyThread + public @NotNull String getPath(@NotNull final Object object) { + + if (object instanceof String) { + return object.toString(); + } else if (!getObjectsType().isInstance(object)) { + throw new RuntimeException("Unknown type of the object " + object); + } + + final Function pathFunction = getPathFunction(); + + if (pathFunction != null) { + return pathFunction.apply(getObjectsType().cast(object)); + } + + throw new RuntimeException("Unknown type of the object " + object); + } + + /** + * Get the name of the object. + * + * @param object the object. + * @return the name. + */ + @FromAnyThread + public @NotNull String getName(@NotNull final Object object) { + + if (object instanceof String) { + final String path = object.toString(); + return FileUtils.getName(path, '/'); + } else if (!getObjectsType().isInstance(object)) { + throw new RuntimeException("Unknown type of the object " + object); + } + + final Function nameFunction = getNameFunction(); + + if (nameFunction != null) { + return nameFunction.apply(getObjectsType().cast(object)); + } + + throw new RuntimeException("Unknown type of the object " + object); + } + + /** + * Fill the tree by the root element. + * + * @param element the root element. + */ + @FXThread + public void fill(@NotNull final VirtualResourceElement element) { + + final TreeItem> newRoot = new TreeItem<>(element); + newRoot.setExpanded(true); + + fill(newRoot); + setRoot(newRoot); + } + + /** + * Expand all nodes. + */ + @FXThread + public void expandAll() { + UIUtils.visit(getRoot(), item -> item.setExpanded(true)); + } + + /** + * Fill the tree item. + * + * @param item the tree item. + */ + @FXThread + private void fill(@NotNull final TreeItem> item) { + + final VirtualResourceElement element = item.getValue(); + if(!element.hasChildren()) { + return; + } + + final ObservableList>> items = item.getChildren(); + + final Array> children = element.getChildren(); + children.sort(NAME_COMPARATOR); + children.forEach(child -> items.add(new TreeItem<>(child))); + + items.forEach(this::fill); + } + + /** + * Get open function. + * + * @return the open resource function. + */ + @FromAnyThread + protected @Nullable Consumer> getOpenFunction() { + return openFunction; + } + + /** + * Set open function. + * + * @param openFunction the open resource function. + */ + @FromAnyThread + public void setOpenFunction(@Nullable final Consumer> openFunction) { + this.openFunction = openFunction; + } +} 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 new file mode 100644 index 00000000..8384775a --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/VirtualResourceTreeCell.java @@ -0,0 +1,58 @@ +package com.ss.editor.ui.component.virtual.tree; + +import static com.ss.editor.manager.FileIconManager.DEFAULT_FILE_ICON_SIZE; +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 javafx.scene.control.TreeCell; +import javafx.scene.control.TreeView; +import javafx.scene.image.ImageView; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * The implementation of the cell for {@link TreeView} to show resource. + * + * @author JavaSaBr + */ +public class VirtualResourceTreeCell extends TreeCell> { + + /** + * The icon manager. + */ + @NotNull + private static final FileIconManager ICON_MANAGER = FileIconManager.getInstance(); + + /** + * The icon. + */ + @NotNull + private final ImageView icon; + + protected VirtualResourceTreeCell() { + this.icon = new ImageView(); + } + + @Override + protected void updateItem(@Nullable final VirtualResourceElement item, boolean empty) { + super.updateItem(item, empty); + + if (item == null) { + setText(StringUtils.EMPTY); + setGraphic(null); + return; + } + + final Path file = Paths.get(item.getPath()); + final boolean folder = item instanceof FolderVirtualResourceElement; + + icon.setImage(ICON_MANAGER.getIcon(file, folder, false, DEFAULT_FILE_ICON_SIZE)); + + setText(item.getName()); + setGraphic(icon); + } +} 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 new file mode 100644 index 00000000..ce41fce9 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/FolderVirtualResourceElement.java @@ -0,0 +1,45 @@ +package com.ss.editor.ui.component.virtual.tree.resource; + +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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The implementation of fake folder resource element. + * + * @author JavaSaBr + */ +public class FolderVirtualResourceElement extends VirtualResourceElement { + + /** + * The list of children. + */ + @NotNull + private final Array> children; + + public FolderVirtualResourceElement(@NotNull final VirtualResourceTree resourceTree, @NotNull final String path) { + super(resourceTree, path); + this.children = ArrayFactory.newArray(VirtualResourceElement.class); + } + + @Override + @FromAnyThread + public void addChild(@NotNull final VirtualResourceElement child) { + this.children.add(child); + } + + @Override + @FromAnyThread + public @Nullable Array> getChildren() { + return children; + } + + @Override + @FromAnyThread + public boolean hasChildren() { + return !children.isEmpty(); + } +} diff --git a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/ObjectVirtualResourceElement.java b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/ObjectVirtualResourceElement.java new file mode 100644 index 00000000..f12edb63 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/ObjectVirtualResourceElement.java @@ -0,0 +1,17 @@ +package com.ss.editor.ui.component.virtual.tree.resource; + +import com.ss.editor.ui.component.virtual.tree.VirtualResourceTree; +import org.jetbrains.annotations.NotNull; + +/** + * The default implementation of the virtual resource element. + * + * @param the type of presented object. + * @author JavaSaBr + */ +public class ObjectVirtualResourceElement extends VirtualResourceElement { + + public ObjectVirtualResourceElement(@NotNull final VirtualResourceTree resourceTree, @NotNull final T object) { + super(resourceTree, object); + } +} diff --git a/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/RootVirtualResourceElement.java b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/RootVirtualResourceElement.java new file mode 100644 index 00000000..eed6d7a1 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/RootVirtualResourceElement.java @@ -0,0 +1,16 @@ +package com.ss.editor.ui.component.virtual.tree.resource; + +import com.ss.editor.ui.component.virtual.tree.VirtualResourceTree; +import org.jetbrains.annotations.NotNull; + +/** + * The root implementation of the virtual resource element. + * + * @author JavaSaBr + */ +public class RootVirtualResourceElement extends FolderVirtualResourceElement { + + public RootVirtualResourceElement(@NotNull final VirtualResourceTree resourceTree) { + super(resourceTree, "/"); + } +} 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 new file mode 100644 index 00000000..f3d1a2fd --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElement.java @@ -0,0 +1,121 @@ +package com.ss.editor.ui.component.virtual.tree.resource; + +import static com.ss.rlib.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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The base implementation of a virtual resource. + * + * @author JavaSaBr + */ +public abstract class VirtualResourceElement implements Comparable> { + + /** + * The logger. + */ + @NotNull + protected static final Logger LOGGER = LoggerManager.getLogger(VirtualResourceElement.class); + + /** + * The virtual resource tree. + */ + @NotNull + protected final VirtualResourceTree resourceTree; + + /** + * The resource object. + */ + @NotNull + protected final T object; + + public VirtualResourceElement(@NotNull final VirtualResourceTree resourceTree, @NotNull final T object) { + this.resourceTree = resourceTree; + this.object = object; + } + + /** + * Get the type of this resource element. + * + * @return the type of this resource element. + */ + @FromAnyThread + public @NotNull Class getType() { + return unsafeCast(object.getClass()); + } + + /** + * Get the path of this resource. + * + * @return the path of this resource. + */ + @FromAnyThread + public @NotNull String getPath() { + return resourceTree.getPath(object); + } + + /** + * Get the name of this resource. + * + * @return the name of this resource. + */ + @FromAnyThread + public @NotNull String getName() { + return resourceTree.getName(object); + } + + /** + * Get the resource object. + * + * @return the resource object. + */ + @FromAnyThread + public @NotNull T getObject() { + return object; + } + + /** + * Add a child to this element. + * + * @param child the new child. + */ + @FromAnyThread + public void addChild(@NotNull final VirtualResourceElement child) { + + } + + /** + * Get the list of children of this element. + * + * @return list of children resource elements. + */ + @FromAnyThread + public @Nullable Array> getChildren() { + return null; + } + + /** + * Check this element to has children. + * + * @return true if this element has children. + */ + @FromAnyThread + public boolean hasChildren() { + return false; + } + + @Override + public int compareTo(@NotNull final VirtualResourceElement o) { + return 0; + } + + @Override + public String toString() { + return object.toString(); + } +} 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 new file mode 100644 index 00000000..a023af26 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/component/virtual/tree/resource/VirtualResourceElementFactory.java @@ -0,0 +1,110 @@ +package com.ss.editor.ui.component.virtual.tree.resource; + +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 org.jetbrains.annotations.NotNull; + +/** + * The factory to create a virtual resource elements. + * + * @author JavaSaBr + */ +public class VirtualResourceElementFactory { + + /** + * Build the root virtual resource elements for the resources. + * + * @param resources the resources. + * @return the root element. + */ + @FromAnyThread + public static @NotNull RootVirtualResourceElement build(@NotNull final Array resources, + @NotNull final VirtualResourceTree resourceTree) { + + final ObjectDictionary> parentToChildren = DictionaryFactory.newObjectDictionary(); + final ObjectDictionary pathToResource = DictionaryFactory.newObjectDictionary(); + resources.forEach(element -> pathToResource.put(resourceTree.getPath(element), element)); + + pathToResource.forEach((key, resource) -> { + + String path = key; + String parent = FileUtils.getParent(path, '/'); + + while (!StringUtils.equals(path, parent)) { + + final Array children = parentToChildren.get(parent, () -> ArrayFactory.newArray(String.class)); + if (!children.contains(path)) { + children.add(path); + } + + path = parent; + parent = FileUtils.getParent(path, '/'); + } + + final Array children = parentToChildren.get("/", () -> ArrayFactory.newArray(String.class)); + if (!children.contains(path)) { + children.add(path); + } + }); + + final ObjectDictionary> pathToResult = DictionaryFactory.newObjectDictionary(); + + parentToChildren.forEach((path, children) -> { + + final T resource = pathToResource.get(path); + + if (resource == null) { + pathToResult.put(path, new FolderVirtualResourceElement(resourceTree, path)); + } else { + pathToResult.put(path, new ObjectVirtualResourceElement<>(resourceTree, resource)); + } + }); + + parentToChildren.forEach((path, children) -> { + + final VirtualResourceElement parent = pathToResult.get(path); + if (parent == null) return; + + for (final String child : children) { + + final T resource = pathToResource.get(child); + VirtualResourceElement element = pathToResult.get(child); + + if (element == null && resource != null) { + element = new ObjectVirtualResourceElement<>(resourceTree, resource); + pathToResult.put(child, element); + } + + if (element != null) { + parent.addChild(element); + } + } + }); + + final RootVirtualResourceElement root = new RootVirtualResourceElement(resourceTree); + final Array rootPaths = parentToChildren.get("/"); + + if (rootPaths == null) { + return root; + } + + rootPaths.forEach(path -> { + + final VirtualResourceElement element = pathToResult.get(path); + + if (element == null) { + return; + } + + root.addChild(element); + }); + + return root; + } +} diff --git a/src/main/java/com/ss/editor/ui/control/app/state/dialog/CreateSceneAppStateDialog.java b/src/main/java/com/ss/editor/ui/control/app/state/dialog/CreateSceneAppStateDialog.java index 595770c1..f7c36685 100644 --- a/src/main/java/com/ss/editor/ui/control/app/state/dialog/CreateSceneAppStateDialog.java +++ b/src/main/java/com/ss/editor/ui/control/app/state/dialog/CreateSceneAppStateDialog.java @@ -4,6 +4,8 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import static com.ss.rlib.util.dictionary.DictionaryFactory.newObjectDictionary; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; 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; @@ -41,7 +43,10 @@ public class CreateSceneAppStateDialog extends AbstractSimpleEditorDialog { @NotNull private static final Point DIALOG_SIZE = new Point(415, 0); + @NotNull private static final ObjectDictionary BUILT_IN = newObjectDictionary(); + + @NotNull private static final Array BUILT_IN_NAMES = ArrayFactory.newArray(String.class); static { @@ -80,22 +85,18 @@ private static void register(@NotNull final EditableSceneAppState appState) { @NotNull private final SceneChangeConsumer changeConsumer; - /** - * Instantiates a new Create scene app state dialog. - * - * @param changeConsumer the change consumer - */ public CreateSceneAppStateDialog(@NotNull final SceneChangeConsumer changeConsumer) { this.changeConsumer = changeConsumer; } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.CREATE_SCENE_APP_STATE_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -136,6 +137,7 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @@ -143,28 +145,29 @@ protected boolean isGridStructure() { /** * @return the check box to chose an option of creating state. */ - @NotNull - private CheckBox getCustomCheckBox() { + @FXThread + private @NotNull CheckBox getCustomCheckBox() { return notNull(customCheckBox); } /** * @return the full class name of creating state. */ - @NotNull - private TextField getStateNameField() { + @FXThread + private @NotNull TextField getStateNameField() { return notNull(stateNameField); } /** * @return the list of built in states. */ - @NotNull - private ComboBox getBuiltInBox() { + @FXThread + private @NotNull ComboBox getBuiltInBox() { return notNull(builtInBox); } @Override + @FXThread protected void processOk() { final CheckBox customCheckBox = getCustomCheckBox(); @@ -202,6 +205,7 @@ protected void processOk() { super.processOk(); } + @FXThread private void check(@NotNull final List appStates, @NotNull final List filters, @NotNull final SceneAppState newExample) { @@ -222,9 +226,9 @@ private void check(@NotNull final List appStates, @NotNull final } } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/control/app/state/property/builder/impl/AppStatePropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/app/state/property/builder/impl/AppStatePropertyBuilder.java index 4e310ec5..e0eb55e6 100644 --- a/src/main/java/com/ss/editor/ui/control/app/state/property/builder/impl/AppStatePropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/app/state/property/builder/impl/AppStatePropertyBuilder.java @@ -1,5 +1,7 @@ package com.ss.editor.ui.control.app.state.property.builder.impl; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.extension.scene.app.state.EditableSceneAppState; import com.ss.editor.model.undo.editor.SceneChangeConsumer; @@ -20,23 +22,21 @@ public class AppStatePropertyBuilder extends EditableModelObjectPropertyBuilder private static final AppStatePropertyBuilder INSTANCE = new AppStatePropertyBuilder(); /** - * Gets instance. + * Get the single instance. * - * @return the instance + * @return the single instance. */ - @NotNull - public static AppStatePropertyBuilder getInstance() { + @FromAnyThread + public static @NotNull AppStatePropertyBuilder getInstance() { return INSTANCE; } - /** - * Instantiates a new App state property builder. - */ protected AppStatePropertyBuilder() { super(SceneChangeConsumer.class); } @Override + @FXThread protected @Nullable List> getProperties(@NotNull final Object object) { if (!(object instanceof EditableSceneAppState)) return null; final EditableSceneAppState state = (EditableSceneAppState) object; 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 new file mode 100644 index 00000000..77c8135c --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/code/BaseCodeArea.java @@ -0,0 +1,184 @@ +package com.ss.editor.ui.control.code; + +import static java.util.Collections.singleton; +import com.ss.editor.annotation.FXThread; +import com.ss.rlib.util.StringUtils; +import org.fxmisc.richtext.CodeArea; +import org.fxmisc.richtext.model.StyleSpans; +import org.fxmisc.richtext.model.StyleSpansBuilder; +import org.fxmisc.undo.UndoManager; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * The base implementation of code area control for this editor. + * + * @author JavaSaBr + */ +public class BaseCodeArea extends CodeArea { + + @NotNull + protected static final String CLASS_KEYWORD = "KEYWORD"; + + @NotNull + protected static final String CLASS_VALUE_TYPE = "VALUETYPE"; + + @NotNull + protected static final String CLASS_VALUE_VALUE = "VALUEVALUE"; + + @NotNull + protected static final String CLASS_PAREN = "PAREN"; + + @NotNull + protected static final String CLASS_BRACE = "BRACE"; + + @NotNull + protected static final String CLASS_BRACKET = "BRACKET"; + + @NotNull + protected static final String CLASS_SEMICOLON = "SEMICOLON"; + + @NotNull + protected static final String CLASS_STRING = "STRING"; + + @NotNull + protected static final String CLASS_COMMENT = "COMMENT"; + + @NotNull + protected static final String[][] AVAILABLE_CLASSES = { + {CLASS_KEYWORD, "keyword"}, + {CLASS_VALUE_TYPE, "value-type"}, + {CLASS_VALUE_VALUE, "value-value"}, + {CLASS_PAREN, "paren"}, + {CLASS_BRACE, "brace"}, + {CLASS_BRACKET, "bracket"}, + {CLASS_SEMICOLON, "semicolon"}, + {CLASS_STRING, "string"}, + {CLASS_COMMENT, "comment"}, + }; + + protected static final String PAREN_PATTERN = "\\(|\\)"; + protected static final String BRACE_PATTERN = "\\{|\\}"; + protected static final String BRACKET_PATTERN = "\\[|\\]"; + protected static final String SEMICOLON_PATTERN = "\\;"; + protected static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\""; + protected static final String COMMENT_PATTERN = "//[^\n]*" + "|" + "/\\*(.|\\R)*?\\*/"; + + public BaseCodeArea() { + richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) + .subscribe(change -> setStyleSpans(0, calculateStyleSpans(getText()))); + } + + /** + * Calculate highlighting for the code. + * + * @param pattern the pattern. + * @param text the text. + * @return the highlight styles. + */ + @FXThread + protected @NotNull StyleSpans> computeHighlighting(@NotNull final Pattern pattern, + @NotNull final String text) { + + final Matcher matcher = pattern.matcher(text); + final StyleSpansBuilder> spansBuilder = new StyleSpansBuilder<>(); + + int lastKwEnd = 0; + + while (matcher.find()) { + + String styleClass = null; + + for (final String[] availableClass : AVAILABLE_CLASSES) { + + try { + styleClass = matcher.group(availableClass[0]) != null ? availableClass[1] : null; + } catch (final IllegalArgumentException e) { + continue; + } + + if(styleClass != null) { + break; + } + } + + assert styleClass != null; + + spansBuilder.add(singleton("plain-code"), matcher.start() - lastKwEnd); + spansBuilder.add(singleton(styleClass), matcher.end() - matcher.start()); + + lastKwEnd = matcher.end(); + } + + spansBuilder.add(singleton("plain-code"), text.length() - lastKwEnd); + + return spansBuilder.create(); + } + + /** + * Gets style spans. + * + * @param text the text + * @return the style spans + */ + @FXThread + protected @NotNull StyleSpans> calculateStyleSpans(@NotNull final String text) { + throw new RuntimeException("unsupported"); + } + + /** + * Load the content. + * + * @param content the content. + */ + @FXThread + public void loadContent(@NotNull final String content) { + appendText(content); + + final UndoManager undoManager = getUndoManager(); + undoManager.forgetHistory(); + } + + /** + * Reload the content. + * + * @param content the content. + */ + @FXThread + public void reloadContent(@NotNull final String content) { + reloadContent(content, false); + } + + /** + * Reload the content. + * + * @param content the content. + * @param clearHistory true if need to clear history. + */ + @FXThread + public void reloadContent(@NotNull final String content, final boolean clearHistory) { + + final String currentContent = getText(); + + if (!StringUtils.equals(currentContent, content)) { + if (content.isEmpty()) { + try { + clear(); + } catch (final IllegalStateException e) { + //FIXME it's a bug in the richfxeditor library + e.printStackTrace(); + } + } else { + replaceText(0, currentContent.length(), content); + } + } + + if (clearHistory) { + final UndoManager undoManager = getUndoManager(); + undoManager.forgetHistory(); + } + } +} diff --git a/src/main/java/com/ss/editor/ui/control/code/GLSLCodeArea.java b/src/main/java/com/ss/editor/ui/control/code/GLSLCodeArea.java new file mode 100644 index 00000000..f7e05540 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/code/GLSLCodeArea.java @@ -0,0 +1,104 @@ +package com.ss.editor.ui.control.code; + +import com.ss.editor.annotation.FXThread; +import com.ss.editor.util.GLSLType; +import org.fxmisc.richtext.model.StyleSpans; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.regex.Pattern; + +/** + * The implementation of code area to show glsl code. + * + * @author JavaSaBr + */ +public class GLSLCodeArea extends BaseCodeArea { + + @NotNull + private static final String[] KEYWORDS = { + "define", "undef", "if", "ifdef", "ifndef", + "else", "elif", "endif", "error", "pragma", + "extension", "version", "line", "attribute", "const", + "uniform", "varying", "layout", "centroid", "flat", + "smooth", "noperspective", "patch", "sample", "break", + "continue", "do", "for", "while", "switch", + "case", "default", "if", "subroutine", "in", "out", "inout", + "void", "true", "false", "invariant", "discard", "return", "struct" + }; + + @NotNull + private static final String[] VALUE_TYPES; + + static { + VALUE_TYPES = Arrays.stream(GLSLType.VALUES) + .map(GLSLType::getRawType) + .toArray(String[]::new); + } + + private static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b"; + private static final String VALUE_TYPE_PATTERN = "\\b(" + String.join("|", VALUE_TYPES) + ")\\b"; + + /** + * The available fields. + */ + @NotNull + private final List fields; + + /** + * THe pattern. + */ + @NotNull + private Pattern pattern; + + public GLSLCodeArea() { + this.pattern = buildPattern(); + this.fields = new ArrayList<>(); + } + + /** + * Get available fields. + * + * @return available fields. + */ + @FXThread + private @Nullable List getFields() { + return fields; + } + + /** + * Build the pattern to highlight code. + * + * @return the pattern to highlight code. + */ + @FXThread + private @NotNull Pattern buildPattern() { + + String result = "(?<" + CLASS_KEYWORD + ">" + KEYWORD_PATTERN + ")" + + "|(?<" + CLASS_VALUE_TYPE + ">" + VALUE_TYPE_PATTERN + ")"; + + final List fields = getFields(); + if (fields != null && !fields.isEmpty()) { + result += "|(?<" + CLASS_VALUE_VALUE + ">" + "\\b(" + String.join("|", fields) + ")\\b"; + } + + result += "|(?<" + CLASS_PAREN + ">" + PAREN_PATTERN + ")" + + "|(?<" + CLASS_BRACE + ">" + BRACE_PATTERN + ")" + + "|(?<" + CLASS_BRACKET + ">" + BRACKET_PATTERN + ")" + + "|(?<" + CLASS_SEMICOLON + ">" + SEMICOLON_PATTERN + ")" + + "|(?<" + CLASS_STRING + ">" + STRING_PATTERN + ")" + + "|(?<" + CLASS_COMMENT + ">" + COMMENT_PATTERN + ")"; + + return Pattern.compile(result); + } + + @Override + @FXThread + protected @NotNull StyleSpans> calculateStyleSpans(@NotNull final String text) { + return computeHighlighting(pattern, text); + } +} diff --git a/src/main/java/com/ss/editor/ui/control/code/MaterialDefinitionCodeArea.java b/src/main/java/com/ss/editor/ui/control/code/MaterialDefinitionCodeArea.java new file mode 100644 index 00000000..1c0bb521 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/code/MaterialDefinitionCodeArea.java @@ -0,0 +1,75 @@ +package com.ss.editor.ui.control.code; + +import com.ss.editor.annotation.FXThread; +import org.fxmisc.richtext.model.StyleSpans; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.regex.Pattern; + +/** + * The implementation of code area to show glsl code. + * + * @author JavaSaBr + */ +public class MaterialDefinitionCodeArea extends BaseCodeArea { + + @NotNull + private static final String[] KEYWORDS = { + "MaterialDef", "MaterialParameters", "Technique", "WorldParameters", "Defines", "ForcedRenderState", + "VertexShaderNodes", "ShaderNode", "Definition", "InputMappings", "OutputMappings", "FragmentShaderNodes" + }; + + @NotNull + private static final String[] VALUE_TYPES = { + "Texture2D", "Float", "Boolean", "Int", "Color", "Vector3", "TextureCubeMap", "Matrix4", "Vector4", "Vector2", + "VertexShader", "TessellationEvaluationShader ", "TessellationControlShader", "FragmentShader", "LightMode", + "FaceCull", "DepthTest", "DepthWrite", "PolyOffset", + "ColorWrite", "Blend", "FragmentShader", "IntArray", "FloatArray", "Vector2Array", "Vector3Array", + "Vector4Array", "Matrix3", "Matrix3Array", "Matrix4Array", "TextureBuffer", "Texture3D", "TextureArray", + "GeometryShader", "Global", "WorldParam", "Attr" + }; + + @NotNull + private static final String[] VALUE_VALUES = { + "true", "false", "Off", "On", "True", "False", "Disable", "SinglePass", "MultiPass", + "SinglePassAndImageBased", "FixedPipeline", "StaticPass", "InPass", "PostPass", "World", "View", + "Legacy", + // glsl versions + "GLSL100", "GLSL110", "GLSL120", "GLSL130", "GLSL140", "GLSL150", "GLSL400", "GLSL330", + "GLSL410", "GLSL420", "GLSL430", "GLSL440", "GLSL450", + // attributes + "inTangent", "inBinormal", "inInterleavedData", "inIndex", "inBindPosePosition", "inBindPoseNormal", + "inBoneWeight", "inBoneIndex", "inBindPoseTangent", "inHWBoneWeight", "inHWBoneIndex", "inInstanceData", + "inPosition", "inSize", "Normal", "inTexCoord", "inColor", + // uniforms + "WorldViewProjectionMatrix", "Time", "NormalMatrix", "WorldViewMatrix", "ViewMatrix", "CameraPosition", + "WorldMatrix", "Resolution", "ViewProjectionMatrix", "ProjectionMatrix", "NormalMatrix", "WorldMatrixInverseTranspose", + "WorldMatrixInverse", "ViewMatrixInverse", "ProjectionMatrixInverse", "ViewProjectionMatrixInverse", + "WorldViewMatrixInverse", "NormalMatrixInverse", "WorldViewProjectionMatrixInverse", + "ViewPort", "FrustumNearFar", "ResolutionInverse", "Aspect", "CameraDirection", "CameraLeft", "CameraUp", + "Tpf", "FrameRate", "LightDirection", "LightPosition", "AmbientLightColor", "LightColor" + }; + + private static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b"; + private static final String VALUE_TYPE_PATTERN = "\\b(" + String.join("|", VALUE_TYPES) + ")\\b"; + private static final String VALUE_VALUE_PATTERN = "\\b(" + String.join("|", VALUE_VALUES) + ")\\b"; + + private static final Pattern PATTERN = Pattern.compile( + "(?" + KEYWORD_PATTERN + ")" + + "|(?" + VALUE_TYPE_PATTERN + ")" + + "|(?" + VALUE_VALUE_PATTERN + ")" + + "|(?" + PAREN_PATTERN + ")" + + "|(?" + BRACE_PATTERN + ")" + + "|(?" + BRACKET_PATTERN + ")" + + "|(?" + SEMICOLON_PATTERN + ")" + + "|(?" + STRING_PATTERN + ")" + + "|(?" + COMMENT_PATTERN + ")" + ); + + @Override + @FXThread + protected @NotNull StyleSpans> calculateStyleSpans(@NotNull final String text) { + return computeHighlighting(PATTERN, text); + } +} diff --git a/src/main/java/com/ss/editor/ui/control/filter/dialog/CreateSceneFilterDialog.java b/src/main/java/com/ss/editor/ui/control/filter/dialog/CreateSceneFilterDialog.java index 458d8b5c..a99533a1 100644 --- a/src/main/java/com/ss/editor/ui/control/filter/dialog/CreateSceneFilterDialog.java +++ b/src/main/java/com/ss/editor/ui/control/filter/dialog/CreateSceneFilterDialog.java @@ -4,6 +4,8 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import static com.ss.rlib.util.dictionary.DictionaryFactory.newObjectDictionary; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.extension.scene.app.state.SceneAppState; import com.ss.editor.extension.scene.filter.EditableSceneFilter; @@ -93,22 +95,18 @@ private static void register(@NotNull final SceneFilter sceneFilter) { @NotNull private final SceneChangeConsumer changeConsumer; - /** - * Instantiates a new Create scene filter dialog. - * - * @param changeConsumer the change consumer - */ public CreateSceneFilterDialog(@NotNull final SceneChangeConsumer changeConsumer) { this.changeConsumer = changeConsumer; } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.CREATE_SCENE_FILTER_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -146,6 +144,7 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @@ -153,28 +152,29 @@ protected boolean isGridStructure() { /** * @return the check box to chose an option of creating filter. */ - @NotNull - private CheckBox getCustomCheckBox() { + @FXThread + private @NotNull CheckBox getCustomCheckBox() { return notNull(customCheckBox); } /** * @return the full class name of creating filter. */ - @NotNull - private TextField getFilterNameField() { + @FXThread + private @NotNull TextField getFilterNameField() { return notNull(filterNameField); } /** * @return the list of built in filters. */ - @NotNull - private ComboBox getBuiltInBox() { + @FXThread + private @NotNull ComboBox getBuiltInBox() { return notNull(builtInBox); } @Override + @FXThread protected void processOk() { final SceneNode currentModel = changeConsumer.getCurrentModel(); @@ -233,9 +233,9 @@ private void check(@NotNull final List appStates, @NotNull final } } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/control/filter/property/builder/impl/FilterPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/filter/property/builder/impl/FilterPropertyBuilder.java index 008606e1..a6d1bf0e 100644 --- a/src/main/java/com/ss/editor/ui/control/filter/property/builder/impl/FilterPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/filter/property/builder/impl/FilterPropertyBuilder.java @@ -1,5 +1,7 @@ package com.ss.editor.ui.control.filter.property.builder.impl; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.extension.scene.filter.EditableSceneFilter; import com.ss.editor.model.undo.editor.ModelChangeConsumer; @@ -20,23 +22,21 @@ public class FilterPropertyBuilder extends EditableModelObjectPropertyBuilder { private static final FilterPropertyBuilder INSTANCE = new FilterPropertyBuilder(); /** - * Gets instance. + * Get the single instance. * - * @return the instance + * @return the single instance */ - @NotNull - public static FilterPropertyBuilder getInstance() { + @FromAnyThread + public static @NotNull FilterPropertyBuilder getInstance() { return INSTANCE; } - /** - * Instantiates a new Filter property builder. - */ protected FilterPropertyBuilder() { super(ModelChangeConsumer.class); } @Override + @FXThread protected @Nullable List> getProperties(@NotNull final Object object) { if (!(object instanceof EditableSceneFilter)) return null; final EditableSceneFilter filter = (EditableSceneFilter) object; diff --git a/src/main/java/com/ss/editor/ui/control/layer/node/LayersRootTreeNode.java b/src/main/java/com/ss/editor/ui/control/layer/node/LayersRootTreeNode.java index 3ba7a81c..9d3c1b4c 100644 --- a/src/main/java/com/ss/editor/ui/control/layer/node/LayersRootTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/layer/node/LayersRootTreeNode.java @@ -1,5 +1,9 @@ package com.ss.editor.ui.control.layer.node; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.extension.scene.SceneLayer; +import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.model.undo.editor.SceneChangeConsumer; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.layer.LayerNodeTree; @@ -7,17 +11,13 @@ import com.ss.editor.ui.control.model.tree.action.scene.CreateSceneLayerAction; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.editor.extension.scene.SceneLayer; -import com.ss.editor.extension.scene.SceneNode; - -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 javafx.collections.ObservableList; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; -import com.ss.rlib.util.array.Array; -import com.ss.rlib.util.array.ArrayFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -28,39 +28,35 @@ */ public class LayersRootTreeNode extends TreeNode { - /** - * Instantiates a new Layers root model node. - * - * @param element the element - * @param objectId the object id - */ public LayersRootTreeNode(@NotNull final LayersRoot element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.SCENE_16; } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { items.add(new CreateSceneLayerAction(nodeTree, this)); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final LayersRoot element = getElement(); final SceneChangeConsumer changeConsumer = element.getChangeConsumer(); final SceneNode sceneNode = changeConsumer.getCurrentModel(); return sceneNode.getName(); } - @NotNull + @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final LayersRoot element = getElement(); final SceneChangeConsumer changeConsumer = element.getChangeConsumer(); @@ -74,6 +70,7 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return nodeTree instanceof LayerNodeTree; } diff --git a/src/main/java/com/ss/editor/ui/control/layer/node/SceneLayerTreeNode.java b/src/main/java/com/ss/editor/ui/control/layer/node/SceneLayerTreeNode.java index 41abc22c..bcb3a7c7 100644 --- a/src/main/java/com/ss/editor/ui/control/layer/node/SceneLayerTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/layer/node/SceneLayerTreeNode.java @@ -2,6 +2,8 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.scene.SceneLayer; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.editor.ModelChangeConsumer; @@ -36,6 +38,7 @@ public SceneLayerTreeNode(@NotNull final SceneLayer element, final long objectId } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); @@ -48,6 +51,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final } @Override + @FXThread public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { final SceneLayer element = getElement(); @@ -57,11 +61,13 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } @Override + @FXThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final SceneLayer element = getElement(); @@ -81,12 +87,14 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean canAccept(@NotNull final TreeNode child, final boolean isCopy) { final Object element = child.getElement(); return element instanceof Spatial && SceneLayer.getLayer((Spatial) element) != getElement(); } @Override + @FXThread public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final Object object, final boolean isCopy) { @@ -109,27 +117,32 @@ public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final } @Override + @FromAnyThread public @NotNull String getName() { final String name = getElement().getName(); return name == null ? "name is null" : name; } @Override + @FXThread public boolean canEditName() { return !getElement().isBuiltIn(); } @Override + @FXThread public boolean canMove() { return false; } @Override + @FXThread public boolean canCopy() { return false; } @Override + @FXThread public @Nullable Image getIcon() { return Icons.LAYERS_16; } @@ -140,12 +153,14 @@ public boolean isHided() { } @Override + @FXThread public void show(@NotNull final NodeTree nodeTree) { final ChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer()); changeConsumer.execute(new ChangeVisibleSceneLayerOperation(getElement(), true)); } @Override + @FXThread public void hide(@NotNull final NodeTree nodeTree) { final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer()); consumer.execute(new ChangeVisibleSceneLayerOperation(getElement(), false)); diff --git a/src/main/java/com/ss/editor/ui/control/material/property/builder/MaterialSettingsPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/material/property/builder/MaterialSettingsPropertyBuilder.java index dcfbb16c..45bf88c7 100644 --- a/src/main/java/com/ss/editor/ui/control/material/property/builder/MaterialSettingsPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/material/property/builder/MaterialSettingsPropertyBuilder.java @@ -7,6 +7,8 @@ import com.jme3.material.RenderState; import com.jme3.shader.VarType; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.extension.property.EditablePropertyType; import com.ss.editor.extension.property.SimpleProperty; @@ -54,13 +56,21 @@ public class MaterialSettingsPropertyBuilder extends MaterialPropertyBuilder { COLOR_TYPES.add(VarType.Vector4); } + @NotNull private static final PropertyBuilder INSTANCE = new MaterialSettingsPropertyBuilder(); + /** + * Get the single instance. + * + * @return the single instance. + */ + @FromAnyThread public static @NotNull PropertyBuilder getInstance() { return INSTANCE; } @Override + @FXThread protected @Nullable List> getProperties(@NotNull final Object object) { if (!(object instanceof MaterialSettings) || object instanceof RootMaterialSettings) { @@ -120,6 +130,14 @@ public class MaterialSettingsPropertyBuilder extends MaterialPropertyBuilder { .collect(Collectors.toList()); } + /** + * Filter material parameters for the presented object. + * + * @param param the material parameter. + * @param object the presented object. + * @return true of we can show the parameter. + */ + @FXThread private boolean filter(@NotNull final MatParam param, @NotNull final Object object) { if (object instanceof TexturesSettings) { @@ -131,6 +149,15 @@ private boolean filter(@NotNull final MatParam param, @NotNull final Object obje return !TEXTURE_TYPES.contains(param.getVarType()) && !COLOR_TYPES.contains(param.getVarType()); } + /** + * Convert the material parameter to an editable property. + * + * @param param the material parameter. + * @param material the material. + * @param settings the settings. + * @return the editable property or null. + */ + @FXThread private @Nullable EditableProperty convert(@NotNull final MatParam param, @NotNull final Material material, @NotNull final MaterialSettings settings) { diff --git a/src/main/java/com/ss/editor/ui/control/material/tree/factory/MaterialSettingsTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/material/tree/factory/MaterialSettingsTreeNodeFactory.java index efcbd29e..0d2da1c4 100644 --- a/src/main/java/com/ss/editor/ui/control/material/tree/factory/MaterialSettingsTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/material/tree/factory/MaterialSettingsTreeNodeFactory.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.material.tree.factory; import static com.ss.rlib.util.ClassUtils.unsafeCast; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.node.material.*; import com.ss.editor.ui.control.material.tree.node.*; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -14,6 +15,7 @@ */ public class MaterialSettingsTreeNodeFactory implements TreeNodeFactory { + @FXThread @Override public > @Nullable V createFor(@Nullable final T element, final long objectId) { diff --git a/src/main/java/com/ss/editor/ui/control/material/tree/node/ColorsSettingsTreeNode.java b/src/main/java/com/ss/editor/ui/control/material/tree/node/ColorsSettingsTreeNode.java index 507e519d..deec8669 100644 --- a/src/main/java/com/ss/editor/ui/control/material/tree/node/ColorsSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/material/tree/node/ColorsSettingsTreeNode.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.material.tree.node; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.node.material.ColorsSettings; import org.jetbrains.annotations.NotNull; @@ -16,6 +17,7 @@ public ColorsSettingsTreeNode(@NotNull final ColorsSettings element, final long } @Override + @FromAnyThread public @NotNull String getName() { return Messages.MATERIAL_SETTINGS_COLORS; } diff --git a/src/main/java/com/ss/editor/ui/control/material/tree/node/OtherSettingsTreeNode.java b/src/main/java/com/ss/editor/ui/control/material/tree/node/OtherSettingsTreeNode.java index 2ce14cd6..2182499e 100644 --- a/src/main/java/com/ss/editor/ui/control/material/tree/node/OtherSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/material/tree/node/OtherSettingsTreeNode.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.material.tree.node; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.node.material.OtherSettings; import org.jetbrains.annotations.NotNull; @@ -16,6 +17,7 @@ public OtherSettingsTreeNode(@NotNull final OtherSettings element, final long ob } @Override + @FromAnyThread public @NotNull String getName() { return Messages.MATERIAL_SETTINGS_OTHER; } diff --git a/src/main/java/com/ss/editor/ui/control/material/tree/node/RenderSettingsTreeNode.java b/src/main/java/com/ss/editor/ui/control/material/tree/node/RenderSettingsTreeNode.java index e9c118b0..2e57b888 100644 --- a/src/main/java/com/ss/editor/ui/control/material/tree/node/RenderSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/material/tree/node/RenderSettingsTreeNode.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.material.tree.node; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.node.material.RenderSettings; import org.jetbrains.annotations.NotNull; @@ -16,6 +17,7 @@ public RenderSettingsTreeNode(@NotNull final RenderSettings element, final long } @Override + @FromAnyThread public @NotNull String getName() { return Messages.MATERIAL_SETTINGS_RENDER; } diff --git a/src/main/java/com/ss/editor/ui/control/material/tree/node/RootMaterialSettingsTreeNode.java b/src/main/java/com/ss/editor/ui/control/material/tree/node/RootMaterialSettingsTreeNode.java index d7336705..aad400ba 100644 --- a/src/main/java/com/ss/editor/ui/control/material/tree/node/RootMaterialSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/material/tree/node/RootMaterialSettingsTreeNode.java @@ -1,6 +1,8 @@ package com.ss.editor.ui.control.material.tree.node; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.node.material.*; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -20,6 +22,7 @@ public RootMaterialSettingsTreeNode(@NotNull final RootMaterialSettings element, } @Override + @FXThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final RootMaterialSettings settings = getElement(); @@ -34,11 +37,13 @@ public RootMaterialSettingsTreeNode(@NotNull final RootMaterialSettings element, } @Override + @FromAnyThread public @NotNull String getName() { return Messages.MATERIAL_SETTINGS_MAIN; } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } diff --git a/src/main/java/com/ss/editor/ui/control/material/tree/node/TexturesSettingsTreeNode.java b/src/main/java/com/ss/editor/ui/control/material/tree/node/TexturesSettingsTreeNode.java index e0eab9a0..a8afbfa9 100644 --- a/src/main/java/com/ss/editor/ui/control/material/tree/node/TexturesSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/material/tree/node/TexturesSettingsTreeNode.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.material.tree.node; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.node.material.TexturesSettings; import org.jetbrains.annotations.NotNull; @@ -16,6 +17,7 @@ public TexturesSettingsTreeNode(@NotNull final TexturesSettings element, final l } @Override + @FromAnyThread public @NotNull String getName() { return Messages.MATERIAL_SETTINGS_TEXTURES; } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/BufferTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/BufferTreeNode.java index f599ac41..3c9804ec 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/BufferTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/BufferTreeNode.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.control.model.node; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.node.TreeNode; import javafx.scene.image.Image; @@ -15,25 +16,18 @@ */ public class BufferTreeNode extends TreeNode { - /** - * Instantiates a new Buffer model node. - * - * @param element the element - * @param objectId the object id - */ public BufferTreeNode(@NotNull final Buffer element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + public @Nullable Image getIcon() { return Icons.DATA_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return getElement().getClass().getSimpleName(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/PositionTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/PositionTreeNode.java index 6ea8d8d6..a13482cf 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/PositionTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/PositionTreeNode.java @@ -1,6 +1,8 @@ package com.ss.editor.ui.control.model.node; import com.jme3.math.Vector3f; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.node.TreeNode; import javafx.scene.image.Image; @@ -20,34 +22,30 @@ public class PositionTreeNode extends TreeNode { @Nullable private String name; - /** - * Instantiates a new Position model node. - * - * @param element the element - * @param objectId the object id - */ public PositionTreeNode(@NotNull final Vector3f element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.WAY_POINT_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return name == null ? "Point 3D" : name; } @Override + @FXThread public boolean isNeedToSaveName() { return true; } @Override + @FXThread public void setName(@Nullable final String name) { this.name = name; } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/VertexBufferTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/VertexBufferTreeNode.java index 85e534d2..c00ebf01 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/VertexBufferTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/VertexBufferTreeNode.java @@ -2,15 +2,17 @@ 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.ui.Icons; import com.ss.editor.ui.control.model.tree.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 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 java.nio.Buffer; @@ -21,36 +23,31 @@ */ public class VertexBufferTreeNode extends TreeNode { - /** - * Instantiates a new Vertex buffer model node. - * - * @param element the element - * @param objectId the object id - */ public VertexBufferTreeNode(@NotNull final VertexBuffer element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.VERTEX_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_VERTEX_BUFFER + " [" + getElement().getBufferType() + "]"; } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return nodeTree instanceof ModelNodeTree; } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final VertexBuffer vertexBuffer = getElement(); diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/ControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/ControlTreeNode.java index 7641086b..c3c66c3e 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/ControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/ControlTreeNode.java @@ -1,6 +1,8 @@ package com.ss.editor.ui.control.model.node.control; import com.jme3.scene.control.Control; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.Named; import com.ss.editor.extension.scene.control.EditableControl; import com.ss.editor.ui.Icons; @@ -21,41 +23,38 @@ */ public class ControlTreeNode extends TreeNode { - /** - * Instantiates a new Control model node. - * - * @param element the element - * @param objectId the object id - */ public ControlTreeNode(@NotNull final T element, final long objectId) { super(element, objectId); } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { items.add(new RemoveControlAction(nodeTree, this)); super.fillContextMenu(nodeTree, items); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.GEAR_16; } @Override + @FXThread public boolean canCopy() { return true; } @Override + @FXThread public boolean canMove() { return true; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final T element = getElement(); diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/SkeletonControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/SkeletonControlTreeNode.java index 250165c9..3066ea87 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/SkeletonControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/SkeletonControlTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.animation.SkeletonControl; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class SkeletonControlTreeNode extends ControlTreeNode { - /** - * Instantiates a new Skeleton control model node. - * - * @param element the element - * @param objectId the object id - */ public SkeletonControlTreeNode(@NotNull final SkeletonControl element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.SKELETON_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_SKELETON_CONTROL; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationControlTreeNode.java index 259fa305..1b1aeb01 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationControlTreeNode.java @@ -3,6 +3,8 @@ import com.jme3.animation.AnimControl; import com.jme3.animation.LoopMode; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.node.control.ControlTreeNode; import com.ss.editor.ui.control.model.tree.ModelNodeTree; @@ -37,12 +39,6 @@ public class AnimationControlTreeNode extends ControlTreeNode { */ private float speed; - /** - * Instantiates a new Animation control model node. - * - * @param element the element - * @param objectId the object id - */ public AnimationControlTreeNode(@NotNull final AnimControl element, final long objectId) { super(element, objectId); this.loopMode = LoopMode.Loop; @@ -50,6 +46,7 @@ public AnimationControlTreeNode(@NotNull final AnimControl element, final long o } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { items.add(new PlaySettingsAction(nodeTree, this)); @@ -62,6 +59,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, * @param loopMode the loop mode. * @param speed the animation speed. */ + @FXThread public void updateSettings(@NotNull LoopMode loopMode, final float speed) { this.loopMode = loopMode; this.speed = speed; @@ -72,6 +70,7 @@ public void updateSettings(@NotNull LoopMode loopMode, final float speed) { * * @return the animation speed. */ + @FXThread public float getSpeed() { return speed; } @@ -81,31 +80,31 @@ public float getSpeed() { * * @return the loop mode. */ - @NotNull - public LoopMode getLoopMode() { + @FXThread + public @NotNull LoopMode getLoopMode() { return loopMode; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_ANIM_CONTROL; } - @Nullable @Override - public Image getIcon() { + public @Nullable Image getIcon() { return Icons.ANIMATION_16; } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return nodeTree instanceof ModelNodeTree; } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final Array> result = ArrayFactory.newArray(TreeNode.class); @@ -119,6 +118,7 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public void notifyChildPreAdd(@NotNull final TreeNode treeNode) { final AnimationTreeNode animationModelNode = (AnimationTreeNode) treeNode; diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationTrackTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationTrackTreeNode.java index 15880acc..03c128b1 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationTrackTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/anim/AnimationTrackTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.animation.AnimControl; import com.jme3.animation.Track; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,12 +28,6 @@ public abstract class AnimationTrackTreeNode extends TreeNode { */ private int channel; - /** - * Instantiates a new Animation model node. - * - * @param element the element - * @param objectId the object id - */ public AnimationTreeNode(@NotNull final Animation element, final long objectId) { super(element, objectId); this.channel = -1; } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { @@ -93,6 +90,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { final Animation element = getElement(); @@ -101,9 +99,9 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { return tracks != null && tracks.length > 0 && nodeTree instanceof ModelNodeTree; } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final Animation element = getElement(); final Track[] tracks = element.getTracks(); @@ -115,11 +113,13 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean canEditName() { return true; } @Override + @FXThread public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { if (StringUtils.equals(getName(), newName)) return; @@ -138,8 +138,8 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin * * @return the node of an animation control. */ - @Nullable - public AnimationControlTreeNode getControlModelNode() { + @FXThread + public @Nullable AnimationControlTreeNode getControlModelNode() { return controlModelNode; } @@ -148,6 +148,7 @@ public AnimationControlTreeNode getControlModelNode() { * * @param controlModelNode the node of an animation control. */ + @FXThread public void setControlModelNode(@Nullable final AnimationControlTreeNode controlModelNode) { this.controlModelNode = controlModelNode; } @@ -157,8 +158,8 @@ public void setControlModelNode(@Nullable final AnimationControlTreeNode control * * @return the animation control. */ - @Nullable - public AnimControl getControl() { + @FXThread + public @Nullable AnimControl getControl() { return control; } @@ -167,13 +168,14 @@ public AnimControl getControl() { * * @param control the animation control. */ + @FXThread public void setControl(@Nullable final AnimControl control) { this.control = control; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return getElement().getName(); } @@ -182,6 +184,7 @@ public String getName() { * * @return the index of playing animation. */ + @FXThread public int getChannel() { return channel; } @@ -191,6 +194,7 @@ public int getChannel() { * * @param channel the index of playing animation. */ + @FXThread public void setChannel(final int channel) { this.channel = channel; } @@ -200,6 +204,7 @@ public void setChannel(final int channel) { * * @return the speed */ + @FXThread public float getSpeed() { return speed; } @@ -209,18 +214,20 @@ public float getSpeed() { * * @param speed the speed */ + @FXThread public void setSpeed(final float speed) { this.speed = speed; } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { if (getChannel() < 0) return Icons.PLAY_16; return getSpeed() < 0.0001F ? Icons.PAUSE_16 : Icons.STOP_16; } @Override + @FXThread public void notifyChildPreAdd(@NotNull final TreeNode treeNode) { final AnimationTrackTreeNode animationTrackModelNode = (AnimationTrackTreeNode) treeNode; animationTrackModelNode.setControl(getControl()); diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionEventTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionEventTreeNode.java index 1098339f..4a3402ac 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionEventTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionEventTreeNode.java @@ -3,15 +3,17 @@ import com.jme3.cinematic.MotionPath; import com.jme3.cinematic.events.MotionEvent; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.node.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 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; /** * The implementation of the {@link ControlTreeNode} to show a {@link MotionEvent} in the tree. @@ -20,31 +22,25 @@ */ public class MotionEventTreeNode extends ControlTreeNode { - /** - * Instantiates a new Motion event model node. - * - * @param element the element - * @param objectId the object id - */ public MotionEventTreeNode(@NotNull final MotionEvent element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_MOTION_CONTROL; } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.MOTION_16; } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final MotionPath path = getElement().getPath(); final Array> result = ArrayFactory.newArray(TreeNode.class); @@ -54,6 +50,7 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionPathTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionPathTreeNode.java index 332ed6b7..46bbb83c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionPathTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/motion/MotionPathTreeNode.java @@ -3,6 +3,8 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.cinematic.MotionPath; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.node.PositionTreeNode; import com.ss.editor.ui.control.model.tree.ModelNodeTree; @@ -21,31 +23,25 @@ */ public class MotionPathTreeNode extends TreeNode { - /** - * Instantiates a new Motion path model node. - * - * @param element the element - * @param objectId the object id - */ public MotionPathTreeNode(@NotNull final MotionPath element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_MOTION_PATH; } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.PATH_16; } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final MotionPath element = getElement(); final int wayPoints = element.getNbWayPoints(); @@ -62,6 +58,7 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return nodeTree instanceof ModelNodeTree; } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/CharacterControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/CharacterControlTreeNode.java index 116e2c5e..059df6a3 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/CharacterControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/CharacterControlTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.control.CharacterControl; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class CharacterControlTreeNode extends PhysicsObjectTreeNode { - /** - * Instantiates a new Character control model node. - * - * @param element the element - * @param objectId the object id - */ public CharacterControlTreeNode(@NotNull final CharacterControl element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.CHARACTER_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_CHARACTER_CONTROL; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RagdollControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RagdollControlTreeNode.java index b937eab2..7f8a8108 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RagdollControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RagdollControlTreeNode.java @@ -3,6 +3,8 @@ import com.jme3.bullet.control.KinematicRagdollControl; import com.jme3.bullet.control.VehicleControl; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.node.control.ControlTreeNode; import javafx.scene.image.Image; @@ -16,25 +18,19 @@ */ public class RagdollControlTreeNode extends ControlTreeNode { - /** - * Instantiates a new Ragdoll control model node. - * - * @param element the element - * @param objectId the object id - */ public RagdollControlTreeNode(@NotNull final KinematicRagdollControl element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.DOLL_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_RAGDOLL_CONTROL; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RigidBodyControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RigidBodyControlTreeNode.java index f5562024..90d76fc2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RigidBodyControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/RigidBodyControlTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.control.RigidBodyControl; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.control.physics.ReactivatePhysicsControl; import com.ss.editor.ui.control.tree.NodeTree; @@ -18,19 +20,13 @@ */ public class RigidBodyControlTreeNode extends PhysicsObjectTreeNode { - /** - * Instantiates a new Rigid body control model node. - * - * @param element the element - * @param objectId the object id - */ public RigidBodyControlTreeNode(@NotNull final RigidBodyControl element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { final RigidBodyControl element = getElement(); @@ -41,9 +37,9 @@ public Image getIcon() { return Icons.RIGID_BODY_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final RigidBodyControl element = getElement(); @@ -55,6 +51,7 @@ public String getName() { } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleControlTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleControlTreeNode.java index 3ea6d989..554c00c2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleControlTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleControlTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.control.VehicleControl; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.node.control.physics.PhysicsObjectTreeNode; import com.ss.editor.ui.control.model.tree.action.control.physics.vehicle.CreateVehicleWheelAction; @@ -19,29 +21,24 @@ */ public class VehicleControlTreeNode extends PhysicsObjectTreeNode { - /** - * Instantiates a new Vehicle control model node. - * - * @param element the element - * @param objectId the object id - */ public VehicleControlTreeNode(@NotNull final VehicleControl element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.VEHICLE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_VEHICLE_CONTROL; } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { diff --git a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleWheelTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleWheelTreeNode.java index ff89c35a..402d9bb3 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleWheelTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/control/physics/vehicle/VehicleWheelTreeNode.java @@ -3,6 +3,8 @@ import com.jme3.bullet.objects.VehicleWheel; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.control.physics.vehicle.RemoveVehicleWheelAction; import com.ss.editor.ui.control.tree.NodeTree; @@ -20,25 +22,19 @@ */ public class VehicleWheelTreeNode extends TreeNode { - /** - * Instantiates a new Vehicle wheel model node. - * - * @param element the element - * @param objectId the object id - */ public VehicleWheelTreeNode(@NotNull final VehicleWheel element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.WHEEL_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final VehicleWheel element = getElement(); final Spatial wheelSpatial = element.getWheelSpatial(); return wheelSpatial != null ? Messages.MODEL_FILE_EDITOR_NODE_WHEEL + " [" + wheelSpatial.getName() + "]" : @@ -46,6 +42,7 @@ public String getName() { } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); diff --git a/src/main/java/com/ss/editor/ui/control/model/node/light/AmbientLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/light/AmbientLightTreeNode.java index ba97a27f..cd4d0f20 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/light/AmbientLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/light/AmbientLightTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.light.AmbientLight; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import org.jetbrains.annotations.NotNull; @@ -17,25 +19,19 @@ */ public class AmbientLightTreeNode extends LightTreeNode { - /** - * Instantiates a new Ambient light model node. - * - * @param element the element - * @param objectId the object id - */ public AmbientLightTreeNode(@NotNull final AmbientLight element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.AMBIENT_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final AmbientLight element = getElement(); final String name = element.getName(); return StringUtils.isEmpty(name) ? Messages.MODEL_FILE_EDITOR_NODE_AMBIENT_LIGHT : name; diff --git a/src/main/java/com/ss/editor/ui/control/model/node/light/DirectionalLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/light/DirectionalLightTreeNode.java index 6cdeb5a2..2f673f2d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/light/DirectionalLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/light/DirectionalLightTreeNode.java @@ -2,14 +2,14 @@ import com.jme3.light.DirectionalLight; import com.ss.editor.Messages; +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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.image.Image; -import com.ss.rlib.util.StringUtils; - /** * The implementation of {@link LightTreeNode} to present direction lights. * @@ -17,25 +17,19 @@ */ public class DirectionalLightTreeNode extends LightTreeNode { - /** - * Instantiates a new Directional light model node. - * - * @param element the element - * @param objectId the object id - */ public DirectionalLightTreeNode(@NotNull final DirectionalLight element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.SUN_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final DirectionalLight element = getElement(); final String name = element.getName(); return StringUtils.isEmpty(name) ? Messages.MODEL_FILE_EDITOR_NODE_DIRECTION_LIGHT : name; diff --git a/src/main/java/com/ss/editor/ui/control/model/node/light/LightProbeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/light/LightProbeTreeNode.java index a1deb403..297f25c5 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/light/LightProbeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/light/LightProbeTreeNode.java @@ -2,30 +2,24 @@ import com.jme3.light.LightProbe; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; /** - * Реализация узла с цветопробой для PBR. + * The tree node to present {@link LightProbe} * - * @author Ronn + * @author JavaSaBr */ public class LightProbeTreeNode extends TreeNode { - /** - * Instantiates a new Light probe model node. - * - * @param element the element - * @param objectId the object id - */ - public LightProbeTreeNode(final LightProbe element, final long objectId) { + public LightProbeTreeNode(@NotNull final LightProbe element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_LIGHT_PROBE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/light/LightTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/light/LightTreeNode.java index a076478e..8f9f56df 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/light/LightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/light/LightTreeNode.java @@ -1,19 +1,19 @@ package com.ss.editor.ui.control.model.node.light; import com.jme3.light.Light; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.RemoveLightAction; import com.ss.editor.ui.control.model.tree.action.RenameNodeAction; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - +import com.ss.rlib.util.StringUtils; import javafx.collections.ObservableList; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; -import com.ss.rlib.util.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The base implementation of {@link TreeNode} to present lights. @@ -23,42 +23,39 @@ */ public class LightTreeNode extends TreeNode { - /** - * Instantiates a new Light model node. - * - * @param element the element - * @param objectId the object id - */ public LightTreeNode(@NotNull final T element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final T element = getElement(); final String name = element.getName(); return StringUtils.isEmpty(name) ? element.getClass().getSimpleName() : name; } @Override + @FXThread public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { final T element = getElement(); element.setName(newName); } @Override + @FXThread public boolean canEditName() { return true; } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.LIGHT_16; } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { items.add(new RemoveLightAction(nodeTree, this)); items.add(new RenameNodeAction(nodeTree, this)); diff --git a/src/main/java/com/ss/editor/ui/control/model/node/light/PointLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/light/PointLightTreeNode.java index 27e52820..bc5c78b6 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/light/PointLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/light/PointLightTreeNode.java @@ -2,14 +2,14 @@ import com.jme3.light.PointLight; import com.ss.editor.Messages; +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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.image.Image; -import com.ss.rlib.util.StringUtils; - /** * The implementation of {@link LightTreeNode} to present point lights. * @@ -17,25 +17,19 @@ */ public class PointLightTreeNode extends LightTreeNode { - /** - * Instantiates a new Point light model node. - * - * @param element the element - * @param objectId the object id - */ public PointLightTreeNode(@NotNull final PointLight element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.POINT_LIGHT_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final PointLight element = getElement(); final String name = element.getName(); return StringUtils.isEmpty(name) ? Messages.MODEL_FILE_EDITOR_NODE_POINT_LIGHT : name; diff --git a/src/main/java/com/ss/editor/ui/control/model/node/light/SpotLightTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/light/SpotLightTreeNode.java index 2fc43f27..27c15a3e 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/light/SpotLightTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/light/SpotLightTreeNode.java @@ -2,14 +2,14 @@ import com.jme3.light.SpotLight; import com.ss.editor.Messages; +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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.image.Image; -import com.ss.rlib.util.StringUtils; - /** * The implementation of {@link LightTreeNode} to present spot lights. * @@ -17,25 +17,19 @@ */ public class SpotLightTreeNode extends LightTreeNode { - /** - * Instantiates a new Spot light model node. - * - * @param element the element - * @param objectId the object id - */ public SpotLightTreeNode(@NotNull final SpotLight element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.LAMP_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final SpotLight element = getElement(); final String name = element.getName(); return StringUtils.isEmpty(name) ? Messages.MODEL_FILE_EDITOR_NODE_SPOT_LIGHT : name; diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/BoxCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/BoxCollisionShapeTreeNode.java index d47afaee..9107a6ef 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/BoxCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/BoxCollisionShapeTreeNode.java @@ -2,6 +2,7 @@ import com.jme3.bullet.collision.shapes.BoxCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,13 @@ */ public class BoxCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Box collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public BoxCollisionShapeTreeNode(@NotNull final BoxCollisionShape element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_BOX_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CapsuleCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CapsuleCollisionShapeTreeNode.java index 7d158d06..ff272e39 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CapsuleCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CapsuleCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class CapsuleCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Capsule collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public CapsuleCollisionShapeTreeNode(@NotNull final CapsuleCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.CAPSULE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_CAPSULE_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ChildCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ChildCollisionShapeTreeNode.java index 6e925472..4533633e 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ChildCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ChildCollisionShapeTreeNode.java @@ -3,14 +3,16 @@ import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; 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 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; /** * The implementation of the {@link TreeNode} to show a {@link ChildCollisionShape} in the tree. @@ -19,19 +21,13 @@ */ public class ChildCollisionShapeTreeNode extends TreeNode { - /** - * Instantiates a new Child collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public ChildCollisionShapeTreeNode(@NotNull final ChildCollisionShape element, final long objectId) { super(element, objectId); } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final ChildCollisionShape element = getElement(); final CollisionShape shape = element.shape; @@ -43,19 +39,21 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } - @Nullable + @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.NODE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_CHILD_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CollisionShapeTreeNode.java index 05124c64..2e010736 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CollisionShapeTreeNode.java @@ -1,6 +1,8 @@ package com.ss.editor.ui.control.model.node.physics.shape; import com.jme3.bullet.collision.shapes.CollisionShape; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.node.TreeNode; import javafx.scene.image.Image; @@ -15,25 +17,19 @@ */ public class CollisionShapeTreeNode extends TreeNode { - /** - * Instantiates a new Collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public CollisionShapeTreeNode(@NotNull final T element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.GEOMETRY_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final T element = getElement(); return element.getClass().getSimpleName(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ComputedCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ComputedCollisionShapeTreeNode.java index 6d960ec2..447abb9f 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ComputedCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ComputedCollisionShapeTreeNode.java @@ -3,6 +3,8 @@ import com.jme3.bullet.collision.shapes.CompoundCollisionShape; import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -21,19 +23,13 @@ */ public class ComputedCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Computed collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public ComputedCollisionShapeTreeNode(@NotNull final CompoundCollisionShape element, final long objectId) { super(element, objectId); } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final CompoundCollisionShape element = getElement(); final List children = element.getChildren(); @@ -44,19 +40,20 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.ATOM_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_COMPUTED_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ConeCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ConeCollisionShapeTreeNode.java index 7aaaef62..b6654f18 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ConeCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/ConeCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.ConeCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class ConeCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Cone collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public ConeCollisionShapeTreeNode(@NotNull final ConeCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.CONE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_CONE_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CylinderCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CylinderCollisionShapeTreeNode.java index 32195cb6..b0e26ba7 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CylinderCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/CylinderCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.CylinderCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class CylinderCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Cylinder collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public CylinderCollisionShapeTreeNode(@NotNull final CylinderCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.CYLINDER_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_CYLINDER_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/GImpactCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/GImpactCollisionShapeTreeNode.java index 2d681cdf..47bbd0fa 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/GImpactCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/GImpactCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.GImpactCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class GImpactCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new G impact collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public GImpactCollisionShapeTreeNode(@NotNull final GImpactCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.MESH_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_GIMPACT_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HeightFieldCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HeightFieldCollisionShapeTreeNode.java index a15c859f..fbf2d48b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HeightFieldCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HeightFieldCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.HeightfieldCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class HeightFieldCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Height field collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public HeightFieldCollisionShapeTreeNode(@NotNull final HeightfieldCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.TERRAIN_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_HEIGHT_FIELD_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HullCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HullCollisionShapeTreeNode.java index 32e6fff6..d714547d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HullCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/HullCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.HullCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class HullCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Hull collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public HullCollisionShapeTreeNode(@NotNull final HullCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.MESH_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_HULL_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/MeshCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/MeshCollisionShapeTreeNode.java index 575ea715..817b0e21 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/MeshCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/MeshCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.MeshCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class MeshCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Mesh collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public MeshCollisionShapeTreeNode(@NotNull final MeshCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.MESH_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_MESH_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/PlaneCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/PlaneCollisionShapeTreeNode.java index 06906186..2ec8df3f 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/PlaneCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/PlaneCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.PlaneCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class PlaneCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Plane collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public PlaneCollisionShapeTreeNode(@NotNull final PlaneCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.PLANE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PLANE_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/SphereCollisionShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/SphereCollisionShapeTreeNode.java index 7aa41577..e0ac503d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/SphereCollisionShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/physics/shape/SphereCollisionShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.bullet.collision.shapes.SphereCollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class SphereCollisionShapeTreeNode extends CollisionShapeTreeNode { - /** - * Instantiates a new Sphere collision shape model node. - * - * @param element the element - * @param objectId the object id - */ public SphereCollisionShapeTreeNode(@NotNull final SphereCollisionShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.SPHERE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_SPHERE_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/MaterialTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/MaterialTreeNode.java index 0d2d7b11..44a6b74e 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/MaterialTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/MaterialTreeNode.java @@ -5,6 +5,8 @@ import com.jme3.scene.AssetLinkNode; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.MakeAsEmbeddedMaterialAction; import com.ss.editor.ui.control.model.tree.action.SaveAsMaterialAction; @@ -29,16 +31,19 @@ public MaterialTreeNode(@NotNull final Material element, final long objectId) { } @Override + @FXThread public @Nullable Image getIcon() { return Icons.MATERIAL_16; } @Override + @FromAnyThread public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_MATERIAL; } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); @@ -58,11 +63,13 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return false; } @Override + @FXThread public boolean canCopy() { return true; } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/MeshTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/MeshTreeNode.java index 978b1721..d80501fd 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/MeshTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/MeshTreeNode.java @@ -4,6 +4,8 @@ import com.jme3.scene.VertexBuffer; import com.jme3.util.IntMap; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -20,31 +22,25 @@ */ public class MeshTreeNode extends TreeNode { - /** - * Instantiates a new Mesh model node. - * - * @param element the element - * @param objectId the object id - */ public MeshTreeNode(@NotNull final Mesh element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.MESH_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_MESH; } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final Array> result = ArrayFactory.newArray(TreeNode.class); @@ -56,11 +52,13 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } @Override + @FXThread public boolean canCopy() { return true; } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/SpatialTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/SpatialTreeNode.java index f9291949..4d1e8bd8 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/SpatialTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/SpatialTreeNode.java @@ -15,6 +15,8 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; import com.jme3.scene.control.Control; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.control.transform.EditorTransformSupport; import com.ss.editor.extension.scene.InvisibleObject; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -24,7 +26,6 @@ import com.ss.editor.ui.control.model.tree.ModelNodeTree; import com.ss.editor.ui.control.model.tree.action.AddUserDataAction; import com.ss.editor.ui.control.model.tree.action.RemoveNodeAction; -import com.ss.editor.ui.control.model.tree.action.RenameNodeAction; import com.ss.editor.ui.control.model.tree.action.control.CreateCustomControlAction; import com.ss.editor.ui.control.model.tree.action.control.CreateMotionControlAction; import com.ss.editor.ui.control.model.tree.action.control.physics.CreateCharacterControlAction; @@ -54,17 +55,12 @@ */ public class SpatialTreeNode extends TreeNode { - /** - * Instantiates a new Spatial model node. - * - * @param element the element - * @param objectId the object id - */ protected SpatialTreeNode(@NotNull final T element, final long objectId) { super(element, objectId); } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { if (!(nodeTree instanceof ModelNodeTree)) return; @@ -78,7 +74,6 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, if (toolMenu != null) items.add(toolMenu); } - if (canEditName()) items.add(new RenameNodeAction(nodeTree, this)); if (canRemove()) items.add(new RemoveNodeAction(nodeTree, this)); if (linkNode == null) { @@ -89,28 +84,26 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, } @Override + @FXThread public boolean canMove() { return true; } @Override + @FXThread public boolean canCopy() { return true; } @Override + @FXThread public boolean canAccept(@NotNull final TreeNode child, final boolean isCopy) { - final Object element = child.getElement(); - - if (element instanceof AbstractControl) { - return true; - } - - return super.canAccept(child, isCopy); + return element instanceof AbstractControl || super.canAccept(child, isCopy); } @Override + @FXThread public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final Object object, final boolean isCopy) { @@ -134,6 +127,7 @@ public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final } @Override + @FXThread public boolean canRemove() { final Node parent = getElement().getParent(); return parent != null && parent.getUserData(EditorTransformSupport.class.getName()) != Boolean.TRUE; @@ -145,8 +139,8 @@ public boolean canRemove() { * @param nodeTree the node tree * @return the menu */ - @Nullable - protected Menu createCreationMenu(@NotNull final NodeTree nodeTree) { + @FXThread + protected @Nullable Menu createCreationMenu(@NotNull final NodeTree nodeTree) { final T element = getElement(); @@ -189,29 +183,32 @@ protected Menu createCreationMenu(@NotNull final NodeTree nodeTree) { * @param nodeTree the node tree * @return the menu */ - @Nullable - protected Menu createToolMenu(final @NotNull NodeTree nodeTree) { + @FXThread + protected @Nullable Menu createToolMenu(final @NotNull NodeTree nodeTree) { return null; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final String name = getElement().getName(); return name == null ? "name is null" : name; } @Override + @FXThread public boolean canEditName() { return true; } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return nodeTree instanceof ModelNodeTree; } @Override + @FXThread public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { if (StringUtils.equals(getName(), newName)) return; @@ -222,9 +219,9 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin consumer.execute(new RenameNodeOperation(spatial.getName(), newName, spatial)); } - @NotNull @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final Array> result = ArrayFactory.newArray(TreeNode.class); final Spatial element = getElement(); @@ -247,6 +244,7 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public void add(@NotNull final TreeNode child) { super.add(child); @@ -262,6 +260,7 @@ public void add(@NotNull final TreeNode child) { } @Override + @FXThread public void remove(@NotNull final TreeNode child) { super.remove(child); diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/DefaultParticleInfluencerTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/DefaultParticleInfluencerTreeNode.java index 64349947..92542c75 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/DefaultParticleInfluencerTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/DefaultParticleInfluencerTreeNode.java @@ -2,6 +2,7 @@ import com.jme3.effect.influencers.DefaultParticleInfluencer; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,13 @@ */ public class DefaultParticleInfluencerTreeNode extends ParticleInfluencerTreeNode { - /** - * Instantiates a new Default particle influencer model node. - * - * @param element the element - * @param objectId the object id - */ public DefaultParticleInfluencerTreeNode(@NotNull final DefaultParticleInfluencer element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_DEFAULT; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/EmptyParticleInfluencerTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/EmptyParticleInfluencerTreeNode.java index bb5bbb14..083c34c4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/EmptyParticleInfluencerTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/EmptyParticleInfluencerTreeNode.java @@ -2,6 +2,7 @@ import com.jme3.effect.influencers.EmptyParticleInfluencer; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,13 @@ */ public class EmptyParticleInfluencerTreeNode extends ParticleInfluencerTreeNode { - /** - * Instantiates a new Empty particle influencer model node. - * - * @param element the element - * @param objectId the object id - */ public EmptyParticleInfluencerTreeNode(@NotNull final EmptyParticleInfluencer element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_EMPTY; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/ParticleInfluencerTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/ParticleInfluencerTreeNode.java index c9483173..9119aeb9 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/ParticleInfluencerTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/ParticleInfluencerTreeNode.java @@ -1,6 +1,8 @@ package com.ss.editor.ui.control.model.node.spatial.particle.emitter.influencer; import com.jme3.effect.influencers.ParticleInfluencer; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.node.TreeNode; import javafx.scene.image.Image; @@ -14,25 +16,19 @@ */ public class ParticleInfluencerTreeNode extends TreeNode { - /** - * Instantiates a new Particle influencer model node. - * - * @param element the element - * @param objectId the object id - */ public ParticleInfluencerTreeNode(@NotNull final ParticleInfluencer element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.INFLUENCER_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final ParticleInfluencer element = getElement(); return element.getClass().getSimpleName(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/RadialParticleInfluencerTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/RadialParticleInfluencerTreeNode.java index 4862af1d..0f8c8f3f 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/RadialParticleInfluencerTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/influencer/RadialParticleInfluencerTreeNode.java @@ -2,6 +2,7 @@ import com.jme3.effect.influencers.RadialParticleInfluencer; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,13 @@ */ public class RadialParticleInfluencerTreeNode extends ParticleInfluencerTreeNode { - /** - * Instantiates a new Radial particle influencer model node. - * - * @param element the element - * @param objectId the object id - */ public RadialParticleInfluencerTreeNode(@NotNull final RadialParticleInfluencer element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_INFLUENCER_RADIAL; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterBoxShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterBoxShapeTreeNode.java index bbcfe2f3..e0ca5af9 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterBoxShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterBoxShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.effect.shapes.EmitterBoxShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class EmitterBoxShapeTreeNode extends EmitterShapeTreeNode { - /** - * Instantiates a new Emitter box shape model node. - * - * @param element the element - * @param objectId the object id - */ public EmitterBoxShapeTreeNode(@NotNull final EmitterBoxShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.CUBE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_BOX; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshConvexHullShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshConvexHullShapeTreeNode.java index 2bef17c5..c045eccd 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshConvexHullShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshConvexHullShapeTreeNode.java @@ -2,6 +2,7 @@ import com.jme3.effect.shapes.EmitterMeshConvexHullShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,13 @@ */ public class EmitterMeshConvexHullShapeTreeNode extends EmitterShapeTreeNode { - /** - * Instantiates a new Emitter mesh convex hull shape model node. - * - * @param element the element - * @param objectId the object id - */ public EmitterMeshConvexHullShapeTreeNode(@NotNull final EmitterMeshConvexHullShape element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_CONVEX_HULL; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshFaceShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshFaceShapeTreeNode.java index 42030728..6b7dcf8d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshFaceShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshFaceShapeTreeNode.java @@ -2,6 +2,7 @@ import com.jme3.effect.shapes.EmitterMeshFaceShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,13 @@ */ public class EmitterMeshFaceShapeTreeNode extends EmitterShapeTreeNode { - /** - * Instantiates a new Emitter mesh face shape model node. - * - * @param element the element - * @param objectId the object id - */ public EmitterMeshFaceShapeTreeNode(@NotNull final EmitterMeshFaceShape element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_FACE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshVertexShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshVertexShapeTreeNode.java index fef08e51..f09a6265 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshVertexShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterMeshVertexShapeTreeNode.java @@ -2,6 +2,7 @@ import com.jme3.effect.shapes.EmitterMeshVertexShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,13 @@ */ public class EmitterMeshVertexShapeTreeNode extends EmitterShapeTreeNode { - /** - * Instantiates a new Emitter mesh vertex shape model node. - * - * @param element the element - * @param objectId the object id - */ public EmitterMeshVertexShapeTreeNode(@NotNull final EmitterMeshVertexShape element, final long objectId) { super(element, objectId); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_MESH_VERTEX; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterPointShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterPointShapeTreeNode.java index 5b053c9c..f510aba8 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterPointShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterPointShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.effect.shapes.EmitterPointShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class EmitterPointShapeTreeNode extends EmitterShapeTreeNode { - /** - * Instantiates a new Emitter point shape model node. - * - * @param element the element - * @param objectId the object id - */ public EmitterPointShapeTreeNode(@NotNull final EmitterPointShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.POINTS_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_POINT; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterShapeTreeNode.java index 38a41114..7bd82067 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterShapeTreeNode.java @@ -1,6 +1,8 @@ package com.ss.editor.ui.control.model.node.spatial.particle.emitter.shape; import com.jme3.effect.shapes.EmitterShape; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.node.TreeNode; import javafx.scene.image.Image; @@ -14,25 +16,19 @@ */ public class EmitterShapeTreeNode extends TreeNode { - /** - * Instantiates a new Emitter shape model node. - * - * @param element the element - * @param objectId the object id - */ public EmitterShapeTreeNode(@NotNull final EmitterShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.GEOMETRY_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final EmitterShape element = getElement(); return element.getClass().getSimpleName(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterSphereShapeTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterSphereShapeTreeNode.java index 71fa1cc5..dc5a5f47 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterSphereShapeTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/shape/EmitterSphereShapeTreeNode.java @@ -2,6 +2,8 @@ import com.jme3.effect.shapes.EmitterSphereShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -14,25 +16,19 @@ */ public class EmitterSphereShapeTreeNode extends EmitterShapeTreeNode { - /** - * Instantiates a new Emitter sphere shape model node. - * - * @param element the element - * @param objectId the object id - */ public EmitterSphereShapeTreeNode(@NotNull final EmitterSphereShape element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.SPHERE_16; } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { return Messages.MODEL_FILE_EDITOR_NODE_PARTICLE_EMITTER_SHAPE_SPHERE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencerTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencerTreeNode.java index 508756e7..234e5202 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencerTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencerTreeNode.java @@ -1,16 +1,16 @@ package com.ss.editor.ui.control.model.node.spatial.particle.emitter.toneg0d.influencer; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer.RemoveParticleInfluencerAction; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import javafx.collections.ObservableList; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import tonegod.emitter.influencers.ParticleInfluencer; /** @@ -20,31 +20,26 @@ */ public class Toneg0DParticleInfluencerTreeNode extends TreeNode { - /** - * Instantiates a new Particle influencer model node. - * - * @param element the element - * @param objectId the object id - */ public Toneg0DParticleInfluencerTreeNode(@NotNull final ParticleInfluencer element, final long objectId) { super(element, objectId); } - @Nullable @Override - public Image getIcon() { + @FXThread + public @Nullable Image getIcon() { return Icons.INFLUENCER_16; } @Override + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { items.add(new RemoveParticleInfluencerAction(nodeTree, this)); super.fillContextMenu(nodeTree, items); } - @NotNull @Override - public String getName() { + @FromAnyThread + public @NotNull String getName() { final ParticleInfluencer element = getElement(); return element.getName(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencersTreeNode.java b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencersTreeNode.java index e1b7d5ed..b2f4f16c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencersTreeNode.java +++ b/src/main/java/com/ss/editor/ui/control/model/node/spatial/particle/emitter/toneg0d/influencer/Toneg0DParticleInfluencersTreeNode.java @@ -3,6 +3,8 @@ import static com.ss.rlib.util.ClassUtils.getConstructor; import static com.ss.rlib.util.ClassUtils.newInstance; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.node.particles.Toneg0dParticleInfluencers; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.ModelNodeTree; @@ -51,29 +53,24 @@ public class Toneg0DParticleInfluencersTreeNode extends TreeNode nodeTree, @NotNull final ObservableList items) { final Toneg0dParticleInfluencers element = getElement(); @@ -92,9 +89,10 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final super.fillContextMenu(nodeTree, items); } - @NotNull + @Override - public Array> getChildren(@NotNull final NodeTree nodeTree) { + @FXThread + public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final Array> result = ArrayFactory.newArray(TreeNode.class); final Toneg0dParticleInfluencers element = getElement(); final List influencers = element.getInfluencers(); @@ -103,6 +101,7 @@ public Array> getChildren(@NotNull final NodeTree nodeTree) { } @Override + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return nodeTree instanceof ModelNodeTree; } diff --git a/src/main/java/com/ss/editor/ui/control/model/property/ModelPropertyEditor.java b/src/main/java/com/ss/editor/ui/control/model/property/ModelPropertyEditor.java index f12d6497..8ceb8ba7 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/ModelPropertyEditor.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/ModelPropertyEditor.java @@ -4,6 +4,7 @@ import com.jme3.material.Material; import com.jme3.scene.AssetLinkNode; import com.jme3.scene.Spatial; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.node.particles.Toneg0dParticleInfluencers; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.PropertyEditor; @@ -28,6 +29,7 @@ public ModelPropertyEditor(@NotNull final ModelChangeConsumer changeConsumer) { super(changeConsumer); } + @FXThread protected boolean isNeedUpdate(@Nullable final Object object) { final Object currentObject = getCurrentObject(); @@ -40,6 +42,7 @@ protected boolean isNeedUpdate(@Nullable final Object object) { return super.isNeedUpdate(object); } + @FXThread @Override protected boolean canEdit(@NotNull final Object object, @Nullable final Object parent) { diff --git a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/AudioNodePropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/AudioNodePropertyBuilder.java index e4d4163f..68561037 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/AudioNodePropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/AudioNodePropertyBuilder.java @@ -6,6 +6,8 @@ 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.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.builder.impl.AbstractPropertyBuilder; @@ -45,10 +47,11 @@ public class AudioNodePropertyBuilder extends AbstractPropertyBuilder> getProperties(@NotNull final Object object) { if(!(object instanceof EditableControl)) return null; return ((EditableControl) object).getEditableProperties(); diff --git a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EditableModelObjectPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EditableModelObjectPropertyBuilder.java index 7a9bf66f..f48f82ac 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EditableModelObjectPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EditableModelObjectPropertyBuilder.java @@ -4,6 +4,7 @@ import com.jme3.light.PointLight; 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.model.undo.editor.ModelChangeConsumer; @@ -27,6 +28,7 @@ protected EditableModelObjectPropertyBuilder(@NotNull final Class description) { super.buildFor(container, changeConsumer, description); diff --git a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EmitterShapePropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EmitterShapePropertyBuilder.java index 58ef2822..7a689d2b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EmitterShapePropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/EmitterShapePropertyBuilder.java @@ -6,6 +6,8 @@ import com.jme3.effect.shapes.EmitterSphereShape; 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.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.builder.impl.AbstractPropertyBuilder; @@ -27,10 +29,11 @@ public class EmitterShapePropertyBuilder extends AbstractPropertyBuilder> getProperties(final @NotNull Object object) { if(!(object instanceof Material)) return null; @@ -82,6 +86,14 @@ protected MaterialPropertyBuilder() { .collect(toList()); } + /** + * Convert the material parameter to editable property. + * + * @param param the material parameter. + * @param material the material. + * @return the editable property or null. + */ + @FXThread private @Nullable EditableProperty convert(@NotNull final MatParam param, @NotNull final Material material) { @@ -95,28 +107,57 @@ protected MaterialPropertyBuilder() { (object, newValue) -> applyParam(param, object, newValue)); } - protected void applyParam(@NotNull final MatParam param, @NotNull final Material object, - @Nullable final Object newValue) { + /** + * Apply changes for the material parameter. + * + * @param param the parameter. + * @param material the material. + * @param newValue the new value. + */ + @FXThread + protected void applyParam(@NotNull final MatParam param, @NotNull final Material material, + @Nullable final Object newValue) { + if (newValue == null) { - object.clearParam(param.getName()); + material.clearParam(param.getName()); } else { - object.setParam(param.getName(), param.getVarType(), newValue); + material.setParam(param.getName(), param.getVarType(), newValue); } } + /** + * Get relevant value of the material parameter. + * + * @param param the material parameter. + * @param material the 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()); return currentParam == null ? null : currentParam.getValue(); } + /** + * Convert material parameter type to editable property type. + * + * @param varType the material parameter type. + * @return the editable property type or null. + */ + @FXThread protected @Nullable EditablePropertyType convert(@NotNull final VarType varType) { switch (varType) { - case Boolean: return EditablePropertyType.BOOLEAN; - case Float: return EditablePropertyType.FLOAT; - case Int: return EditablePropertyType.INTEGER; - case Vector4: return EditablePropertyType.COLOR; - case Texture2D: return EditablePropertyType.TEXTURE_2D; + case Boolean: + return EditablePropertyType.BOOLEAN; + case Float: + return EditablePropertyType.FLOAT; + case Int: + return EditablePropertyType.INTEGER; + case Vector4: + return EditablePropertyType.COLOR; + case Texture2D: + return EditablePropertyType.TEXTURE_2D; } return null; diff --git a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/MeshPropertyBuilder.java b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/MeshPropertyBuilder.java index cd7af4de..565713d1 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/MeshPropertyBuilder.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/builder/impl/MeshPropertyBuilder.java @@ -2,6 +2,8 @@ import com.jme3.scene.Mesh; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.builder.impl.AbstractPropertyBuilder; @@ -26,10 +28,11 @@ public class MeshPropertyBuilder extends AbstractPropertyBuilder createNodeSelectorDialog() { return new LightSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); } + @FXThread @Override protected void reload() { diff --git a/src/main/java/com/ss/editor/ui/control/model/property/control/LayerModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/model/property/control/LayerModelPropertyControl.java index ffebc187..680ac403 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/control/LayerModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/control/LayerModelPropertyControl.java @@ -3,6 +3,8 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.scene.SceneLayer; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -63,6 +65,7 @@ public LayerModelPropertyControl(@Nullable final SceneLayer layer, @NotNull fina setSyncHandler(this::getLayer); } + @FromAnyThread @Override public @NotNull SixObjectConsumer> newChangeHandler() { return (changeConsumer, object, propName, newValue, oldValue, handler) -> { @@ -84,11 +87,13 @@ private SceneLayer getLayer(@NotNull final Spatial spatial) { return sceneLayer == null ? SceneLayer.NO_LAYER : sceneLayer; } + @FromAnyThread @Override protected boolean isSingleRow() { return true; } + @FXThread @Override protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -119,6 +124,7 @@ private void updateLevel(@Nullable final SceneLayer layer) { return notNull(layerComboBox); } + @FXThread @Override protected void reload() { diff --git a/src/main/java/com/ss/editor/ui/control/model/property/control/NodeElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/model/property/control/NodeElementModelPropertyControl.java index cb3f2889..35a1518c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/control/NodeElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/control/NodeElementModelPropertyControl.java @@ -2,6 +2,7 @@ import com.jme3.scene.Node; import com.jme3.scene.Spatial; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.model.tree.dialog.NodeSelectorDialog; import javafx.scene.control.Label; @@ -27,6 +28,7 @@ protected NodeSelectorDialog createNodeSelectorDialog() { return new NodeSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); } + @FXThread @Override protected void reload() { diff --git a/src/main/java/com/ss/editor/ui/control/model/property/control/PointLightElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/model/property/control/PointLightElementModelPropertyControl.java index 1388317b..cfa7534c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/control/PointLightElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/control/PointLightElementModelPropertyControl.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.model.property.control; import com.jme3.light.PointLight; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.model.tree.dialog.LightSelectorDialog; import com.ss.editor.ui.control.model.tree.dialog.NodeSelectorDialog; @@ -28,6 +29,7 @@ protected NodeSelectorDialog createNodeSelectorDialog() { return new LightSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); } + @FXThread @Override protected void reload() { diff --git a/src/main/java/com/ss/editor/ui/control/model/property/control/SpatialElementModelPropertyControl.java b/src/main/java/com/ss/editor/ui/control/model/property/control/SpatialElementModelPropertyControl.java index 13cadb3a..929f603b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/control/SpatialElementModelPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/control/SpatialElementModelPropertyControl.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.model.property.control; import com.jme3.scene.Spatial; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.model.tree.dialog.NodeSelectorDialog; import com.ss.editor.ui.control.model.tree.dialog.SpatialSelectorDialog; @@ -27,6 +28,7 @@ protected NodeSelectorDialog createNodeSelectorDialog() { return new SpatialSelectorDialog<>(changeConsumer.getCurrentModel(), type, this::processAdd); } + @FXThread @Override protected void reload() { diff --git a/src/main/java/com/ss/editor/ui/control/model/property/control/particle/MaterialEmitterPropertyControl.java b/src/main/java/com/ss/editor/ui/control/model/property/control/particle/MaterialEmitterPropertyControl.java index aceffe56..db236175 100644 --- a/src/main/java/com/ss/editor/ui/control/model/property/control/particle/MaterialEmitterPropertyControl.java +++ b/src/main/java/com/ss/editor/ui/control/model/property/control/particle/MaterialEmitterPropertyControl.java @@ -3,9 +3,10 @@ import static com.ss.editor.util.EditorUtil.getRealFile; import com.jme3.asset.AssetKey; import com.jme3.material.Material; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.property.impl.MaterialPropertyControl; -import com.ss.editor.ui.dialog.asset.ParticlesAssetEditorDialog; +import com.ss.editor.ui.dialog.asset.file.ParticlesAssetEditorDialog; import com.ss.editor.ui.event.impl.RequestedOpenFileEvent; import com.ss.rlib.util.StringUtils; import javafx.scene.control.Label; @@ -34,6 +35,7 @@ public MaterialEmitterPropertyControl(@NotNull final ParticlesMaterial element, /** * Show dialog for choosing another material. */ + @FXThread protected void processChange() { final ParticlesAssetEditorDialog dialog = new ParticlesAssetEditorDialog(this::addMaterial); dialog.setExtensionFilter(MATERIAL_EXTENSIONS); @@ -47,6 +49,7 @@ private void addMaterial(@NotNull final ParticlesMaterial particlesMaterial) { changed(particlesMaterial, getPropertyValue()); } + @FXThread @Override protected void processEdit() { @@ -67,6 +70,7 @@ protected void processEdit() { FX_EVENT_MANAGER.notify(event); } + @FXThread @Override protected void reload() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/AddUserDataAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/AddUserDataAction.java index 0e052508..ed052bd8 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/AddUserDataAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/AddUserDataAction.java @@ -75,11 +75,13 @@ public AddUserDataAction(@NotNull final NodeTree nodeTree, @NotNull final Tre super(nodeTree, node); } + @FXThread @Override protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_USER_DATA; } + @FXThread @Override protected @Nullable Image getIcon() { return Icons.ADD_12; diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateEditableSkyAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateEditableSkyAction.java index c5f80d9d..d5d29085 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateEditableSkyAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateEditableSkyAction.java @@ -15,26 +15,19 @@ */ public class CreateEditableSkyAction extends CreateSkyAction { - /** - * Instantiates a new Create sky action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateEditableSkyAction(final @NotNull NodeTree nodeTree, final @NotNull TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_EDITABLE_SKY; } - @NotNull @Override @FXThread - protected CreateSkyDialog createDialog() { + protected @NotNull CreateSkyDialog createDialog() { return new CreateEditableSkyDialog(getNode(), getNodeTree()); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateNodeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateNodeAction.java index 096f170b..54f735be 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateNodeAction.java @@ -24,30 +24,24 @@ */ public class CreateNodeAction extends AbstractNodeAction { - /** - * Instantiates a new Create node action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateNodeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.NODE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_NODE; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateSkyAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateSkyAction.java index 83fd41ac..df9a03d0 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateSkyAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/CreateSkyAction.java @@ -19,30 +19,24 @@ */ public class CreateSkyAction extends AbstractNodeAction { - /** - * Instantiates a new Create sky action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateSkyAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.SKY_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_SKY; } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -50,9 +44,8 @@ protected void process() { dialog.show(); } - @NotNull @FXThread - protected CreateSkyDialog createDialog() { + protected @NotNull CreateSkyDialog createDialog() { return new CreateSkyDialog(getNode(), getNodeTree()); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/LinkModelAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/LinkModelAction.java index da854897..41096382 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/LinkModelAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/LinkModelAction.java @@ -41,35 +41,31 @@ */ public class LinkModelAction extends AbstractNodeAction { + @NotNull private static final Predicate> ACTION_TESTER = type -> type == NewFileAction.class || type == DeleteFileAction.class || type == RenameFileAction.class; + @NotNull private static final Array MODEL_EXTENSIONS = ArrayFactory.newArray(String.class); static { MODEL_EXTENSIONS.add(FileExtensions.JME_OBJECT); } - /** - * Instantiates a new Link model action. - * - * @param nodeTree the node tree - * @param node the node - */ public LinkModelAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.LINK_FILE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_LINK_MODEL; } @@ -85,6 +81,7 @@ protected void process() { * * @param file the file */ + @FXThread protected void processOpen(@NotNull final Path file) { final NodeTree nodeTree = getNodeTree(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/LoadModelAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/LoadModelAction.java index 57dea7bc..24e9600a 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/LoadModelAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/LoadModelAction.java @@ -38,40 +38,36 @@ */ public class LoadModelAction extends AbstractNodeAction { + @NotNull private static final Predicate> ACTION_TESTER = type -> type == NewFileAction.class || type == DeleteFileAction.class || type == RenameFileAction.class; + @NotNull private static final Array MODEL_EXTENSIONS = ArrayFactory.newArray(String.class); static { MODEL_EXTENSIONS.add(FileExtensions.JME_OBJECT); } - /** - * Instantiates a new Load model action. - * - * @param nodeTree the node tree - * @param node the node - */ public LoadModelAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.OPEN_FILE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_LOAD_MODEL; } - @FXThread @Override + @FXThread protected void process() { super.process(); UIUtils.openFileAssetDialog(this::processOpen, MODEL_EXTENSIONS, ACTION_TESTER); @@ -82,6 +78,7 @@ protected void process() { * * @param file the file */ + @FXThread protected void processOpen(@NotNull final Path file) { final NodeTree nodeTree = getNodeTree(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/MakeAsEmbeddedMaterialAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/MakeAsEmbeddedMaterialAction.java index ed02bf86..b748ef1d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/MakeAsEmbeddedMaterialAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/MakeAsEmbeddedMaterialAction.java @@ -27,11 +27,13 @@ public MakeAsEmbeddedMaterialAction(@NotNull final NodeTree nodeTree, @NotNul } @Override + @FXThread protected @Nullable Image getIcon() { return Icons.INFLUENCER_16; } @Override + @FXThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_MAKE_EMBEDDED; } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/OptimizeGeometryAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/OptimizeGeometryAction.java index 3474334a..6cee5a40 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/OptimizeGeometryAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/OptimizeGeometryAction.java @@ -23,30 +23,24 @@ */ public class OptimizeGeometryAction extends AbstractNodeAction { - /** - * Instantiates a new Optimize geometry action. - * - * @param nodeTree the node tree - * @param node the node - */ public OptimizeGeometryAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.INFLUENCER_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_OPTIMIZE_GEOMETRY; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveControlAction.java index 14f47a57..3da65618 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveControlAction.java @@ -24,30 +24,24 @@ */ public class RemoveControlAction extends AbstractNodeAction { - /** - * Instantiates a new Remove control action. - * - * @param nodeTree the node tree - * @param node the node - */ public RemoveControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.REMOVE_12; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveLightAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveLightAction.java index 67343706..55c6cee8 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveLightAction.java @@ -24,30 +24,24 @@ */ public class RemoveLightAction extends AbstractNodeAction { - /** - * Instantiates a new Remove light action. - * - * @param nodeTree the node tree - * @param node the node - */ public RemoveLightAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.REMOVE_12; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveNodeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveNodeAction.java index 40d2c9e5..f2546ca3 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/RemoveNodeAction.java @@ -11,12 +11,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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.image.Image; - /** * The action to remove a node from model. * @@ -24,30 +22,24 @@ */ public class RemoveNodeAction extends AbstractNodeAction { - /** - * Instantiates a new Remove node action. - * - * @param nodeTree the node tree - * @param node the node - */ public RemoveNodeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.REMOVE_12; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/RenameNodeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/RenameNodeAction.java index b431ae6d..6152b45c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/RenameNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/RenameNodeAction.java @@ -7,12 +7,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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.image.Image; - /** * The action to rename a model node. * @@ -20,30 +18,24 @@ */ public class RenameNodeAction extends AbstractNodeAction { - /** - * Instantiates a new Rename node action. - * - * @param nodeTree the node tree - * @param node the node - */ public RenameNodeAction(@NotNull final NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.EDIT_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_RENAME; } - @FXThread @Override + @FXThread protected void process() { super.process(); final NodeTree nodeTree = getNodeTree(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/SaveAsMaterialAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/SaveAsMaterialAction.java index b016f162..b07d155a 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/SaveAsMaterialAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/SaveAsMaterialAction.java @@ -49,11 +49,13 @@ public SaveAsMaterialAction(@NotNull final NodeTree nodeTree, @NotNull final } @Override + @FXThread protected @Nullable Image getIcon() { return Icons.SAVE_16; } @Override + @FXThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_SAVE_AS; } @@ -70,6 +72,7 @@ protected void process() { * * @param file the file to save */ + @FXThread private void processSave(@NotNull final Path file) { final TreeNode node = getNode(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/TangentGeneratorAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/TangentGeneratorAction.java index 0c880f23..127335eb 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/TangentGeneratorAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/TangentGeneratorAction.java @@ -19,30 +19,24 @@ */ public class TangentGeneratorAction extends AbstractNodeAction { - /** - * Instantiates a new Tangent generator action. - * - * @param nodeTree the node tree - * @param node the node - */ public TangentGeneratorAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_TANGENT_GENERATOR; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.MESH_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); final GenerateTangentsDialog dialog = new GenerateTangentsDialog(getNodeTree(), getNode()); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/ManualExtractSubAnimationAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/ManualExtractSubAnimationAction.java index 7f6dacc5..0dfcde01 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/ManualExtractSubAnimationAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/ManualExtractSubAnimationAction.java @@ -20,30 +20,24 @@ */ public class ManualExtractSubAnimationAction extends AbstractNodeAction { - /** - * Instantiates a new Manual extract sub animation action. - * - * @param nodeTree the node tree - * @param node the node - */ public ManualExtractSubAnimationAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ANIMATION_MANUAL_EXTRAXT_SUB_ANIMATION; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.EXTRACT_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); final NodeTree nodeTree = getNodeTree(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PauseAnimationAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PauseAnimationAction.java index 5d1dfdae..43b67943 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PauseAnimationAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PauseAnimationAction.java @@ -2,12 +2,13 @@ import com.jme3.animation.AnimChannel; import com.jme3.animation.AnimControl; +import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.node.control.anim.AnimationTreeNode; -import com.ss.editor.ui.control.tree.action.AbstractNodeAction; 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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -20,30 +21,25 @@ */ public class PauseAnimationAction extends AbstractNodeAction { - /** - * Instantiates a new Pause animation action. - * - * @param nodeTree the node tree - * @param node the node - */ public PauseAnimationAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull + @Override - protected String getName() { - return "Pause"; //Messages.MODEL_NODE_TREE_ACTION_ANIMATION_STOP; + @FXThread + protected @NotNull String getName() { + return Messages.MODEL_NODE_TREE_ACTION_ANIMATION_PAUSE; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.PAUSE_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlayAnimationAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlayAnimationAction.java index 1c79c416..edb59e44 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlayAnimationAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlayAnimationAction.java @@ -3,12 +3,13 @@ import com.jme3.animation.*; import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.JMEThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.node.control.anim.AnimationControlTreeNode; import com.ss.editor.ui.control.model.node.control.anim.AnimationTreeNode; -import com.ss.editor.ui.control.tree.action.AbstractNodeAction; 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 javafx.scene.image.Image; @@ -22,30 +23,24 @@ */ public class PlayAnimationAction extends AbstractNodeAction implements AnimEventListener { - /** - * Instantiates a new Play animation action. - * - * @param nodeTree the node tree - * @param node the node - */ public PlayAnimationAction(final NodeTree nodeTree, final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ANIMATION_PLAY; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.PLAY_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -81,6 +76,7 @@ protected void process() { } @Override + @JMEThread public void onAnimCycleDone(@NotNull final AnimControl control, @NotNull final AnimChannel channel, @NotNull final String animName) { @@ -97,6 +93,7 @@ public void onAnimCycleDone(@NotNull final AnimControl control, @NotNull final A } @Override + @JMEThread public void onAnimChange(@NotNull final AnimControl control, @NotNull final AnimChannel channel, @NotNull final String animName) { } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlaySettingsAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlaySettingsAction.java index ce0eef87..25650df7 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlaySettingsAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/PlaySettingsAction.java @@ -31,30 +31,24 @@ public class PlaySettingsAction extends AbstractNodeAction @NotNull private static final String PROPERTY_SPEED = "speed"; - /** - * Instantiates a new Play settings action. - * - * @param nodeTree the node tree - * @param node the node - */ public PlaySettingsAction(@NotNull final NodeTree nodeTree, @NotNull final AnimationControlTreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ANIMATION_PLAY_SETTINGS; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.SETTINGS_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/RemoveAnimationAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/RemoveAnimationAction.java index 0d0ed469..4b79e75d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/RemoveAnimationAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/RemoveAnimationAction.java @@ -22,30 +22,24 @@ */ public class RemoveAnimationAction extends AbstractNodeAction { - /** - * Instantiates a new Remove animation action. - * - * @param nodeTree the node tree - * @param node the node - */ public RemoveAnimationAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.REMOVE_12; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/StopAnimationAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/StopAnimationAction.java index 4cdf2f91..49826d20 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/StopAnimationAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/animation/StopAnimationAction.java @@ -24,30 +24,24 @@ */ public class StopAnimationAction extends AbstractNodeAction { - /** - * Instantiates a new Stop animation action. - * - * @param nodeTree the node tree - * @param node the node - */ public StopAnimationAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ANIMATION_STOP; } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.STOP_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/CreateAudioNodeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/CreateAudioNodeAction.java index 757c1fab..31606e13 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/CreateAudioNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/CreateAudioNodeAction.java @@ -25,30 +25,24 @@ */ public class CreateAudioNodeAction extends AbstractNodeAction { - /** - * Instantiates a new Create audio node action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateAudioNodeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.AUDIO_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_AUDIO_NODE; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/PlayAudioNodeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/PlayAudioNodeAction.java index a353f7e5..d2ba0377 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/PlayAudioNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/PlayAudioNodeAction.java @@ -8,17 +8,15 @@ import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.Icons; -import com.ss.editor.ui.control.tree.action.AbstractNodeAction; +import com.ss.editor.ui.control.model.node.spatial.AudioTreeNode; 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.editor.ui.control.model.node.spatial.AudioTreeNode; import com.ss.editor.util.AudioNodeUtils; - +import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.image.Image; - /** * The action to play an audio node. * @@ -26,30 +24,24 @@ */ public class PlayAudioNodeAction extends AbstractNodeAction { - /** - * Instantiates a new Play audio node action. - * - * @param nodeTree the node tree - * @param node the node - */ public PlayAudioNodeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.PLAY_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_AUDIO_PLAY; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/StopAudioNodeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/StopAudioNodeAction.java index 3b7f4e30..eb8ab69e 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/StopAudioNodeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/audio/StopAudioNodeAction.java @@ -22,30 +22,25 @@ */ public class StopAudioNodeAction extends AbstractNodeAction { - /** - * Instantiates a new Stop audio node action. - * - * @param nodeTree the node tree - * @param node the node - */ public StopAudioNodeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.STOP_16; } - @NotNull + @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_AUDIO_STOP; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/AbstractCreateControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/AbstractCreateControlAction.java index 4926808f..1cb44983 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/AbstractCreateControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/AbstractCreateControlAction.java @@ -18,18 +18,12 @@ */ public abstract class AbstractCreateControlAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create control action. - * - * @param nodeTree the node tree - * @param node the node - */ public AbstractCreateControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -49,6 +43,6 @@ protected void process() { * @param parent the parent * @return the control */ - @NotNull - protected abstract Control createControl(@NotNull final Spatial parent); + @FXThread + protected abstract @NotNull Control createControl(@NotNull final Spatial parent); } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateCustomControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateCustomControlAction.java index 23fdb845..1cb682e4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateCustomControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateCustomControlAction.java @@ -32,12 +32,14 @@ public CreateCustomControlAction(@NotNull final NodeTree nodeTree, @NotNull f super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.GEAR_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateMotionControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateMotionControlAction.java index 2304d177..a8b2a8ba 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateMotionControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/CreateMotionControlAction.java @@ -7,6 +7,7 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -21,31 +22,25 @@ */ public class CreateMotionControlAction extends AbstractCreateControlAction { - /** - * Instantiates a new Create motion control action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateMotionControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.GEAR_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_CONTROL_NOTION; } - @NotNull @Override - protected Control createControl(@NotNull final Spatial parent) { + @FXThread + protected @NotNull Control createControl(@NotNull final Spatial parent) { final MotionPath motionPath = new MotionPath(); motionPath.addWayPoint(Vector3f.ZERO.clone()); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateCharacterControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateCharacterControlAction.java index 571256dd..3b2248f2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateCharacterControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateCharacterControlAction.java @@ -5,6 +5,7 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.control.AbstractCreateControlAction; import com.ss.editor.ui.control.tree.NodeTree; @@ -20,31 +21,26 @@ */ public class CreateCharacterControlAction extends AbstractCreateControlAction { - /** - * Instantiates a new Create character control action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateCharacterControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CHARACTER_16; } - @NotNull + @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_CONTROL_CHARACTER; } - @NotNull @Override - protected Control createControl(@NotNull final Spatial parent) { + @FXThread + protected @NotNull Control createControl(@NotNull final Spatial parent) { return new CharacterControl(new CapsuleCollisionShape(0.6f, 1.8f), 0.03f); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateKinematicRagdollControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateKinematicRagdollControlAction.java index 6cf15254..75e01604 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateKinematicRagdollControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateKinematicRagdollControlAction.java @@ -4,6 +4,7 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.control.AbstractCreateControlAction; import com.ss.editor.ui.control.tree.NodeTree; @@ -19,32 +20,25 @@ */ public class CreateKinematicRagdollControlAction extends AbstractCreateControlAction { - /** - * Instantiates a new Create kinematic ragdoll control action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateKinematicRagdollControlAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateKinematicRagdollControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable + @FXThread @Override - protected Image getIcon() { + protected @Nullable Image getIcon() { return Icons.ATOM_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_CONTROL_KINEMATIC_RAGDOLL; } - @NotNull @Override - protected Control createControl(@NotNull final Spatial parent) { + @FXThread + protected @NotNull Control createControl(@NotNull final Spatial parent) { return new KinematicRagdollControl(0.5F); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateRigidBodyControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateRigidBodyControlAction.java index af3c8586..0356eab6 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateRigidBodyControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateRigidBodyControlAction.java @@ -3,6 +3,7 @@ import com.jme3.bullet.control.RigidBodyControl; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.control.AbstractCreateControlAction; import com.ss.editor.ui.control.tree.NodeTree; @@ -18,31 +19,25 @@ */ public class CreateRigidBodyControlAction extends AbstractCreateControlAction { - /** - * Instantiates a new Create rigid body control action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateRigidBodyControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.RIGID_BODY_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_CONTROL_RIGID_BODY; } - @NotNull @Override - protected RigidBodyControl createControl(@NotNull final Spatial parent) { + @FXThread + protected @NotNull RigidBodyControl createControl(@NotNull final Spatial parent) { final RigidBodyControl rigidBodyControl = new RigidBodyControl(); rigidBodyControl.setEnabled(false); return rigidBodyControl; diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateStaticRigidBodyControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateStaticRigidBodyControlAction.java index 07b53ed6..215ff33f 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateStaticRigidBodyControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/CreateStaticRigidBodyControlAction.java @@ -3,6 +3,7 @@ import com.jme3.bullet.control.RigidBodyControl; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -17,32 +18,27 @@ */ public class CreateStaticRigidBodyControlAction extends CreateRigidBodyControlAction { - /** - * Instantiates a new Create static rigid body control action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateStaticRigidBodyControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.STATIC_RIGID_BODY_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_CONTROL_STATIC_RIGID_BODY; } - @NotNull + @Override - protected RigidBodyControl createControl(@NotNull final Spatial parent) { + @FXThread + protected @NotNull RigidBodyControl createControl(@NotNull final Spatial parent) { final RigidBodyControl rigidBodyControl = super.createControl(parent); rigidBodyControl.setMass(0F); return rigidBodyControl; diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/ReactivatePhysicsControl.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/ReactivatePhysicsControl.java index fd397193..2f4b6326 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/ReactivatePhysicsControl.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/ReactivatePhysicsControl.java @@ -29,12 +29,14 @@ public ReactivatePhysicsControl(@NotNull final NodeTree nodeTree, @NotNull fi super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.REPLAY_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleControlAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleControlAction.java index 71d00792..fed714f9 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleControlAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleControlAction.java @@ -6,6 +6,7 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.control.AbstractCreateControlAction; import com.ss.editor.ui.control.tree.NodeTree; @@ -21,31 +22,25 @@ */ public class CreateVehicleControlAction extends AbstractCreateControlAction { - /** - * Instantiates a new Create vehicle control action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateVehicleControlAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.VEHICLE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_CONTROL_VEHICLE; } - @NotNull @Override - protected Control createControl(@NotNull final Spatial parent) { + @FXThread + protected @NotNull Control createControl(@NotNull final Spatial parent) { return new VehicleControl(new BoxCollisionShape(new Vector3f(1F, 1F, 1F)), 1F); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleWheelAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleWheelAction.java index be5cf823..e0fb9ad1 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleWheelAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/CreateVehicleWheelAction.java @@ -70,12 +70,14 @@ public CreateVehicleWheelAction(@NotNull final NodeTree nodeTree, @NotNull fi super(nodeTree, node); } + @FXThread @NotNull @Override protected String getName() { return Messages.MODEL_NODE_TREE_ACTION_ADD_WHEEL; } + @FXThread @Nullable @Override protected Image getIcon() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/RemoveVehicleWheelAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/RemoveVehicleWheelAction.java index c503db00..c53596fb 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/RemoveVehicleWheelAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/control/physics/vehicle/RemoveVehicleWheelAction.java @@ -33,12 +33,14 @@ public RemoveVehicleWheelAction(@NotNull final NodeTree nodeTree, @NotNull fi super(nodeTree, node); } + @FXThread @NotNull @Override protected String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } + @FXThread @Nullable @Override protected Image getIcon() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/AbstractCreateGeometryAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/AbstractCreateGeometryAction.java index 33340b3a..512f7a6d 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/AbstractCreateGeometryAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/AbstractCreateGeometryAction.java @@ -22,18 +22,12 @@ */ public abstract class AbstractCreateGeometryAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create geometry action. - * - * @param nodeTree the node tree - * @param node the node - */ public AbstractCreateGeometryAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -61,6 +55,6 @@ protected void process() { * * @return the geometry */ - @NotNull - protected abstract Geometry createGeometry(); + @FXThread + protected abstract @NotNull Geometry createGeometry(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateBoxAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateBoxAction.java index 4e2d62fc..ed670201 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateBoxAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateBoxAction.java @@ -3,6 +3,7 @@ import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -19,31 +20,25 @@ */ public class CreateBoxAction extends AbstractCreateGeometryAction { - /** - * Instantiates a new Create box action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateBoxAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CUBE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_BOX; } - @NotNull @Override - protected Geometry createGeometry() { + @FXThread + protected @NotNull Geometry createGeometry() { return new Geometry("Box", new Box(1, 1, 1)); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateQuadAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateQuadAction.java index beb4d56a..4c55ccc2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateQuadAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateQuadAction.java @@ -3,6 +3,7 @@ import com.jme3.scene.Geometry; import com.jme3.scene.shape.Quad; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -19,31 +20,25 @@ */ public class CreateQuadAction extends AbstractCreateGeometryAction { - /** - * Instantiates a new Create quad action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateQuadAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.PLANE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_QUAD; } - @NotNull @Override - protected Geometry createGeometry() { + @FXThread + protected @NotNull Geometry createGeometry() { return new Geometry("Quad", new Quad(2, 2)); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateSphereAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateSphereAction.java index 6842fb44..04ce67a3 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateSphereAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/CreateSphereAction.java @@ -3,6 +3,7 @@ import com.jme3.scene.Geometry; import com.jme3.scene.shape.Sphere; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -19,31 +20,25 @@ */ public class CreateSphereAction extends AbstractCreateGeometryAction { - /** - * Instantiates a new Create sphere action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateSphereAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.SPHERE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_SPHERE; } - @NotNull @Override - protected Geometry createGeometry() { + @FXThread + protected @NotNull Geometry createGeometry() { return new Geometry("Sphere", new Sphere(30, 30, 1)); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/GenerateLoDAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/GenerateLoDAction.java index 1487d45d..11449c17 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/GenerateLoDAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/geometry/GenerateLoDAction.java @@ -22,30 +22,24 @@ */ public class GenerateLoDAction extends AbstractNodeAction { - /** - * Instantiates a new Generate lo d action. - * - * @param nodeTree the node tree - * @param node the node - */ public GenerateLoDAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.MESH_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_LOD_GENERATOR; } - @FXThread @Override + @FXThread protected void process() { final GeometryTreeNode modelNode = ClassUtils.unsafeCast(getNode()); final Geometry geometry = modelNode.getElement(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/AbstractCreateLightAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/AbstractCreateLightAction.java index ffc0d4e8..1aaafea9 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/AbstractCreateLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/AbstractCreateLightAction.java @@ -20,18 +20,12 @@ */ public abstract class AbstractCreateLightAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create light action. - * - * @param nodeTree the node tree - * @param node the node - */ public AbstractCreateLightAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -50,6 +44,6 @@ protected void process() { * * @return the light */ - @NotNull - protected abstract Light createLight(); + @FXThread + protected abstract @NotNull Light createLight(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateAmbientLightAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateAmbientLightAction.java index d9eecd10..9b9983f4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateAmbientLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateAmbientLightAction.java @@ -3,6 +3,7 @@ import com.jme3.light.AmbientLight; import com.jme3.light.Light; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -19,31 +20,25 @@ */ public class CreateAmbientLightAction extends AbstractCreateLightAction { - /** - * Instantiates a new Create ambient light action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateAmbientLightAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.AMBIENT_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_AMBIENT_LIGHT; } - @NotNull @Override - protected Light createLight() { + @FXThread + protected @NotNull Light createLight() { return new AmbientLight(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateDirectionLightAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateDirectionLightAction.java index 69d34ea0..ffc9453b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateDirectionLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateDirectionLightAction.java @@ -3,6 +3,7 @@ import com.jme3.light.DirectionalLight; import com.jme3.light.Light; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -19,31 +20,25 @@ */ public class CreateDirectionLightAction extends AbstractCreateLightAction { - /** - * Instantiates a new Create direction light action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateDirectionLightAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.SUN_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_DIRECTION_LIGHT; } - @NotNull @Override - protected Light createLight() { + @FXThread + protected @NotNull Light createLight() { return new DirectionalLight(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreatePointLightAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreatePointLightAction.java index 84af5133..ec040b17 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreatePointLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreatePointLightAction.java @@ -3,6 +3,7 @@ import com.jme3.light.Light; import com.jme3.light.PointLight; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -19,31 +20,26 @@ */ public class CreatePointLightAction extends AbstractCreateLightAction { - /** - * Instantiates a new Create point light action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreatePointLightAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.POINT_LIGHT_16; } - @NotNull + @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_POINT_LIGHT; } - @NotNull @Override - protected Light createLight() { + @FXThread + protected @NotNull Light createLight() { return new PointLight(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateSpotLightAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateSpotLightAction.java index 14b6ecac..dca192de 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateSpotLightAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/light/CreateSpotLightAction.java @@ -3,6 +3,7 @@ import com.jme3.light.Light; import com.jme3.light.SpotLight; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -19,31 +20,25 @@ */ public class CreateSpotLightAction extends AbstractCreateLightAction { - /** - * Instantiates a new Create spot light action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateSpotLightAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.LAMP_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_SPOT_LIGHT; } - @NotNull @Override - protected Light createLight() { + @FXThread + protected @NotNull Light createLight() { return new SpotLight(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/operation/AddChildOperation.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/operation/AddChildOperation.java index c79d9734..7154f3e7 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/operation/AddChildOperation.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/operation/AddChildOperation.java @@ -33,22 +33,10 @@ public class AddChildOperation extends AbstractEditorOperation nodeTree, @NotNull super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.EMITTER_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/ResetParticleEmittersAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/ResetParticleEmittersAction.java index 34a483a1..b6b4f5d2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/ResetParticleEmittersAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/ResetParticleEmittersAction.java @@ -32,12 +32,14 @@ public ResetParticleEmittersAction(@NotNull final NodeTree nodeTree, @NotNull super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.REPLAY_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java index 87c3aca4..7bd4bb33 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/AbstractCreateParticleInfluencerAction.java @@ -6,9 +6,9 @@ import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.Icons; -import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.model.tree.action.operation.particle.emitter.ChangeParticleInfluencerOperation; 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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -21,25 +21,19 @@ */ public abstract class AbstractCreateParticleInfluencerAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ public AbstractCreateParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.INFLUENCER_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -58,6 +52,6 @@ protected void process() { * * @return the particle influencer */ - @NotNull - protected abstract ParticleInfluencer createInfluencer(); + @FXThread + protected abstract @NotNull ParticleInfluencer createInfluencer(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateDefaultParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateDefaultParticleInfluencerAction.java index 699c1250..99a7070a 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateDefaultParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateDefaultParticleInfluencerAction.java @@ -3,6 +3,7 @@ import com.jme3.effect.influencers.DefaultParticleInfluencer; import com.jme3.effect.influencers.ParticleInfluencer; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -14,26 +15,19 @@ */ public class CreateDefaultParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create default particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateDefaultParticleInfluencerAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateDefaultParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new DefaultParticleInfluencer(); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_DEFAULT; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateEmptyParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateEmptyParticleInfluencerAction.java index c4cedd79..59973336 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateEmptyParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateEmptyParticleInfluencerAction.java @@ -3,6 +3,7 @@ import com.jme3.effect.influencers.EmptyParticleInfluencer; import com.jme3.effect.influencers.ParticleInfluencer; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -14,26 +15,19 @@ */ public class CreateEmptyParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create empty particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateEmptyParticleInfluencerAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateEmptyParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new EmptyParticleInfluencer(); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_EMPTY; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateRadialParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateRadialParticleInfluencerAction.java index 3984b7ff..8070c157 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateRadialParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/influencer/CreateRadialParticleInfluencerAction.java @@ -4,6 +4,7 @@ import com.jme3.effect.influencers.ParticleInfluencer; import com.jme3.effect.influencers.RadialParticleInfluencer; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -15,26 +16,19 @@ */ public class CreateRadialParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create radial particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateRadialParticleInfluencerAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateRadialParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new RadialParticleInfluencer(); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_INFLUENCER_RADIAL; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/AbstractCreateShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/AbstractCreateShapeEmitterAction.java index 26bb10d2..2f1f0c90 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/AbstractCreateShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/AbstractCreateShapeEmitterAction.java @@ -9,9 +9,9 @@ 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.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.model.tree.action.operation.particle.emitter.ChangeEmitterShapeOperation; 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; @@ -28,20 +28,13 @@ */ public abstract class AbstractCreateShapeEmitterAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ - public AbstractCreateShapeEmitterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public AbstractCreateShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.GEOMETRY_16; } @@ -67,8 +60,8 @@ protected void process() { * * @return the dialog size or null. */ - @Nullable - protected Point getDialogSize() { + @FXThread + protected @Nullable Point getDialogSize() { return null; } @@ -77,14 +70,15 @@ protected Point getDialogSize() { * * @return the dialog title. */ - @NotNull - protected abstract String getDialogTitle(); + @FXThread + protected abstract @NotNull String getDialogTitle(); /** * Handle the result from the dialog. * * @param vars the table with variables. */ + @FXThread private void handleResult(@NotNull final VarTable vars) { final TreeNode treeNode = getNode(); @@ -101,8 +95,8 @@ private void handleResult(@NotNull final VarTable vars) { * * @return the list of definitions. */ - @NotNull - protected abstract Array getPropertyDefinitions(); + @FXThread + protected abstract @NotNull Array getPropertyDefinitions(); /** * Create emitter shape. @@ -110,6 +104,6 @@ private void handleResult(@NotNull final VarTable vars) { * @param vars the table with variables. * @return the emitter shape. */ - @NotNull - protected abstract EmitterShape createEmitterShape(@NotNull final VarTable vars); + @FXThread + protected abstract @NotNull EmitterShape createEmitterShape(@NotNull final VarTable vars); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateBoxShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateBoxShapeEmitterAction.java index e2c67287..12911038 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateBoxShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateBoxShapeEmitterAction.java @@ -6,6 +6,7 @@ import com.jme3.effect.shapes.EmitterShape; import com.jme3.math.Vector3f; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -30,46 +31,40 @@ public class CreateBoxShapeEmitterAction extends AbstractCreateShapeEmitterActio @NotNull private static final String PROPERTY_MAX = "max"; - /** - * Instantiates a new Create box shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateBoxShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CUBE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_BOX_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(VECTOR_3F, Messages.MODEL_PROPERTY_MIN, PROPERTY_MIN, new Vector3f(1F, 1F, 1F))); definitions.add(new PropertyDefinition(VECTOR_3F, Messages.MODEL_PROPERTY_MAX, PROPERTY_MAX, new Vector3f(1F, 1F, 1F))); return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_BOX_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected EmitterShape createEmitterShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull EmitterShape createEmitterShape(@NotNull final VarTable vars) { final Vector3f min = vars.get(PROPERTY_MIN); final Vector3f max = vars.get(PROPERTY_MAX); return new EmitterBoxShape(min, max); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshConvexHullShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshConvexHullShapeEmitterAction.java index 21fbe44d..72f509e9 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshConvexHullShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshConvexHullShapeEmitterAction.java @@ -5,6 +5,7 @@ import com.jme3.effect.shapes.EmitterMeshVertexShape; import com.jme3.scene.Mesh; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -18,26 +19,20 @@ */ public class CreateMeshConvexHullShapeEmitterAction extends CreateMeshVertexShapeEmitterAction { - /** - * Instantiates a new Create mesh convex hull shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateMeshConvexHullShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull + @FXThread @Override - protected EmitterMeshVertexShape createEmitterShape(@NotNull final List meshes) { + protected @NotNull EmitterMeshVertexShape createEmitterShape(@NotNull final List meshes) { return new EmitterMeshConvexHullShape(meshes); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_CONVEX_HULL_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshFaceShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshFaceShapeEmitterAction.java index e00567d4..0056dff9 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshFaceShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshFaceShapeEmitterAction.java @@ -5,6 +5,7 @@ import com.jme3.effect.shapes.EmitterMeshVertexShape; import com.jme3.scene.Mesh; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -18,26 +19,19 @@ */ public class CreateMeshFaceShapeEmitterAction extends CreateMeshVertexShapeEmitterAction { - /** - * Instantiates a new Create mesh face shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateMeshFaceShapeEmitterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateMeshFaceShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected EmitterMeshVertexShape createEmitterShape(@NotNull final List meshes) { + @FXThread + protected @NotNull EmitterMeshVertexShape createEmitterShape(@NotNull final List meshes) { return new EmitterMeshFaceShape(meshes); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_FACE_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java index b441a761..3fa0969b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateMeshVertexShapeEmitterAction.java @@ -8,10 +8,11 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; 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.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; @@ -31,53 +32,46 @@ public class CreateMeshVertexShapeEmitterAction extends AbstractCreateShapeEmitt @NotNull private static final String PROPERTY_GEOMETRY = "geometry"; - /** - * Instantiates a new Create mesh vertex shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateMeshVertexShapeEmitterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateMeshVertexShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.MESH_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_MESH_VERTEX_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(GEOMETRY_FROM_ASSET_FOLDER, Messages.MODEL_PROPERTY_GEOMETRY, PROPERTY_GEOMETRY, null)); return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.ASSET_EDITOR_DIALOG_TITLE; } - @NotNull @Override - protected EmitterShape createEmitterShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull EmitterShape createEmitterShape(@NotNull final VarTable vars) { final Geometry geometry = vars.get(PROPERTY_GEOMETRY); final List meshes = singletonList(geometry.getMesh()); return createEmitterShape(meshes); } - @NotNull - protected EmitterMeshVertexShape createEmitterShape(final List meshes) { + @FXThread + protected @NotNull EmitterMeshVertexShape createEmitterShape(final List meshes) { return new EmitterMeshVertexShape(meshes); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreatePointShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreatePointShapeEmitterAction.java index 6d194d7b..419bc3aa 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreatePointShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreatePointShapeEmitterAction.java @@ -6,10 +6,11 @@ import com.jme3.effect.shapes.EmitterShape; import com.jme3.math.Vector3f; 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.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; @@ -27,46 +28,39 @@ public class CreatePointShapeEmitterAction extends AbstractCreateShapeEmitterAct @NotNull private static final String PROPERTY_POINT = "point"; - /** - * Instantiates a new Create point shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreatePointShapeEmitterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreatePointShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.POINTS_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_POINT_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(VECTOR_3F, Messages.MODEL_PROPERTY_POINT, PROPERTY_POINT, new Vector3f(1F, 1F, 1F))); return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_POINT_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected EmitterShape createEmitterShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull EmitterShape createEmitterShape(@NotNull final VarTable vars) { final Vector3f point = vars.get(PROPERTY_POINT); return new EmitterPointShape(point); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateSphereShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateSphereShapeEmitterAction.java index a9e670be..baf07ad2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateSphereShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/shape/CreateSphereShapeEmitterAction.java @@ -7,10 +7,11 @@ import com.jme3.effect.shapes.EmitterSphereShape; import com.jme3.math.Vector3f; 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.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; @@ -31,47 +32,40 @@ public class CreateSphereShapeEmitterAction extends AbstractCreateShapeEmitterAc @NotNull private static final String PROPERTY_RADIUS = "radius"; - /** - * Instantiates a new Create sphere shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateSphereShapeEmitterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateSphereShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.SPHERE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_SPHERE_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(VECTOR_3F, Messages.MODEL_PROPERTY_CENTER, PROPERTY_CENTER, new Vector3f(1F, 1F, 1F))); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_RADIUS, PROPERTY_RADIUS, 1F)); return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_SPHERE_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected EmitterShape createEmitterShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull EmitterShape createEmitterShape(@NotNull final VarTable vars) { final Vector3f center = vars.get(PROPERTY_CENTER); final float radius = vars.getFloat(PROPERTY_RADIUS); return new EmitterSphereShape(center, radius); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dParticleEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dParticleEmitterAction.java index d4901e45..efb7b007 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dParticleEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dParticleEmitterAction.java @@ -38,12 +38,14 @@ public CreateToneg0dParticleEmitterAction(@NotNull final NodeTree nodeTree, @ super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.EMITTER_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dSoftParticleEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dSoftParticleEmitterAction.java index 52922404..3adf2ba2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dSoftParticleEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/CreateToneg0dSoftParticleEmitterAction.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -26,6 +27,7 @@ public CreateToneg0dSoftParticleEmitterAction(@NotNull final NodeTree nodeTre super(nodeTree, node); } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/AbstractCreateParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/AbstractCreateParticleInfluencerAction.java index a226d917..a5f5c1c9 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/AbstractCreateParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/AbstractCreateParticleInfluencerAction.java @@ -5,9 +5,9 @@ import com.ss.editor.model.node.particles.Toneg0dParticleInfluencers; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.Icons; -import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.model.tree.action.operation.particle.emitter.toneg0d.AddParticleInfluencerOperation; 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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -22,24 +22,19 @@ */ public abstract class AbstractCreateParticleInfluencerAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public AbstractCreateParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public AbstractCreateParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.INFLUENCER_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -59,6 +54,6 @@ protected void process() { * * @return the particle influencer */ - @NotNull - protected abstract ParticleInfluencer createInfluencer(); + @FXThread + protected abstract @NotNull ParticleInfluencer createInfluencer(); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateAlphaParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateAlphaParticleInfluencerAction.java index 43ec16b7..df8d6950 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateAlphaParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateAlphaParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateAlphaParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create alpha particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateAlphaParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateAlphaParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_ALPHA; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new AlphaInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateColorParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateColorParticleInfluencerAction.java index 8a5d6217..bfc2984b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateColorParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateColorParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateColorParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create color particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateColorParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateColorParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_COLOR; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new ColorInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateDestinationParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateDestinationParticleInfluencerAction.java index 9c38a16c..0a3420d7 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateDestinationParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateDestinationParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateDestinationParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create destination particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateDestinationParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateDestinationParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_DESTINATION; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new DestinationInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateGravityParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateGravityParticleInfluencerAction.java index 4ec999ea..3c5104d6 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateGravityParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateGravityParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateGravityParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create gravity particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateGravityParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateGravityParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_GRAVITY; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new GravityInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateImpulseParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateImpulseParticleInfluencerAction.java index d78cbff5..fadb61b2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateImpulseParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateImpulseParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateImpulseParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create impulse particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateImpulseParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateImpulseParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_IMPULSE; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new ImpulseInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreatePhysicsParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreatePhysicsParticleInfluencerAction.java index 6f61c4f3..4f22a9a8 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreatePhysicsParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreatePhysicsParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreatePhysicsParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create physics particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreatePhysicsParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreatePhysicsParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_PHYSICS; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new PhysicsInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRadialVelocityParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRadialVelocityParticleInfluencerAction.java index 69bd69a7..05d95a2e 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRadialVelocityParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRadialVelocityParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateRadialVelocityParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create radial velocity particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateRadialVelocityParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateRadialVelocityParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_RADIAL_VELOCITY; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new RadialVelocityInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRotationParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRotationParticleInfluencerAction.java index 112a78b6..f2c1ea48 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRotationParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateRotationParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateRotationParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create rotation particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateRotationParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateRotationParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_ROTATION; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new RotationInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSizeParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSizeParticleInfluencerAction.java index 77bf7d8e..d6bddb2c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSizeParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSizeParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,21 @@ */ public class CreateSizeParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create size particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateSizeParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + + public CreateSizeParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_SIZE; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new SizeInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSpriteParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSpriteParticleInfluencerAction.java index 74e5ade2..38ff9a22 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSpriteParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/CreateSpriteParticleInfluencerAction.java @@ -1,11 +1,10 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.influerencer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ModelChangeConsumer; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; - import org.jetbrains.annotations.NotNull; - import tonegod.emitter.Messages; import tonegod.emitter.ParticleEmitterNode; import tonegod.emitter.influencers.ParticleInfluencer; @@ -18,25 +17,20 @@ */ public class CreateSpriteParticleInfluencerAction extends AbstractCreateParticleInfluencerAction { - /** - * Instantiates a new Create sprite particle influencer action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateSpriteParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public CreateSpriteParticleInfluencerAction(@NotNull final NodeTree nodeTree, + @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.PARTICLE_INFLUENCER_SPRITE; } - @NotNull @Override - protected ParticleInfluencer createInfluencer() { + @FXThread + protected @NotNull ParticleInfluencer createInfluencer() { return new SpriteInfluencer(); } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/RemoveParticleInfluencerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/RemoveParticleInfluencerAction.java index 1001f025..7ddeb028 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/RemoveParticleInfluencerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/influerencer/RemoveParticleInfluencerAction.java @@ -37,12 +37,14 @@ public RemoveParticleInfluencerAction(@NotNull final NodeTree nodeTree, @NotN super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.REMOVE_12; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/AbstractCreateParticleMeshAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/AbstractCreateParticleMeshAction.java index fc58700a..fba92d34 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/AbstractCreateParticleMeshAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/AbstractCreateParticleMeshAction.java @@ -35,6 +35,7 @@ public abstract class AbstractCreateParticleMeshAction extends AbstractNodeActio super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateImpostorParticleMeshAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateImpostorParticleMeshAction.java index 7dbc2390..66a8e99a 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateImpostorParticleMeshAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateImpostorParticleMeshAction.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.mesh; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -30,12 +31,14 @@ public CreateImpostorParticleMeshAction(@NotNull final NodeTree nodeTree, @No super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.IMPOSTOR_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreatePointParticleMeshAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreatePointParticleMeshAction.java index dc767efc..573b1c23 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreatePointParticleMeshAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreatePointParticleMeshAction.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.mesh; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -30,12 +31,14 @@ public CreatePointParticleMeshAction(@NotNull final NodeTree nodeTree, @NotNu super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.POINTS_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateQuadParticleMeshAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateQuadParticleMeshAction.java index 88678b82..0ae863f4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateQuadParticleMeshAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/CreateQuadParticleMeshAction.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.model.tree.action.particle.emitter.toneg0d.mesh; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -30,12 +31,14 @@ public CreateQuadParticleMeshAction(@NotNull final NodeTree nodeTree, @NotNul super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.QUAD_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/LoadModelParticlesMeshAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/LoadModelParticlesMeshAction.java index a7369e3d..fb637d59 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/LoadModelParticlesMeshAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/mesh/LoadModelParticlesMeshAction.java @@ -61,12 +61,14 @@ public LoadModelParticlesMeshAction(@NotNull final NodeTree nodeTree, @NotNul super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.OPEN_FILE_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/AbstractCreateShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/AbstractCreateShapeEmitterAction.java index 0072fa7e..e81fb91b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/AbstractCreateShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/AbstractCreateShapeEmitterAction.java @@ -8,9 +8,9 @@ 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.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.model.tree.action.operation.particle.emitter.toneg0d.ChangeEmitterMeshOperation; 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; @@ -26,25 +26,18 @@ */ public abstract class AbstractCreateShapeEmitterAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ - public AbstractCreateShapeEmitterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public AbstractCreateShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.GEOMETRY_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); final GenericFactoryDialog dialog = new GenericFactoryDialog(getPropertyDefinitions(), this::handleResult); @@ -57,14 +50,15 @@ protected void process() { * * @return the dialog title. */ - @NotNull - protected abstract String getDialogTitle(); + @FXThread + protected abstract @NotNull String getDialogTitle(); /** * Handle the result from the dialog. * * @param vars the table with variables. */ + @FXThread private void handleResult(@NotNull final VarTable vars) { final TreeNode treeNode = getNode(); @@ -81,8 +75,8 @@ private void handleResult(@NotNull final VarTable vars) { * * @return the list of definitions. */ - @NotNull - protected abstract Array getPropertyDefinitions(); + @FXThread + protected abstract @NotNull Array getPropertyDefinitions(); /** * Create a mesh. @@ -90,6 +84,6 @@ private void handleResult(@NotNull final VarTable vars) { * @param vars the table with variables. * @return the mesh */ - @NotNull - protected abstract Mesh createMesh(@NotNull final VarTable vars); + @FXThread + protected abstract @NotNull Mesh createMesh(@NotNull final VarTable vars); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateBoxShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateBoxShapeEmitterAction.java index 0946e132..ffe1e952 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateBoxShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateBoxShapeEmitterAction.java @@ -5,6 +5,7 @@ import com.jme3.scene.Mesh; import com.jme3.scene.shape.Box; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -27,31 +28,25 @@ public class CreateBoxShapeEmitterAction extends AbstractCreateShapeEmitterActio @NotNull private static final String PROPERTY_SIZE = "size"; - /** - * Instantiates a new Create box shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateBoxShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CUBE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_BOX_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(VECTOR_3F, Messages.MODEL_PROPERTY_SIZE, PROPERTY_SIZE, new Vector3f(1, 1, 1))); @@ -59,15 +54,15 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_BOX_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Mesh createMesh(@NotNull final VarTable vars) { + @FXThread + protected @NotNull Mesh createMesh(@NotNull final VarTable vars) { final Vector3f size = vars.get(PROPERTY_SIZE); return new Box(size.getX(), size.getY(), size.getZ()); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateCylinderShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateCylinderShapeEmitterAction.java index 2c5cf28d..2d331ddd 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateCylinderShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateCylinderShapeEmitterAction.java @@ -5,10 +5,11 @@ import com.jme3.scene.Mesh; import com.jme3.scene.shape.Cylinder; 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.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; @@ -36,31 +37,25 @@ public class CreateCylinderShapeEmitterAction extends AbstractCreateShapeEmitter @NotNull private static final String PROPERTY_HEIGHT = "height"; - /** - * Instantiates a new Create cylinder shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateCylinderShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CYLINDER_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_CYLINDER_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(INTEGER, Messages.MODEL_PROPERTY_AXIS_SAMPLES, PROPERTY_AXIS_SAMPLES, 8)); @@ -71,15 +66,15 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_CYLINDER_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Mesh createMesh(@NotNull final VarTable vars) { + @FXThread + protected @NotNull Mesh createMesh(@NotNull final VarTable vars) { final int axisSamples = vars.getInteger(PROPERTY_AXIS_SAMPLES); final int radialSamples = vars.getInteger(PROPERTY_RADIAL_SAMPLES); final float radius = vars.getFloat(PROPERTY_RADIUS); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateDomeShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateDomeShapeEmitterAction.java index 4770c0b0..19d875ac 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateDomeShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateDomeShapeEmitterAction.java @@ -5,10 +5,11 @@ import com.jme3.scene.Mesh; import com.jme3.scene.shape.Dome; 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.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; @@ -33,31 +34,25 @@ public class CreateDomeShapeEmitterAction extends AbstractCreateShapeEmitterActi @NotNull private static final String PROPERTY_RADIUS = "radius"; - /** - * Instantiates a new Create dome shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateDomeShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.DOME_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_DOME_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(INTEGER, Messages.MODEL_PROPERTY_PLANES, PROPERTY_PLANES, 10)); @@ -67,15 +62,15 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_DOME_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Mesh createMesh(@NotNull final VarTable vars) { + @FXThread + protected @NotNull Mesh createMesh(@NotNull final VarTable vars) { final int planes = vars.getInteger(PROPERTY_PLANES); final int radialSamples = vars.getInteger(PROPERTY_RADIAL_SAMPLES); final float radius = vars.getFloat(PROPERTY_RADIUS); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateQuadShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateQuadShapeEmitterAction.java index 8092e098..c713fd4c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateQuadShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateQuadShapeEmitterAction.java @@ -5,6 +5,7 @@ import com.jme3.scene.Mesh; import com.jme3.scene.shape.Quad; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -33,31 +34,25 @@ public class CreateQuadShapeEmitterAction extends AbstractCreateShapeEmitterActi @NotNull private static final String PROPERTY_FLIP_COORDS = "flipCoords"; - /** - * Instantiates a new Create quad shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateQuadShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.QUAD_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_QUAD_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_WIDTH, PROPERTY_WIDTH, 1F)); @@ -67,15 +62,15 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_QUAD_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Mesh createMesh(@NotNull final VarTable vars) { + @FXThread + protected @NotNull Mesh createMesh(@NotNull final VarTable vars) { final float width = vars.getFloat(PROPERTY_WIDTH); final float height = vars.getFloat(PROPERTY_HEIGHT); final boolean flipCoords = vars.getBoolean(PROPERTY_FLIP_COORDS); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateSphereShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateSphereShapeEmitterAction.java index f0ef38eb..12b92916 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateSphereShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateSphereShapeEmitterAction.java @@ -5,10 +5,11 @@ import com.jme3.scene.Mesh; import com.jme3.scene.shape.Sphere; 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.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; @@ -33,32 +34,25 @@ public class CreateSphereShapeEmitterAction extends AbstractCreateShapeEmitterAc @NotNull private static final String PROPERTY_RADIUS = "radius"; - /** - * Instantiates a new Create sphere shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateSphereShapeEmitterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateSphereShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.SPHERE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_SPHERE_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(INTEGER, Messages.MODEL_PROPERTY_Z_SAMPLES, PROPERTY_Z_SAMPLES, 10)); @@ -68,15 +62,15 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_SPHERE_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Mesh createMesh(@NotNull final VarTable vars) { + @FXThread + protected @NotNull Mesh createMesh(@NotNull final VarTable vars) { final int zSamples = vars.getInteger(PROPERTY_Z_SAMPLES); final int radialSamples = vars.getInteger(PROPERTY_RADIAL_SAMPLES); final float radius = vars.getFloat(PROPERTY_RADIUS); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTorusShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTorusShapeEmitterAction.java index b36c6969..b7de7a10 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTorusShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTorusShapeEmitterAction.java @@ -5,10 +5,11 @@ import com.jme3.scene.Mesh; import com.jme3.scene.shape.Torus; 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.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; @@ -36,31 +37,25 @@ public class CreateTorusShapeEmitterAction extends AbstractCreateShapeEmitterAct @NotNull private static final String PROPERTY_OUTER_RADIUS = "outerRadius"; - /** - * Instantiates a new Create torus shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateTorusShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.TORUS_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_TORUS_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(INTEGER, Messages.MODEL_PROPERTY_CIRCLE_SAMPLES, PROPERTY_CIRCLE_SAMPLES, 10)); @@ -71,15 +66,15 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_TORUS_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Mesh createMesh(@NotNull final VarTable vars) { + @FXThread + protected @NotNull Mesh createMesh(@NotNull final VarTable vars) { final int circleSamples = vars.getInteger(PROPERTY_CIRCLE_SAMPLES); final int radialSamples = vars.getInteger(PROPERTY_RADIAL_SAMPLES); final float innerRadius = vars.getFloat(PROPERTY_INNER_RADIUS); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTriangleShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTriangleShapeEmitterAction.java index 5f40f9bc..8967b5b8 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTriangleShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/CreateTriangleShapeEmitterAction.java @@ -3,10 +3,11 @@ import static com.ss.editor.extension.property.EditablePropertyType.FLOAT; import com.jme3.scene.Mesh; 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.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; @@ -26,31 +27,25 @@ public class CreateTriangleShapeEmitterAction extends AbstractCreateShapeEmitter @NotNull private static final String PROPERTY_SIZE = "size"; - /** - * Instantiates a new Create triangle shape emitter action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateTriangleShapeEmitterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.TRIANGLE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_PARTICLE_EMITTER_TRIANGLE_SHAPE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_SIZE, PROPERTY_SIZE, 1F)); @@ -58,15 +53,15 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_PARTICLE_EMITTER_TRIANGLE_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Mesh createMesh(@NotNull final VarTable vars) { + @FXThread + protected @NotNull Mesh createMesh(@NotNull final VarTable vars) { final float size = vars.getFloat(PROPERTY_SIZE); return new TriangleEmitterShape(size); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/LoadModelShapeEmitterAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/LoadModelShapeEmitterAction.java index 57986cf7..0c1ac344 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/LoadModelShapeEmitterAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/particle/emitter/toneg0d/shape/LoadModelShapeEmitterAction.java @@ -47,6 +47,7 @@ public class LoadModelShapeEmitterAction extends AbstractNodeAction nodeTree, @NotNull super(nodeTree, node); } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/AbstractCreateShapeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/AbstractCreateShapeAction.java index 958a244c..ffaf877f 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/AbstractCreateShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/AbstractCreateShapeAction.java @@ -9,9 +9,9 @@ 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.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.model.tree.action.operation.ChangeCollisionShapeOperation; 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; @@ -26,24 +26,18 @@ */ public abstract class AbstractCreateShapeAction extends AbstractNodeAction { - /** - * Instantiates a new Abstract create shape action. - * - * @param nodeTree the node tree - * @param node the node - */ AbstractCreateShapeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.GEOMETRY_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -60,14 +54,15 @@ protected void process() { * * @return the dialog title. */ - @NotNull - protected abstract String getDialogTitle(); + @FXThread + protected abstract @NotNull String getDialogTitle(); /** * Handle the result from the dialog. * * @param vars the table with variables. */ + @FXThread private void handleResult(@NotNull final VarTable vars) { final TreeNode treeNode = getNode(); @@ -85,8 +80,8 @@ private void handleResult(@NotNull final VarTable vars) { * * @return the list of definitions. */ - @NotNull - protected abstract Array getPropertyDefinitions(); + @FXThread + protected abstract @NotNull Array getPropertyDefinitions(); /** * Create a collision shape. @@ -94,6 +89,6 @@ private void handleResult(@NotNull final VarTable vars) { * @param vars the table with variables. * @return the collision shape */ - @NotNull - protected abstract CollisionShape createShape(@NotNull final VarTable vars); + @FXThread + protected abstract @NotNull CollisionShape createShape(@NotNull final VarTable vars); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateBoxCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateBoxCollisionShapeAction.java index 200a314c..7b6426b0 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateBoxCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateBoxCollisionShapeAction.java @@ -5,6 +5,7 @@ import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.math.Vector3f; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; 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; @@ -23,40 +24,36 @@ public class CreateBoxCollisionShapeAction extends AbstractCreateShapeAction { @NotNull private static final String PROPERTY_HALF_EXTENTS = "halfExtents"; - /** - * Instantiates a new Create box collision shape action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateBoxCollisionShapeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_BOX_COLLISION_SHAPE; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_BOX_COLLISION_SHAPE_DIALOG_TITLE; } - @NotNull + @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(VECTOR_3F, Messages.MODEL_PROPERTY_HALF_EXTENTS, PROPERTY_HALF_EXTENTS, new Vector3f(1, 1, 1))); return definitions; } - @NotNull + @Override - protected CollisionShape createShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) { final Vector3f halfExtents = vars.get(PROPERTY_HALF_EXTENTS); return new BoxCollisionShape(halfExtents); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCapsuleCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCapsuleCollisionShapeAction.java index 0fa8362f..0b49e14b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCapsuleCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCapsuleCollisionShapeAction.java @@ -4,6 +4,7 @@ import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; import com.jme3.bullet.collision.shapes.CollisionShape; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; @@ -28,47 +29,41 @@ public class CreateCapsuleCollisionShapeAction extends AbstractCreateShapeAction @NotNull private static final String PROPERTY_HEIGHT = "height"; - /** - * Instantiates a new Create capsule collision shape action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateCapsuleCollisionShapeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CAPSULE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CAPSULE_COLLISION_SHAPE; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_CAPSULE_COLLISION_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_RADIUS, PROPERTY_RADIUS, 1F)); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_HEIGHT, PROPERTY_HEIGHT, 1F)); return definitions; } - @NotNull @Override - protected CollisionShape createShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) { final float height = vars.getFloat(PROPERTY_HEIGHT); final float radius = vars.getFloat(PROPERTY_RADIUS); return new CapsuleCollisionShape(radius, height); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateConeCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateConeCollisionShapeAction.java index ac7ac104..a232df54 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateConeCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateConeCollisionShapeAction.java @@ -5,10 +5,11 @@ import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.bullet.collision.shapes.ConeCollisionShape; 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.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; @@ -38,38 +39,31 @@ protected enum Axis { @NotNull private static final String PROPERTY_AXIS = "axis"; - /** - * Instantiates a new Create cone collision shape action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateConeCollisionShapeAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateConeCollisionShapeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CONE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CONE_COLLISION_SHAPE; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_CONE_COLLISION_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_RADIUS, PROPERTY_RADIUS, 1F)); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_HEIGHT, PROPERTY_HEIGHT, 1F)); @@ -77,9 +71,9 @@ protected Array getPropertyDefinitions() { return definitions; } - @NotNull @Override - protected CollisionShape createShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) { final float height = vars.getFloat(PROPERTY_HEIGHT); final float radius = vars.getFloat(PROPERTY_RADIUS); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCylinderCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCylinderCollisionShapeAction.java index 678db1c1..14a9876b 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCylinderCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateCylinderCollisionShapeAction.java @@ -6,11 +6,12 @@ import com.jme3.bullet.collision.shapes.CylinderCollisionShape; import com.jme3.math.Vector3f; 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.control.model.tree.action.physics.shape.CreateConeCollisionShapeAction.Axis; 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; @@ -31,47 +32,40 @@ public class CreateCylinderCollisionShapeAction extends AbstractCreateShapeActio @NotNull private static final String PROPERTY_AXIS = "axis"; - /** - * Instantiates a new Create cylinder collision shape action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateCylinderCollisionShapeAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateCylinderCollisionShapeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.CYLINDER_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CYLINDER_COLLISION_SHAPE; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_CYLINDER_COLLISION_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(VECTOR_3F, Messages.MODEL_PROPERTY_HALF_EXTENTS, PROPERTY_HALF_EXTENTS, new Vector3f(1, 1, 1))); definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_AXIS, PROPERTY_AXIS, Axis.X)); return definitions; } - @NotNull @Override - protected CollisionShape createShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) { final Vector3f halfExtents = vars.get(PROPERTY_HALF_EXTENTS); final Axis axis = vars.get(PROPERTY_AXIS); return new CylinderCollisionShape(halfExtents, axis.ordinal()); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateSphereCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateSphereCollisionShapeAction.java index a42ac34d..a661231c 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateSphereCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/CreateSphereCollisionShapeAction.java @@ -4,10 +4,11 @@ import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.bullet.collision.shapes.SphereCollisionShape; 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.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; @@ -25,46 +26,39 @@ public class CreateSphereCollisionShapeAction extends AbstractCreateShapeAction @NotNull private static final String PROPERTY_RADIUS = "radius"; - /** - * Instantiates a new Create sphere collision shape action. - * - * @param nodeTree the node tree - * @param node the node - */ - public CreateSphereCollisionShapeAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public CreateSphereCollisionShapeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.SPHERE_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_SPHERE_COLLISION_SHAPE; } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { return Messages.CREATE_SPHERE_COLLISION_SHAPE_DIALOG_TITLE; } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(FLOAT, Messages.MODEL_PROPERTY_RADIUS, PROPERTY_RADIUS, 1F)); return definitions; } - @NotNull @Override - protected CollisionShape createShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) { final float radius = vars.get(PROPERTY_RADIUS); return new SphereCollisionShape(radius); } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/GenerateCollisionShapeAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/GenerateCollisionShapeAction.java index d7ff70c4..a3d82c8a 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/GenerateCollisionShapeAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/physics/shape/GenerateCollisionShapeAction.java @@ -17,11 +17,11 @@ import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.model.tree.action.operation.ChangeCollisionShapeOperation; 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; @@ -39,24 +39,18 @@ public class GenerateCollisionShapeAction extends AbstractCreateShapeAction { @NotNull private static final Array EMPTY_DEFINITIONS = ArrayFactory.asArray(); - /** - * Instantiates a new Generate collision shape action. - * - * @param nodeTree the node tree - * @param node the node - */ public GenerateCollisionShapeAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.INFLUENCER_16; } - @FXThread @Override + @FXThread protected void process() { super.process(); @@ -97,27 +91,27 @@ protected void process() { changeConsumer.execute(new ChangeCollisionShapeOperation(shape, object.getCollisionShape(), object)); } - @NotNull @Override - protected String getDialogTitle() { + @FXThread + protected @NotNull String getDialogTitle() { throw new RuntimeException(); } - @NotNull @Override - protected Array getPropertyDefinitions() { + @FXThread + protected @NotNull Array getPropertyDefinitions() { return EMPTY_DEFINITIONS; } - @NotNull @Override - protected CollisionShape createShape(@NotNull final VarTable vars) { + @FXThread + protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) { throw new RuntimeException(); } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_GENERATE_COLLISION_SHAPE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/CreateSceneLayerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/CreateSceneLayerAction.java index d16ecc6e..2b3edbe0 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/CreateSceneLayerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/CreateSceneLayerAction.java @@ -2,23 +2,21 @@ import com.ss.editor.Messages; 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.ModelChangeConsumer; import com.ss.editor.model.undo.editor.SceneChangeConsumer; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.layer.LayersRoot; import com.ss.editor.ui.control.layer.node.LayersRootTreeNode; -import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.model.tree.action.operation.scene.AddSceneLayerOperation; 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.editor.extension.scene.SceneLayer; -import com.ss.editor.extension.scene.SceneNode; - +import javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javafx.scene.image.Image; - /** * The action to create a scene layer. * @@ -26,30 +24,24 @@ */ public class CreateSceneLayerAction extends AbstractNodeAction { - /** - * Instantiates a new Create scene layer action. - * - * @param nodeTree the node tree - * @param node the node - */ public CreateSceneLayerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.LAYERS_16; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_CREATE_LAYER; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/RemoveSceneLayerAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/RemoveSceneLayerAction.java index 95935310..f1fe73a4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/RemoveSceneLayerAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/scene/RemoveSceneLayerAction.java @@ -9,9 +9,9 @@ import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.layer.LayersRoot; import com.ss.editor.ui.control.layer.node.SceneLayerTreeNode; -import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.model.tree.action.operation.scene.RemoveSceneLayerOperation; 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 javafx.scene.image.Image; import org.jetbrains.annotations.NotNull; @@ -24,30 +24,24 @@ */ public class RemoveSceneLayerAction extends AbstractNodeAction { - /** - * Instantiates a new Remove scene layer action. - * - * @param nodeTree the node tree - * @param node the node - */ public RemoveSceneLayerAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { super(nodeTree, node); } - @Nullable @Override - protected Image getIcon() { + @FXThread + protected @Nullable Image getIcon() { return Icons.REMOVE_12; } - @NotNull @Override - protected String getName() { + @FXThread + protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } - @FXThread @Override + @FXThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/action/terrain/CreateTerrainAction.java b/src/main/java/com/ss/editor/ui/control/model/tree/action/terrain/CreateTerrainAction.java index 4b82a90b..e44eb1f6 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/action/terrain/CreateTerrainAction.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/action/terrain/CreateTerrainAction.java @@ -29,12 +29,14 @@ public CreateTerrainAction(@NotNull final NodeTree nodeTree, @NotNull final T super(nodeTree, node); } + @FXThread @Nullable @Override protected Image getIcon() { return Icons.TERRAIN_16; } + @FXThread @NotNull @Override protected String getName() { diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/CreateCustomControlDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/CreateCustomControlDialog.java index 78f736ad..0ea94bac 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/CreateCustomControlDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/CreateCustomControlDialog.java @@ -5,6 +5,8 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.scene.control.EditableControl; import com.ss.editor.extension.scene.control.impl.EditableBillboardControl; import com.ss.editor.manager.ClasspathManager; @@ -99,49 +101,44 @@ private static void register(@NotNull final EditableControl editableControl) { @NotNull private final Spatial spatial; - /** - * Instantiates a new Create custom control dialog. - * - * @param changeConsumer the change consumer - * @param spatial the spatial - */ public CreateCustomControlDialog(@NotNull final ModelChangeConsumer changeConsumer, @NotNull final Spatial spatial) { this.changeConsumer = changeConsumer; this.spatial = spatial; } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.CREATE_CUSTOM_CONTROL_DIALOG_TITLE; } /** * @return the check box to chose an option of creating control. */ - @NotNull - private CheckBox getCustomCheckBox() { + @FXThread + private @NotNull CheckBox getCustomCheckBox() { return notNull(customCheckBox); } /** * @return the list of built in controls. */ - @NotNull - private ComboBox getBuiltInBox() { + @FXThread + private @NotNull ComboBox getBuiltInBox() { return notNull(builtInBox); } /** * @return the list of available custom controls.. */ - @NotNull - private ComboBox> getCustomComboBox() { + @FXThread + private @NotNull ComboBox> getCustomComboBox() { return notNull(customComboBox); } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -189,11 +186,13 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @Override + @FXThread protected void processOk() { final CheckBox customCheckBox = getCustomCheckBox(); @@ -221,9 +220,9 @@ protected void processOk() { super.processOk(); } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/GenerateTangentsDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/GenerateTangentsDialog.java index 0ea64e2f..9eec5313 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/GenerateTangentsDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/GenerateTangentsDialog.java @@ -5,6 +5,8 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.tool.TangentGenerator; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.model.tree.action.operation.ChangeMeshOperation; @@ -80,12 +82,6 @@ public enum AlgorithmType { @Nullable private CheckBox splitMirroredCheckBox; - /** - * Instantiates a new Generate tangents dialog. - * - * @param nodeTree the node tree - * @param node the node - */ public GenerateTangentsDialog(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { this.nodeTree = nodeTree; this.node = node; @@ -96,8 +92,8 @@ public GenerateTangentsDialog(@NotNull final NodeTree nodeTree, @NotNull fina * * @return the node tree component. */ - @NotNull - protected NodeTree getNodeTree() { + @FXThread + protected @NotNull NodeTree getNodeTree() { return nodeTree; } @@ -106,18 +102,19 @@ protected NodeTree getNodeTree() { * * @return the generated node. */ - @NotNull - protected TreeNode getNode() { + @FXThread + protected @NotNull TreeNode getNode() { return node; } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.GENERATE_TANGENTS_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -147,6 +144,7 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @@ -154,20 +152,21 @@ protected boolean isGridStructure() { /** * @return the check box about spliting mirrored. */ - @NotNull - private CheckBox getSplitMirroredCheckBox() { + @FXThread + private @NotNull CheckBox getSplitMirroredCheckBox() { return notNull(splitMirroredCheckBox); } /** * @return the list of types. */ - @NotNull - private ComboBox getAlgorithmTypeComboBox() { + @FXThread + private @NotNull ComboBox getAlgorithmTypeComboBox() { return notNull(algorithmTypeComboBox); } @Override + @FXThread protected void processOk() { final NodeTree nodeTree = getNodeTree(); @@ -193,15 +192,15 @@ protected void processOk() { super.processOk(); } - @NotNull @Override - protected String getButtonOkText() { + @FromAnyThread + protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_GENERATE; } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/LightSelectorDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/LightSelectorDialog.java index 7b545c58..6246b31a 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/LightSelectorDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/LightSelectorDialog.java @@ -3,6 +3,7 @@ import com.jme3.light.Light; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -15,21 +16,14 @@ */ public class LightSelectorDialog extends NodeSelectorDialog { - /** - * Instantiates a new Light selector dialog. - * - * @param model the model - * @param type the type - * @param handler the handler - */ public LightSelectorDialog(@NotNull final Spatial model, @NotNull final Class type, @NotNull final Consumer handler) { super(model, type, handler); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.LIGHT_SELECTOR_DIALOG_TITLE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/NodeSelectorDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/NodeSelectorDialog.java index 4328301c..22a2de74 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/NodeSelectorDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/NodeSelectorDialog.java @@ -3,6 +3,8 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.control.model.tree.ModelNodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.css.CSSClasses; @@ -57,13 +59,6 @@ public class NodeSelectorDialog extends AbstractSimpleEditorDialog { @Nullable private T selected; - /** - * Instantiates a new Node selector dialog. - * - * @param model the model - * @param type the type - * @param handler the handler - */ public NodeSelectorDialog(@NotNull final Spatial model, @NotNull final Class type, @NotNull final Consumer handler) { this.model = model; @@ -82,18 +77,19 @@ public NodeSelectorDialog(@NotNull final Spatial model, @NotNull final Class * * @return the model tree component. */ - @NotNull - protected ModelNodeTree getNodeTree() { + @FXThread + protected @NotNull ModelNodeTree getNodeTree() { return notNull(nodeTree); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.NODE_SELECTOR_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -107,6 +103,7 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @@ -116,8 +113,8 @@ protected boolean isGridStructure() { * * @return the loaded model. */ - @NotNull - protected Spatial getModel() { + @FXThread + protected @NotNull Spatial getModel() { return model; } @@ -126,14 +123,15 @@ protected Spatial getModel() { * * @return the type of selectable objects. */ - @NotNull - protected Class getType() { + @FXThread + protected @NotNull Class getType() { return type; } /** * Handle a selected object. */ + @FXThread private void processSelect(@Nullable final Object object) { final Object result = object instanceof TreeNode ? ((TreeNode) object).getElement() : object; final Class type = getType(); @@ -143,20 +141,21 @@ private void processSelect(@Nullable final Object object) { } @Override + @FXThread protected void processOk() { handler.accept(selected); super.processOk(); } - @NotNull @Override - protected String getButtonOkText() { + @FromAnyThread + protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_SELECT; } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/SpatialSelectorDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/SpatialSelectorDialog.java index 46c4750e..e37d0ea4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/SpatialSelectorDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/SpatialSelectorDialog.java @@ -2,6 +2,7 @@ import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -14,21 +15,14 @@ */ public class SpatialSelectorDialog extends NodeSelectorDialog { - /** - * Instantiates a new spatial selector dialog. - * - * @param model the model - * @param type the type - * @param handler the handler - */ public SpatialSelectorDialog(@NotNull final Spatial model, @NotNull final Class type, @NotNull final Consumer handler) { super(model, type, handler); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.NODE_SELECTOR_DIALOG_TITLE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/animation/ExtractSubAnimationDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/animation/ExtractSubAnimationDialog.java index 9ecbc9f1..90f7f5f4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/animation/ExtractSubAnimationDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/animation/ExtractSubAnimationDialog.java @@ -5,6 +5,9 @@ import com.jme3.animation.AnimControl; import com.jme3.animation.Animation; 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.manager.ExecutorManager; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.model.node.control.anim.AnimationTreeNode; @@ -67,14 +70,7 @@ public class ExtractSubAnimationDialog extends AbstractSimpleEditorDialog { @Nullable private IntegerTextField endFrameField; - /** - * Instantiates a new Extract sub animation dialog. - * - * @param nodeTree the node tree - * @param node the node - */ - public ExtractSubAnimationDialog(@NotNull final NodeTree nodeTree, - @NotNull final AnimationTreeNode node) { + public ExtractSubAnimationDialog(@NotNull final NodeTree nodeTree, @NotNull final AnimationTreeNode node) { this.nodeTree = nodeTree; this.node = node; @@ -99,8 +95,8 @@ public ExtractSubAnimationDialog(@NotNull final NodeTree nodeTree, * * @return the node tree component. */ - @NotNull - protected NodeTree getNodeTree() { + @FXThread + protected @NotNull NodeTree getNodeTree() { return nodeTree; } @@ -109,18 +105,19 @@ protected NodeTree getNodeTree() { * * @return the animation node. */ - @NotNull - protected AnimationTreeNode getNode() { + @FXThread + protected @NotNull AnimationTreeNode getNode() { return node; } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.MANUAL_EXTRACT_ANIMATION_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -154,6 +151,7 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @@ -161,28 +159,29 @@ protected boolean isGridStructure() { /** * @return the field with a value of new animation name. */ - @NotNull - private TextField getNameField() { + @FXThread + private @NotNull TextField getNameField() { return notNull(nameField); } /** * @return the field with a value of start frame. */ - @NotNull - private IntegerTextField getStartFrameField() { + @FXThread + private @NotNull IntegerTextField getStartFrameField() { return notNull(startFrameField); } /** * @return the field with a value of end frame. */ - @NotNull - private IntegerTextField getEndFrameField() { + @FXThread + private @NotNull IntegerTextField getEndFrameField() { return notNull(endFrameField); } @Override + @FXThread protected void processOk() { EditorUtil.incrementLoading(); EXECUTOR_MANAGER.addBackgroundTask(this::processExtract); @@ -192,6 +191,7 @@ protected void processOk() { /** * Process of extraction a sub animation. */ + @BackgroundThread private void processExtract() { final AnimationTreeNode node = getNode(); @@ -218,15 +218,15 @@ private void processExtract() { EXECUTOR_MANAGER.addFXTask(EditorUtil::decrementLoading); } - @NotNull @Override - protected String getButtonOkText() { + @FromAnyThread + protected @NotNull String getButtonOkText() { return Messages.MANUAL_EXTRACT_ANIMATION_DIALOG_BUTTON_OK; } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/GeometrySelectorDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/GeometrySelectorDialog.java index 8ff2bafe..d10c1586 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/GeometrySelectorDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/GeometrySelectorDialog.java @@ -3,6 +3,7 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; import com.ss.editor.Messages; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.ui.control.model.tree.dialog.NodeSelectorDialog; import org.jetbrains.annotations.NotNull; @@ -16,19 +17,13 @@ */ public class GeometrySelectorDialog extends NodeSelectorDialog { - /** - * Instantiates a new Geometry selector dialog. - * - * @param model the model - * @param handler the handler - */ public GeometrySelectorDialog(@NotNull final Spatial model, @NotNull final Consumer handler) { super(model, Geometry.class, handler); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.GEOMETRY_SELECTOR_DIALOG_TITLE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/lod/GenerateLodLevelsDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/lod/GenerateLodLevelsDialog.java index 7882b1ac..c011d3a4 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/lod/GenerateLodLevelsDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/geometry/lod/GenerateLodLevelsDialog.java @@ -7,6 +7,8 @@ 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.manager.ExecutorManager; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.FXConstants; @@ -110,6 +112,7 @@ public GenerateLodLevelsDialog(@NotNull final NodeTree nodeTree, final @NotNu /** * @return the node tree component. */ + @FXThread private @NotNull NodeTree getNodeTree() { return nodeTree; } @@ -119,6 +122,7 @@ public GenerateLodLevelsDialog(@NotNull final NodeTree nodeTree, final @NotNu * * @return the mesh. */ + @FXThread public @NotNull Mesh getMesh() { return mesh; } @@ -126,6 +130,7 @@ public GenerateLodLevelsDialog(@NotNull final NodeTree nodeTree, final @NotNu /** * @return the geometry. */ + @FXThread private @NotNull Geometry getGeometry() { return geometry; } @@ -135,6 +140,7 @@ public GenerateLodLevelsDialog(@NotNull final NodeTree nodeTree, final @NotNu * * @return the reduction method. */ + @FXThread public @NotNull ReductionMethod getMethod() { final ComboBox comboBox = getReductionMethodComboBox(); final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); @@ -144,16 +150,19 @@ public GenerateLodLevelsDialog(@NotNull final NodeTree nodeTree, final @NotNu /** * @return the list view with levels of LoD. */ + @FXThread private @NotNull ListView getLevelsList() { return notNull(levelsList); } @Override + @FromAnyThread protected @NotNull String getTitleText() { return Messages.GENERATE_LOD_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -213,6 +222,7 @@ protected void createContent(@NotNull final VBox root) { /** * Update disabling of OK button. */ + @FXThread private void updateButtonOk() { final ListView levelsList = getLevelsList(); @@ -225,6 +235,7 @@ private void updateButtonOk() { /** * Clear added levels. */ + @FXThread private void clearLevels() { final ListView levelsList = getLevelsList(); final ObservableList items = levelsList.getItems(); @@ -234,6 +245,7 @@ private void clearLevels() { /** * Remove a selected level. */ + @FXThread private void processRemove() { final ListView levelsList = getLevelsList(); @@ -246,6 +258,7 @@ private void processRemove() { /** * Add a new level. */ + @FXThread private void processAdd() { final ListView levelsList = getLevelsList(); @@ -260,17 +273,20 @@ private void processAdd() { } @Override + @FXThread protected void processKey(@NotNull final KeyEvent event) { } /** * @return the list of reduction methods. */ + @FXThread private @NotNull ComboBox getReductionMethodComboBox() { return notNull(reductionMethodComboBox); } @Override + @FXThread protected void processOk() { EditorUtil.incrementLoading(); EXECUTOR_MANAGER.addBackgroundTask(this::processGenerate); @@ -280,6 +296,7 @@ protected void processOk() { /** * Process of generating. */ + @FXThread private void processGenerate() { final Geometry geometry = getGeometry(); @@ -325,11 +342,13 @@ private void processGenerate() { } @Override + @FromAnyThread protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_GENERATE; } @Override + @FromAnyThread protected @NotNull Point getSize() { return DIALOG_SIZE; } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/sky/CreateSkyDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/sky/CreateSkyDialog.java index ff25a2af..04741bc2 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/sky/CreateSkyDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/sky/CreateSkyDialog.java @@ -19,6 +19,8 @@ import com.ss.editor.JFXApplication; 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.extension.util.SSSkyFactory; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -248,18 +250,19 @@ public CreateSkyDialog(@NotNull final TreeNode parentNode, /** * @return the list of sky types. */ - @NotNull - private ComboBox getSkyTypeComboBox() { + @FXThread + private @NotNull ComboBox getSkyTypeComboBox() { return notNull(skyTypeComboBox); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.CREATE_SKY_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -343,6 +346,7 @@ protected void createContent(@NotNull final VBox root) { /** * Create multiple textures settings. */ + @FXThread private void createMultipleTextureSettings() { multipleTextureSettings = new GridPane(); @@ -409,6 +413,7 @@ private void createMultipleTextureSettings() { /** * @return true id need to use SS factory. */ + @FXThread protected boolean isEditableSky() { return false; } @@ -416,6 +421,7 @@ protected boolean isEditableSky() { /** * Create single texture settings. */ + @FXThread private void createSingleTextureSettings() { singleTextureSettings = new GridPane(); @@ -456,30 +462,31 @@ private void createSingleTextureSettings() { /** * @return the settings root. */ - @NotNull - private VBox getSettingsRoot() { + @FXThread + private @NotNull VBox getSettingsRoot() { return notNull(settingsRoot); } /** * @return the container of single texture settings. */ - @NotNull - private GridPane getSingleTextureSettings() { + @FXThread + private @NotNull GridPane getSingleTextureSettings() { return notNull(singleTextureSettings); } /** * @return the container of multiply texture settings. */ - @NotNull - private GridPane getMultipleTextureSettings() { + @FXThread + private @NotNull GridPane getMultipleTextureSettings() { return notNull(multipleTextureSettings); } /** * Handle changing sky type. */ + @FXThread private void processChange(@NotNull final SkyType newValue) { final VBox settingsRoot = getSettingsRoot(); @@ -506,86 +513,87 @@ private void processChange(@NotNull final SkyType newValue) { /** * @return the single texture control. */ - @NotNull - private ChooseTextureControl getSingleTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getSingleTextureControl() { return notNull(singleTextureControl); } /** * @return the list of env types. */ - @NotNull - private ComboBox getEnvMapTypeComboBox() { + @FXThread + private @NotNull ComboBox getEnvMapTypeComboBox() { return notNull(envMapTypeComboBox); } /** * @return the material folder control. */ - @NotNull - private ChooseFolderControl getMaterialFolderControl() { + @FXThread + private @NotNull ChooseFolderControl getMaterialFolderControl() { return notNull(materialFolderControl); } /** * @return the material name field. */ - @NotNull - private TextField getMaterialNameField() { + @FXThread + private @NotNull TextField getMaterialNameField() { return notNull(materialNameField); } /** * @return the top texture control. */ - @NotNull - private ChooseTextureControl getTopTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getTopTextureControl() { return notNull(topTextureControl); } /** * @return the bottom texture control. */ - @NotNull - private ChooseTextureControl getBottomTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getBottomTextureControl() { return notNull(bottomTextureControl); } /** * @return the north texture control. */ - @NotNull - private ChooseTextureControl getNorthTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getNorthTextureControl() { return notNull(northTextureControl); } /** * @return the south texture control. */ - @NotNull - private ChooseTextureControl getSouthTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getSouthTextureControl() { return notNull(southTextureControl); } /** * @return the east texture control. */ - @NotNull - private ChooseTextureControl getEastTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getEastTextureControl() { return notNull(eastTextureControl); } /** * @return the west texture control. */ - @NotNull - private ChooseTextureControl getWestTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getWestTextureControl() { return notNull(westTextureControl); } /** * Validate the dialog. */ + @FXThread private void validate() { if (!isReady()) return; @@ -655,52 +663,53 @@ private void validate() { /** * @return the check box for flipping. */ - @NotNull - private CheckBox getFlipYCheckBox() { + @FXThread + private @NotNull CheckBox getFlipYCheckBox() { return notNull(flipYCheckBox); } /** * @return the scale control for X. */ - @NotNull - private FloatTextField getNormalScaleXField() { + @FXThread + private @NotNull FloatTextField getNormalScaleXField() { return notNull(normalScaleXField); } /** * @return the scale control for Y. */ - @NotNull - private FloatTextField getNormalScaleYField() { + @FXThread + private @NotNull FloatTextField getNormalScaleYField() { return notNull(normalScaleYField); } /** * @return the scale control for Z. */ - @NotNull - private FloatTextField getNormalScaleZField() { + @FXThread + private @NotNull FloatTextField getNormalScaleZField() { return notNull(normalScaleZField); } /** * @return the node tree. */ - @NotNull - private NodeTree getNodeTree() { + @FXThread + private @NotNull NodeTree getNodeTree() { return nodeTree; } /** * @return the parent node. */ - @NotNull - private TreeNode getParentNode() { + @FXThread + private @NotNull TreeNode getParentNode() { return parentNode; } @Override + @FXThread protected void processOk() { EditorUtil.incrementLoading(); @@ -721,6 +730,7 @@ protected void processOk() { /** * The process of creating a new sky. */ + @FXThread private void createSkyInBackground() { final AssetManager assetManager = EDITOR.getAssetManager(); @@ -751,6 +761,7 @@ private void createSkyInBackground() { /** * Create a new sky using multiply textures. */ + @FXThread private void createMultipleTexture(@NotNull final AssetManager assetManager, @NotNull final ChangeConsumer changeConsumer, @NotNull final Vector3f scale) { @@ -805,6 +816,7 @@ private void createMultipleTexture(@NotNull final AssetManager assetManager, /** * Create a new sky using a single texture. */ + @FXThread private void createSingleTexture(@NotNull final AssetManager assetManager, @NotNull final ChangeConsumer changeConsumer, @NotNull final Vector3f scale) { @@ -844,7 +856,7 @@ private void createSingleTexture(@NotNull final AssetManager assetManager, * @param geometry the sky geometry. */ @BackgroundThread - private Material createMaterialFileIfNeed(@NotNull final Geometry geometry) { + private @NotNull Material createMaterialFileIfNeed(@NotNull final Geometry geometry) { final TextField materialNameField = getMaterialNameField(); final ChooseFolderControl materialFolderControl = getMaterialFolderControl(); @@ -868,9 +880,9 @@ private Material createMaterialFileIfNeed(@NotNull final Geometry geometry) { return assetManager.loadMaterial(assetPath); } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/terrain/CreateTerrainDialog.java b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/terrain/CreateTerrainDialog.java index d2e0a9d9..d88cc039 100644 --- a/src/main/java/com/ss/editor/ui/control/model/tree/dialog/terrain/CreateTerrainDialog.java +++ b/src/main/java/com/ss/editor/ui/control/model/tree/dialog/terrain/CreateTerrainDialog.java @@ -22,6 +22,8 @@ import com.ss.editor.JFXApplication; 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.manager.ExecutorManager; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.choose.ChooseFolderControl; @@ -263,12 +265,6 @@ public String toString() { @Nullable private FloatTextField hillMaxRadiusField; - /** - * Instantiates a new Create terrain dialog. - * - * @param parentNode the parent node - * @param nodeTree the node tree - */ public CreateTerrainDialog(@NotNull final TreeNode parentNode, @NotNull final NodeTree nodeTree) { this.parentNode = parentNode; this.nodeTree = nodeTree; @@ -289,6 +285,7 @@ public CreateTerrainDialog(@NotNull final TreeNode parentNode, @NotNull final } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -448,6 +445,7 @@ protected void createContent(@NotNull final VBox root) { /** * Update a list of available path sizes. */ + @FXThread private void updatePathSizeValues() { final ComboBox pathSizeComboBox = getPatchSizeComboBox(); @@ -475,118 +473,119 @@ private void updatePathSizeValues() { /** * @return the total size combo box. */ - @NotNull - private ComboBox getTotalSizeComboBox() { + @FXThread + private @NotNull ComboBox getTotalSizeComboBox() { return notNull(totalSizeComboBox); } /** * @return the patch size combo box. */ - @NotNull - private ComboBox getPatchSizeComboBox() { + @FXThread + private @NotNull ComboBox getPatchSizeComboBox() { return notNull(patchSizeComboBox); } /** * @return the alpha blend texture size combo box. */ - @NotNull - private ComboBox getAlphaBlendTextureSizeComboBox() { + @FXThread + private @NotNull ComboBox getAlphaBlendTextureSizeComboBox() { return notNull(alphaBlendTextureSizeComboBox); } /** * @return the min radius field. */ - @NotNull - private FloatTextField getHillMinRadiusField() { + @FXThread + private @NotNull FloatTextField getHillMinRadiusField() { return notNull(hillMinRadiusField); } /** * @return the max radius field. */ - @NotNull - private FloatTextField getHillMaxRadiusField() { + @FXThread + private @NotNull FloatTextField getHillMaxRadiusField() { return notNull(hillMaxRadiusField); } /** * @return the settingsRoot. */ - @NotNull - private VBox getSettingsRoot() { + @FXThread + private @NotNull VBox getSettingsRoot() { return notNull(settingsRoot); } /** * @return the base texture control. */ - @NotNull - private ChooseTextureControl getBaseTextureControl() { + @FXThread + private @NotNull ChooseTextureControl getBaseTextureControl() { return notNull(baseTextureControl); } /** * @return the base image control. */ - @NotNull - private ChooseTextureControl getHeightMapImageControl() { + @FXThread + private @NotNull ChooseTextureControl getHeightMapImageControl() { return notNull(heightMapImageControl); } /** * @return the type of height map. */ - @NotNull - private ComboBox getHeightMapTypeComboBox() { + @FXThread + private @NotNull ComboBox getHeightMapTypeComboBox() { return notNull(heightMapTypeComboBox); } /** * @return the height map scale field. */ - @NotNull - private FloatTextField getHeightMapScaleField() { + @FXThread + private @NotNull FloatTextField getHeightMapScaleField() { return notNull(heightMapScaleField); } /** * @return the height map smooth field. */ - @NotNull - private FloatTextField getHeightMapSmoothField() { + @FXThread + private @NotNull FloatTextField getHeightMapSmoothField() { return notNull(heightMapSmoothField); } /** * @return the flattening field. */ - @NotNull - private IntegerTextField getHillFlatteningField() { + @FXThread + private @NotNull IntegerTextField getHillFlatteningField() { return notNull(hillFlatteningField); } /** * @return the iterations field. */ - @NotNull - private IntegerTextField getHillIterationsField() { + @FXThread + private @NotNull IntegerTextField getHillIterationsField() { return notNull(hillIterationsField); } /** * @return the alpha texture folder control. */ - @NotNull - private ChooseFolderControl getAlphaTextureFolderControl() { + @FXThread + private @NotNull ChooseFolderControl getAlphaTextureFolderControl() { return notNull(alphaTextureFolderControl); } /** * Handle changing type of heightmap. */ + @FXThread private void processChangeType(@NotNull final HeightMapType newValue) { final VBox root = getSettingsRoot(); @@ -615,6 +614,7 @@ private void processChangeType(@NotNull final HeightMapType newValue) { /** * Validate. */ + @FXThread private void validate() { final FloatTextField hillMaxRadiusField = getHillMaxRadiusField(); @@ -647,6 +647,7 @@ private void validate() { } @Override + @FXThread protected void processOk() { super.processOk(); EditorUtil.incrementLoading(); @@ -813,31 +814,31 @@ private void createTerrainInBackground() throws Exception { changeConsumer.execute(new AddChildOperation(terrainNode, parent)); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.CREATE_TERRAIN_DIALOG_TITLE; } /** * @return the node tree. */ - @NotNull - private NodeTree getNodeTree() { + @FXThread + private @NotNull NodeTree getNodeTree() { return nodeTree; } /** * @return the parent node. */ - @NotNull - private TreeNode getParentNode() { + @FXThread + private @NotNull TreeNode getParentNode() { return parentNode; } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } 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 78f25ac1..f42eea22 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 @@ -4,6 +4,7 @@ import com.ss.editor.Editor; import com.ss.editor.JFXApplication; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.manager.JavaFXImageManager; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -183,8 +184,8 @@ public PropertyControl(@Nullable final T propertyValue, @NotNull final String pr * * @return the six object consumer */ - @NotNull - public SixObjectConsumer<@NotNull C, @NotNull D, @NotNull String, @Nullable T, @Nullable T, @NotNull BiConsumer> newChangeHandler() { + @FromAnyThread + public @NotNull SixObjectConsumer<@NotNull C, @NotNull D, @NotNull String, @Nullable T, @Nullable T, @NotNull BiConsumer> newChangeHandler() { return (changeConsumer, object, propName, newValue, oldValue, handler) -> { final PropertyOperation operation = new PropertyOperation<>(object, propName, newValue, oldValue); @@ -237,6 +238,7 @@ public void setApplyHandler(@NotNull final BiConsumer applyHandler) { * * @return the handler for getting actual value. */ + @FromAnyThread protected @Nullable Function getSyncHandler() { return syncHandler; } @@ -256,6 +258,7 @@ public void setSyncHandler(@Nullable final Function syncHandler) { * * @return the edit object. */ + @FromAnyThread protected @NotNull D getEditObject() { return notNull(editObject); } @@ -265,6 +268,7 @@ public void setSyncHandler(@Nullable final Function syncHandler) { * * @return true if this control has an edit object. */ + @FromAnyThread protected boolean hasEditObject() { return editObject != null; } @@ -272,6 +276,7 @@ protected boolean hasEditObject() { /** * Initializing control. */ + @FXThread protected void reload() { } @@ -303,6 +308,7 @@ public void sync() { /** * Create this control. */ + @FXThread protected void createComponents() { setAlignment(isSingleRow() ? Pos.CENTER_RIGHT : Pos.CENTER); @@ -326,11 +332,39 @@ protected void createComponents() { FXUtils.addToPane(container, this); } + /** + * Get the property name label. + * + * @return the property name label. + */ + @FXThread + protected @NotNull Label getPropertyNameLabel() { + return propertyNameLabel; + } + + /** + * Change control width percent. + * + * @param controlWidthPercent the control width percent. + */ + @FXThread + public void changeControlWidthPercent(final double controlWidthPercent) { + + if (!isSingleRow()) { + return; + } + + final Label propertyNameLabel = getPropertyNameLabel(); + propertyNameLabel.maxWidthProperty().unbind(); + propertyNameLabel.maxWidthProperty().bind(widthProperty().multiply(1D - controlWidthPercent)); + } + /** * Is single row boolean. * * @return true if this control is single row. */ + @FromAnyThread protected boolean isSingleRow() { return false; } @@ -340,6 +374,7 @@ protected boolean isSingleRow() { * * @param container the container */ + @FXThread protected void createComponents(@NotNull final HBox container) { } @@ -348,6 +383,7 @@ protected void createComponents(@NotNull final HBox container) { * * @return the name of the property. */ + @FromAnyThread protected @NotNull String getPropertyName() { return propertyName; } @@ -357,6 +393,7 @@ protected void createComponents(@NotNull final HBox container) { * * @return the consumer of changes. */ + @FromAnyThread protected @NotNull C getChangeConsumer() { return changeConsumer; } @@ -367,6 +404,7 @@ protected void createComponents(@NotNull final HBox container) { * @param newValue the new value * @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()); } @@ -386,6 +424,7 @@ protected void changed(@Nullable final T newValue, @Nullable final T oldValue) { * * @return the handler for handling new value. */ + @FromAnyThread protected @NotNull BiConsumer getApplyHandler() { return notNull(applyHandler); } @@ -395,6 +434,7 @@ protected void changed(@Nullable final T newValue, @Nullable final T oldValue) { * * @param propertyValue the value of the property. */ + @FXThread protected void setPropertyValue(@Nullable final T propertyValue) { this.propertyValue = propertyValue; } @@ -404,6 +444,7 @@ protected void setPropertyValue(@Nullable final T propertyValue) { * * @param ignoreListener the flag for ignoring listeners. */ + @FXThread protected void setIgnoreListener(final boolean ignoreListener) { this.ignoreListener = ignoreListener; } @@ -413,6 +454,7 @@ protected void setIgnoreListener(final boolean ignoreListener) { * * @return true if need to ignore listeners. */ + @FXThread protected boolean isIgnoreListener() { return ignoreListener; } 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 ca05205a..96d7d204 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,6 +1,7 @@ package com.ss.editor.ui.control.property; import static com.ss.rlib.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; @@ -63,6 +64,7 @@ public PropertyEditor(@NotNull final C changeConsumer) { /** * @return The container of controls. */ + @FXThread private @NotNull VBox getContainer() { return notNull(container); } @@ -70,6 +72,7 @@ public PropertyEditor(@NotNull final C changeConsumer) { /** * Create components. */ + @FXThread private void createComponents() { this.container = new VBox(); this.container.prefWidthProperty() @@ -89,6 +92,7 @@ private void createComponents() { * * @param object the object */ + @FXThread public void syncFor(@Nullable final Object object) { if (!isNeedUpdate(object)) return; @@ -106,6 +110,7 @@ public void syncFor(@Nullable final Object object) { /** * Sync all properties with controls. */ + @FXThread public void refresh() { final Object object = getCurrentObject(); @@ -128,6 +133,7 @@ public void refresh() { * @param object the object * @param parent the parent */ + @FXThread public void buildFor(@Nullable final Object object, @Nullable final Object parent) { if (getCurrentObject() == object) return; @@ -152,6 +158,7 @@ public void buildFor(@Nullable final Object object, @Nullable final Object paren * @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) { return true; } @@ -162,6 +169,7 @@ protected boolean canEdit(@NotNull final Object object, @Nullable final Object p * @param object the object * @param parent the parent */ + @FXThread public void rebuildFor(@Nullable final Object object, @Nullable final Object parent) { if (getCurrentObject() != object) return; @@ -177,6 +185,7 @@ public void rebuildFor(@Nullable final Object object, @Nullable final Object par /** * Rebuild this editor. */ + @FXThread public void rebuild() { rebuildFor(getCurrentObject(), null); } @@ -187,6 +196,7 @@ public void rebuild() { * @param object the object * @return the boolean */ + @FXThread protected boolean isNeedUpdate(@Nullable final Object object) { final Object currentObject = getCurrentObject(); if (object instanceof EditableProperty) { @@ -198,6 +208,7 @@ protected boolean isNeedUpdate(@Nullable final Object object) { /** * @param currentObject the current editable object. */ + @FXThread private void setCurrentObject(@Nullable final Object currentObject) { this.currentObject = currentObject; } @@ -207,6 +218,7 @@ private void setCurrentObject(@Nullable final Object currentObject) { * * @return the current editable object. */ + @FXThread protected @Nullable Object getCurrentObject() { return currentObject; } @@ -216,6 +228,7 @@ private void setCurrentObject(@Nullable final Object currentObject) { * * @param currentParent the current parent. */ + @FXThread protected void setCurrentParent(@Nullable final Object currentParent) { this.currentParent = currentParent; } @@ -225,6 +238,7 @@ protected void setCurrentParent(@Nullable final Object currentParent) { * * @return the current parent. */ + @FXThread protected @Nullable Object getCurrentParent() { return currentParent; } 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 new file mode 100644 index 00000000..629865cb --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/builder/PropertyBuilderFilter.java @@ -0,0 +1,23 @@ +package com.ss.editor.ui.control.property.builder; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The interface to filter builder for some objects. + * + * @author JavaSaBr + */ +@FunctionalInterface +public interface PropertyBuilderFilter { + + /** + * Check the property builder and the object. + * + * @param builder the property builder. + * @param object the object. + * @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); +} 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 3dabd246..96900704 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 @@ -1,5 +1,7 @@ package com.ss.editor.ui.control.property.builder; +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.app.state.property.builder.impl.AppStatePropertyBuilder; import com.ss.editor.ui.control.filter.property.builder.impl.FilterPropertyBuilder; @@ -21,15 +23,26 @@ public class PropertyBuilderRegistry { @NotNull private static final PropertyBuilderRegistry INSTANCE = new PropertyBuilderRegistry(); + @FromAnyThread public static @NotNull PropertyBuilderRegistry getInstance() { return INSTANCE; } + /** + * The list of property builders. + */ @NotNull private final Array builders; + /** + * THe list of filters. + */ + @NotNull + private final Array filters; + private PropertyBuilderRegistry() { builders = ArrayFactory.newArray(PropertyBuilder.class); + filters = ArrayFactory.newArray(PropertyBuilderFilter.class); builders.add(AudioNodePropertyBuilder.getInstance()); builders.add(ParticleEmitterPropertyBuilder.getInstance()); builders.add(GeometryPropertyBuilder.getInstance()); @@ -48,15 +61,27 @@ private PropertyBuilderRegistry() { builders.add(Toneg0dParticleInfluencerPropertyBuilder.getInstance()); builders.add(MaterialSettingsPropertyBuilder.getInstance()); } + /** * Register a new property builder. * * @param builder the property builder. */ + @FromAnyThread public void register(@NotNull final PropertyBuilder builder) { builders.add(builder); } + /** + * Register a new property builder filter. + * + * @param filter the property builder filter. + */ + @FromAnyThread + public void register(@NotNull final PropertyBuilderFilter filter) { + filters.add(filter); + } + /** * Build properties controls for the object to the container. * @@ -65,10 +90,25 @@ public void register(@NotNull final PropertyBuilder builder) { * @param container the container for containing these controls. * @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) { for (final PropertyBuilder builder : builders) { + + boolean needSkip = false; + + for (final PropertyBuilderFilter filter : filters) { + if (filter.skip(builder, object, parent)) { + needSkip = true; + break; + } + } + + if (needSkip) { + continue; + } + builder.buildFor(object, parent, container, changeConsumer); } } 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 2e321a4e..b43e2950 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 @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.property.builder.impl; import com.ss.editor.Editor; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.css.CSSClasses; @@ -20,24 +21,23 @@ public abstract class AbstractPropertyBuilder implements PropertyBuilder { /** - * The constant EDITOR. + * The jME part of the editor. */ @NotNull protected static final Editor EDITOR = Editor.getInstance(); + /** + * The type of change consumer, + */ @NotNull private final Class type; - /** - * Instantiates a new Abstract property builder. - * - * @param type the type - */ protected AbstractPropertyBuilder(@NotNull final 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) { @@ -47,15 +47,16 @@ public void buildFor(@NotNull final Object object, @Nullable final Object parent } /** - * Build for. + * Build properties for the object. * - * @param object the object - * @param parent the parent - * @param container the container - * @param changeConsumer the change consumer + * @param object the object. + * @param parent the parent. + * @param container the container. + * @param changeConsumer the change consumer. */ - protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container, - @NotNull final C changeConsumer) { + @FXThread + protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, + @NotNull final VBox container, @NotNull final C changeConsumer) { } /** @@ -63,6 +64,7 @@ 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); 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 428c433c..eac70054 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 @@ -4,7 +4,9 @@ import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; +import com.jme3.math.Vector4f; 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; @@ -32,6 +34,7 @@ protected EditableObjectPropertyBuilder(@NotNull final Class type) } @Override + @FXThread protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container, @NotNull final C changeConsumer) { @@ -43,6 +46,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object } } + @FXThread protected void buildFor(@NotNull final VBox container, @NotNull final C changeConsumer, @NotNull final EditableProperty description) { @@ -80,7 +84,16 @@ protected void buildFor(@NotNull final VBox container, @NotNull final C changeCo case COLOR: { final EditableProperty property = cast(description); - final ColorRGBA color = property.getValue(); + final Object undefine = description.getValue(); + final ColorRGBA color; + + // for some cases with materials + if (undefine instanceof Vector4f) { + final Vector4f vector4f = (Vector4f) undefine; + color = new ColorRGBA(vector4f.getX(), vector4f.getY(), vector4f.getZ(), vector4f.getW()); + } else { + color = (ColorRGBA) undefine; + } final ColorPropertyControl> propertyControl = new ColorPropertyControl<>(color, property.getName(), changeConsumer); @@ -110,6 +123,17 @@ protected void buildFor(@NotNull final VBox container, @NotNull final C changeCo addControl(container, property, propertyControl); break; } + case READ_ONLY_STRING: { + + final EditableProperty property = cast(description); + final Object currentValue = property.getValue(); + + final DefaultSinglePropertyControl, Object> propertyControl = + new DefaultSinglePropertyControl<>(currentValue, property.getName(), changeConsumer); + + addControl(container, property, propertyControl); + break; + } case VECTOR_2F: { final EditableProperty property = cast(description); @@ -155,6 +179,10 @@ protected void buildFor(@NotNull final VBox container, @NotNull final C changeCo addControl(container, property, propertyControl); break; } + case SEPARATOR: { + buildSplitLine(container); + break; + } default: { break; } @@ -169,6 +197,7 @@ protected void buildFor(@NotNull final VBox container, @NotNull final C changeCo * @param property the property * @param propertyControl the property control */ + @FXThread protected void addControl(@NotNull final VBox container, @NotNull final EditableProperty property, @NotNull final PropertyControl, T> propertyControl) { @@ -185,10 +214,12 @@ protected void addControl(@NotNull final VBox container, @NotNull final Edit * @param object the editable object. * @return the list of properties or null. */ + @FXThread protected @Nullable List> getProperties(final @NotNull Object object) { return null; } + @FXThread protected @NotNull EditableProperty cast(@NotNull final EditableProperty property) { return ClassUtils.unsafeCast(property); } 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 734eca94..43631806 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 @@ -7,6 +7,7 @@ import com.jme3.audio.AudioKey; import com.jme3.audio.AudioNode; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.property.PropertyControl; @@ -47,33 +48,40 @@ public class AudioKeyPropertyControl extends PropertyC public AudioKeyPropertyControl(@Nullable final AudioKey element, @NotNull final String paramName, @NotNull final C changeConsumer) { super(element, paramName, changeConsumer); - setOnDragOver(this::dragOver); - setOnDragDropped(this::dragDropped); - setOnDragExited(this::dragExited); + setOnDragOver(this::handleDragOverEvent); + setOnDragDropped(this::handleDragDroppedEvent); + setOnDragExited(this::handleDragExitedEvent); } /** - * Handle grad exiting. + * Handle grad exited events. + * + * @param dragEvent the drag exited event. */ - private void dragExited(@NotNull final DragEvent dragEvent) { + private void handleDragExitedEvent(@NotNull final DragEvent dragEvent) { } /** - * Handle dropped files to editor. + * Handle dropped event. + * + * @param dragEvent the dropped event. */ - private void dragDropped(@NotNull final DragEvent dragEvent) { + private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { UIUtils.handleDroppedFile(dragEvent, AUDIO_EXTENSIONS, this, AudioKeyPropertyControl::addAudioData); } /** - * Handle drag over. + * Handle drag over events. + * + * @param dragEvent the drag over events. */ - private void dragOver(@NotNull final DragEvent dragEvent) { + private void handleDragOverEvent(@NotNull final DragEvent dragEvent) { UIUtils.acceptIfHasFile(dragEvent, AUDIO_EXTENSIONS); } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -108,10 +116,17 @@ protected void createComponents(@NotNull final HBox container) { /** * Show dialog for choosing another audio key. */ + @FXThread protected void processChange() { UIUtils.openFileAssetDialog(this::addAudioData, AUDIO_EXTENSIONS, DEFAULT_ACTION_TESTER); } + /** + * Add the new audio data. + * + * @param file the audio file. + */ + @FXThread private void addAudioData(@NotNull final Path file) { final Path assetFile = notNull(getAssetFile(file)); @@ -129,6 +144,7 @@ private void addAudioData(@NotNull final Path file) { /** * Open this audio data in the audio viewer. */ + @FXThread protected void processOpen() { final AudioKey element = getPropertyValue(); @@ -152,12 +168,13 @@ protected void processOpen() { * * @return the label with name of the audio key. */ - @NotNull - private Label getAudioKeyLabel() { + @FXThread + private @NotNull Label getAudioKeyLabel() { return notNull(audioKeyLabel); } @Override + @FXThread protected void reload() { final AudioKey element = getPropertyValue(); final Label audioKeyLabel = getAudioKeyLabel(); 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 6def4493..075be8ed 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,13 +1,18 @@ 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 javafx.beans.property.DoubleProperty; 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; @@ -40,6 +45,7 @@ public BooleanPropertyControl(@Nullable final Boolean propertyValue, @NotNull fi } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -52,6 +58,35 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FXThread + public void changeControlWidthPercent(final double controlWidthPercent) { + + final CheckBox checkBox = getCheckBox(); + final DoubleProperty widthProperty = checkBox.prefWidthProperty(); + + if (widthProperty.isBound()) { + super.changeControlWidthPercent(controlWidthPercent); + widthProperty.unbind(); + widthProperty.bind(widthProperty().multiply(controlWidthPercent)); + } + } + + /** + * Disable the offset of checkbox control. + */ + @FXThread + public void disableCheckboxOffset() { + + final CheckBox checkBox = getCheckBox(); + checkBox.prefWidthProperty().unbind(); + checkBox.setPrefWidth(Region.USE_COMPUTED_SIZE); + + final Label propertyNameLabel = getPropertyNameLabel(); + propertyNameLabel.maxWidthProperty().unbind(); + } + + @Override + @FromAnyThread protected boolean isSingleRow() { return true; } @@ -59,11 +94,13 @@ protected boolean isSingleRow() { /** * @return the {@link CheckBox} with current value. */ + @FXThread private @NotNull CheckBox getCheckBox() { return notNull(checkBox); } @Override + @FXThread protected void reload() { final Boolean value = getPropertyValue(); final CheckBox checkBox = getCheckBox(); @@ -73,6 +110,7 @@ protected void reload() { /** * Update the value. */ + @FXThread private void updateValue() { if (isIgnoreListener()) return; final CheckBox checkBox = getCheckBox(); 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 6fde6be4..7c7a29cb 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 @@ -2,6 +2,8 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.math.ColorRGBA; +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; @@ -33,6 +35,7 @@ public ColorPropertyControl(@Nullable final ColorRGBA propertyValue, @NotNull fi } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -45,11 +48,23 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FXThread + public void changeControlWidthPercent(final double controlWidthPercent) { + super.changeControlWidthPercent(controlWidthPercent); + + final ColorPicker colorPicker = getColorPicker(); + colorPicker.prefWidthProperty().unbind(); + colorPicker.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); + } + + @Override + @FXThread protected void setPropertyValue(@Nullable final ColorRGBA color) { super.setPropertyValue(color == null ? null : color.clone()); } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } @@ -57,11 +72,13 @@ protected boolean isSingleRow() { /** * @return the color picker. */ + @FXThread private @NotNull ColorPicker getColorPicker() { return notNull(colorPicker); } @Override + @FXThread protected void reload() { final ColorPicker colorPicker = getColorPicker(); colorPicker.setValue(UIUtils.from(getPropertyValue())); @@ -70,6 +87,7 @@ protected void reload() { /** * Updating value. */ + @FXThread private void updateValue() { if (isIgnoreListener()) return; 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 ce60f1cc..83c39fad 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,6 +1,8 @@ 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; @@ -44,6 +46,7 @@ public DefaultPropertyControl(@Nullable final T propertyValue, @NotNull final St * * @param toStringFunction the string function. */ + @FromAnyThread public void setToStringFunction(@Nullable final Function toStringFunction) { this.toStringFunction = toStringFunction; } @@ -51,6 +54,7 @@ public void setToStringFunction(@Nullable final Function toStringFunc /** * @return the string function. */ + @FromAnyThread private @Nullable Function getToStringFunction() { return toStringFunction; } @@ -63,6 +67,7 @@ public void setToStringFunction(@Nullable final Function toStringFunc } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -75,6 +80,7 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FXThread public void reload() { super.reload(); 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 b61c0bb7..8faeff99 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 @@ -1,5 +1,7 @@ package com.ss.editor.ui.control.property.impl; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; @@ -21,6 +23,7 @@ public DefaultSinglePropertyControl(@Nullable final T propertyValue, @NotNull fi } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); getPropertyValueLabel().prefWidthProperty() @@ -28,6 +31,7 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } 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 2311ab4d..80262086 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 @@ -2,6 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.property.PropertyControl; @@ -50,6 +51,7 @@ public ElementPropertyControl(@NotNull final Class type, @Nullable final T pr } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -81,12 +83,14 @@ protected void createComponents(@NotNull final HBox container) { /** * Show dialog to choose an element. */ + @FXThread protected void processAdd() { } /** * Open this material in the material editor. */ + @FXThread protected void processRemove() { changed(null, getPropertyValue()); } @@ -96,6 +100,7 @@ protected void processRemove() { * * @return the label with name of the material. */ + @FXThread protected @NotNull Label getElementLabel() { return notNull(elementLabel); } 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 98263106..2c2fda6a 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 @@ -2,6 +2,8 @@ import static com.ss.editor.util.EditorUtil.getAvailableValues; 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; @@ -53,13 +55,14 @@ public EnumPropertyControl(@Nullable final E propertyValue, @NotNull final Strin } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); enumComboBox = new ComboBox<>(); enumComboBox.getSelectionModel() .selectedItemProperty() - .addListener((observable, oldValue, newValue) -> updateCullHint()); + .addListener((observable, oldValue, newValue) -> change()); enumComboBox.prefWidthProperty() .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); @@ -70,6 +73,7 @@ protected void createComponents(@NotNull final HBox container) { /** * @return the list of available options of the {@link Enum} value. */ + @FXThread private @NotNull ComboBox getEnumComboBox() { return notNull(enumComboBox); } @@ -77,7 +81,8 @@ protected void createComponents(@NotNull final HBox container) { /** * Update selected {@link Enum} value. */ - private void updateCullHint() { + @FXThread + private void change() { if (isIgnoreListener()) return; final ComboBox enumComboBox = getEnumComboBox(); @@ -88,6 +93,7 @@ private void updateCullHint() { } @Override + @FXThread protected void reload() { final E element = getPropertyValue(); @@ -98,6 +104,7 @@ protected void reload() { } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } 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 new file mode 100644 index 00000000..e67d9c63 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/impl/FloatArrayPropertyControl.java @@ -0,0 +1,134 @@ +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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.BiConsumer; + +/** + * The implementation of the {@link PropertyControl} to edit float array values. + * + * @param the type parameter + * @param the type parameter + * @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) { + super(propertyValue, propertyName, changeConsumer); + } + + public FloatArrayPropertyControl(@Nullable final float[] propertyValue, @NotNull final String propertyName, + @NotNull final C changeConsumer, + @Nullable final SixObjectConsumer> 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(); + + if (element == null) { + valueField.setText(StringUtils.EMPTY); + } else { + valueField.setText(ArrayUtils.toString(element, " ", false, false)); + } + + valueField.positionCaret(caretPosition); + } + + /** + * Update the value. + */ + @FXThread + private void updateValue(@Nullable final KeyEvent event) { + if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return; + + final String textValue = getValueField().getText(); + float[] newValue = null; + + if (!StringUtils.isEmpty(textValue)) { + + final String splitter = textValue.contains(" ") ? " " : ","; + final String[] splited = textValue.split(splitter); + + newValue = new float[splited.length]; + + for (int i = 0; i < splited.length; i++) { + try { + newValue[i] = Float.parseFloat(splited[i]); + } catch (final NumberFormatException e) { + LOGGER.warning(this, e); + newValue = getPropertyValue(); + break; + } + } + } + + changed(newValue, getPropertyValue()); + } +} 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 0fe39950..078825d5 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 @@ -2,6 +2,7 @@ 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; @@ -41,6 +42,17 @@ public FloatPropertyControl(@Nullable final Float propertyValue, @NotNull final } @Override + @FXThread + public void changeControlWidthPercent(final double controlWidthPercent) { + super.changeControlWidthPercent(controlWidthPercent); + + final FloatTextField valueField = getValueField(); + valueField.prefWidthProperty().unbind(); + valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); + } + + @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -85,6 +97,7 @@ public void setMinMax(final float min, final float max) { } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } @@ -92,11 +105,13 @@ protected boolean isSingleRow() { /** * @return the filed with current value. */ + @FXThread private @NotNull FloatTextField getValueField() { return notNull(valueField); } @Override + @FXThread protected void reload() { final Float value = getPropertyValue(); final FloatTextField valueField = getValueField(); @@ -108,6 +123,7 @@ protected void reload() { /** * Update the value. */ + @FXThread private void updateValue() { if (isIgnoreListener()) return; 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 fed0f959..e8379c14 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,6 +1,8 @@ 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; @@ -44,6 +46,17 @@ public IntArrayPropertyControl(@Nullable final int[] propertyValue, @NotNull fin } @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); @@ -57,6 +70,7 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } @@ -64,11 +78,13 @@ protected boolean isSingleRow() { /** * @return the filed with current value. */ + @FXThread private @NotNull TextField getValueField() { return notNull(valueField); } @Override + @FXThread protected void reload() { final int[] element = getPropertyValue(); @@ -88,6 +104,7 @@ protected void reload() { /** * Update the value. */ + @FXThread private void updateValue(@Nullable final KeyEvent event) { if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return; 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 caae67f5..f021b75a 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 @@ -2,6 +2,7 @@ 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; @@ -32,6 +33,17 @@ public IntegerPropertyControl(@Nullable final Integer propertyValue, @NotNull fi } @Override + @FXThread + public void changeControlWidthPercent(final double controlWidthPercent) { + super.changeControlWidthPercent(controlWidthPercent); + + final IntegerTextField valueField = getValueField(); + valueField.prefWidthProperty().unbind(); + valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent)); + } + + @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -44,6 +56,7 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } @@ -51,6 +64,7 @@ protected boolean isSingleRow() { /** * @return the filed with current value. */ + @FXThread private @NotNull IntegerTextField getValueField() { return notNull(valueField); } @@ -87,6 +101,7 @@ public int getScrollPower() { } @Override + @FXThread protected void reload() { final Integer element = getPropertyValue(); final IntegerTextField valueField = getValueField(); @@ -98,6 +113,7 @@ protected void reload() { /** * Update the value. */ + @FXThread private void updateValue() { if (isIgnoreListener()) return; 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 394c2af9..19a185be 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 @@ -4,6 +4,8 @@ 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.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.css.CSSClasses; @@ -63,11 +65,13 @@ public LodLevelPropertyControl(@Nullable final Integer element, @NotNull final S } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -83,14 +87,20 @@ protected void createComponents(@NotNull final HBox container) { FXUtils.addClassTo(levelComboBox, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); } + /** + * Update lod level. + * + * @param newValue the new level. + */ + @FXThread private void updateLevel(@Nullable final Integer newValue) { if (isIgnoreListener()) return; changed(newValue == null ? 0 : newValue, getPropertyValue()); } - @NotNull @Override - public Integer getPropertyValue() { + @FXThread + public @NotNull Integer getPropertyValue() { final Integer value = super.getPropertyValue(); return value == null ? 0 : value; } @@ -100,12 +110,13 @@ public Integer getPropertyValue() { * * @return The lod level combobox. */ - @NotNull - protected ComboBox getLevelComboBox() { + @FXThread + protected @NotNull ComboBox getLevelComboBox() { return ObjectUtils.notNull(levelComboBox); } @Override + @FXThread protected void reload() { if (!hasEditObject()) return; 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 fe3273f2..3551ce59 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 @@ -3,6 +3,7 @@ import static com.ss.editor.util.EditorUtil.*; import static com.ss.rlib.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; @@ -28,11 +29,13 @@ public MaterialKeyPropertyControl(@Nullable final MaterialKey element, @NotNull super(element, paramName, changeConsumer); } + @FXThread @Override protected void processChange() { UIUtils.openFileAssetDialog(this::addMaterial, MATERIAL_EXTENSIONS, DEFAULT_ACTION_TESTER); } + @FXThread @Override protected void addMaterial(@NotNull final Path file) { @@ -48,6 +51,7 @@ protected void addMaterial(@NotNull final Path file) { } } + @FXThread @Override protected void processEdit() { @@ -67,6 +71,7 @@ protected void processEdit() { FX_EVENT_MANAGER.notify(event); } + @FXThread @Override protected void reload() { final MaterialKey element = getPropertyValue(); 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 9193fdf5..e1b0a349 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 @@ -6,6 +6,7 @@ import com.jme3.scene.Spatial; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.Icons; import com.ss.editor.ui.control.property.PropertyControl; @@ -60,22 +61,28 @@ public class MaterialPropertyControl extends Pro public MaterialPropertyControl(@Nullable final V element, @NotNull final String paramName, @NotNull final C changeConsumer) { super(element, paramName, changeConsumer); - setOnDragOver(this::dragOver); - setOnDragDropped(this::dragDropped); - setOnDragExited(this::dragExited); + setOnDragOver(this::handleDragOverEvent); + setOnDragDropped(this::handleDragDroppedEvent); + setOnDragExited(this::handleDragExitedEvent); } /** - * Handle grad exiting. + * Handle grad exited events. + * + * @param dragEvent the drag exited event. */ - private void dragExited(@NotNull final DragEvent dragEvent) { + @FXThread + private void handleDragExitedEvent(@NotNull final DragEvent dragEvent) { } /** - * Handle dropped files to editor. + * Handle dropped events. + * + * @param dragEvent the dropped event. */ - private void dragDropped(@NotNull final DragEvent dragEvent) { + @FXThread + private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { final Dragboard dragboard = dragEvent.getDragboard(); final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); @@ -94,9 +101,12 @@ private void dragDropped(@NotNull final DragEvent dragEvent) { } /** - * Handle drag over. + * Handle drag over events. + * + * @param dragEvent the drag over event. */ - private void dragOver(@NotNull final DragEvent dragEvent) { + @FXThread + private void handleDragOverEvent(@NotNull final DragEvent dragEvent) { final Dragboard dragboard = dragEvent.getDragboard(); final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); @@ -123,10 +133,12 @@ private void dragOver(@NotNull final DragEvent dragEvent) { * * @param file the file */ + @FXThread protected void addMaterial(@NotNull final Path file) { } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -161,12 +173,14 @@ protected void createComponents(@NotNull final HBox container) { /** * Show dialog for choosing another material. */ + @FXThread protected void processChange() { } /** * Open this material in the material editor. */ + @FXThread protected void processEdit() { } @@ -175,8 +189,8 @@ protected void processEdit() { * * @return the label with name of the material. */ - @NotNull - protected Label getMaterialLabel() { + @FXThread + protected @NotNull Label getMaterialLabel() { return notNull(materialLabel); } } 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 e934058d..193beacb 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 @@ -4,6 +4,7 @@ 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; @@ -25,11 +26,13 @@ public MinMaxPropertyControl(@Nullable final Vector2f propertyValue, @NotNull fi } @Override + @FXThread protected float checkResultXValue(final float x, final float y) { return min(x, y); } @Override + @FXThread protected float checkResultYValue(final float x, final 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 920b3590..96a19f72 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 @@ -4,6 +4,7 @@ import static com.ss.rlib.geom.util.AngleUtils.radiansToDegree; import static com.ss.rlib.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; @@ -19,7 +20,7 @@ import org.jetbrains.annotations.Nullable; /** - * The implementation of the {@link ModelPropertyControl} to edit {@link Quaternion} values. + * The implementation of the {@link PropertyControl} to edit {@link Quaternion} values. * * @param the type parameter * @param the type parameter @@ -51,6 +52,7 @@ public QuaternionPropertyControl(@Nullable final Quaternion propertyValue, @NotN } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -92,6 +94,7 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FXThread protected void setPropertyValue(@Nullable final Quaternion quaternion) { super.setPropertyValue(quaternion == null ? null : quaternion.clone()); } @@ -99,6 +102,7 @@ protected void setPropertyValue(@Nullable final Quaternion quaternion) { /** * @return the field X. */ + @FXThread private @NotNull FloatTextField getXField() { return notNull(xField); } @@ -106,6 +110,7 @@ protected void setPropertyValue(@Nullable final Quaternion quaternion) { /** * @return the field Y. */ + @FXThread private @NotNull FloatTextField getYFiled() { return notNull(yField); } @@ -113,11 +118,13 @@ protected void setPropertyValue(@Nullable final Quaternion quaternion) { /** * @return the field Z. */ + @FXThread private @NotNull FloatTextField getZField() { return notNull(zField); } @Override + @FXThread protected void reload() { final float[] angles = new float[3]; @@ -143,6 +150,7 @@ protected void reload() { /** * Updating rotation. */ + @FXThread private void updateRotation(@Nullable final KeyEvent event) { if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return; 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 0dd8cc1b..93ab16de 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,6 +1,8 @@ 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; @@ -33,6 +35,7 @@ public StringPropertyControl(@Nullable final String propertyValue, @NotNull fina } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -45,6 +48,7 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FromAnyThread protected boolean isSingleRow() { return true; } @@ -52,11 +56,13 @@ protected boolean isSingleRow() { /** * @return the filed with current value. */ + @FXThread private @NotNull TextField getValueField() { return notNull(valueField); } @Override + @FXThread protected void reload() { final String value = getPropertyValue(); final TextField valueField = getValueField(); @@ -68,6 +74,7 @@ protected void reload() { /** * Update the value. */ + @FXThread private void updateValue(@NotNull final KeyEvent event) { if (isIgnoreListener() || event.getCode() != KeyCode.ENTER) return; 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 index 02b07606..e0f402c9 100644 --- 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 @@ -9,6 +9,7 @@ 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; @@ -89,32 +90,55 @@ public class Texture2DPropertyControl extends Prope @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::dragOver); - setOnDragDropped(this::dragDropped); + setOnDragOver(this::handleDragOverEvent); + setOnDragDropped(this::handleDragDroppedEvent); + } + + @Override + @FXThread + public void changeControlWidthPercent(final double controlWidthPercent) { } /** - * Handle dropped files to editor. + * Handle drag dropped events. + * + * @param dragEvent the drag dropped event. */ - protected void dragDropped(@NotNull final DragEvent dragEvent) { + @FXThread + protected void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { UIUtils.handleDroppedFile(dragEvent, TEXTURE_EXTENSIONS, this, Texture2DPropertyControl::setTexture); } /** - * Handle drag over. + * Handle drag over events. + * + * @param dragEvent the drag over event. */ - protected void dragOver(@NotNull final DragEvent dragEvent) { + @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); - textureLabel = new Label(NO_TEXTURE); + fieldContainer = new HBox(); + + if (!isSingleRow()) { + fieldContainer.prefWidthProperty().bind(container.widthProperty()); + } + textureTooltip = new ImageChannelPreview(); final VBox previewContainer = new VBox(); @@ -139,39 +163,74 @@ protected void createComponents(@NotNull final HBox container) { removeButton.setOnAction(event -> processRemove()); removeButton.disableProperty().bind(buildDisableRemoveCondition()); - textureLabel.prefWidthProperty().bind(widthProperty() - .subtract(removeButton.widthProperty()) - .subtract(previewContainer.widthProperty()) - .subtract(settingsButton.widthProperty()) - .subtract(addButton.widthProperty())); - - FXUtils.addToPane(textureLabel, container); - FXUtils.addToPane(previewContainer, container); - FXUtils.addToPane(addButton, container); - FXUtils.addToPane(settingsButton, container); - FXUtils.addToPane(removeButton, container); + 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.addClassesTo(container, CSSClasses.DEF_HBOX, CSSClasses.TEXT_INPUT_CONTAINER, - CSSClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER); FXUtils.addClassTo(previewContainer, CSSClasses.ABSTRACT_PARAM_CONTROL_PREVIEW_CONTAINER); - FXUtils.addClassTo(textureLabel, CSSClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL); 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); } @@ -179,6 +238,7 @@ protected void createComponents(@NotNull final HBox container) { /** * Process to remove the current texture. */ + @FXThread protected void processRemove() { setTexture(null); } @@ -186,6 +246,7 @@ protected void processRemove() { /** * Process to add a new texture. */ + @FXThread protected void processAdd() { UIUtils.openFileAssetDialog(this::setTexture, TEXTURE_EXTENSIONS, DEFAULT_ACTION_TESTER); } @@ -193,6 +254,7 @@ protected void processAdd() { /** * Process to open texture's settings. */ + @FXThread protected void openSettings() { final Texture2D texture = notNull(getPropertyValue()); @@ -223,6 +285,7 @@ protected void openSettings() { * * @param varTable the var table. */ + @FXThread private void applyChanges(@NotNull final VarTable varTable) { final Texture2D texture = notNull(getPropertyValue()); @@ -265,6 +328,7 @@ private void applyChanges(@NotNull final VarTable varTable) { * * @param file the file to new texture. */ + @FXThread protected void setTexture(@Nullable final Path file) { if (file == null) { @@ -285,13 +349,16 @@ protected void setTexture(@Nullable final Path file) { } @Override + @FXThread protected void reload() { final Texture2D texture2D = getPropertyValue(); final AssetKey key = texture2D == null ? null : texture2D.getKey(); - final Label textureLabel = getTextureLabel(); - textureLabel.setText(key == null ? NO_TEXTURE : key.getName()); + if (!isSingleRow()) { + final Label textureLabel = getTextureLabel(); + textureLabel.setText(key == null ? NO_TEXTURE : key.getName()); + } final ImageChannelPreview textureTooltip = getTextureTooltip(); final ImageView preview = getTexturePreview(); 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 new file mode 100644 index 00000000..97ce2c58 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/impl/Texture2DSingleRowPropertyControl.java @@ -0,0 +1,28 @@ +package com.ss.editor.ui.control.property.impl; + +import com.jme3.texture.Texture2D; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.model.undo.editor.ChangeConsumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The single row implementation of the control to edit textures. + * + * @param the type of a {@link ChangeConsumer} + * @param the type of an editing object. + * @author JavaSaBr + */ +public class Texture2DSingleRowPropertyControl extends Texture2DPropertyControl { + + public Texture2DSingleRowPropertyControl(@Nullable final Texture2D propertyValue, + @NotNull final String propertyName, @NotNull final C changeConsumer) { + super(propertyValue, propertyName, changeConsumer); + } + + @Override + @FromAnyThread + protected boolean isSingleRow() { + return true; + } +} 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 index 369f0511..f2a88bf8 100644 --- 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 @@ -2,6 +2,8 @@ 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; @@ -35,49 +37,76 @@ public class Vector2FPropertyControl extends Proper @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); - final HBox field = new HBox(); - field.prefWidthProperty() + 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(field.widthProperty().multiply(0.5)); + 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(field.widthProperty().multiply(0.5)); + yField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.5)); yField.setScrollPower(10F); - FXUtils.addToPane(xField, field); - FXUtils.addToPane(yField, field); - FXUtils.addToPane(field, container); + FXUtils.addToPane(xField, fieldContainer); + FXUtils.addToPane(yField, fieldContainer); + FXUtils.addToPane(fieldContainer, container); - FXUtils.addClassesTo(field, CSSClasses.DEF_HBOX, CSSClasses.TEXT_INPUT_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(field, xField, yField); + 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; } @@ -89,6 +118,7 @@ protected boolean isSingleRow() { * @param y the y * @return the float */ + @FXThread protected float checkResultXValue(final float x, final float y) { return x; } @@ -100,6 +130,7 @@ protected float checkResultXValue(final float x, final float y) { * @param y the y * @return the float */ + @FXThread protected float checkResultYValue(final float x, final float y) { return y; } @@ -109,6 +140,7 @@ protected float checkResultYValue(final float x, final float y) { * * @return the field X. */ + @FXThread protected @NotNull FloatTextField getXField() { return notNull(xField); } @@ -118,11 +150,13 @@ protected float checkResultYValue(final float x, final float y) { * * @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(); @@ -133,7 +167,7 @@ protected void reload() { final FloatTextField yField = getYField(); yField.setValue(vector.getY()); - yField.positionCaret(xField.getText().length()); + yField.positionCaret(yField.getText().length()); } /** @@ -141,6 +175,7 @@ protected void reload() { * * @param event the event */ + @FXThread private void updateVector(@Nullable final KeyEvent event) { if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return; 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 index f42d1042..2ca9fffe 100644 --- 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 @@ -2,6 +2,7 @@ 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; @@ -57,6 +58,7 @@ public Vector3FPropertyControl(@Nullable final Vector3f propertyValue, @NotNull } @Override + @FXThread protected void createComponents(@NotNull final HBox container) { super.createComponents(container); @@ -101,6 +103,7 @@ protected void createComponents(@NotNull final HBox container) { } @Override + @FXThread protected void setPropertyValue(@Nullable final Vector3f vector) { super.setPropertyValue(vector == null ? null : vector.clone()); } @@ -110,6 +113,7 @@ protected void setPropertyValue(@Nullable final Vector3f vector) { * * @return the scroll power. */ + @FXThread protected float getScrollPower() { return 10F; } @@ -119,6 +123,7 @@ protected float getScrollPower() { * * @return the field X. */ + @FXThread protected @NotNull FloatTextField getXField() { return notNull(xField); } @@ -128,6 +133,7 @@ protected float getScrollPower() { * * @return the field Y. */ + @FXThread protected @NotNull FloatTextField getYFiled() { return notNull(yField); } @@ -137,11 +143,13 @@ protected float getScrollPower() { * * @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(); @@ -164,6 +172,7 @@ protected void reload() { * * @param event the event */ + @FXThread protected void updateVector(@Nullable final KeyEvent event) { if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return; 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 new file mode 100644 index 00000000..299cc0cd --- /dev/null +++ b/src/main/java/com/ss/editor/ui/control/property/impl/Vector3FSingleRowPropertyControl.java @@ -0,0 +1,237 @@ +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.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 com.jme3.math.Vector3f} values. + * + * @param the type parameter + * @param the type parameter + * @author JavaSaBr. + */ +public class Vector3FSingleRowPropertyControl extends PropertyControl { + + /** + * The field X. + */ + @Nullable + private FloatTextField xField; + + /** + * The field Y. + */ + @Nullable + private FloatTextField yField; + + /** + * The field Z. + */ + @Nullable + private FloatTextField zField; + + /** + * The field container. + */ + @Nullable + private HBox fieldContainer; + + public Vector3FSingleRowPropertyControl(@Nullable final Vector3f 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.33)); + xField.setScrollPower(10F); + + yField = new FloatTextField(); + yField.setOnKeyReleased(this::updateVector); + yField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); + yField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.33)); + yField.setScrollPower(10F); + + zField = new FloatTextField(); + zField.setOnKeyReleased(this::updateVector); + zField.addChangeListener((observable, oldValue, newValue) -> updateVector(null)); + zField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.33)); + zField.setScrollPower(10F); + + FXUtils.addToPane(xField, fieldContainer); + FXUtils.addToPane(yField, fieldContainer); + FXUtils.addToPane(zField, 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, zField, CSSClasses.TRANSPARENT_TEXT_FIELD); + + UIUtils.addFocusBinding(fieldContainer, xField, yField, zField); + } + + /** + * @return the field container. + */ + @FXThread + private @NotNull HBox getFieldContainer() { + return notNull(fieldContainer); + } + + @Override + @FXThread + protected void setPropertyValue(@Nullable final Vector3f vector) { + super.setPropertyValue(vector == null ? null : vector.clone()); + } + + @Override + @FromAnyThread + protected boolean isSingleRow() { + return true; + } + + /** + * Check result x value. + * + * @param x the x. + * @param y the y. + * @param z the z. + * @return the result x value. + */ + @FXThread + protected float checkResultXValue(final float x, final float y, final float z) { + return x; + } + + /** + * Check result y value. + * + * @param x the x. + * @param y the y. + * @param z the z. + * @return the result y value. + */ + @FXThread + protected float checkResultYValue(final float x, final float y, final float z) { + return y; + } + + /** + * Check result z value. + * + * @param x the x. + * @param y the y. + * @param z the z. + * @return the result z value. + */ + @FXThread + protected float checkResultZValue(final float x, final float y, final float z) { + return z; + } + + /** + * 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); + } + + /** + * Get the Z field. + * + * @return the Z field. + */ + @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 yField = getYField(); + yField.setValue(vector.getY()); + yField.positionCaret(yField.getText().length()); + + final FloatTextField zField = getZField(); + zField.setValue(vector.getZ()); + zField.positionCaret(zField.getText().length()); + } + + /** + * Update the current value. + * + * @param event the change 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 FloatTextField zField = getZField(); + final float z = zField.getValue(); + + final Vector3f oldValue = getPropertyValue() == null ? Vector3f.ZERO : getPropertyValue(); + final Vector3f 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/tree/action/AbstractNodeAction.java b/src/main/java/com/ss/editor/ui/control/tree/action/AbstractNodeAction.java index 77a62d04..a37937af 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 @@ -80,6 +80,7 @@ public AbstractNodeAction(@NotNull final NodeTree nodeTree, @NotNull final Tr * * @return the name of this action. */ + @FXThread protected abstract @NotNull String getName(); /** @@ -95,6 +96,7 @@ protected void process() { * * @return he icon or null. */ + @FXThread protected @Nullable Image getIcon() { return null; } @@ -104,6 +106,7 @@ protected void process() { * * @return the component of the model three. */ + @FXThread protected @NotNull NodeTree getNodeTree() { return nodeTree; } @@ -113,6 +116,7 @@ protected void process() { * * @return the node of the model. */ + @FXThread protected @NotNull TreeNode getNode() { return node; } 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 afa83556..6a11bb33 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 @@ -1,8 +1,11 @@ package com.ss.editor.ui.control.tree.node; import com.ss.editor.Editor; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.UObject; import com.ss.editor.model.undo.editor.ChangeConsumer; +import com.ss.editor.ui.control.model.tree.action.RenameNodeAction; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.rlib.util.array.Array; import com.ss.rlib.util.array.ArrayFactory; @@ -74,8 +77,8 @@ public TreeNode(@NotNull final T element, final long objectId) { * * @return the element of the {@link com.jme3.scene.Spatial}. */ - @NotNull - public T getElement() { + @FromAnyThread + public @NotNull T getElement() { return element; } @@ -84,6 +87,7 @@ public T getElement() { * * @return the name of this node. */ + @FromAnyThread public @NotNull String getName() { return "unknown name"; } @@ -93,6 +97,7 @@ public T getElement() { * * @param name the name. */ + @FXThread public void setName(@NotNull final String name) { } @@ -101,6 +106,7 @@ public void setName(@NotNull final String name) { * * @return true if need to save name. */ + @FromAnyThread public boolean isNeedToSaveName() { return false; } @@ -111,6 +117,7 @@ public boolean isNeedToSaveName() { * @param nodeTree the node tree * @return true of this node has any children. */ + @FXThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return false; } @@ -121,6 +128,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { * @param nodeTree the node tree * @return the array of children of this node. */ + @FXThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { return EMPTY_ARRAY; } @@ -130,8 +138,8 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { * * @return the parent of this node. */ - @Nullable - public TreeNode getParent() { + @FXThread + public @Nullable TreeNode getParent() { return parent; } @@ -140,7 +148,8 @@ public TreeNode getParent() { * * @param parent the parent. */ - protected void setParent(final TreeNode parent) { + @FXThread + protected void setParent(@Nullable final TreeNode parent) { this.parent = parent; } @@ -149,6 +158,7 @@ protected void setParent(final TreeNode parent) { * * @return the icon of this node. */ + @FXThread public @Nullable Image getIcon() { return null; } @@ -159,7 +169,9 @@ protected void setParent(final TreeNode parent) { * @param nodeTree the node tree * @param items the items */ + @FXThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { + if (canEditName()) items.add(new RenameNodeAction(nodeTree, this)); } /** @@ -167,6 +179,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final * * @param child the child */ + @FXThread public void remove(@NotNull final TreeNode child) { } @@ -175,6 +188,7 @@ public void remove(@NotNull final TreeNode child) { * * @param child the child */ + @FXThread public void add(@NotNull final TreeNode child) { } @@ -184,6 +198,7 @@ public void add(@NotNull final TreeNode child) { * @param nodeTree the node tree * @param newName the new name */ + @FXThread public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { } @@ -194,6 +209,7 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin * @param isCopy true if need to copy the object. * @return true of this node can accept the child. */ + @FXThread public boolean canAccept(@NotNull final TreeNode child, final boolean isCopy) { return false; } @@ -205,6 +221,7 @@ public boolean canAccept(@NotNull final TreeNode child, final boolean isCopy) * @param object the object. * @param isCopy true if need to copy the object. */ + @FXThread public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final Object object, final boolean isCopy) { } @@ -215,6 +232,7 @@ public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final * @param dragboard the dragboard * @return true if this node can accept external resource. */ + @FXThread public boolean canAcceptExternal(@NotNull final Dragboard dragboard) { return false; } @@ -225,6 +243,7 @@ public boolean canAcceptExternal(@NotNull final Dragboard dragboard) { * @param dragboard the dragboard * @param consumer the consumer */ + @FXThread public void acceptExternal(@NotNull final Dragboard dragboard, @NotNull final ChangeConsumer consumer) { } @@ -233,6 +252,7 @@ public void acceptExternal(@NotNull final Dragboard dragboard, @NotNull final Ch * * @return true if this node supports moving. */ + @FXThread public boolean canMove() { return false; } @@ -242,6 +262,7 @@ public boolean canMove() { * * @return true if this node supports copying. */ + @FXThread public boolean canCopy() { return false; } @@ -251,6 +272,7 @@ public boolean canCopy() { * * @return true if this node supports name editing. */ + @FXThread public boolean canEditName() { return false; } @@ -260,6 +282,7 @@ public boolean canEditName() { * * @return true if you can remove this node. */ + @FXThread public boolean canRemove() { return true; } @@ -269,12 +292,13 @@ public boolean canRemove() { * * @return the new copy of this node. */ - @NotNull - public TreeNode copy() { + @FXThread + public @NotNull TreeNode copy() { throw new UnsupportedOperationException(); } @Override + @FromAnyThread public long getObjectId() { return objectId; } @@ -308,6 +332,7 @@ public int hashCode() { * * @param treeNode the model node. */ + @FXThread public void notifyChildAdded(@NotNull final TreeNode treeNode) { } @@ -316,6 +341,7 @@ public void notifyChildAdded(@NotNull final TreeNode treeNode) { * * @param treeNode the model node. */ + @FXThread public void notifyChildRemoved(@NotNull final TreeNode treeNode) { treeNode.setParent(null); } @@ -325,6 +351,7 @@ public void notifyChildRemoved(@NotNull final TreeNode treeNode) { * * @param treeNode the model node. */ + @FXThread public void notifyChildPreAdd(@NotNull final TreeNode treeNode) { treeNode.setParent(this); } @@ -334,6 +361,7 @@ public void notifyChildPreAdd(@NotNull final TreeNode treeNode) { * * @param treeNode the model node. */ + @FXThread public void notifyChildPreRemove(@NotNull final TreeNode treeNode) { } } diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/TreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/TreeNodeFactory.java index 1b02dbda..824dd75b 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/TreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/TreeNodeFactory.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.control.tree.node; +import com.ss.editor.annotation.FXThread; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,14 +20,15 @@ public interface TreeNodeFactory extends Comparable { * @param objectId the object id. * @return the tree node. */ - @Nullable - > V createFor(@Nullable final T element, final long objectId); + @FXThread + > @Nullable V createFor(@Nullable final T element, final long objectId); /** * Gets an order of this factory. * * @return the order. */ + @FXThread default int getOrder() { return 0; } diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/AnimationTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/AnimationTreeNodeFactory.java index 8aa7cbc5..45b64f24 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/AnimationTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/AnimationTreeNodeFactory.java @@ -2,6 +2,7 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; import com.jme3.animation.*; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.model.node.control.anim.*; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.control.tree.node.TreeNodeFactory; @@ -15,8 +16,8 @@ public class AnimationTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof Animation) { return unsafeCast(new AnimationTreeNode((Animation) element, objectId)); @@ -36,6 +37,7 @@ public > V createFor(@Nullable final T element, final l } @Override + @FXThread public int getOrder() { return 1; } diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/CollisionTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/CollisionTreeNodeFactory.java index 1cec4eda..0d1ef3ee 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/CollisionTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/CollisionTreeNodeFactory.java @@ -3,6 +3,7 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; import com.jme3.bullet.collision.shapes.*; import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.model.node.physics.shape.*; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.control.tree.node.TreeNodeFactory; @@ -16,8 +17,8 @@ public class CollisionTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof ChildCollisionShape) { return unsafeCast(new ChildCollisionShapeTreeNode((ChildCollisionShape) element, objectId)); diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/ControlTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/ControlTreeNodeFactory.java index ae8c1ceb..574967de 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/ControlTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/ControlTreeNodeFactory.java @@ -8,6 +8,7 @@ import com.jme3.bullet.control.VehicleControl; import com.jme3.cinematic.events.MotionEvent; import com.jme3.scene.control.Control; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.model.node.control.ControlTreeNode; import com.ss.editor.ui.control.model.node.control.SkeletonControlTreeNode; import com.ss.editor.ui.control.model.node.control.motion.MotionEventTreeNode; @@ -27,8 +28,8 @@ public class ControlTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof MotionEvent) { return unsafeCast(new MotionEventTreeNode((MotionEvent) element, objectId)); diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultParticlesTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultParticlesTreeNodeFactory.java index 7bef4e63..107aa7a9 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultParticlesTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultParticlesTreeNodeFactory.java @@ -7,6 +7,7 @@ import com.jme3.effect.influencers.ParticleInfluencer; import com.jme3.effect.influencers.RadialParticleInfluencer; import com.jme3.effect.shapes.*; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.model.node.spatial.particle.emitter.ParticleEmitterTreeNode; import com.ss.editor.ui.control.model.node.spatial.particle.emitter.influencer.DefaultParticleInfluencerTreeNode; import com.ss.editor.ui.control.model.node.spatial.particle.emitter.influencer.EmptyParticleInfluencerTreeNode; @@ -25,8 +26,8 @@ public class DefaultParticlesTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof ParticleEmitter) { return unsafeCast(new ParticleEmitterTreeNode((ParticleEmitter) element, objectId)); @@ -65,6 +66,7 @@ public > V createFor(@Nullable final T element, final l } @Override + @FXThread public int getOrder() { return 1; } diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultTreeNodeFactory.java index 3cfcd329..708d74a1 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/DefaultTreeNodeFactory.java @@ -9,6 +9,7 @@ import com.jme3.scene.Node; import com.jme3.terrain.geomipmap.TerrainGrid; import com.jme3.terrain.geomipmap.TerrainQuad; +import com.ss.editor.annotation.FXThread; import com.ss.editor.extension.scene.SceneLayer; import com.ss.editor.extension.scene.SceneNode; import com.ss.editor.ui.control.layer.LayersRoot; @@ -30,8 +31,8 @@ public class DefaultTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof LayersRoot) { return unsafeCast(new LayersRootTreeNode((LayersRoot) element, objectId)); diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/LightTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/LightTreeNodeFactory.java index 9b3eaf48..0023bb80 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/LightTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/LightTreeNodeFactory.java @@ -2,6 +2,7 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; import com.jme3.light.*; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.model.node.light.*; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.control.tree.node.TreeNodeFactory; @@ -15,8 +16,8 @@ public class LightTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof LightProbe) { return unsafeCast(new LightProbeTreeNode((LightProbe) element, objectId)); diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/PrimitiveTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/PrimitiveTreeNodeFactory.java index 175be35f..2ecd12cc 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/PrimitiveTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/PrimitiveTreeNodeFactory.java @@ -5,6 +5,7 @@ import com.jme3.cinematic.MotionPath; import com.jme3.math.Vector3f; import com.jme3.scene.VertexBuffer; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.control.model.node.BufferTreeNode; import com.ss.editor.ui.control.model.node.PositionTreeNode; import com.ss.editor.ui.control.model.node.VertexBufferTreeNode; @@ -24,8 +25,8 @@ public class PrimitiveTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof Vector3f) { return unsafeCast(new PositionTreeNode((Vector3f) element, objectId)); @@ -43,6 +44,7 @@ public > V createFor(@Nullable final T element, final l } @Override + @FXThread public int getOrder() { return 1; } diff --git a/src/main/java/com/ss/editor/ui/control/tree/node/impl/Toneg0dTreeNodeFactory.java b/src/main/java/com/ss/editor/ui/control/tree/node/impl/Toneg0dTreeNodeFactory.java index a18115ad..7e683acc 100644 --- a/src/main/java/com/ss/editor/ui/control/tree/node/impl/Toneg0dTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/ui/control/tree/node/impl/Toneg0dTreeNodeFactory.java @@ -1,6 +1,7 @@ package com.ss.editor.ui.control.tree.node.impl; import static com.ss.rlib.util.ClassUtils.unsafeCast; +import com.ss.editor.annotation.FXThread; import com.ss.editor.model.node.particles.Toneg0dParticleInfluencers; import com.ss.editor.ui.control.model.node.spatial.particle.emitter.toneg0d.Toneg0DParticleEmitterNodeTreeNode; import com.ss.editor.ui.control.model.node.spatial.particle.emitter.toneg0d.influencer.Toneg0DParticleInfluencerTreeNode; @@ -19,8 +20,8 @@ public class Toneg0dTreeNodeFactory implements TreeNodeFactory { @Override - @Nullable - public > V createFor(@Nullable final T element, final long objectId) { + @FXThread + public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof ParticleEmitterNode) { return unsafeCast(new Toneg0DParticleEmitterNodeTreeNode((ParticleEmitterNode) element, objectId)); @@ -34,6 +35,7 @@ public > V createFor(@Nullable final T element, final l } @Override + @FXThread public int getOrder() { return 1; } 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 d143b38f..c69d654a 100644 --- a/src/main/java/com/ss/editor/ui/css/CSSClasses.java +++ b/src/main/java/com/ss/editor/ui/css/CSSClasses.java @@ -1,5 +1,7 @@ package com.ss.editor.ui.css; +import org.jetbrains.annotations.NotNull; + /** * The list of custom css classes. * @@ -7,503 +9,160 @@ */ public interface CSSClasses { - /** - * The constant SPECIAL_FONT_13. - */ - String SPECIAL_FONT_13 = "special-font-13"; - /** - * The constant SPECIAL_FONT_14. - */ - String SPECIAL_FONT_14 = "special-font-14"; - /** - * The constant SPECIAL_FONT_16. - */ - String SPECIAL_FONT_16 = "special-font-16"; - /** - * The constant MAIN_SPLIT_PANEL. - */ - String MAIN_SPLIT_PANEL = "main-split-pane"; - - /** - * The constant DEF_HBOX. - */ - String DEF_HBOX = "hbox"; - /** - * The constant DEF_VBOX. - */ - String DEF_VBOX = "vbox"; - /** - * The constant DEF_GRID_PANE. - */ - String DEF_GRID_PANE = "grid-pane"; - /** - * The constant DEF_STACK_PANE. - */ - String DEF_STACK_PANE = "stack-pane"; - /** - * The constant DEF_BORDER_PANE. - */ - String DEF_BORDER_PANE = "border-pane"; - - /** - * The constant DIALOG_ROOT. - */ - String DIALOG_ROOT = "dialog-root"; - /** - * The constant DIALOG_ACTIONS_ROOT. - */ - String DIALOG_ACTIONS_ROOT = "dialog-actions-root"; - /** - * The constant DIALOG_CONTENT_ROOT. - */ - String DIALOG_CONTENT_ROOT = "dialog-content-root"; - /** - * The constant DIALOG_BUTTON. - */ - String DIALOG_BUTTON = "dialog-button"; - /** - * The constant DIALOG_LABEL_WARNING. - */ - String DIALOG_LABEL_WARNING = "dialog-label-warning"; - /** - * The constant DIALOG_DYNAMIC_LABEL. - */ - String DIALOG_DYNAMIC_LABEL = "dialog-dynamic-label"; - /** - * The constant DIALOG_FIELD. - */ - String DIALOG_FIELD = "dialog-field"; - - /** - * The constant TEXT_INPUT_CONTAINER. - */ - String TEXT_INPUT_CONTAINER = "text-input-container"; - - /** - * The constant CHOOSE_TEXTURE_CONTROL. - */ - String CHOOSE_TEXTURE_CONTROL = "choose-texture-control"; - /** - * The constant CHOOSE_TEXTURE_CONTROL_TEXTURE_LABEL. - */ - String CHOOSE_TEXTURE_CONTROL_TEXTURE_LABEL = "choose-texture-control-texture-label"; - /** - * The constant CHOOSE_TEXTURE_CONTROL_PREVIEW. - */ - String CHOOSE_TEXTURE_CONTROL_PREVIEW = "choose-texture-control-preview"; - - /** - * The constant CHOOSE_RESOURCE_CONTROL. - */ - String CHOOSE_RESOURCE_CONTROL = "choose-resource-control"; - - /** - * The constant TEXT_FIELD_IN_COMBO_BOX. - */ - String TEXT_FIELD_IN_COMBO_BOX = "text-field-in-combo-box"; - /** - * The constant TRANSPARENT_SPINNER. - */ - String TRANSPARENT_SPINNER = "transparent-spinner"; - /** - * The constant TRANSPARENT_TEXT_FIELD. - */ - String TRANSPARENT_TEXT_FIELD = "transparent-text-field"; - /** - * The constant TRANSPARENT_TREE_VIEW. - */ - String TRANSPARENT_TREE_VIEW = "transparent-tree-view"; - /** - * The constant TRANSPARENT_LIST_VIEW. - */ - String TRANSPARENT_LIST_VIEW = "transparent-list-view"; - /** - * The constant TRANSPARENT_LIST_CELL. - */ - String TRANSPARENT_LIST_CELL = "transparent-list-cell"; - /** - * The constant TRANSPARENT_COMBO_BOX. - */ - String TRANSPARENT_COMBO_BOX = "transparent-combo-box"; - /** - * The constant TRANSPARENT_TEXT_AREA. - */ - String TRANSPARENT_TEXT_AREA = "transparent-text-area"; - - /** - * The constant BUTTON_WITHOUT_LEFT_BORDER. - */ - String BUTTON_WITHOUT_LEFT_BORDER = "button-without-left-border"; - /** - * The constant BUTTON_WITHOUT_LEFT_RIGHT_BORDER. - */ - String BUTTON_WITHOUT_LEFT_RIGHT_BORDER = "button-without-left-right-border"; - /** - * The constant BUTTON_WITHOUT_RIGHT_BORDER. - */ - String BUTTON_WITHOUT_RIGHT_BORDER = "button-without-right-border"; - - /** - * The constant PROCESSING_COMPONENT_CONTAINER. - */ - String PROCESSING_COMPONENT_CONTAINER = "processing-component-container"; - /** - * The constant PROCESSING_COMPONENT_TERRAIN_EDITOR. - */ - String PROCESSING_COMPONENT_TERRAIN_EDITOR = "processing-component-terrain-editor"; - /** - * The constant PROCESSING_COMPONENT_TERRAIN_EDITOR_TEXTURE_LAYER. - */ - String PROCESSING_COMPONENT_TERRAIN_EDITOR_TEXTURE_LAYER = "processing-component-terrain-layer"; - /** - * The constant TERRAIN_EDITING_TEXTURE_LAYERS_SETTINGS_BUTTONS. - */ - String PROCESSING_COMPONENT_TERRAIN_EDITOR_LAYERS_SETTINGS_BUTTONS = "processing-component-terrain-texture-layers-settings-buttons"; - - /** - * The constant LIST_VIEW_WITHOUT_SCROLL. - */ - String LIST_VIEW_WITHOUT_SCROLL = "list-view-without-scroll"; - - /** - * The constant FLAT_BUTTON. - */ - String FLAT_BUTTON = "flat-button"; - /** - * The constant INPUT_CONTROL_TOOLBAR_BUTTON. - */ - String INPUT_CONTROL_TOOLBAR_BUTTON = "input-control-toolbar-button"; - /** - * The constant FILE_EDITOR_TOOLBAR_BUTTON. - */ - String FILE_EDITOR_TOOLBAR_BUTTON = "file-editor-toolbar-button"; - /** - * The constant FILE_EDITOR_TOOLBAR_LABEL. - */ - String FILE_EDITOR_TOOLBAR_LABEL = "file-editor-toolbar-label"; - /** - * The constant FILE_EDITOR_TOOLBAR_FIELD. - */ - String FILE_EDITOR_TOOLBAR_FIELD = "file-editor-toolbar-field"; - - /** - * The constant FILE_EDITOR_TOOLBAR. - */ - String FILE_EDITOR_TOOLBAR = "file-editor-toolbar"; - /** - * The constant FILE_EDITOR_EDITOR_AREA. - */ - String FILE_EDITOR_EDITOR_AREA = "file-editor-editor-area"; - /** - * The constant FILE_EDITOR_MAIN_SPLIT_PANE. - */ - String FILE_EDITOR_MAIN_SPLIT_PANE = "file-editor-main-split-pane"; - /** - * The constant FILE_EDITOR_TOOL_SPLIT_PANE. - */ - String FILE_EDITOR_TOOL_SPLIT_PANE = "file-editor-tool-split-pane"; - /** - * The constant FILE_EDITOR_TOOL_COMPONENT. - */ - String FILE_EDITOR_TOOL_COMPONENT = "file-editor-tool-component"; - - /** - * The constant MEDIUM_TOGGLE_BUTTON. - */ - String MEDIUM_TOGGLE_BUTTON = "medium-toggle-button"; - - /** - * The constant MATERIAL_FILE_EDITOR_PROPERTIES_COMPONENT. - */ - String MATERIAL_FILE_EDITOR_PROPERTIES_COMPONENT = "material-file-editor-properties-component"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL = "material-file-editor-param-control"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL_NAME. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL_NAME = "material-file-editor-param-control-name"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL_TEXTURE_PREVIEW. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL_TEXTURE_PREVIEW = "material-file-editor-param-control-texture-preview"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL_BUTTON. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL_BUTTON = "material-file-editor-param-control-button"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL_COLOR_PICKER. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL_COLOR_PICKER = "material-file-editor-param-control-color-picker"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL_CHECKBOX. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL_CHECKBOX = "material-file-editor-param-control-checkbox"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL_SPINNER. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL_SPINNER = "MaterialParamControlSpinner"; - /** - * The constant MATERIAL_FILE_EDITOR_PARAM_CONTROL_COMBO_BOX. - */ - String MATERIAL_FILE_EDITOR_PARAM_CONTROL_COMBO_BOX = "material-file-editor-param-control-combo-box"; - - /** - * The constant SCENE_EDITOR_STATS_CONTAINER. - */ - String SCENE_EDITOR_STATS_CONTAINER = "scene-editor-stats-container"; - - /** - * The constant ABSTRACT_NODE_TREE_CONTAINER. - */ - String ABSTRACT_NODE_TREE_CONTAINER = "abstract-node-tree-container"; - /** - * The constant ABSTRACT_NODE_TREE_CELL. - */ - String ABSTRACT_NODE_TREE_CELL = "abstract-node-tree-cell"; - - /** - * The constant ABSTRACT_PARAM_CONTROL_CONTAINER. - */ - String ABSTRACT_PARAM_CONTROL_CONTAINER = "abstract-param-control-container"; - /** - * The constant ABSTRACT_PARAM_CONTROL_CONTAINER_SPLIT_LINE. - */ - String ABSTRACT_PARAM_CONTROL_CONTAINER_SPLIT_LINE = "abstract-param-control-container-split-line"; - /** - * The constant ABSTRACT_PARAM_CONTROL. - */ - String ABSTRACT_PARAM_CONTROL = "abstract-param-control"; - /** - * The constant ABSTRACT_PARAM_EDITOR_CONTROL. - */ - String ABSTRACT_PARAM_EDITOR_CONTROL = "abstract-param-editor-control"; - /** - * The constant ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW. - */ - String ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW = "abstract-param-control-param-name-single-row"; - /** - * The constant ABSTRACT_PARAM_CONTROL_PARAM_NAME. - */ - String ABSTRACT_PARAM_CONTROL_PARAM_NAME = "abstract-param-control-param-name"; - /** - * The constant ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL. - */ - String ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL = "abstract-param-control-element-label"; - /** - * The constant ABSTRACT_PARAM_CONTROL_PREVIEW_CONTAINER. - */ - String ABSTRACT_PARAM_CONTROL_PREVIEW_CONTAINER = "abstract-param-control-preview-container"; - /** - * The constant ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER. - */ - String ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER = "abstract-param-control-input-container"; - /** - * The constant ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER. - */ - String ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER = "abstract-param-control-short-input-container"; - /** - * The constant ABSTRACT_PARAM_CONTROL_CHECK_BOX. - */ - String ABSTRACT_PARAM_CONTROL_CHECK_BOX = "abstract-param-control-checkbox"; - /** - * The constant ABSTRACT_PARAM_CONTROL_COLOR_PICKER. - */ - String ABSTRACT_PARAM_CONTROL_COLOR_PICKER = "abstract-param-control-param-color-picker"; - /** - * The constant ABSTRACT_PARAM_CONTROL_COMBO_BOX. - */ - String ABSTRACT_PARAM_CONTROL_COMBO_BOX = "abstract-param-control-combobox"; - /** - * The constant ABSTRACT_PARAM_CONTROL_VECTOR2F_FIELD. - */ - String ABSTRACT_PARAM_CONTROL_VECTOR2F_FIELD = "abstract-param-control-vector2f-field"; - /** - * The constant ABSTRACT_PARAM_CONTROL_VECTOR3F_FIELD. - */ - String ABSTRACT_PARAM_CONTROL_VECTOR3F_FIELD = "abstract-param-control-vector3f-field"; - /** - * The constant ABSTRACT_PARAM_CONTROL_LABEL_VALUE. - */ - String ABSTRACT_PARAM_CONTROL_LABEL_VALUE = "abstract-param-control-label-value"; - /** - * The constant ABSTRACT_PARAM_CONTROL_NUMBER_LABEL. - */ - String ABSTRACT_PARAM_CONTROL_NUMBER_LABEL = "abstract-param-control-number-label"; - /** - * The constant ABSTRACT_PARAM_CONTROL_INFLUENCER. - */ - String ABSTRACT_PARAM_CONTROL_INFLUENCER = "abstract-param-control-influencer"; - /** - * The constant ABSTRACT_PARAM_CONTROL_INFLUENCER_ELEMENT. - */ - String ABSTRACT_PARAM_CONTROL_INFLUENCER_ELEMENT = "abstract-param-control-influencer-element"; - /** - * The constant ABSTRACT_RESOURCE_PROPERTY_CONTROL. - */ - String ABSTRACT_RESOURCE_PROPERTY_CONTROL = "abstract-resource-property-control"; - - /** - * The constant EDITOR_SCRIPTING_COMPONENT. - */ - String EDITOR_SCRIPTING_COMPONENT = "editor-scripting-component"; - /** - * The constant GROOVY_EDITOR_COMPONENT. - */ - String GROOVY_EDITOR_COMPONENT = "groovy-editor-component"; - - /** - * The constant SCENE_APP_STATE_CONTAINER. - */ - String SCENE_APP_STATE_CONTAINER = "scene-app-state-container"; - /** - * The constant SCENE_APP_STATE_LIST_CELL. - */ - String SCENE_APP_STATE_LIST_CELL = "scene-app-state-list-cell"; - - /** - * The constant SCENE_FILTER_CONTAINER. - */ - String SCENE_FILTER_CONTAINER = "scene-filter-container"; - /** - * The constant SCENE_FILTER_LIST_CELL. - */ - String SCENE_FILTER_LIST_CELL = "scene-filter-list-cell"; - - /** - * The constant SETTINGS_DIALOG. - */ - String SETTINGS_DIALOG = "settings-dialog"; - /** - * The constant SETTINGS_DIALOG_LABEL. - */ - String SETTINGS_DIALOG_LABEL = "settings-dialog-label"; - /** - * The constant SETTINGS_DIALOG_FIELD. - */ - String SETTINGS_DIALOG_FIELD = "settings-dialog-field"; - /** - * The constant SETTINGS_DIALOG_SHORT_LABEL. - */ - String SETTINGS_DIALOG_SHORT_LABEL = "settings-dialog-short-label"; - /** - * The constant SETTINGS_DIALOG_MESSAGE_LABEL. - */ - String SETTINGS_DIALOG_MESSAGE_LABEL = "settings-dialog-message-label"; - - /** - * The constant CONFIRM_DIALOG. - */ - String CONFIRM_DIALOG = "confirm-dialog"; - - /** - * The constant CREATE_SKY_DIALOG. - */ - String CREATE_SKY_DIALOG = "create-sky-dialog"; - - /** - * The constant ABOUT_DIALOG. - */ - String ABOUT_DIALOG = "about-dialog"; - /** - * The constant ABOUT_DIALOG_LONG_LABEL. - */ - String ABOUT_DIALOG_LONG_LABEL = "about-dialog-long-label"; - /** - * The constant ABOUT_DIALOG_TITLE_LABEL. - */ - String ABOUT_DIALOG_TITLE_LABEL = "about-dialog-title-label"; - - /** - * The constant FILE_CREATOR_DIALOG. - */ - String FILE_CREATOR_DIALOG = "file-creator-dialog"; - - /** - * The constant SAVE_AS_DIALOG. - */ - String SAVE_AS_DIALOG = "save-as-dialog"; - - /** - * The constant GENERATE_LOD_DIALOG. - */ - String GENERATE_LOD_DIALOG = "generate-lod-dialog"; - /** - * The constant PLUGINS_DIALOG. - */ - String PLUGINS_DIALOG = "plugins-dialog"; - - /** - * The constant CREATE_TERRAIN_DIALOG. - */ - String CREATE_TERRAIN_DIALOG = "create-terrain-dialog"; - - /** - * The constant NODE_SELECTOR_DIALOG. - */ - String NODE_SELECTOR_DIALOG = "node-selector-dialog"; - - /** - * The constant ASSET_EDITOR_DIALOG. - */ - String ASSET_EDITOR_DIALOG = "asset-editor-dialog"; - /** - * The constant ASSET_EDITOR_DIALOG_ACTIONS. - */ - String ASSET_EDITOR_DIALOG_ACTIONS = "asset-editor-dialog-actions"; - /** - * The constant ASSET_EDITOR_DIALOG_PREVIEW_CONTAINER. - */ - String ASSET_EDITOR_DIALOG_PREVIEW_CONTAINER = "asset-editor-dialog-preview-container"; - - /** - * The constant OPEN_EXTERNAL_FOLDER_EDITOR_DIALOG. - */ - String OPEN_EXTERNAL_FOLDER_EDITOR_DIALOG = "open-external-folder-editor-dialog"; - - /** - * The constant AUDIO_VIEW_EDITOR_CONTAINER. - */ - String AUDIO_VIEW_EDITOR_CONTAINER = "audio-view-editor-container"; - - /** - * The constant TEXT_EDITOR_TEXT_AREA. - */ - String TEXT_EDITOR_TEXT_AREA = "text-editor-text-area"; - - /** - * The constant IMAGE_VIEW_EDITOR_CONTAINER. - */ - String IMAGE_VIEW_EDITOR_CONTAINER = "image-view-editor-container"; - - /** - * The constant PHYSICS_NODE_LIST_CONTROL. - */ - String PHYSICS_NODE_LIST_CONTROL = "physics-node-list-control"; - - /** - * The constant CUSTOM_TOOLTIP. - */ - String CUSTOM_TOOLTIP = "custom-tooltip"; - - /** - * The constant IMAGE_CHANNEL_PREVIEW. - */ - String IMAGE_CHANNEL_PREVIEW = "image-channel-preview"; - - /** - * The constant IMAGE_PREVIEW. - */ - String IMAGE_PREVIEW = "image-preview"; - - /** - * The constant PLUGIN_LIST_CELL. - */ - String PLUGIN_LIST_CELL = "plugin-list-cell"; - - /** - * The constant STATS_3D_STATE. - */ - String STATS_3D_STATE = "stats-3dstate"; + @NotNull String SPECIAL_FONT_13 = "special-font-13"; + @NotNull String SPECIAL_FONT_14 = "special-font-14"; + @NotNull String SPECIAL_FONT_16 = "special-font-16"; + @NotNull String MAIN_SPLIT_PANEL = "main-split-pane"; + + @NotNull String DEF_HBOX = "hbox"; + @NotNull String DEF_VBOX = "vbox"; + @NotNull String DEF_GRID_PANE = "grid-pane"; + @NotNull String DEF_STACK_PANE = "stack-pane"; + @NotNull String DEF_BORDER_PANE = "border-pane"; + + @NotNull String DIALOG_ROOT = "dialog-root"; + @NotNull String DIALOG_ACTIONS_ROOT = "dialog-actions-root"; + @NotNull String DIALOG_CONTENT_ROOT = "dialog-content-root"; + @NotNull String DIALOG_BUTTON = "dialog-button"; + @NotNull String DIALOG_LABEL_WARNING = "dialog-label-warning"; + @NotNull String DIALOG_DYNAMIC_LABEL = "dialog-dynamic-label"; + @NotNull String DIALOG_FIELD = "dialog-field"; + + @NotNull String TEXT_INPUT_CONTAINER = "text-input-container"; + + @NotNull String TEXT_INPUT_CONTAINER_WITHOUT_PADDING = "text-input-container-without-padding"; + + @NotNull String CHOOSE_TEXTURE_CONTROL = "choose-texture-control"; + @NotNull String CHOOSE_TEXTURE_CONTROL_TEXTURE_LABEL = "choose-texture-control-texture-label"; + @NotNull String CHOOSE_TEXTURE_CONTROL_PREVIEW = "choose-texture-control-preview"; + + @NotNull String CHOOSE_RESOURCE_CONTROL = "choose-resource-control"; + + @NotNull String TEXT_FIELD_IN_COMBO_BOX = "text-field-in-combo-box"; + @NotNull String TRANSPARENT_SPINNER = "transparent-spinner"; + @NotNull String TRANSPARENT_TEXT_FIELD = "transparent-text-field"; + @NotNull String TRANSPARENT_TREE_VIEW = "transparent-tree-view"; + @NotNull String TRANSPARENT_LIST_VIEW = "transparent-list-view"; + @NotNull String TRANSPARENT_LIST_CELL = "transparent-list-cell"; + @NotNull String TRANSPARENT_COMBO_BOX = "transparent-combo-box"; + @NotNull String TRANSPARENT_TEXT_AREA = "transparent-text-area"; + + @NotNull String BUTTON_WITHOUT_LEFT_BORDER = "button-without-left-border"; + @NotNull String BUTTON_WITHOUT_LEFT_RIGHT_BORDER = "button-without-left-right-border"; + @NotNull String BUTTON_WITHOUT_RIGHT_BORDER = "button-without-right-border"; + + @NotNull String PROCESSING_COMPONENT_CONTAINER = "processing-component-container"; + @NotNull String PROCESSING_COMPONENT_TERRAIN_EDITOR = "processing-component-terrain-editor"; + @NotNull String PROCESSING_COMPONENT_TERRAIN_EDITOR_TEXTURE_LAYER = "processing-component-terrain-layer"; + @NotNull String PROCESSING_COMPONENT_TERRAIN_EDITOR_LAYERS_SETTINGS_BUTTONS = "processing-component-terrain-texture-layers-settings-buttons"; + + @NotNull String LIST_VIEW_WITHOUT_SCROLL = "list-view-without-scroll"; + + @NotNull String FLAT_BUTTON = "flat-button"; + @NotNull String INPUT_CONTROL_TOOLBAR_BUTTON = "input-control-toolbar-button"; + @NotNull String FILE_EDITOR_TOOLBAR_BUTTON = "file-editor-toolbar-button"; + @NotNull String FILE_EDITOR_TOOLBAR_LABEL = "file-editor-toolbar-label"; + @NotNull String FILE_EDITOR_TOOLBAR_FIELD = "file-editor-toolbar-field"; + + @NotNull String FILE_EDITOR_TOOLBAR = "file-editor-toolbar"; + @NotNull String FILE_EDITOR_EDITOR_AREA = "file-editor-editor-area"; + @NotNull String FILE_EDITOR_MAIN_SPLIT_PANE = "file-editor-main-split-pane"; + @NotNull String FILE_EDITOR_TOOL_SPLIT_PANE = "file-editor-tool-split-pane"; + @NotNull String FILE_EDITOR_TOOL_COMPONENT = "file-editor-tool-component"; + + @NotNull String MEDIUM_TOGGLE_BUTTON = "medium-toggle-button"; + + @NotNull String MATERIAL_FILE_EDITOR_PROPERTIES_COMPONENT = "material-file-editor-properties-component"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL = "material-file-editor-param-control"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL_NAME = "material-file-editor-param-control-name"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL_TEXTURE_PREVIEW = "material-file-editor-param-control-texture-preview"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL_BUTTON = "material-file-editor-param-control-button"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL_COLOR_PICKER = "material-file-editor-param-control-color-picker"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL_CHECKBOX = "material-file-editor-param-control-checkbox"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL_SPINNER = "MaterialParamControlSpinner"; + @NotNull String MATERIAL_FILE_EDITOR_PARAM_CONTROL_COMBO_BOX = "material-file-editor-param-control-combo-box"; + + @NotNull String SCENE_EDITOR_STATS_CONTAINER = "scene-editor-stats-container"; + + @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 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 EDITOR_SCRIPTING_COMPONENT = "editor-scripting-component"; + @NotNull String GROOVY_EDITOR_COMPONENT = "groovy-editor-component"; + + @NotNull String SCENE_APP_STATE_CONTAINER = "scene-app-state-container"; + @NotNull String SCENE_APP_STATE_LIST_CELL = "scene-app-state-list-cell"; + + @NotNull String SCENE_FILTER_CONTAINER = "scene-filter-container"; + @NotNull String SCENE_FILTER_LIST_CELL = "scene-filter-list-cell"; + + @NotNull String SETTINGS_DIALOG = "settings-dialog"; + @NotNull String SETTINGS_DIALOG_LABEL = "settings-dialog-label"; + @NotNull String SETTINGS_DIALOG_FIELD = "settings-dialog-field"; + @NotNull String SETTINGS_DIALOG_SHORT_LABEL = "settings-dialog-short-label"; + @NotNull String SETTINGS_DIALOG_MESSAGE_LABEL = "settings-dialog-message-label"; + + @NotNull String CONFIRM_DIALOG = "confirm-dialog"; + + @NotNull String CREATE_SKY_DIALOG = "create-sky-dialog"; + + @NotNull String ABOUT_DIALOG = "about-dialog"; + @NotNull String ABOUT_DIALOG_LONG_LABEL = "about-dialog-long-label"; + @NotNull String ABOUT_DIALOG_TITLE_LABEL = "about-dialog-title-label"; + + @NotNull String FILE_CREATOR_DIALOG = "file-creator-dialog"; + + @NotNull String SAVE_AS_DIALOG = "save-as-dialog"; + + @NotNull String GENERATE_LOD_DIALOG = "generate-lod-dialog"; + @NotNull String PLUGINS_DIALOG = "plugins-dialog"; + + @NotNull String CREATE_TERRAIN_DIALOG = "create-terrain-dialog"; + + @NotNull String NODE_SELECTOR_DIALOG = "node-selector-dialog"; + + @NotNull String ASSET_EDITOR_DIALOG = "asset-editor-dialog"; + @NotNull String ASSET_EDITOR_DIALOG_ACTIONS = "asset-editor-dialog-actions"; + @NotNull String ASSET_EDITOR_DIALOG_PREVIEW_CONTAINER = "asset-editor-dialog-preview-container"; + + @NotNull String OPEN_EXTERNAL_FOLDER_EDITOR_DIALOG = "open-external-folder-editor-dialog"; + + @NotNull String AUDIO_VIEW_EDITOR_CONTAINER = "audio-view-editor-container"; + + @NotNull String TEXT_EDITOR_TEXT_AREA = "text-editor-text-area"; + + @NotNull String IMAGE_VIEW_EDITOR_CONTAINER = "image-view-editor-container"; + + @NotNull String PHYSICS_NODE_LIST_CONTROL = "physics-node-list-control"; + + @NotNull String CUSTOM_TOOLTIP = "custom-tooltip"; + + @NotNull String IMAGE_CHANNEL_PREVIEW = "image-channel-preview"; + + @NotNull String IMAGE_PREVIEW = "image-preview"; + + @NotNull String PLUGIN_LIST_CELL = "plugin-list-cell"; + + @NotNull String STATS_3D_STATE = "stats-3dstate"; } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/ui/css/CSSIds.java b/src/main/java/com/ss/editor/ui/css/CSSIds.java index 61b24d9c..9e3c93dc 100644 --- a/src/main/java/com/ss/editor/ui/css/CSSIds.java +++ b/src/main/java/com/ss/editor/ui/css/CSSIds.java @@ -1,5 +1,7 @@ package com.ss.editor.ui.css; +import org.jetbrains.annotations.NotNull; + /** * The list of css ids which used in the editor. * @@ -7,50 +9,20 @@ */ public interface CSSIds { - /** - * The constant ROOT. - */ - String ROOT = "Root"; - /** - * The constant ROOT_CONTAINER. - */ - String ROOT_CONTAINER = "RootContainer"; - - /** - * The constant EDITOR_MENU_BAR_COMPONENT. - */ - String EDITOR_MENU_BAR_COMPONENT = "EditorMenuBarComponent"; - - /** - * The constant EDITOR_AREA_COMPONENT. - */ - String EDITOR_AREA_COMPONENT = "EditorAreaComponent"; - - /** - * The constant GLOBAL_LEFT_TOOL_COMPONENT. - */ - String GLOBAL_LEFT_TOOL_COMPONENT = "GlobalLeftToolComponent"; - /** - * The constant GLOBAL_BOTTOM_TOOL_COMPONENT. - */ - String GLOBAL_BOTTOM_TOOL_COMPONENT = "GlobalBottomToolComponent"; - - /** - * The constant LOG_VIEW. - */ - String LOG_VIEW = "LogView"; - - /** - * The constant EDITOR_LOADING_LAYER. - */ - String EDITOR_LOADING_LAYER = "EditorLoadingLayer"; - /** - * The constant EDITOR_LOADING_PROGRESS. - */ - String EDITOR_LOADING_PROGRESS = "EditorLoadingProgress"; - - /** - * The constant ASSET_COMPONENT. - */ - String ASSET_COMPONENT = "AssetComponent"; + @NotNull String ROOT = "Root"; + @NotNull String ROOT_CONTAINER = "RootContainer"; + + @NotNull String EDITOR_MENU_BAR_COMPONENT = "EditorMenuBarComponent"; + + @NotNull String EDITOR_AREA_COMPONENT = "EditorAreaComponent"; + + @NotNull String GLOBAL_LEFT_TOOL_COMPONENT = "GlobalLeftToolComponent"; + @NotNull String GLOBAL_BOTTOM_TOOL_COMPONENT = "GlobalBottomToolComponent"; + + @NotNull String LOG_VIEW = "LogView"; + + @NotNull String EDITOR_LOADING_LAYER = "EditorLoadingLayer"; + @NotNull String EDITOR_LOADING_PROGRESS = "EditorLoadingProgress"; + + @NotNull String ASSET_COMPONENT = "AssetComponent"; } 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 49e9d39d..36071e93 100644 --- a/src/main/java/com/ss/editor/ui/css/CSSRegistry.java +++ b/src/main/java/com/ss/editor/ui/css/CSSRegistry.java @@ -1,10 +1,13 @@ package com.ss.editor.ui.css; +import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.annotation.FromAnyThread; import com.ss.rlib.util.array.Array; import com.ss.rlib.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; +import java.net.URL; + /** * The registry of available css files. * @@ -15,8 +18,8 @@ public class CSSRegistry { @NotNull private static final CSSRegistry INSTANCE = new CSSRegistry(); - @NotNull - public static CSSRegistry getInstance() { + @FromAnyThread + public static @NotNull CSSRegistry getInstance() { return INSTANCE; } @@ -33,11 +36,22 @@ private CSSRegistry() { /** * Add the CSS file to this registry. * - * @param cssFile the CSS file. + * @param cssFile the URL to the CSS file. + */ + @FromAnyThread + public void register(@NotNull final URL cssFile) { + availableCssFiles.add(cssFile.toExternalForm()); + } + + /** + * Add the CSS file to this registry. + * + * @param cssFile the path to CSS file. + * @param classLoader the class loader which can load this path. */ @FromAnyThread - public void register(@NotNull String cssFile) { - availableCssFiles.add(cssFile); + public void register(@NotNull final String cssFile, @NotNull final ClassLoader classLoader) { + register(notNull(classLoader.getResource(cssFile))); } /** @@ -45,8 +59,8 @@ public void register(@NotNull String cssFile) { * * @return the list of available css files. */ - @NotNull - public Array getAvailableCssFiles() { + @FromAnyThread + public @NotNull Array getAvailableCssFiles() { return availableCssFiles; } } diff --git a/src/main/java/com/ss/editor/ui/css/CssColorTheme.java b/src/main/java/com/ss/editor/ui/css/CssColorTheme.java index eb8da815..e3eb6304 100644 --- a/src/main/java/com/ss/editor/ui/css/CssColorTheme.java +++ b/src/main/java/com/ss/editor/ui/css/CssColorTheme.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.css; +import com.ss.editor.annotation.FromAnyThread; import javafx.scene.paint.Color; import org.jetbrains.annotations.NotNull; @@ -9,7 +10,7 @@ * @author JavaSaBr */ public enum CssColorTheme { - LIGHT("/ui/css/light-color.css", "White", Color.BLACK), + LIGHT("/ui/css/light-color.css", "White", Color.web("#5d626e")), SHADOW("/ui/css/shadow-color.css", "Shadow", Color.web("#c8d2e1")), DARK("/ui/css/dark-color.css", "Dark", Color.web("#c8dae2")),; @@ -48,30 +49,31 @@ public static CssColorTheme valueOf(final int index) { /** * @return the name of this theme. */ - @NotNull - public String getName() { + @FromAnyThread + public @NotNull String getName() { return name; } /** * @return the css file. */ - @NotNull - public String getCssFile() { + @FromAnyThread + public @NotNull String getCssFile() { return cssFile; } /** * @return the icon color. */ - @NotNull - public Color getIconColor() { + @FromAnyThread + public @NotNull Color getIconColor() { return iconColor; } /** * @return true if this theme is dark. */ + @FromAnyThread public boolean needRepaintIcons() { return true; } 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 301a5b51..cebef51e 100644 --- a/src/main/java/com/ss/editor/ui/dialog/AbstractSimpleEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/AbstractSimpleEditorDialog.java @@ -2,6 +2,7 @@ import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.ui.css.CSSClasses; import com.ss.editor.util.EditorUtil; @@ -97,6 +98,7 @@ protected boolean isReady() { } @Override + @FXThread protected void processKey(@NotNull final KeyEvent event) { super.processKey(event); final Button okButton = getOkButton(); @@ -106,6 +108,7 @@ protected void processKey(@NotNull final KeyEvent event) { } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); } @@ -115,6 +118,7 @@ protected void createContent(@NotNull final GridPane root) { * * @return the ok button. */ + @FXThread protected @Nullable Button getOkButton() { return okButton; } @@ -124,19 +128,19 @@ protected void createContent(@NotNull final GridPane root) { * * @return the close button. */ + @FXThread protected @Nullable Button getCloseButton() { return closeButton; } @Override + @FXThread protected void createActions(@NotNull final VBox root) { super.createActions(root); - HBox container = null; + final HBox container = new HBox(); - if (needCloseButton() || needOkButton()) { - container = new HBox(); - } + createBeforeActions(container); if (needOkButton()) { okButton = new Button(getButtonOkText()); @@ -160,12 +164,18 @@ protected void createActions(@NotNull final VBox root) { createAdditionalActions(container); - if (container != null) { + if (!container.getChildren().isEmpty()) { FXUtils.addToPane(container, root); FXUtils.addClassTo(container, CSSClasses.DEF_HBOX); } } + @FXThread + protected void createBeforeActions(@NotNull final HBox container) { + + } + + @FXThread protected void createAdditionalActions(@NotNull final HBox container) { } @@ -173,6 +183,7 @@ protected void createAdditionalActions(@NotNull final HBox container) { /** * @return true if need to add an ok button here. */ + @FromAnyThread protected boolean needOkButton() { return true; } @@ -180,10 +191,12 @@ protected boolean needOkButton() { /** * @return true if need to add a close button here. */ + @FromAnyThread protected boolean needCloseButton() { return true; } + @FXThread private void safeProcessOk() { try { processOk(); @@ -197,6 +210,7 @@ private void safeProcessOk() { * * @return the the button's close text. */ + @FromAnyThread protected @NotNull String getButtonCloseText() { return Messages.SIMPLE_DIALOG_BUTTON_CLOSE; } @@ -206,6 +220,7 @@ private void safeProcessOk() { * * @return the button's ok text. */ + @FromAnyThread protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_OK; } 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 e66799d7..5e2fd723 100644 --- a/src/main/java/com/ss/editor/ui/dialog/ConfirmDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/ConfirmDialog.java @@ -2,6 +2,8 @@ import static com.ss.rlib.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 javafx.scene.control.Button; @@ -38,12 +40,6 @@ public class ConfirmDialog extends AbstractSimpleEditorDialog { @Nullable private Label questionLabel; - /** - * Instantiates a new Confirm dialog. - * - * @param handler the handler - * @param question the question - */ public ConfirmDialog(@NotNull final Consumer<@Nullable Boolean> handler, @NotNull final String question) { this.handler = handler; final Label questionLabel = getQuestionLabel(); @@ -53,16 +49,19 @@ public ConfirmDialog(@NotNull final Consumer<@Nullable Boolean> handler, @NotNul /** * @return the label. */ + @FromAnyThread private @NotNull Label getQuestionLabel() { return notNull(questionLabel); } @Override + @FromAnyThread protected @NotNull String getTitleText() { return Messages.QUESTION_DIALOG_TITLE; } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -74,16 +73,19 @@ protected void createContent(@NotNull final VBox root) { } @Override + @FromAnyThread protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_YES; } @Override + @FromAnyThread protected @NotNull String getButtonCloseText() { return Messages.SIMPLE_DIALOG_BUTTON_NO; } @Override + @FXThread protected void processKey(@NotNull final KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { processClose(); @@ -91,12 +93,14 @@ protected void processKey(@NotNull final KeyEvent event) { } @Override + @FXThread protected void processOk() { super.processOk(); handler.accept(Boolean.TRUE); } @Override + @FXThread protected void processClose() { super.processClose(); handler.accept(Boolean.FALSE); @@ -111,11 +115,13 @@ protected void processCancel() { } @Override + @FromAnyThread protected @NotNull Point getSize() { return DIALOG_SIZE; } @Override + @FXThread protected void createAdditionalActions(@NotNull final HBox container) { super.createAdditionalActions(container); 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 cac193b9..766a04f0 100644 --- a/src/main/java/com/ss/editor/ui/dialog/EditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/EditorDialog.java @@ -125,6 +125,7 @@ public EditorDialog() { /** * @return true if this dialog should be resizable. */ + @FromAnyThread protected boolean isResizable() { return true; } @@ -324,6 +325,7 @@ public void show(@NotNull final Window owner) { * * @return the dialog id */ + @FromAnyThread protected @NotNull String getDialogId() { return getClass().getSimpleName(); } 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 d1845313..f8ea855d 100644 --- a/src/main/java/com/ss/editor/ui/dialog/RenameDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/RenameDialog.java @@ -2,6 +2,8 @@ import static com.ss.rlib.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 javafx.scene.control.Button; @@ -45,6 +47,7 @@ public class RenameDialog extends AbstractSimpleEditorDialog { private TextField nameField; @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -63,19 +66,21 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @Override + @FXThread public void show(@NotNull final Window owner) { super.show(owner); EXECUTOR_MANAGER.addFXTask(() -> getNameField().requestFocus()); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.RENAME_DIALOG_TITLE; } @@ -84,6 +89,7 @@ protected String getTitleText() { * * @param initName the initial name. */ + @FXThread public void setInitName(@NotNull final String initName) { final TextField nameField = getNameField(); nameField.setText(initName); @@ -92,16 +98,16 @@ public void setInitName(@NotNull final String initName) { /** * @return the text field. */ - @NotNull - private TextField getNameField() { + @FXThread + private @NotNull TextField getNameField() { return notNull(nameField); } /** * @return the function for validation name. */ - @Nullable - private Function getValidator() { + @FXThread + private @Nullable Function getValidator() { return validator; } @@ -110,6 +116,7 @@ private Function getValidator() { * * @param validator the function for validation name. */ + @FXThread public void setValidator(@Nullable final Function validator) { this.validator = validator; } @@ -117,8 +124,8 @@ public void setValidator(@Nullable final Function validator) { /** * @return the function for handling a new name. */ - @Nullable - private Consumer getHandler() { + @FXThread + private @Nullable Consumer getHandler() { return handler; } @@ -127,6 +134,7 @@ private Consumer getHandler() { * * @param handler the function for handling a new name. */ + @FXThread public void setHandler(@Nullable final Consumer handler) { this.handler = handler; } @@ -134,21 +142,22 @@ public void setHandler(@Nullable final Consumer handler) { /** * Validate a new name. */ + @FXThread private void validateName(@NotNull final String name) { final Function validator = getValidator(); final Button okButton = getOkButton(); okButton.setDisable(!(validator == null || validator.apply(name))); } - @NotNull @Override - protected String getButtonCloseText() { + @FromAnyThread + protected @NotNull String getButtonCloseText() { return Messages.SIMPLE_DIALOG_BUTTON_CANCEL; } - @NotNull @Override - protected String getButtonOkText() { + @FromAnyThread + protected @NotNull String getButtonOkText() { return Messages.RENAME_DIALOG_BUTTON_OK; } @@ -156,6 +165,7 @@ protected String getButtonOkText() { * Finish this dialog. */ @Override + @FXThread protected void processOk() { super.processOk(); @@ -166,9 +176,9 @@ protected void processOk() { handler.accept(nameField.getText()); } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } 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 54992b0f..45874121 100644 --- a/src/main/java/com/ss/editor/ui/dialog/SettingsDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/SettingsDialog.java @@ -9,6 +9,8 @@ import com.ss.editor.Editor; import com.ss.editor.JFXApplication; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.manager.ClasspathManager; import com.ss.editor.manager.ExecutorManager; @@ -241,6 +243,7 @@ public SettingsDialog() { } @Override + @FXThread public void show(@NotNull final Window owner) { super.show(owner); setIgnoreListeners(true); @@ -255,6 +258,7 @@ public void show(@NotNull final Window owner) { /** * @param ignoreListeners the flag of ignoring listeners. */ + @FXThread private void setIgnoreListeners(final boolean ignoreListeners) { this.ignoreListeners = ignoreListeners; } @@ -262,11 +266,13 @@ private void setIgnoreListeners(final boolean ignoreListeners) { /** * @return true of the listeners are ignored. */ + @FXThread private boolean isIgnoreListeners() { return ignoreListeners; } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -322,6 +328,7 @@ protected void createContent(@NotNull final VBox root) { /** * Create the libraries folder control. */ + @FXThread private void createLibrariesFolderControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -360,6 +367,7 @@ private void createLibrariesFolderControl(@NotNull final VBox root) { /** * Create the classes folder control. */ + @FXThread private void createClassesFolderControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -398,6 +406,7 @@ private void createClassesFolderControl(@NotNull final VBox root) { /** * Create the additional envs control. */ + @FXThread private void createAdditionalEnvsControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -436,6 +445,7 @@ private void createAdditionalEnvsControl(@NotNull final VBox root) { /** * Process of removing the additional classpath. */ + @FXThread private void processRemoveLibrariesFolder() { setLibrariesFolder(null); @@ -446,6 +456,7 @@ private void processRemoveLibrariesFolder() { /** * Process of removing the additional classpath. */ + @FXThread private void processRemoveClassesFolder() { setClassesFolder(null); @@ -456,6 +467,7 @@ private void processRemoveClassesFolder() { /** * Process of removing the additional envs. */ + @FXThread private void processRemoveEF() { setAdditionalEnvsFolder(null); @@ -466,30 +478,31 @@ private void processRemoveEF() { /** * @return the libraries folder field. */ - @NotNull - private TextField getLibrariesFolderField() { + @FXThread + private @NotNull TextField getLibrariesFolderField() { return notNull(librariesFolderField); } /** * @return the classes folder field. */ - @NotNull - private TextField getClassesFolderField() { + @FXThread + private @NotNull TextField getClassesFolderField() { return notNull(classesFolderField); } /** * @return the additional envs field. */ - @NotNull - private TextField getAdditionalEnvsField() { + @FXThread + private @NotNull TextField getAdditionalEnvsField() { return notNull(additionalEnvsField); } /** * Add a new libraries folder. */ + @FXThread private void processAddLibrariesFolder() { final CheckBox checkBox = getNativeFileChooserCheckBox(); @@ -525,6 +538,7 @@ private void processAddLibrariesFolder() { /** * Add a new classes folder. */ + @FXThread private void processAddClassesFolder() { final CheckBox checkBox = getNativeFileChooserCheckBox(); @@ -560,6 +574,7 @@ private void processAddClassesFolder() { /** * Process of adding the additional envs. */ + @FXThread private void processAddEF() { final CheckBox checkBox = getNativeFileChooserCheckBox(); @@ -595,6 +610,7 @@ private void processAddEF() { /** * Create gamma correction control. */ + @FXThread private void createGammaCorrectionControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -616,6 +632,7 @@ private void createGammaCorrectionControl(@NotNull final VBox root) { /** * Create tonemap filter control. */ + @FXThread private void createToneMapFilterControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -637,6 +654,7 @@ private void createToneMapFilterControl(@NotNull final VBox root) { /** * Create white point control. */ + @FXThread private void createToneMapFilterWhitePointControl(@NotNull final VBox root) { final CheckBox filterCheckBox = getToneMapFilterCheckBox(); @@ -708,6 +726,7 @@ private void createToneMapFilterWhitePointControl(@NotNull final VBox root) { /** * The process of scrolling. */ + @FXThread private void processScroll(@NotNull final Spinner spinner, @NotNull final ScrollEvent event) { if (!event.isControlDown()) return; @@ -723,6 +742,7 @@ private void processScroll(@NotNull final Spinner spinner, @NotNull fina /** * Create FXAA control. */ + @FXThread private void createFXAAControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -744,6 +764,7 @@ private void createFXAAControl(@NotNull final VBox root) { /** * Create native file chooser control. */ + @FXThread private void createNativeFileChooserControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -765,6 +786,7 @@ private void createNativeFileChooserControl(@NotNull final VBox root) { /** * Create stop render control. */ + @FXThread private void createStopRenderControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -786,6 +808,7 @@ private void createStopRenderControl(@NotNull final VBox root) { /** * Create the checkbox for configuring enabling google analytics. */ + @FXThread private void createGoogleAnalyticsControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -807,6 +830,7 @@ private void createGoogleAnalyticsControl(@NotNull final VBox root) { /** * Create the checkbox for configuring auto tangent generating. */ + @FXThread private void createAutoTangentGeneratingControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -828,6 +852,7 @@ private void createAutoTangentGeneratingControl(@NotNull final VBox root) { /** * Create the checkbox for configuring using flip textures by default. */ + @FXThread private void createUseFlippedTextureDefaultControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -849,6 +874,7 @@ private void createUseFlippedTextureDefaultControl(@NotNull final VBox root) { /** * Create the checkbox for configuring enabling camera lamp by default. */ + @FXThread private void createDefaultCameraLampEnabledControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -870,6 +896,7 @@ private void createDefaultCameraLampEnabledControl(@NotNull final VBox root) { /** * Create the anisotropy control */ + @FXThread private void createAnisotropyControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -897,6 +924,7 @@ private void createAnisotropyControl(@NotNull final VBox root) { /** * Create the theme control */ + @FXThread private void createThemeControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -924,6 +952,7 @@ private void createThemeControl(@NotNull final VBox root) { /** * Create the open GL control */ + @FXThread private void createOpenGLControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -951,6 +980,7 @@ private void createOpenGLControl(@NotNull final VBox root) { /** * Create the frame rate control. */ + @FXThread private void createFrameRateControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -974,6 +1004,7 @@ private void createFrameRateControl(@NotNull final VBox root) { /** * Create the camera angle control. */ + @FXThread private void createCameraAngleControl(@NotNull final VBox root) { final HBox container = new HBox(); @@ -997,6 +1028,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the gamma correction checkbox. */ + @FXThread private @NotNull CheckBox getGammaCorrectionCheckBox() { return notNull(gammaCorrectionCheckBox); } @@ -1004,6 +1036,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the tone map filter checkbox. */ + @FXThread private @NotNull CheckBox getToneMapFilterCheckBox() { return notNull(toneMapFilterCheckBox); } @@ -1011,6 +1044,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the white point X. */ + @FXThread private @NotNull Spinner getToneMapFilterWhitePointX() { return notNull(toneMapFilterWhitePointX); } @@ -1018,6 +1052,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the white point Y. */ + @FXThread private @NotNull Spinner getToneMapFilterWhitePointY() { return notNull(toneMapFilterWhitePointY); } @@ -1025,6 +1060,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the white point Z. */ + @FXThread private @NotNull Spinner getToneMapFilterWhitePointZ() { return notNull(toneMapFilterWhitePointZ); } @@ -1032,6 +1068,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the FXAA checkbox. */ + @FXThread private @NotNull CheckBox getFXAAFilterCheckBox() { return notNull(fxaaFilterCheckBox); } @@ -1039,6 +1076,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the checkbox to enable using native file choosers. */ + @FXThread private @NotNull CheckBox getNativeFileChooserCheckBox() { return notNull(nativeFileChooserCheckBox); } @@ -1046,6 +1084,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the Stop Render On Lost Focus checkbox. */ + @FXThread private @NotNull CheckBox getStopRenderOnLostFocusCheckBox() { return notNull(stopRenderOnLostFocusCheckBox); } @@ -1053,6 +1092,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the list with anisotropy levels. */ + @FXThread private @NotNull ComboBox getAnisotropyComboBox() { return notNull(anisotropyComboBox); } @@ -1060,6 +1100,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return The frame rate field. */ + @FXThread private @NotNull IntegerTextField getFrameRateField() { return notNull(frameRateField); } @@ -1067,6 +1108,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the camera angle field. */ + @FXThread private @NotNull IntegerTextField getCameraAngleField() { return notNull(cameraAngleField); } @@ -1074,6 +1116,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the checkbox for enabling auto tangent generating. */ + @FXThread private @NotNull CheckBox getAutoTangentGeneratingCheckBox() { return notNull(autoTangentGeneratingCheckBox); } @@ -1081,6 +1124,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the checkbox for enabling camera lamp by default. */ + @FXThread private @NotNull CheckBox getDefaultCameraLampEnabledCheckBox() { return notNull(defaultCameraLampEnabledCheckBox); } @@ -1088,6 +1132,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the checkbox for enabling use flip texture by default. */ + @FXThread private @NotNull CheckBox getDefaultUseFlippedTextureCheckBox() { return notNull(defaultUseFlippedTextureCheckBox); } @@ -1095,6 +1140,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the checkbox for enabling google analytics. */ + @FXThread private @NotNull CheckBox getGoogleAnalyticsCheckBox() { return notNull(googleAnalyticsCheckBox); } @@ -1102,6 +1148,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * @return the message label. */ + @FXThread private @NotNull Label getMessageLabel() { return notNull(messageLabel); } @@ -1109,6 +1156,7 @@ private void createCameraAngleControl(@NotNull final VBox root) { /** * Validate changes. */ + @FXThread private void validate() { if (isIgnoreListeners()) return; @@ -1154,6 +1202,7 @@ private void validate() { /** * Load current settings. */ + @FXThread private void load() { final EditorConfig editorConfig = EditorConfig.getInstance(); @@ -1242,6 +1291,7 @@ private void load() { /** * @return the list with themes. */ + @FXThread private @NotNull ComboBox getThemeComboBox() { return notNull(themeComboBox); } @@ -1249,6 +1299,7 @@ private void load() { /** * @return the list with open GL versions. */ + @FXThread private @NotNull ComboBox getOpenGLVersionComboBox() { return notNull(openGLVersionComboBox); } @@ -1256,6 +1307,7 @@ private void load() { /** * @return the libraries folder. */ + @FXThread private @Nullable Path getLibrariesFolder() { return librariesFolder; } @@ -1263,6 +1315,7 @@ private void load() { /** * @return the classes folder. */ + @FXThread private @Nullable Path getClassesFolder() { return classesFolder; } @@ -1270,6 +1323,7 @@ private void load() { /** * @param librariesFolder the libraries folder. */ + @FXThread private void setLibrariesFolder(@Nullable final Path librariesFolder) { this.librariesFolder = librariesFolder; } @@ -1277,6 +1331,7 @@ private void setLibrariesFolder(@Nullable final Path librariesFolder) { /** * @param classesFolder the classes folder. */ + @FXThread private void setClassesFolder(@Nullable final Path classesFolder) { this.classesFolder = classesFolder; } @@ -1284,6 +1339,7 @@ private void setClassesFolder(@Nullable final Path classesFolder) { /** * @param additionalEnvsFolder the additional envs folder. */ + @FXThread private void setAdditionalEnvsFolder(@Nullable final Path additionalEnvsFolder) { this.additionalEnvsFolder = additionalEnvsFolder; } @@ -1291,11 +1347,13 @@ private void setAdditionalEnvsFolder(@Nullable final Path additionalEnvsFolder) /** * @return the additional envs folder. */ + @FXThread private @Nullable Path getAdditionalEnvsFolder() { return additionalEnvsFolder; } @Override + @FXThread protected void createActions(@NotNull final VBox root) { super.createActions(root); @@ -1318,6 +1376,7 @@ protected void createActions(@NotNull final VBox root) { /** * Save new settings. */ + @FXThread private void processOk() { int needRestart = 0; @@ -1458,11 +1517,13 @@ private void processOk() { } @Override + @FromAnyThread protected @NotNull String getTitleText() { return Messages.SETTINGS_DIALOG_TITLE; } @Override + @FromAnyThread protected @NotNull Point getSize() { return DIALOG_SIZE; } 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 2f5ccfa7..5f405d1e 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 @@ -2,6 +2,8 @@ import com.ss.editor.JFXApplication; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.Config; import com.ss.editor.ui.Icons; import com.ss.editor.ui.component.creator.FileCreator; @@ -43,7 +45,6 @@ public class AboutDialog extends AbstractSimpleEditorDialog { @NotNull private static final String LIBRARIES; - static { final InputStream iconsResource = FileCreator.class.getResourceAsStream("/credits/icons.txt"); final InputStream librariesResource = FileCreator.class.getResourceAsStream("/credits/libraries.txt"); @@ -52,6 +53,7 @@ public class AboutDialog extends AbstractSimpleEditorDialog { } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -116,21 +118,21 @@ protected void createContent(@NotNull final VBox root) { FXUtils.addClassTo(applicationLabel, CSSClasses.ABOUT_DIALOG_TITLE_LABEL); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.ABOUT_DIALOG_TITLE; } - @NotNull @Override - protected String getButtonOkText() { + @FromAnyThread + protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_OK; } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/AssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/AssetEditorDialog.java deleted file mode 100644 index 385d4264..00000000 --- a/src/main/java/com/ss/editor/ui/dialog/asset/AssetEditorDialog.java +++ /dev/null @@ -1,550 +0,0 @@ -package com.ss.editor.ui.dialog.asset; - -import static com.ss.editor.Messages.ASSET_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 com.ss.editor.Editor; -import com.ss.editor.Messages; -import com.ss.editor.config.EditorConfig; -import com.ss.editor.manager.ExecutorManager; -import com.ss.editor.manager.JMEFilePreviewManager; -import com.ss.editor.manager.JavaFXImageManager; -import com.ss.editor.ui.Icons; -import com.ss.editor.ui.component.asset.tree.ResourceTree; -import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; -import com.ss.editor.ui.css.CSSClasses; -import com.ss.editor.ui.dialog.EditorDialog; -import com.ss.editor.ui.event.FXEventManager; -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.editor.util.EditorUtil; -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 javafx.beans.binding.BooleanBinding; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.ReadOnlyObjectProperty; -import javafx.event.Event; -import javafx.event.EventHandler; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.*; -import javafx.scene.control.TextArea; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Region; -import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import javafx.stage.Window; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Predicate; - -/** - * The implementation of the {@link EditorDialog} to choose the object from an asset folder. - * - * @param the type parameter - * @author JavaSaBr - */ -public class AssetEditorDialog extends EditorDialog { - - /** - * The constant DIALOG_SIZE. - */ - @NotNull - protected static final Point DIALOG_SIZE = new Point(-1, -1); - - /** - * The image manager. - */ - @NotNull - protected static final JavaFXImageManager JAVA_FX_IMAGE_MANAGER = JavaFXImageManager.getInstance(); - - /** - * The executing manager. - */ - @NotNull - protected static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); - - /** - * The event manager. - */ - @NotNull - protected static final FXEventManager FX_EVENT_MANAGER = FXEventManager.getInstance(); - - /** - * The editor. - */ - @NotNull - protected static final Editor EDITOR = Editor.getInstance(); - - @NotNull - private final EventHandler createdFileHandler = event -> processEvent((CreatedFileEvent) event); - - @NotNull - private final EventHandler selectFileHandle = event -> processEvent((RequestSelectFileEvent) event); - - @NotNull - private final EventHandler deletedFileHandler = event -> processEvent((DeletedFileEvent) event); - - /** - * The list of waited files to select. - */ - @NotNull - private final Array waitedFilesToSelect; - - /** - * The function for handling the choose. - */ - @NotNull - protected final Consumer consumer; - - /** - * The function for validating the choose. - */ - @Nullable - private final Function validator; - - /** - * The tree with all resources. - */ - @Nullable - private ResourceTree resourceTree; - - /** - * The image preview. - */ - @Nullable - ImageView imageView; - - /** - * The preview of text files. - */ - @Nullable - TextArea textView; - - /** - * The label with any warning. - */ - @Nullable - private Label warningLabel; - - /** - * The OK button. - */ - @Nullable - protected Button okButton; - - /** - * Instantiates a new Asset editor dialog. - * - * @param consumer the consumer - */ - public AssetEditorDialog(@NotNull final Consumer consumer) { - this(consumer, null); - } - - /** - * Instantiates a new Asset editor dialog. - * - * @param consumer the consumer - * @param validator the validator - */ - public AssetEditorDialog(@NotNull final Consumer consumer, @Nullable final Function validator) { - this.waitedFilesToSelect = ArrayFactory.newArray(Path.class); - this.consumer = consumer; - this.validator = validator; - } - - /** - * Sets extension filter. - * - * @param extensionFilter the list of available extensions. - */ - public void setExtensionFilter(@NotNull final Array extensionFilter) { - getResourceTree().setExtensionFilter(extensionFilter); - } - - /** - * Sets action tester. - * - * @param actionTester the action tester. - */ - public void setActionTester(@Nullable final Predicate> actionTester) { - getResourceTree().setActionTester(actionTester); - } - - /** - * Sets only folders. - * - * @param onlyFolders true if need to show only folders. - */ - void setOnlyFolders(final boolean onlyFolders) { - getResourceTree().setOnlyFolders(onlyFolders); - } - - @Override - protected void createContent(@NotNull final VBox root) { - - final HBox container = new HBox(); - - resourceTree = new ResourceTree(this::processOpen, false); - resourceTree.prefHeightProperty().bind(root.heightProperty()); - resourceTree.prefWidthProperty().bind(root.widthProperty().multiply(0.5)); - resourceTree.getSelectionModel() - .selectedItemProperty() - .addListener((observable, oldValue, newValue) -> processSelected(newValue)); - - final Region secondPart = buildSecondPart(container); - secondPart.prefHeightProperty().bind(root.heightProperty()); - secondPart.prefWidthProperty().bind(root.widthProperty().multiply(0.5)); - - FXUtils.addToPane(resourceTree, container); - FXUtils.addToPane(secondPart, container); - FXUtils.addToPane(container, root); - - root.setOnKeyReleased(this::processKeyEvent); - - FXUtils.addClassTo(container, CSSClasses.DEF_HBOX); - FXUtils.addClassTo(root, CSSClasses.ASSET_EDITOR_DIALOG); - } - - /** - * Build second part parent. - * - * @param container the container - * @return the parent - */ - protected @NotNull Region buildSecondPart(@NotNull final HBox container) { - - final StackPane previewContainer = new StackPane(); - - imageView = new ImageView(); - imageView.fitHeightProperty().bind(previewContainer.heightProperty().subtract(2)); - imageView.fitWidthProperty().bind(previewContainer.widthProperty().subtract(2)); - - textView = new TextArea(); - textView.setEditable(false); - textView.prefWidthProperty().bind(previewContainer.widthProperty().subtract(2)); - textView.prefHeightProperty().bind(previewContainer.heightProperty().subtract(2)); - - FXUtils.addToPane(imageView, previewContainer); - FXUtils.addToPane(textView, previewContainer); - - FXUtils.addClassTo(previewContainer, CSSClasses.ASSET_EDITOR_DIALOG_PREVIEW_CONTAINER); - FXUtils.addClassTo(textView, CSSClasses.TRANSPARENT_TEXT_AREA); - - return previewContainer; - } - - /** - * Gets ok button. - * - * @return the ok button. - */ - public @NotNull Button getOkButton() { - return notNull(okButton); - } - - /** - * The process of opening the element. - * - * @param element the element - */ - protected void processOpen(@NotNull final ResourceElement element) { - hide(); - } - - private void processKeyEvent(@NotNull final KeyEvent event) { - final Button okButton = getOkButton(); - if (event.getCode() == KeyCode.ENTER && !okButton.isDisable()) { - processSelect(); - } - } - - @Override - public void show(@NotNull final Window owner) { - super.show(owner); - - final EditorConfig editorConfig = EditorConfig.getInstance(); - - final ResourceTree resourceTree = getResourceTree(); - final Path currentAsset = notNull(editorConfig.getCurrentAsset()); - - resourceTree.fill(currentAsset); - - FX_EVENT_MANAGER.addEventHandler(CreatedFileEvent.EVENT_TYPE, createdFileHandler); - FX_EVENT_MANAGER.addEventHandler(RequestSelectFileEvent.EVENT_TYPE, selectFileHandle); - FX_EVENT_MANAGER.addEventHandler(DeletedFileEvent.EVENT_TYPE, deletedFileHandler); - - EXECUTOR_MANAGER.addFXTask(resourceTree::requestFocus); - } - - /** - * Handle creating file event. - */ - private void processEvent(@NotNull final CreatedFileEvent event) { - - final Path file = event.getFile(); - - final Array waitedFilesToSelect = getWaitedFilesToSelect(); - final boolean waitedSelect = waitedFilesToSelect.contains(file); - - final ResourceTree resourceTree = getResourceTree(); - resourceTree.notifyCreated(file); - - if (waitedSelect) waitedFilesToSelect.fastRemove(file); - if (waitedSelect || event.isNeedSelect()) resourceTree.expandTo(file, true); - } - - /** - * Handle deleting file event. - */ - private void processEvent(@NotNull final DeletedFileEvent event) { - - final Path file = event.getFile(); - - final ResourceTree resourceTree = getResourceTree(); - resourceTree.notifyDeleted(file); - } - - /** - * Handle selecting file event. - */ - private void processEvent(@NotNull final RequestSelectFileEvent event) { - - final Path file = event.getFile(); - - final ResourceTree resourceTree = getResourceTree(); - final ResourceElement element = createFor(file); - final TreeItem treeItem = findItemForValue(resourceTree.getRoot(), element); - - if (treeItem == null) { - getWaitedFilesToSelect().add(file); - return; - } - - resourceTree.expandTo(treeItem, true); - } - - /** - * @return the list of waited files to select. - */ - private @NotNull Array getWaitedFilesToSelect() { - return waitedFilesToSelect; - } - - /** - * @return the image preview. - */ - private @NotNull ImageView getImageView() { - return notNull(imageView); - } - - /** - * @return the text preview. - */ - private @NotNull TextArea getTextView() { - return notNull(textView); - } - - /** - * Gets validator. - * - * @return the function for validating the choose. - */ - protected @Nullable Function getValidator() { - return validator; - } - - /** - * @return the label with any warning. - */ - private @NotNull Label getWarningLabel() { - return notNull(warningLabel); - } - - /** - * Handle selected element in the tree. - */ - private void processSelected(@Nullable final TreeItem newValue) { - - final ResourceElement element = newValue == null ? null : newValue.getValue(); - final Path file = element == null ? null : element.getFile(); - - validate(getWarningLabel(), element); - - try { - updatePreview(file); - } catch (final Exception e) { - EditorUtil.handleException(LOGGER, this, e); - } - } - - /** - * Update the preview of the file. - * - * @param file the file for preview or null. - */ - private void updatePreview(@Nullable final Path file) { - - final ImageView imageView = getImageView(); - imageView.setVisible(false); - - final TextArea textView = getTextView(); - textView.setVisible(false); - - final int width = (int) imageView.getFitWidth(); - final int height = (int) imageView.getFitHeight(); - - if (JMEFilePreviewManager.isJmeFile(file)) { - - final JMEFilePreviewManager previewManager = JMEFilePreviewManager.getInstance(); - previewManager.show(file, width, height); - - final ImageView sourceView = previewManager.getImageView(); - final ObjectProperty imageProperty = imageView.imageProperty(); - imageProperty.bind(sourceView.imageProperty()); - - imageView.setVisible(true); - - } else if (JavaFXImageManager.isImage(file)) { - - final Image preview = JAVA_FX_IMAGE_MANAGER.getImagePreview(file, width, height); - imageView.setImage(preview); - imageView.setVisible(true); - - } else if (JMEFilePreviewManager.isAudioFile(file)) { - } else if (file != null && !Files.isDirectory(file)) { - - imageView.imageProperty().unbind(); - imageView.setImage(null); - - textView.setText(FileUtils.read(file)); - textView.setVisible(true); - - } else { - imageView.imageProperty().unbind(); - imageView.setImage(null); - } - } - - @Override - public void hide() { - - FX_EVENT_MANAGER.removeEventHandler(CreatedFileEvent.EVENT_TYPE, createdFileHandler); - FX_EVENT_MANAGER.removeEventHandler(RequestSelectFileEvent.EVENT_TYPE, selectFileHandle); - FX_EVENT_MANAGER.removeEventHandler(DeletedFileEvent.EVENT_TYPE, deletedFileHandler); - - final JMEFilePreviewManager previewManager = JMEFilePreviewManager.getInstance(); - previewManager.clear(); - - super.hide(); - } - - /** - * Validate the resource element. - * - * @param warningLabel the warning label - * @param element the element. - */ - protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) { - } - - @Override - protected void createActions(@NotNull final VBox root) { - - final HBox container = new HBox(); - - warningLabel = new Label(); - warningLabel.setGraphic(new ImageView(Icons.WARNING_24)); - warningLabel.setVisible(false); - - okButton = new Button(Messages.SIMPLE_DIALOG_BUTTON_SELECT); - okButton.setOnAction(event -> processSelect()); - okButton.disableProperty().bind(buildDisableCondition()); - - final Button cancelButton = new Button(Messages.SIMPLE_DIALOG_BUTTON_CANCEL); - cancelButton.setOnAction(event -> hide()); - - FXUtils.addClassTo(container, CSSClasses.DEF_HBOX); - FXUtils.addClassTo(warningLabel, CSSClasses.DIALOG_LABEL_WARNING); - FXUtils.addClassTo(okButton, cancelButton, CSSClasses.DIALOG_BUTTON); - FXUtils.addClassTo(root, CSSClasses.ASSET_EDITOR_DIALOG_ACTIONS); - - FXUtils.addToPane(warningLabel, container); - FXUtils.addToPane(okButton, container); - FXUtils.addToPane(cancelButton, container); - FXUtils.addToPane(container, root); - } - - /** - * Build disable condition boolean binding. - * - * @return the boolean binding - */ - protected @NotNull BooleanBinding buildDisableCondition() { - - final ResourceTree resourceTree = getResourceTree(); - final MultipleSelectionModel> selectionModel = resourceTree.getSelectionModel(); - final ReadOnlyObjectProperty> selectedItemProperty = selectionModel.selectedItemProperty(); - - final Label warningLabel = getWarningLabel(); - return warningLabel.visibleProperty().or(selectedItemProperty.isNull()); - } - - /** - * Gets consumer. - * - * @return the function for handling the choose. - */ - protected @NotNull Consumer getConsumer() { - return consumer; - } - - /** - * @return the tree with all resources. - */ - private @NotNull ResourceTree getResourceTree() { - return notNull(resourceTree); - } - - /** - * The process of choosing the element. - */ - private void processSelect() { - - final ResourceTree resourceTree = getResourceTree(); - final MultipleSelectionModel> selectionModel = resourceTree.getSelectionModel(); - final TreeItem selectedItem = selectionModel.getSelectedItem(); - - if (selectedItem == null) { - hide(); - return; - } - - processOpen(selectedItem.getValue()); - } - - @Override - protected @NotNull String getTitleText() { - return ASSET_EDITOR_DIALOG_TITLE; - } - - @Override - protected @NotNull Point getSize() { - return DIALOG_SIZE; - } -} 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 new file mode 100644 index 00000000..eba2bf38 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/dialog/asset/BaseAssetEditorDialog.java @@ -0,0 +1,467 @@ +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 com.ss.editor.Editor; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.manager.JMEFilePreviewManager; +import com.ss.editor.manager.JavaFXImageManager; +import com.ss.editor.manager.ResourceManager; +import com.ss.editor.ui.Icons; +import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; +import com.ss.editor.util.EditorUtil; +import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.util.FileUtils; +import com.ss.rlib.util.StringUtils; +import com.ss.rlib.util.Utils; +import javafx.beans.binding.BooleanBinding; +import javafx.beans.property.ObjectProperty; +import javafx.beans.value.ObservableBooleanValue; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.control.TreeItem; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.net.URL; +import java.nio.file.Path; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * The base implementation of the {@link AbstractSimpleEditorDialog} to choose some asset resource. + * + * @author JavaSaBr + */ +public class BaseAssetEditorDialog extends AbstractSimpleEditorDialog { + + /** + * The dialog size. + */ + @NotNull + protected static final Point DIALOG_SIZE = new Point(-1, -1); + + /** + * The image manager. + */ + @NotNull + protected static final JavaFXImageManager JAVA_FX_IMAGE_MANAGER = JavaFXImageManager.getInstance(); + + /** + * The editor. + */ + @NotNull + protected static final Editor EDITOR = Editor.getInstance(); + + /** + * The function to handle the choose. + */ + @NotNull + protected final Consumer consumer; + + /** + * The function to validate the choose. + */ + @Nullable + private final Function<@NotNull C, @Nullable String> validator; + + /** + * The image preview. + */ + @Nullable + private ImageView imageView; + + /** + * The preview of text files. + */ + @Nullable + private TextArea textView; + + /** + * The label with any warning. + */ + @Nullable + private Label warningLabel; + + public BaseAssetEditorDialog(@NotNull final Consumer consumer) { + this(consumer, null); + } + + public BaseAssetEditorDialog(@NotNull final Consumer consumer, + @Nullable final Function<@NotNull C, @Nullable String> validator) { + this.consumer = consumer; + this.validator = validator; + } + + @Override + @FXThread + protected void createContent(@NotNull final VBox root) { + + final HBox container = new HBox(); + + final Region firstPart = buildFirstPart(container); + firstPart.prefHeightProperty().bind(root.heightProperty()); + firstPart.prefWidthProperty().bind(root.widthProperty().multiply(0.5)); + + final Region secondPart = buildSecondPart(container); + secondPart.prefHeightProperty().bind(root.heightProperty()); + secondPart.prefWidthProperty().bind(root.widthProperty().multiply(0.5)); + + FXUtils.addToPane(firstPart, container); + FXUtils.addToPane(secondPart, container); + FXUtils.addToPane(container, root); + + FXUtils.addClassTo(container, CSSClasses.DEF_HBOX); + FXUtils.addClassTo(root, CSSClasses.ASSET_EDITOR_DIALOG); + } + + /** + * Build the first part of this dialog. + * + * @param container the horizontal container. + * @return the built component. + */ + @FXThread + protected @NotNull Region buildFirstPart(@NotNull final HBox container) { + throw new RuntimeException("unsupported"); + } + + /** + * Get the target object from the asset element. + * + * @param element the asset element. + * @return the target object. + */ + @FXThread + protected @Nullable C getObject(@NotNull final T element) { + throw new RuntimeException("unsupported"); + } + + /** + * Gets consumer. + * + * @return the function for handling the choose. + */ + @FromAnyThread + protected @NotNull Consumer getConsumer() { + return consumer; + } + + /** + * Handle selected element in the tree. + */ + @FXThread + protected void processSelected(@Nullable final TreeItem newValue) { + + final T element = newValue == null ? null : newValue.getValue(); + final String assetPath = element == null ? null : getAssetPath(element); + final Path realFile = element == null ? null : getRealFile(element); + + validate(getWarningLabel(), element); + try { + + if (assetPath != null) { + updatePreview(assetPath); + } else if (realFile != null) { + updatePreview(realFile); + } else { + updatePreview((String) null); + } + + } catch (final Exception e) { + EditorUtil.handleException(LOGGER, this, e); + } + } + + /** + * Try to get an asset path from the element. + * + * @param element the element. + * @return the asset path or null. + */ + @FXThread + protected @Nullable String getAssetPath(@NotNull final T element) { + return null; + } + + /** + * Try to get a real file from the element. + * + * @param element the element. + * @return the real file or null. + */ + @FXThread + protected @Nullable Path getRealFile(@NotNull final T element) { + return null; + } + + /** + * Update the preview of the file. + * + * @param file the file. + */ + @FXThread + private void updatePreview(@NotNull final Path file) { + + final ImageView imageView = getImageView(); + imageView.setVisible(false); + + final TextArea textView = getTextView(); + textView.setVisible(false); + + final int width = (int) imageView.getFitWidth(); + final int height = (int) imageView.getFitHeight(); + + if (JMEFilePreviewManager.isJmeFile(file)) { + + final JMEFilePreviewManager previewManager = JMEFilePreviewManager.getInstance(); + previewManager.show(file, width, height); + + final ImageView sourceView = previewManager.getImageView(); + final ObjectProperty imageProperty = imageView.imageProperty(); + imageProperty.bind(sourceView.imageProperty()); + + imageView.setVisible(true); + + } else if (JavaFXImageManager.isImage(file)) { + + final Image preview = JAVA_FX_IMAGE_MANAGER.getImagePreview(file, width, height); + imageView.setImage(preview); + imageView.setVisible(true); + + } else if (!StringUtils.isEmpty(FileUtils.getExtension(file))) { + + imageView.imageProperty().unbind(); + imageView.setImage(null); + + textView.setText(FileUtils.read(file)); + textView.setVisible(true); + + } else { + imageView.imageProperty().unbind(); + imageView.setImage(null); + } + } + + /** + * Update the preview of the object by the asset path. + * + * @param assetPath the asset path of the object. + */ + @FXThread + private void updatePreview(@Nullable final String assetPath) { + + final ImageView imageView = getImageView(); + imageView.setVisible(false); + + final TextArea textView = getTextView(); + textView.setVisible(false); + + final int width = (int) imageView.getFitWidth(); + final int height = (int) imageView.getFitHeight(); + + if (JMEFilePreviewManager.isJmeFile(assetPath)) { + + final JMEFilePreviewManager previewManager = JMEFilePreviewManager.getInstance(); + previewManager.show(assetPath, width, height); + + final ImageView sourceView = previewManager.getImageView(); + final ObjectProperty imageProperty = imageView.imageProperty(); + imageProperty.bind(sourceView.imageProperty()); + + imageView.setVisible(true); + + } else if (JavaFXImageManager.isImage(assetPath)) { + + final Image preview = JAVA_FX_IMAGE_MANAGER.getImagePreview(assetPath, width, height); + imageView.setImage(preview); + imageView.setVisible(true); + + } else if (assetPath != null && !StringUtils.isEmpty(FileUtils.getExtension(assetPath))) { + + final ResourceManager resourceManager = ResourceManager.getInstance(); + final URL url = resourceManager.tryToFindResource(assetPath); + + String content; + + if (url != null) { + content = Utils.get(url, first -> FileUtils.read(first.openStream())); + } else { + final Path realFile = EditorUtil.getRealFile(assetPath); + content = realFile == null ? "" : FileUtils.read(realFile); + } + + imageView.imageProperty().unbind(); + imageView.setImage(null); + + textView.setText(content); + textView.setVisible(true); + + } else { + imageView.imageProperty().unbind(); + imageView.setImage(null); + } + } + + /** + * Validate the resource element. + * + * @param warningLabel the warning label + * @param element the element. + */ + @FXThread + protected void validate(@NotNull final Label warningLabel, @Nullable final T element) { + + final Function<@NotNull C, @Nullable String> validator = getValidator(); + if (validator == null) return; + + final C object = element == null ? null : getObject(element); + final String message = object == null ? null : validator.apply(object); + + if (message == null) { + warningLabel.setText(StringUtils.EMPTY); + warningLabel.setVisible(false); + } else { + warningLabel.setText(message); + warningLabel.setVisible(true); + } + } + + /** + * Build second part parent. + * + * @param container the container + * @return the parent + */ + @FXThread + protected @NotNull Region buildSecondPart(@NotNull final HBox container) { + + final StackPane previewContainer = new StackPane(); + + imageView = new ImageView(); + imageView.fitHeightProperty().bind(previewContainer.heightProperty().subtract(2)); + imageView.fitWidthProperty().bind(previewContainer.widthProperty().subtract(2)); + + textView = new TextArea(); + textView.setEditable(false); + textView.prefWidthProperty().bind(previewContainer.widthProperty().subtract(2)); + textView.prefHeightProperty().bind(previewContainer.heightProperty().subtract(2)); + + FXUtils.addToPane(imageView, previewContainer); + FXUtils.addToPane(textView, previewContainer); + + FXUtils.addClassTo(previewContainer, CSSClasses.ASSET_EDITOR_DIALOG_PREVIEW_CONTAINER); + FXUtils.addClassTo(textView, CSSClasses.TRANSPARENT_TEXT_AREA); + + return previewContainer; + } + + /** + * @return the image preview. + */ + @FXThread + protected @NotNull ImageView getImageView() { + return notNull(imageView); + } + + /** + * @return the text preview. + */ + @FXThread + protected @NotNull TextArea getTextView() { + return notNull(textView); + } + + /** + * Gets validator. + * + * @return the function for validating the choose. + */ + @FXThread + protected @Nullable Function<@NotNull C, @Nullable String> getValidator() { + return validator; + } + + /** + * @return the label with any warning. + */ + @FXThread + protected @NotNull Label getWarningLabel() { + return notNull(warningLabel); + } + + @Override + @FXThread + public void hide() { + + final JMEFilePreviewManager previewManager = JMEFilePreviewManager.getInstance(); + previewManager.clear(); + + super.hide(); + } + + @Override + @FXThread + protected void createBeforeActions(@NotNull final HBox container) { + super.createBeforeActions(container); + + warningLabel = new Label(); + warningLabel.setGraphic(new ImageView(Icons.WARNING_24)); + warningLabel.setVisible(false); + + FXUtils.addClassTo(warningLabel, CSSClasses.DIALOG_LABEL_WARNING); + FXUtils.addToPane(warningLabel, container); + } + + @Override + @FXThread + protected void createActions(@NotNull final VBox root) { + super.createActions(root); + + final Button okButton = notNull(getOkButton()); + okButton.disableProperty().bind(buildDisableCondition()); + } + + /** + * Build disable condition. + * + * @return the disable condition. + */ + @FXThread + protected @NotNull BooleanBinding buildDisableCondition() { + final Label warningLabel = getWarningLabel(); + return warningLabel.visibleProperty().or(buildAdditionalDisableCondition()); + } + + /** + * Build additional disable condition. + * + * @return the additional condition. + */ + @FXThread + protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() { + throw new RuntimeException("unsupported"); + } + + @Override + @FromAnyThread + protected @NotNull Point getSize() { + return DIALOG_SIZE; + } + + @Override + @FromAnyThread + protected @NotNull String getTitleText() { + return ASSET_EDITOR_DIALOG_TITLE; + } +} 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 new file mode 100644 index 00000000..ffbde3c9 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/dialog/asset/file/AssetEditorDialog.java @@ -0,0 +1,275 @@ +package com.ss.editor.ui.dialog.asset.file; + +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 com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.config.EditorConfig; +import com.ss.editor.manager.ExecutorManager; +import com.ss.editor.ui.component.asset.tree.ResourceTree; +import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; +import com.ss.editor.ui.dialog.EditorDialog; +import com.ss.editor.ui.dialog.asset.BaseAssetEditorDialog; +import com.ss.editor.ui.event.FXEventManager; +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 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; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; +import javafx.stage.Window; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.nio.file.Path; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; + +/** + * The implementation of the {@link EditorDialog} to choose the object from an asset folder. + * + * @param the type parameter + * @author JavaSaBr + */ +public class AssetEditorDialog extends BaseAssetEditorDialog { + + /** + * The executing manager. + */ + @NotNull + protected static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); + + /** + * The event manager. + */ + @NotNull + protected static final FXEventManager FX_EVENT_MANAGER = FXEventManager.getInstance(); + + /** + * The handler created files events. + */ + @NotNull + private final EventHandler createdFileHandler = event -> processEvent((CreatedFileEvent) event); + + /** + * The handler selected file events. + */ + @NotNull + private final EventHandler selectFileHandle = event -> processEvent((RequestSelectFileEvent) event); + + /** + * The handler deleted file events, + */ + @NotNull + private final EventHandler deletedFileHandler = event -> processEvent((DeletedFileEvent) event); + + /** + * The list of waited files to select. + */ + @NotNull + private final Array waitedFilesToSelect; + + /** + * The tree with all resources. + */ + @Nullable + private ResourceTree resourceTree; + + public AssetEditorDialog(@NotNull final Consumer consumer) { + this(consumer, null); + } + + public AssetEditorDialog(@NotNull final Consumer consumer, @Nullable final Function validator) { + super(consumer, validator); + this.waitedFilesToSelect = ArrayFactory.newArray(Path.class); + } + + /** + * Sets extension filter. + * + * @param extensionFilter the list of available extensions. + */ + @FromAnyThread + public void setExtensionFilter(@NotNull final Array extensionFilter) { + getResourceTree().setExtensionFilter(extensionFilter); + } + + /** + * Sets action tester. + * + * @param actionTester the action tester. + */ + @FromAnyThread + public void setActionTester(@Nullable final Predicate> actionTester) { + getResourceTree().setActionTester(actionTester); + } + + /** + * Sets only folders. + * + * @param onlyFolders true if need to show only folders. + */ + @FromAnyThread + public void setOnlyFolders(final boolean onlyFolders) { + getResourceTree().setOnlyFolders(onlyFolders); + } + + @Override + @FXThread + protected @NotNull Region buildFirstPart(@NotNull final HBox container) { + + resourceTree = new ResourceTree(this::processOpen, false); + resourceTree.getSelectionModel() + .selectedItemProperty() + .addListener((observable, oldValue, newValue) -> processSelected(newValue)); + + return resourceTree; + } + + /** + * The process of opening the element. + * + * @param element the element + */ + @FXThread + protected void processOpen(@NotNull final ResourceElement element) { + hide(); + } + + @Override + @FXThread + public void show(@NotNull final Window owner) { + super.show(owner); + + final EditorConfig editorConfig = EditorConfig.getInstance(); + + final ResourceTree resourceTree = getResourceTree(); + final Path currentAsset = notNull(editorConfig.getCurrentAsset()); + + resourceTree.fill(currentAsset); + + FX_EVENT_MANAGER.addEventHandler(CreatedFileEvent.EVENT_TYPE, createdFileHandler); + FX_EVENT_MANAGER.addEventHandler(RequestSelectFileEvent.EVENT_TYPE, selectFileHandle); + FX_EVENT_MANAGER.addEventHandler(DeletedFileEvent.EVENT_TYPE, deletedFileHandler); + + EXECUTOR_MANAGER.addFXTask(resourceTree::requestFocus); + } + + /** + * Handle creating file event. + */ + @FXThread + private void processEvent(@NotNull final CreatedFileEvent event) { + + final Path file = event.getFile(); + + final Array waitedFilesToSelect = getWaitedFilesToSelect(); + final boolean waitedSelect = waitedFilesToSelect.contains(file); + + final ResourceTree resourceTree = getResourceTree(); + resourceTree.notifyCreated(file); + + if (waitedSelect) waitedFilesToSelect.fastRemove(file); + if (waitedSelect || event.isNeedSelect()) resourceTree.expandTo(file, true); + } + + /** + * Handle deleting file event. + */ + @FXThread + private void processEvent(@NotNull final DeletedFileEvent event) { + + final Path file = event.getFile(); + + final ResourceTree resourceTree = getResourceTree(); + resourceTree.notifyDeleted(file); + } + + /** + * Handle selecting file event. + */ + @FXThread + private void processEvent(@NotNull final RequestSelectFileEvent event) { + + final Path file = event.getFile(); + + final ResourceTree resourceTree = getResourceTree(); + final ResourceElement element = createFor(file); + final TreeItem treeItem = findItemForValue(resourceTree.getRoot(), element); + + if (treeItem == null) { + getWaitedFilesToSelect().add(file); + return; + } + + resourceTree.expandTo(treeItem, true); + } + + /** + * @return the list of waited files to select. + */ + @FromAnyThread + private @NotNull Array getWaitedFilesToSelect() { + return waitedFilesToSelect; + } + + @Override + @FXThread + protected @Nullable Path getRealFile(@NotNull final ResourceElement element) { + return element.getFile(); + } + + @Override + @FXThread + public void hide() { + + FX_EVENT_MANAGER.removeEventHandler(CreatedFileEvent.EVENT_TYPE, createdFileHandler); + FX_EVENT_MANAGER.removeEventHandler(RequestSelectFileEvent.EVENT_TYPE, selectFileHandle); + FX_EVENT_MANAGER.removeEventHandler(DeletedFileEvent.EVENT_TYPE, deletedFileHandler); + + super.hide(); + } + + @Override + @FXThread + protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() { + final ResourceTree resourceTree = getResourceTree(); + final MultipleSelectionModel> selectionModel = resourceTree.getSelectionModel(); + final ReadOnlyObjectProperty> selectedItemProperty = selectionModel.selectedItemProperty(); + return selectedItemProperty.isNull(); + } + + /** + * @return the tree with all resources. + */ + @FXThread + private @NotNull ResourceTree getResourceTree() { + return notNull(resourceTree); + } + + @Override + @FXThread + protected void processOk() { + super.processOk(); + + final ResourceTree resourceTree = getResourceTree(); + final MultipleSelectionModel> selectionModel = resourceTree.getSelectionModel(); + final TreeItem selectedItem = selectionModel.getSelectedItem(); + + if (selectedItem == null) { + hide(); + return; + } + + processOpen(selectedItem.getValue()); + } +} diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/FileAssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/file/FileAssetEditorDialog.java similarity index 65% rename from src/main/java/com/ss/editor/ui/dialog/asset/FileAssetEditorDialog.java rename to src/main/java/com/ss/editor/ui/dialog/asset/file/FileAssetEditorDialog.java index 4981d366..dd64ff9f 100644 --- a/src/main/java/com/ss/editor/ui/dialog/asset/FileAssetEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/asset/file/FileAssetEditorDialog.java @@ -1,6 +1,7 @@ -package com.ss.editor.ui.dialog.asset; +package com.ss.editor.ui.dialog.asset.file; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.asset.tree.resource.FolderResourceElement; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import javafx.scene.control.Label; @@ -27,6 +28,7 @@ public FileAssetEditorDialog(@NotNull final Consumer consumer, @Nullable f } @Override + @FXThread protected void processOpen(@NotNull final ResourceElement element) { super.processOpen(element); final Consumer consumer = getConsumer(); @@ -34,25 +36,24 @@ protected void processOpen(@NotNull final ResourceElement element) { } @Override + @FXThread + protected @Nullable Path getObject(@NotNull final ResourceElement element) { + return element.getFile(); + } + + @Override + @FXThread protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) { super.validate(warningLabel, element); - if (element == null) { - LOGGER.warning(this, "The element is null."); - return; - } - - final Function validator = getValidator(); - String message = validator == null ? null : validator.apply(element.getFile()); - - if (message == null && element instanceof FolderResourceElement ) { - message = Messages.ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE; - } + final Function<@NotNull Path, @Nullable String> validator = getValidator(); + final boolean visible = warningLabel.isVisible(); - if (message != null) { - warningLabel.setText(message); + if (!visible && element instanceof FolderResourceElement) { + warningLabel.setText(Messages.ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE); + warningLabel.setVisible(true); + } else if (validator == null) { + warningLabel.setVisible(false); } - - warningLabel.setVisible(message != null); } } diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/FolderAssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/file/FolderAssetEditorDialog.java similarity index 62% rename from src/main/java/com/ss/editor/ui/dialog/asset/FolderAssetEditorDialog.java rename to src/main/java/com/ss/editor/ui/dialog/asset/file/FolderAssetEditorDialog.java index faa9c89f..0220cf3a 100644 --- a/src/main/java/com/ss/editor/ui/dialog/asset/FolderAssetEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/asset/file/FolderAssetEditorDialog.java @@ -1,7 +1,7 @@ -package com.ss.editor.ui.dialog.asset; +package com.ss.editor.ui.dialog.asset.file; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; -import javafx.scene.control.Label; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,6 +28,7 @@ public FolderAssetEditorDialog(@NotNull final Consumer consumer, } @Override + @FXThread protected void processOpen(@NotNull final ResourceElement element) { super.processOpen(element); final Consumer consumer = getConsumer(); @@ -35,21 +36,8 @@ protected void processOpen(@NotNull final ResourceElement element) { } @Override - protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) { - super.validate(warningLabel, element); - - if (element == null) { - LOGGER.warning(this, "The element is null."); - return; - } - - final Function validator = getValidator(); - String message = validator == null ? null : validator.apply(element.getFile()); - - if (message != null) { - warningLabel.setText(message); - } - - warningLabel.setVisible(message != null); + @FXThread + protected @Nullable Path getObject(@NotNull final ResourceElement element) { + return element.getFile(); } } diff --git a/src/main/java/com/ss/editor/ui/dialog/asset/ParticlesAssetEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/asset/file/ParticlesAssetEditorDialog.java similarity index 78% rename from src/main/java/com/ss/editor/ui/dialog/asset/ParticlesAssetEditorDialog.java rename to src/main/java/com/ss/editor/ui/dialog/asset/file/ParticlesAssetEditorDialog.java index 0c3ed88a..2bd7716a 100644 --- a/src/main/java/com/ss/editor/ui/dialog/asset/ParticlesAssetEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/asset/file/ParticlesAssetEditorDialog.java @@ -1,4 +1,4 @@ -package com.ss.editor.ui.dialog.asset; +package com.ss.editor.ui.dialog.asset.file; import static com.ss.editor.util.EditorUtil.getAssetFile; import static com.ss.editor.util.EditorUtil.toAssetPath; @@ -10,17 +10,21 @@ import com.jme3.material.MaterialDef; import com.jme3.shader.VarType; import com.ss.editor.Messages; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; import com.ss.editor.ui.css.CSSClasses; import com.ss.rlib.ui.util.FXUtils; -import javafx.beans.binding.BooleanBinding; +import javafx.beans.binding.Bindings; +import javafx.beans.property.ReadOnlyObjectProperty; +import javafx.beans.value.ObservableBooleanValue; import javafx.collections.ObservableList; -import javafx.scene.control.*; -import javafx.scene.image.ImageView; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.control.SingleSelectionModel; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; -import javafx.scene.layout.StackPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import tonegod.emitter.material.ParticlesMaterial; @@ -61,18 +65,14 @@ public class ParticlesAssetEditorDialog extends AssetEditorDialog consumer) { super(consumer); } - @NotNull @Override - protected Region buildSecondPart(@NotNull final HBox container) { + protected @NotNull Region buildSecondPart(@NotNull final HBox container) { + + final Region preview = super.buildSecondPart(container); textureParamNameLabel = new Label(Messages.PARTICLE_ASSET_EDITOR_DIALOG_TEXTURE_PARAM_LABEL + ":"); textureParamNameLabel.prefWidthProperty().bind(container.widthProperty().multiply(0.25)); @@ -86,30 +86,14 @@ protected Region buildSecondPart(@NotNull final HBox container) { applyLightingTransformCheckBox = new CheckBox(); applyLightingTransformCheckBox.prefWidthProperty().bind(container.widthProperty().multiply(0.25)); - final StackPane previewContainer = new StackPane(); - - imageView = new ImageView(); - imageView.fitHeightProperty().bind(previewContainer.heightProperty().subtract(2)); - imageView.fitWidthProperty().bind(previewContainer.widthProperty().subtract(2)); - - textView = new TextArea(); - textView.setEditable(false); - textView.prefWidthProperty().bind(previewContainer.widthProperty().subtract(2)); - textView.prefHeightProperty().bind(previewContainer.heightProperty().subtract(2)); - - FXUtils.addToPane(imageView, previewContainer); - FXUtils.addToPane(textView, previewContainer); - final GridPane settingsContainer = new GridPane(); settingsContainer.add(textureParamNameLabel, 0, 0); settingsContainer.add(textureParamNameComboBox, 1, 0); settingsContainer.add(applyLightingTransformLabel, 0, 1); settingsContainer.add(applyLightingTransformCheckBox, 1, 1); - settingsContainer.add(previewContainer, 0, 2, 2, 1); + settingsContainer.add(preview, 0, 2, 2, 1); FXUtils.addClassTo(settingsContainer, CSSClasses.DEF_GRID_PANE); - FXUtils.addClassTo(previewContainer, CSSClasses.ASSET_EDITOR_DIALOG_PREVIEW_CONTAINER); - FXUtils.addClassTo(textView, CSSClasses.TRANSPARENT_TEXT_AREA); return settingsContainer; } @@ -117,20 +101,21 @@ protected Region buildSecondPart(@NotNull final HBox container) { /** * @return the combo box with texture parameter name. */ - @NotNull - private ComboBox getTextureParamNameComboBox() { + @FXThread + private @NotNull ComboBox getTextureParamNameComboBox() { return notNull(textureParamNameComboBox); } /** * @return the check box for applying the lighting transform. */ - @NotNull - private CheckBox getApplyLightingTransformCheckBox() { + @FXThread + private @NotNull CheckBox getApplyLightingTransformCheckBox() { return notNull(applyLightingTransformCheckBox); } @Override + @FXThread protected void processOpen(@NotNull final ResourceElement element) { super.processOpen(element); @@ -155,16 +140,18 @@ protected void processOpen(@NotNull final ResourceElement element) { consumer.accept(new ParticlesMaterial(material, textureParamName, transformBox.isSelected())); } - @NotNull @Override - protected BooleanBinding buildDisableCondition() { + @FXThread + protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() { final ComboBox comboBox = getTextureParamNameComboBox(); final SingleSelectionModel selectionModel = comboBox.getSelectionModel(); - return super.buildDisableCondition().or(selectionModel.selectedItemProperty() - .isNull().or(selectionModel.selectedItemProperty().isEqualTo(""))); + final ReadOnlyObjectProperty itemProperty = selectionModel.selectedItemProperty(); + final ObservableBooleanValue parent = super.buildAdditionalDisableCondition(); + return Bindings.and(parent, itemProperty.isNull().or(itemProperty.isEqualTo(""))); } @Override + @FXThread protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) { final ComboBox comboBox = getTextureParamNameComboBox(); 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 new file mode 100644 index 00000000..3a612153 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/dialog/asset/virtual/StringVirtualAssetEditorDialog.java @@ -0,0 +1,49 @@ +package com.ss.editor.ui.dialog.asset.virtual; + +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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * The implementation to work with string resources. + * + * @author JavaSaBr + */ +public class StringVirtualAssetEditorDialog extends VirtualAssetEditorDialog { + + @NotNull + public static final Function<@NotNull String, @Nullable String> DEFAULT_VALIDATOR = resource -> { + + final String extension = FileUtils.getExtension(resource); + + if (StringUtils.isEmpty(extension)) { + return Messages.ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE; + } + + return null; + }; + + public StringVirtualAssetEditorDialog(@NotNull final Consumer consumer, + @NotNull final Array resources) { + this(consumer, DEFAULT_VALIDATOR, resources); + } + + public StringVirtualAssetEditorDialog(@NotNull final Consumer consumer, + @Nullable final Function<@NotNull String, @Nullable String> validator, + @NotNull final Array resources) { + super(consumer, validator, resources); + } + + @Override + @FromAnyThread + protected @NotNull Class getObjectsType() { + return String.class; + } +} 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 new file mode 100644 index 00000000..74c5bb23 --- /dev/null +++ b/src/main/java/com/ss/editor/ui/dialog/asset/virtual/VirtualAssetEditorDialog.java @@ -0,0 +1,172 @@ +package com.ss.editor.ui.dialog.asset.virtual; + +import static com.ss.rlib.util.ObjectUtils.notNull; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.ui.component.virtual.tree.VirtualResourceTree; +import com.ss.editor.ui.component.virtual.tree.resource.RootVirtualResourceElement; +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 javafx.beans.binding.Bindings; +import javafx.beans.binding.BooleanBinding; +import javafx.beans.property.ReadOnlyObjectProperty; +import javafx.beans.value.ObservableBooleanValue; +import javafx.scene.control.MultipleSelectionModel; +import javafx.scene.control.TreeItem; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; +import javafx.stage.Window; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * The implementation of the {@link BaseAssetEditorDialog} to choose the object from a virtual asset. + * + * @param the type parameter + * @author JavaSaBr + */ +public class VirtualAssetEditorDialog extends BaseAssetEditorDialog, C> { + + /** + * The all resources. + */ + @NotNull + private final Array resources; + + /** + * The tree with all resources. + */ + @Nullable + private VirtualResourceTree resourceTree; + + public VirtualAssetEditorDialog(@NotNull final Consumer consumer, @NotNull final Array resources) { + this(consumer, null, resources); + } + + public VirtualAssetEditorDialog(@NotNull final Consumer consumer, + @Nullable final Function<@NotNull C, @Nullable String> validator, + @NotNull final Array resources) { + super(consumer, validator); + this.resources = resources; + } + + /** + * @see VirtualResourceTree#setPathFunction(Function) + */ + @FromAnyThread + public void setPathFunction(@Nullable final Function pathFunction) { + getResourceTree().setPathFunction(pathFunction); + } + + @Override + @FXThread + protected @Nullable String getAssetPath(@NotNull final VirtualResourceElement element) { + return getResourceTree().getPath(element.getObject()); + } + + @Override + @FXThread + protected @NotNull Region buildFirstPart(@NotNull final HBox container) { + + resourceTree = new VirtualResourceTree<>(getObjectsType()); + resourceTree.getSelectionModel().selectedItemProperty() + .addListener((observable, oldValue, newValue) -> processSelected(newValue)); + + return resourceTree; + } + + /** + * Get the type of presented objects. + * + * @return the type of presented objects. + */ + @FromAnyThread + protected @NotNull Class getObjectsType() { + throw new RuntimeException("unsupported"); + } + + @Override + @FXThread + public void show(@NotNull final Window owner) { + super.show(owner); + + final VirtualResourceTree resourceTree = getResourceTree(); + final RootVirtualResourceElement newRoot = + VirtualResourceElementFactory.build(resources, resourceTree); + + resourceTree.fill(newRoot); + resourceTree.expandAll(); + + EXECUTOR_MANAGER.addFXTask(resourceTree::requestFocus); + } + + @Override + @FXThread + protected @Nullable C getObject(@NotNull final VirtualResourceElement element) { + final Object object = element.getObject(); + final Class type = getObjectsType(); + return type.isInstance(object) ? type.cast(object) : null; + } + + /** + * @return the tree with all resources. + */ + @FXThread + private @NotNull VirtualResourceTree getResourceTree() { + return notNull(resourceTree); + } + + @Override + @FXThread + protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() { + + final VirtualResourceTree resourceTree = getResourceTree(); + final MultipleSelectionModel>> selectionModel = resourceTree.getSelectionModel(); + final ReadOnlyObjectProperty>> selectedItemProperty = selectionModel.selectedItemProperty(); + + final Class type = getObjectsType(); + final BooleanBinding typeCondition = new BooleanBinding() { + + @Override + protected boolean computeValue() { + final TreeItem> treeItem = selectedItemProperty.get(); + return treeItem == null || !type.isInstance(treeItem.getValue().getObject()); + } + + @Override + public Boolean getValue() { + return computeValue(); + } + }; + + return Bindings.or(selectedItemProperty.isNull(), typeCondition); + } + + @Override + @FXThread + protected void processOk() { + super.processOk(); + + final VirtualResourceTree resourceTree = getResourceTree(); + final MultipleSelectionModel>> selectionModel = resourceTree.getSelectionModel(); + final TreeItem> selectedItem = selectionModel.getSelectedItem(); + + if (selectedItem == null) { + hide(); + return; + } + + final VirtualResourceElement element = selectedItem.getValue(); + final Object object = element.getObject(); + final Class type = getObjectsType(); + + if (type.isInstance(object)) { + getConsumer().accept(type.cast(object)); + } + } +} diff --git a/src/main/java/com/ss/editor/ui/dialog/converter/ModelConverterDialog.java b/src/main/java/com/ss/editor/ui/dialog/converter/ModelConverterDialog.java index 741ed2a6..300d43bb 100644 --- a/src/main/java/com/ss/editor/ui/dialog/converter/ModelConverterDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/converter/ModelConverterDialog.java @@ -2,6 +2,8 @@ import static com.ss.rlib.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.control.choose.ChooseFolderControl; import com.ss.editor.ui.css.CSSClasses; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; @@ -66,13 +68,6 @@ public class ModelConverterDialog extends AbstractSimpleEditorDialog { @Nullable private CheckBox overwriteMaterialsCheckBox; - /** - * Instantiates a new Model converter dialog. - * - * @param source the source - * @param destination the destination - * @param callback the callback - */ public ModelConverterDialog(@NotNull final Path source, @NotNull final Path destination, @NotNull final Consumer callback) { this.callback = callback; @@ -81,6 +76,7 @@ public ModelConverterDialog(@NotNull final Path source, @NotNull final Path dest } @Override + @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); @@ -136,6 +132,7 @@ protected void createContent(@NotNull final GridPane root) { } @Override + @FromAnyThread protected boolean isGridStructure() { return true; } @@ -143,6 +140,7 @@ protected boolean isGridStructure() { /** * Validate. */ + @FXThread private void validate() { final Button okButton = getOkButton(); @@ -173,8 +171,8 @@ private void validate() { /** * @return the export materials check box. */ - @NotNull - private CheckBox getExportMaterialsCheckBox() { + @FXThread + private @NotNull CheckBox getExportMaterialsCheckBox() { return notNull(exportMaterialsCheckBox); } @@ -183,6 +181,7 @@ private CheckBox getExportMaterialsCheckBox() { * * @return true if need to export materials. */ + @FXThread public boolean isExportMaterials() { return getExportMaterialsCheckBox().isSelected(); } @@ -190,8 +189,8 @@ public boolean isExportMaterials() { /** * @return the overwrite materials check box. */ - @NotNull - private CheckBox getOverwriteMaterialsCheckBox() { + @FXThread + private @NotNull CheckBox getOverwriteMaterialsCheckBox() { return notNull(overwriteMaterialsCheckBox); } @@ -200,6 +199,7 @@ private CheckBox getOverwriteMaterialsCheckBox() { * * @return true if we can overwrite materials. */ + @FXThread public boolean isOverwriteMaterials() { return getOverwriteMaterialsCheckBox().isSelected(); } @@ -207,8 +207,8 @@ public boolean isOverwriteMaterials() { /** * @return the destination folder control. */ - @NotNull - private ChooseFolderControl getDestinationControl() { + @FXThread + private @NotNull ChooseFolderControl getDestinationControl() { return notNull(destinationControl); } @@ -217,16 +217,16 @@ private ChooseFolderControl getDestinationControl() { * * @return the destination folder. */ - @NotNull - public Path getDestinationFolder() { + @FXThread + public @NotNull Path getDestinationFolder() { return notNull(getDestinationControl().getFolder()); } /** * @return the materials destination folder control. */ - @NotNull - private ChooseFolderControl getMaterialsFolderControl() { + @FXThread + private @NotNull ChooseFolderControl getMaterialsFolderControl() { return notNull(materialsFolderControl); } @@ -235,16 +235,16 @@ private ChooseFolderControl getMaterialsFolderControl() { * * @return the materials destination folder. */ - @NotNull - public Path getMaterialsFolder() { + @FXThread + public @NotNull Path getMaterialsFolder() { return notNull(getMaterialsFolderControl().getFolder()); } /** * @return the filename field. */ - @NotNull - private TextField getFilenameField() { + @FXThread + private @NotNull TextField getFilenameField() { return notNull(filenameField); } @@ -253,40 +253,41 @@ private TextField getFilenameField() { * * @return the filename. */ - @NotNull - public String getFilename() { + @FXThread + public @NotNull String getFilename() { return getFilenameField().getText(); } /** * @return the callback. */ - @NotNull - private Consumer getCallback() { + @FXThread + private @NotNull Consumer getCallback() { return callback; } @Override + @FXThread protected void processOk() { super.processOk(); getCallback().accept(this); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.MODEL_CONVERTER_DIALOG_TITLE; } - @NotNull @Override - protected String getButtonOkText() { + @FromAnyThread + protected @NotNull String getButtonOkText() { return Messages.MODEL_CONVERTER_DIALOG_BUTTON_OK; } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } diff --git a/src/main/java/com/ss/editor/ui/dialog/folder/OpenExternalFolderEditorDialog.java b/src/main/java/com/ss/editor/ui/dialog/folder/OpenExternalFolderEditorDialog.java index 99f3daba..50d1b910 100644 --- a/src/main/java/com/ss/editor/ui/dialog/folder/OpenExternalFolderEditorDialog.java +++ b/src/main/java/com/ss/editor/ui/dialog/folder/OpenExternalFolderEditorDialog.java @@ -4,6 +4,7 @@ import com.ss.editor.Editor; import com.ss.editor.Messages; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.ui.component.asset.tree.ResourceTree; import com.ss.editor.ui.component.asset.tree.resource.ResourceElement; @@ -72,6 +73,7 @@ public OpenExternalFolderEditorDialog(@NotNull final Consumer<@NotNull Path> con } @Override + @FXThread protected void createContent(@NotNull final VBox root) { resourceTree = new ResourceTree(this::processOpen, false); @@ -111,6 +113,7 @@ protected void processOk() { } @Override + @FXThread public void show(@NotNull final Window owner) { super.show(owner); @@ -136,6 +139,7 @@ public void show(@NotNull final Window owner) { /** * Handle selected element in the tree. */ + @FXThread private void processSelected(@Nullable final TreeItem newValue) { final ResourceElement element = newValue == null ? null : newValue.getValue(); final Path file = element == null ? null : element.getFile(); @@ -148,6 +152,7 @@ private void processSelected(@Nullable final TreeItem newValue) * * @return the function for handling the choose. */ + @FXThread protected @NotNull Consumer<@NotNull Path> getConsumer() { return consumer; } @@ -157,6 +162,7 @@ private void processSelected(@Nullable final TreeItem newValue) * * @param initDirectory the init directory. */ + @FXThread public void setInitDirectory(@Nullable final Path initDirectory) { this.initDirectory = initDirectory; } @@ -166,6 +172,7 @@ public void setInitDirectory(@Nullable final Path initDirectory) { * * @return the init directory. */ + @FXThread public @Nullable Path getInitDirectory() { return initDirectory; } @@ -173,16 +180,19 @@ public void setInitDirectory(@Nullable final Path initDirectory) { /** * @return the tree with all resources. */ + @FXThread private @NotNull ResourceTree getResourceTree() { return notNull(resourceTree); } @Override + @FromAnyThread protected @NotNull Point getSize() { return DIALOG_SIZE; } @Override + @FromAnyThread protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_SELECT; } 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 ff48fd95..ef916f3b 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 @@ -5,6 +5,8 @@ import com.ss.editor.Messages; import com.ss.editor.analytics.google.GAEvent; import com.ss.editor.analytics.google.GAnalytics; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.PluginManager; import com.ss.editor.plugin.EditorPlugin; import com.ss.editor.ui.FXConstants; @@ -64,6 +66,7 @@ public PluginsDialog() { } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -104,23 +107,24 @@ protected void createContent(@NotNull final VBox root) { FXUtils.addClassTo(root, CSSClasses.PLUGINS_DIALOG); } - @NotNull @Override - protected String getTitleText() { + @FromAnyThread + protected @NotNull String getTitleText() { return Messages.PLUGINS_DIALOG_TITLE; } /** * @return the list of installed plugins. */ - @NotNull - private ListView getPluginListView() { + @FXThread + private @NotNull ListView getPluginListView() { return notNull(pluginListView); } /** * Refresh the list of installed plugins. */ + @FXThread private void refreshPlugins() { final ObservableList items = pluginListView.getItems(); @@ -132,6 +136,7 @@ private void refreshPlugins() { /** * Process remove. */ + @FXThread private void processRemove() { final ListView pluginListView = getPluginListView(); @@ -150,12 +155,13 @@ private void processRemove() { /** * @return the list of original plugin ids. */ - @NotNull - private Array getOriginalIds() { + @FXThread + private @NotNull Array getOriginalIds() { return originalIds; } @Override + @FXThread protected void processClose() { super.processClose(); @@ -179,6 +185,7 @@ protected void processClose() { /** * Process install a plugin. */ + @FXThread private void processAdd() { GAnalytics.sendPageView("PluginChooseDialog", null, "/dialog/PluginChooseDialog"); @@ -201,19 +208,20 @@ private void processAdd() { } @Override + @FromAnyThread protected boolean needOkButton() { return false; } - @NotNull @Override - protected String getButtonCloseText() { + @FromAnyThread + protected @NotNull String getButtonCloseText() { return Messages.SIMPLE_DIALOG_BUTTON_CLOSE; } - @NotNull @Override - protected Point getSize() { + @FromAnyThread + protected @NotNull Point getSize() { return DIALOG_SIZE; } } 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 f278b495..f12b805c 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 @@ -117,6 +117,7 @@ public SaveAsEditorDialog(@NotNull final Consumer<@NotNull Path> consumer) { * * @return the title of filename field. */ + @FXThread protected @NotNull String getFileNameLabelText() { return SAVE_AS_EDITOR_DIALOG_FIELD_FILENAME; } @@ -126,6 +127,7 @@ public SaveAsEditorDialog(@NotNull final Consumer<@NotNull Path> consumer) { * * @param extension the target file extension. */ + @FXThread public void setExtension(@NotNull final String extension) { this.extension = extension; getResourceTree().setExtensionFilter(ArrayFactory.asArray(extension)); @@ -136,6 +138,7 @@ public void setExtension(@NotNull final String extension) { * * @return the target file extension. */ + @FXThread private @NotNull String getExtension() { return extension == null ? "" : extension; } @@ -145,11 +148,13 @@ public void setExtension(@NotNull final String extension) { * * @param actionTester the action tester. */ + @FXThread public void setActionTester(@NotNull final Predicate<@NotNull Class> actionTester) { getResourceTree().setActionTester(actionTester); } @Override + @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -205,6 +210,7 @@ protected void createSettings(@NotNull final GridPane root) { * * @param newValue the new selected item. */ + @FXThread protected void processSelection(@Nullable final TreeItem newValue) { if (newValue != null) { @@ -284,11 +290,13 @@ protected void validateFileName() { * * @return the filename field. */ + @FXThread protected @NotNull TextField getFileNameField() { return notNull(fileNameField); } @Override + @FXThread public void show(@NotNull final Window owner) { super.show(owner); @@ -317,6 +325,7 @@ private void expand(@NotNull final Path file, @NotNull final ResourceTree resour /** * Handle creating file event. */ + @FXThread private void processEvent(@NotNull final CreatedFileEvent event) { final Path file = event.getFile(); @@ -334,6 +343,7 @@ private void processEvent(@NotNull final CreatedFileEvent event) { /** * Handle deleting file event. */ + @FXThread private void processEvent(@NotNull final DeletedFileEvent event) { final Path file = event.getFile(); @@ -345,6 +355,7 @@ private void processEvent(@NotNull final DeletedFileEvent event) { /** * Handle selecting file event. */ + @FXThread private void processEvent(@NotNull final RequestSelectFileEvent event) { final Path file = event.getFile(); @@ -364,11 +375,13 @@ private void processEvent(@NotNull final RequestSelectFileEvent event) { /** * @return the list of waited files to select. */ + @FXThread private @NotNull Array getWaitedFilesToSelect() { return waitedFilesToSelect; } @Override + @FXThread public void hide() { FX_EVENT_MANAGER.removeEventHandler(CreatedFileEvent.EVENT_TYPE, createdFileHandler); FX_EVENT_MANAGER.removeEventHandler(RequestSelectFileEvent.EVENT_TYPE, selectFileHandle); @@ -381,6 +394,7 @@ public void hide() { * * @return the function for handling the choose. */ + @FXThread protected @NotNull Consumer<@NotNull Path> getConsumer() { return consumer; } @@ -388,21 +402,25 @@ public void hide() { /** * @return the tree with all resources. */ + @FXThread private @NotNull ResourceTree getResourceTree() { return notNull(resourceTree); } @Override + @FromAnyThread protected @NotNull String getTitleText() { return SAVE_AS_EDITOR_DIALOG_TITLE; } @Override + @FromAnyThread protected @NotNull Point getSize() { return DIALOG_SIZE; } @Override + @FromAnyThread protected @NotNull String getButtonOkText() { return Messages.SIMPLE_DIALOG_BUTTON_SAVE; } 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 096525a8..a9216667 100644 --- a/src/main/java/com/ss/editor/ui/scene/EditorFXScene.java +++ b/src/main/java/com/ss/editor/ui/scene/EditorFXScene.java @@ -84,11 +84,6 @@ public class EditorFXScene extends Scene { @Nullable private Node focused; - /** - * Instantiates a new Editor fx scene. - * - * @param root the root - */ public EditorFXScene(@NotNull final Group root) { super(root); @@ -131,9 +126,8 @@ public EditorFXScene(@NotNull final Group root) { * * @return the view for drawing JME. */ - @NotNull @FXThread - public ImageView getCanvas() { + public @NotNull ImageView getCanvas() { return canvas; } @@ -156,9 +150,8 @@ public void hideCanvas() { * @param id the component id. * @return the component or null. */ - @Nullable @FXThread - public T findComponent(@NotNull final String id) { + public @Nullable T findComponent(@NotNull final String id) { final Array components = getComponents(); return unsafeCast(components.search(id, (component, toCheck) -> StringUtils.equals(toCheck, component.getComponentId()))); @@ -169,9 +162,8 @@ public T findComponent(@NotNull final String id) { * * @return the list of components. */ - @NotNull @FXThread - public Array getComponents() { + public @NotNull Array getComponents() { return components; } @@ -180,18 +172,16 @@ public Array getComponents() { * * @return the container of this scene. */ - @NotNull @FXThread - public StackPane getContainer() { + public @NotNull StackPane getContainer() { return container; } /** * @return the loading layer. */ - @NotNull @FXThread - private VBox getLoadingLayer() { + private @NotNull VBox getLoadingLayer() { return loadingLayer; } @@ -200,9 +190,8 @@ private VBox getLoadingLayer() { * * @return the hide layer. */ - @NotNull @FXThread - public StackPane getHideLayer() { + public @NotNull StackPane getHideLayer() { return hideLayer; } 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 ff6b92e3..c3068303 100644 --- a/src/main/java/com/ss/editor/ui/tooltip/CustomTooltip.java +++ b/src/main/java/com/ss/editor/ui/tooltip/CustomTooltip.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.tooltip; +import com.ss.editor.annotation.FXThread; import com.ss.editor.ui.css.CSSClasses; import com.ss.rlib.ui.util.FXUtils; import javafx.scene.Scene; @@ -24,7 +25,7 @@ public abstract class CustomTooltip extends Tooltip { /** * Instantiates a new Custom tooltip. */ - CustomTooltip() { + public CustomTooltip() { this.root = createRoot(); this.root.setStyle("-fx-background-color: -var-menu-background-color;"); @@ -37,28 +38,29 @@ public abstract class CustomTooltip extends Tooltip { } /** - * Gets root. + * Get the root container. * * @return the root container. */ - @NotNull - protected R getRoot() { + @FXThread + protected @NotNull R getRoot() { return root; } /** - * Create root r. + * Create the root container. * - * @return the r + * @return the root container. */ - @NotNull - protected abstract R createRoot(); + @FXThread + protected abstract @NotNull R createRoot(); /** * Create content of this tooltip. * - * @param root the root + * @param root the root container. */ + @FXThread protected void createContent(@NotNull final R root) { } } 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 77bed962..f0125ac3 100644 --- a/src/main/java/com/ss/editor/ui/tooltip/ImageChannelPreview.java +++ b/src/main/java/com/ss/editor/ui/tooltip/ImageChannelPreview.java @@ -125,6 +125,7 @@ public class ImageChannelPreview extends CustomTooltip { } @Override + @FXThread protected @NotNull GridPane createRoot() { final GridPane gridPane = new GridPane(); FXUtils.addClassesTo(gridPane, CSSClasses.DEF_GRID_PANE, CSSClasses.IMAGE_CHANNEL_PREVIEW); @@ -200,6 +201,7 @@ public void clean() { /** * @param resourcePath the resource path. */ + @FXThread private void setResourcePath(@Nullable final String resourcePath) { this.resourcePath = resourcePath; } @@ -207,6 +209,7 @@ private void setResourcePath(@Nullable final String resourcePath) { /** * @return the resource path. */ + @FXThread private @Nullable String getResourcePath() { return resourcePath; } @@ -214,6 +217,7 @@ private void setResourcePath(@Nullable final String resourcePath) { /** * @param file the file. */ + @FXThread private void setFile(@Nullable final Path file) { this.file = file; } @@ -221,6 +225,7 @@ private void setFile(@Nullable final Path file) { /** * @return the file. */ + @FXThread private @Nullable Path getFile() { return file; } @@ -228,6 +233,7 @@ private void setFile(@Nullable final Path file) { /** * @param needToBuildFile true of need to build from the file. */ + @FXThread private void setNeedToBuildFile(final boolean needToBuildFile) { this.needToBuildFile = needToBuildFile; } @@ -235,6 +241,7 @@ private void setNeedToBuildFile(final boolean needToBuildFile) { /** * @return true of need to build from the file. */ + @FXThread private boolean isNeedToBuildFile() { return needToBuildFile; } @@ -242,6 +249,7 @@ private boolean isNeedToBuildFile() { /** * @param needToBuildResource true of need to build from the resource path. */ + @FXThread private void setNeedToBuildResource(final boolean needToBuildResource) { this.needToBuildResource = needToBuildResource; } @@ -249,11 +257,13 @@ private void setNeedToBuildResource(final boolean needToBuildResource) { /** * @return true of need to build from the resource path. */ + @FXThread private boolean isNeedToBuildResource() { return needToBuildResource; } @Override + @FXThread protected void show() { super.show(); @@ -286,6 +296,7 @@ protected void show() { } } + @FXThread private void buildPreview(@Nullable final Image image) { if (image == null || image.getWidth() != 120) { 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 24c0f0b0..a2790288 100644 --- a/src/main/java/com/ss/editor/ui/tooltip/ImagePreview.java +++ b/src/main/java/com/ss/editor/ui/tooltip/ImagePreview.java @@ -40,6 +40,7 @@ public ImagePreview(@NotNull final Path path) { } @Override + @FXThread protected void createContent(@NotNull final BorderPane root) { super.createContent(root); @@ -51,11 +52,13 @@ protected void createContent(@NotNull final BorderPane root) { } @Override + @FXThread public void show(final Window owner) { super.show(owner); } @Override + @FXThread protected void show() { final ImageView imageView = getImageView(); @@ -67,6 +70,7 @@ protected void show() { } @Override + @FXThread protected @NotNull BorderPane createRoot() { final BorderPane pane = new BorderPane(); FXUtils.addClassesTo(pane, CSSClasses.IMAGE_PREVIEW); diff --git a/src/main/java/com/ss/editor/ui/util/DynamicIconSupport.java b/src/main/java/com/ss/editor/ui/util/DynamicIconSupport.java index 97ffd0e2..f5862805 100644 --- a/src/main/java/com/ss/editor/ui/util/DynamicIconSupport.java +++ b/src/main/java/com/ss/editor/ui/util/DynamicIconSupport.java @@ -1,5 +1,6 @@ package com.ss.editor.ui.util; +import com.ss.editor.annotation.FXThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.manager.FileIconManager; import com.ss.editor.ui.css.CssColorTheme; @@ -52,6 +53,7 @@ public class DynamicIconSupport { * * @param buttons the buttons. */ + @FXThread public static void addSupport(@NotNull final ToggleButton... buttons) { for (final ToggleButton button : buttons) { addSupport(button); @@ -63,6 +65,7 @@ public static void addSupport(@NotNull final ToggleButton... buttons) { * * @param buttons the buttons. */ + @FXThread public static void addSupport(@NotNull final ButtonBase... buttons) { for (final ButtonBase button : buttons) { addSupport(button); @@ -74,6 +77,7 @@ public static void addSupport(@NotNull final ButtonBase... buttons) { * * @param button the button. */ + @FXThread public static void addSupport(@NotNull final ToggleButton button) { final EditorConfig editorConfig = EditorConfig.getInstance(); @@ -111,6 +115,7 @@ public static void addSupport(@NotNull final ToggleButton button) { * * @param button the button. */ + @FXThread public static void addSupport(@NotNull final ButtonBase button) { final EditorConfig editorConfig = EditorConfig.getInstance(); @@ -150,6 +155,7 @@ public static void addSupport(@NotNull final ButtonBase button) { * @param imageView the image view. * @param condition the condition of changing. */ + @FXThread public static void updateListener(@NotNull final Node node, @NotNull final ImageView imageView, @NotNull final ReadOnlyBooleanProperty condition) { updateListener(node, imageView, condition, SELECTED_IMAGE_LISTENER, NOT_SELECTED_IMAGE, SELECTED_IMAGE); @@ -162,11 +168,13 @@ public static void updateListener(@NotNull final Node node, @NotNull final Image * @param imageView the image view. * @param condition the condition of changing. */ + @FXThread public static void updateListener2(@NotNull final Node node, @NotNull final ImageView imageView, @NotNull final ReadOnlyBooleanProperty condition) { updateListener(node, imageView, condition, SELECTED_IMAGE_LISTENER_2, NOT_SELECTED_IMAGE_2, SELECTED_IMAGE_2); } + @FXThread private static void updateListener(@NotNull final Node node, @NotNull final ImageView imageView, @NotNull final ReadOnlyBooleanProperty condition, @NotNull final Object listenerKey, @NotNull final Object notSelectedKey, 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 d297788d..cffaca5f 100644 --- a/src/main/java/com/ss/editor/ui/util/UIUtils.java +++ b/src/main/java/com/ss/editor/ui/util/UIUtils.java @@ -7,9 +7,10 @@ import com.ss.editor.annotation.FXThread; import com.ss.editor.model.UObject; import com.ss.editor.ui.component.ScreenComponent; -import com.ss.editor.ui.dialog.asset.AssetEditorDialog; -import com.ss.editor.ui.dialog.asset.FileAssetEditorDialog; -import com.ss.editor.ui.dialog.asset.FolderAssetEditorDialog; +import com.ss.editor.ui.dialog.asset.file.AssetEditorDialog; +import com.ss.editor.ui.dialog.asset.file.FileAssetEditorDialog; +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.ClassUtils; import com.ss.rlib.util.FileUtils; @@ -44,6 +45,7 @@ import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Consumer; +import java.util.function.Function; import java.util.function.Predicate; /** @@ -62,6 +64,7 @@ public class UIUtils { * @param pane the pane. * @param controls the controls. */ + @FXThread public static void addFocusBinding(@NotNull final Pane pane, @NotNull final Control... controls) { final BooleanProperty focused = new BooleanPropertyBase(false) { @@ -407,6 +410,48 @@ public static void overrideTooltipBehavior(int openDelayInMillis, int visibleDur return container; } + /** + * Visit all items. + * + * @param the type parameter. + * @param item the tree item. + * @param visitor the visitor. + */ + @FXThread + public static void visit(@NotNull final TreeItem item, @NotNull final Consumer> visitor) { + visitor.accept(item); + + final ObservableList> children = item.getChildren(); + if (children.isEmpty()) return; + + for (final TreeItem child : children) { + visit(child, visitor); + } + } + + /** + * Visit all items. + * + * @param the type parameter. + * @param item the tree item. + * @param visitor the visitor. + */ + @FXThread + public static boolean visitUntil(@NotNull final TreeItem item, + @NotNull final Predicate> visitor) { + + if (!visitor.test(item)) return false; + + final ObservableList> children = item.getChildren(); + if (children.isEmpty()) return true; + + for (final TreeItem child : children) { + if (!visitUntil(child, visitor)) return false; + } + + return true; + } + /** * Collect all elements of tree items. * @@ -505,6 +550,16 @@ public static boolean isNotHotKey(@Nullable final KeyEvent event) { */ @FXThread public static void consumeIfIsNotHotKey(@Nullable final KeyEvent event) { + + if (event == null) { + return; + } + + final KeyCode code = event.getCode(); + if (code == KeyCode.ESCAPE || code == KeyCode.ENTER) { + return; + } + if (isNotHotKey(event)) { event.consume(); } @@ -528,6 +583,33 @@ public static void updateEditedCell(final Labeled cell) { } } + /** + * Open an resource asset dialog. + * + * @param handler the result handler. + * @param resources the resources. + */ + @FXThread + public static void openResourceAssetDialog(@NotNull final Consumer handler, + @NotNull final Array resources) { + openResourceAssetDialog(handler, null, resources); + } + + /** + * Open an resource asset dialog. + * + * @param handler the result handler. + * @param validator the validator. + * @param resources the resources. + */ + @FXThread + public static void openResourceAssetDialog(@NotNull final Consumer handler, + @Nullable final Function validator, + @NotNull final Array resources) { + final StringVirtualAssetEditorDialog dialog = new StringVirtualAssetEditorDialog(handler, validator, resources); + dialog.show(); + } + /** * Open an asset dialog. * @@ -588,6 +670,7 @@ public static void openSaveAsDialog(@NotNull final Consumer<@NotNull Path> handl * @param dragEvent the drag event. * @param extensions the extensions. */ + @FXThread public static void acceptIfHasFile(@NotNull final DragEvent dragEvent, @NotNull final Array extensions) { final Dragboard dragboard = dragEvent.getDragboard(); @@ -606,6 +689,7 @@ public static void acceptIfHasFile(@NotNull final DragEvent dragEvent, @NotNull * @param dragEvent the drag event. * @param targetExtension the extension. */ + @FXThread public static void acceptIfHasFile(@NotNull final DragEvent dragEvent, @NotNull final String targetExtension) { final Dragboard dragboard = dragEvent.getDragboard(); @@ -626,6 +710,7 @@ public static void acceptIfHasFile(@NotNull final DragEvent dragEvent, @NotNull * @param extensions the extensions. * @return true if there are required file. */ + @FXThread public static boolean isHasFile(@NotNull final Dragboard dragboard, @NotNull final Array extensions) { final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); @@ -647,6 +732,7 @@ public static boolean isHasFile(@NotNull final Dragboard dragboard, @NotNull fin * @param targetExtension the target extension. * @return true if there are required file. */ + @FXThread public static boolean isHasFile(@NotNull final Dragboard dragboard, @NotNull final String targetExtension) { final List files = unsafeCast(dragboard.getContent(DataFormat.FILES)); @@ -668,6 +754,7 @@ public static boolean isHasFile(@NotNull final Dragboard dragboard, @NotNull fin * @param extensions the extensions. * @param handler the handler. */ + @FXThread public static void handleDroppedFile(@NotNull final DragEvent dragEvent, @NotNull final Array extensions, @NotNull final Consumer handler) { @@ -697,6 +784,7 @@ public static void handleDroppedFile(@NotNull final DragEvent dragEvent, @NotNul * @param firstArg the first argument. * @param handler the handler. */ + @FXThread public static void handleDroppedFile(@NotNull final DragEvent dragEvent, @NotNull final Array extensions, @NotNull final F firstArg, @NotNull final BiConsumer handler) { @@ -729,6 +817,7 @@ public static void handleDroppedFile(@NotNull final DragEvent dragEvent, * @param secondArg the second argument. * @param handler the handler. */ + @FXThread public static void handleDroppedFile(@NotNull final DragEvent dragEvent, @NotNull final String targetExtension, @NotNull final F firstArg, @NotNull final S secondArg, @@ -748,6 +837,7 @@ public static void handleDroppedFile(@NotNull final DragEvent dragEvent, * @param secondArg the second argument. * @param handler the handler. */ + @FXThread public static void handleDroppedFile(@NotNull final Dragboard dragboard, @NotNull final String targetExtension, @NotNull final F firstArg, @NotNull final S secondArg, @@ -780,6 +870,7 @@ public static void handleDroppedFile(@NotNull final Dragboard dragboard, * @param secondArg the second argument. * @param handler the handler. */ + @FXThread public static void handleDroppedFile(@NotNull final DragEvent dragEvent, @NotNull final Array extensions, @NotNull final F firstArg, @NotNull final S secondArg, diff --git a/src/main/java/com/ss/editor/util/EditorUtil.java b/src/main/java/com/ss/editor/util/EditorUtil.java index 953b880f..fe8ccf99 100644 --- a/src/main/java/com/ss/editor/util/EditorUtil.java +++ b/src/main/java/com/ss/editor/util/EditorUtil.java @@ -14,6 +14,7 @@ import com.ss.editor.JFXApplication; import com.ss.editor.analytics.google.GAnalytics; import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.config.EditorConfig; import com.ss.editor.extension.scene.SceneLayer; import com.ss.editor.extension.scene.SceneNode; @@ -82,6 +83,7 @@ public abstract class EditorUtil { * @param paths the list of files. * @param content the content to store. */ + @FXThread public static void addCopiedFile(@NotNull final Array paths, @NotNull final ClipboardContent content) { final List files = paths.stream() @@ -120,22 +122,22 @@ public static void addCopiedFile(@NotNull final Array paths, @NotNull fina * @param path the path to resource. * @return true if the resource is exists. */ + @FromAnyThread public static boolean checkExists(@NotNull final String path) { final Class cs = EditorUtil.class; - return cs.getResourceAsStream(path) != null || - cs.getResourceAsStream("/" + path) != null; + return cs.getResource(path) != null || cs.getResource("/" + path) != null; } /** * Check exists boolean. * - * @param path the path to resource. + * @param path the path to resource. * @param classLoader the class loader. * @return true if the resource is exists. */ + @FromAnyThread public static boolean checkExists(@NotNull final String path, @NotNull final ClassLoader classLoader) { - return classLoader.getResourceAsStream(path) != null || - classLoader.getResourceAsStream("/" + path) != null; + return classLoader.getResource(path) != null || classLoader.getResource("/" + path) != null; } /** @@ -145,8 +147,8 @@ public static boolean checkExists(@NotNull final String path, @NotNull final Cla * @param classLoader the class loader. * @return the external form or null. */ - @Nullable - public static String toExternal(@NotNull final String path, @NotNull final ClassLoader classLoader) { + @FromAnyThread + public static @Nullable String toExternal(@NotNull final String path, @NotNull final ClassLoader classLoader) { if (!checkExists(path, classLoader)) return null; URL resource = classLoader.getResource(path); if (resource == null) resource = classLoader.getResource("/" + path); @@ -161,6 +163,7 @@ public static String toExternal(@NotNull final String path, @NotNull final Class * @param second the second point. * @return the angle between these points. */ + @FromAnyThread public static float getAngle(@NotNull final Vector2f center, @NotNull final Vector2f first, @NotNull final Vector2f second) { @@ -189,8 +192,8 @@ public static float getAngle(@NotNull final Vector2f center, @NotNull final Vect * @param path the path to resource. * @return the input stream of the resource or null. */ - @NotNull - public static InputStream getInputStream(@NotNull final String path) { + @FromAnyThread + public static @Nullable InputStream getInputStream(@NotNull final String path) { return JFXApplication.class.getResourceAsStream(path); } @@ -201,8 +204,8 @@ public static InputStream getInputStream(@NotNull final String path) { * @param classLoader the class loader. * @return the input stream of the resource or null. */ - @NotNull - public static InputStream getInputStream(@NotNull final String path, @NotNull final ClassLoader classLoader) { + @FromAnyThread + public static @Nullable InputStream getInputStream(@NotNull final String path, @NotNull final ClassLoader classLoader) { return classLoader.getResourceAsStream(path); } @@ -211,8 +214,8 @@ public static InputStream getInputStream(@NotNull final String path, @NotNull fi * * @return the user name. */ - @NotNull - public static String getUserName() { + @FromAnyThread + public static @NotNull String getUserName() { return System.getProperty("user.name"); } @@ -223,6 +226,7 @@ public static String getUserName() { * @param camera the camera of the screen. * @return true of we can see the position on the screen. */ + @FromAnyThread public static boolean isVisibleOnScreen(@NotNull final Vector3f position, @NotNull final Camera camera) { final int maxHeight = camera.getHeight(); @@ -244,8 +248,9 @@ public static boolean isVisibleOnScreen(@NotNull final Vector3f position, @NotNu * @param store the container of the result. * @param length the distance. */ + @FromAnyThread public static void movePoint(@NotNull final Vector3f first, @NotNull final Vector3f second, - final @NotNull Vector3f store, final int length) { + @NotNull final Vector3f store, final 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; @@ -257,8 +262,8 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto * @param time the unix time. * @return the string presentation. */ - @NotNull - public static String timeFormat(final long time) { + @FromAnyThread + public static @NotNull String timeFormat(final long time) { final SimpleDateFormat format = LOCATE_DATE_FORMAT.get(); return format.format(new Date(time)); } @@ -270,8 +275,8 @@ public static String timeFormat(final long time) { * @param file the file. * @return the relative path. */ - @NotNull - public static Path getAssetFile(@NotNull final Path assetFolder, @NotNull final Path file) { + @FromAnyThread + public static @NotNull Path getAssetFile(@NotNull final Path assetFolder, @NotNull final Path file) { return assetFolder.relativize(file); } @@ -281,8 +286,8 @@ public static Path getAssetFile(@NotNull final Path assetFolder, @NotNull final * @param file the file. * @return the relative path. */ - @Nullable - public static Path getAssetFile(@NotNull final Path file) { + @FromAnyThread + public static @Nullable Path getAssetFile(@NotNull final Path file) { final EditorConfig editorConfig = EditorConfig.getInstance(); final Path currentAsset = editorConfig.getCurrentAsset(); if (currentAsset == null) return null; @@ -295,8 +300,8 @@ public static Path getAssetFile(@NotNull final Path file) { * @param assetFile the file. * @return the absolute path to the file. */ - @Nullable - public static Path getRealFile(@NotNull final Path assetFile) { + @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; @@ -309,8 +314,8 @@ public static Path getRealFile(@NotNull final Path assetFile) { * @param assetFile the asset path to file. * @return the absolute path to the file. */ - @Nullable - public static Path getRealFile(@NotNull final String assetFile) { + @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; @@ -322,6 +327,7 @@ public static Path getRealFile(@NotNull final String assetFile) { * * @return true if you have a file in your system clipboard. */ + @FXThread public static boolean hasFileInClipboard() { final Clipboard clipboard = Clipboard.getSystemClipboard(); if (clipboard == null) return false; @@ -335,8 +341,8 @@ public static boolean hasFileInClipboard() { * @param path the path * @return the valid asset path for the file. */ - @NotNull - public static String toAssetPath(@NotNull final Path path) { + @FromAnyThread + public static @NotNull String toAssetPath(@NotNull final Path path) { if (File.separatorChar == '/') return path.toString(); return path.toString().replace("\\", "/"); } @@ -348,6 +354,7 @@ public static String toAssetPath(@NotNull final Path path) { * @param owner the owner * @param e the e */ + @FromAnyThread public static void handleException(@Nullable final Logger logger, @Nullable final Object owner, @NotNull final Exception e) { handleException(logger, owner, e, null); @@ -361,9 +368,12 @@ public static void handleException(@Nullable final Logger logger, @Nullable fina * @param e the e * @param callback the callback */ + @FromAnyThread public static void handleException(@Nullable Logger logger, @Nullable final Object owner, @NotNull final Exception e, @Nullable final Runnable callback) { - if (logger == null) logger = LOGGER; + if (logger == null) { + logger = LOGGER; + } if (owner == null) { logger.warning(e); @@ -376,41 +386,54 @@ public static void handleException(@Nullable Logger logger, @Nullable final Obje GAnalytics.sendException(e, false); - StringWriter writer = new StringWriter(); - PrintWriter printWriter = new PrintWriter(writer); + final String localizedMessage = e.getLocalizedMessage(); + final String stackTrace = buildStackTrace(e); - e.printStackTrace(printWriter); + final Alert alert = createErrorAlert(e, localizedMessage, stackTrace); + alert.show(); + alert.setWidth(500); + alert.setHeight(220); - final String localizedMessage = e.getLocalizedMessage(); + if (callback != null) alert.setOnHidden(event -> callback.run()); + }); + } - String stackTrace = writer.toString(); + /** + * Build the stack trace of the exception. + * + * @param exception the exception. + * @return the built stack trace. + */ + @FromAnyThread + public static String buildStackTrace(@NotNull final Exception exception) { - int level = 0; + StringWriter writer = new StringWriter(); + PrintWriter printWriter = new PrintWriter(writer); - for (Throwable cause = e.getCause(); cause != null && level < 6; cause = cause.getCause(), level++) { + exception.printStackTrace(printWriter); - writer = new StringWriter(); - printWriter = new PrintWriter(writer); + String stackTrace = writer.toString(); - cause.printStackTrace(printWriter); + int level = 0; - stackTrace += "\n caused by " + writer.toString(); - } + for (Throwable cause = exception.getCause(); cause != null && level < 6; cause = cause.getCause(), level++) { - final Alert alert = createErrorAlert(e, localizedMessage, stackTrace); - alert.show(); - alert.setWidth(500); - alert.setHeight(220); + writer = new StringWriter(); + printWriter = new PrintWriter(writer); - if (callback != null) alert.setOnHidden(event -> callback.run()); - }); + cause.printStackTrace(printWriter); + + stackTrace += "\n caused by " + writer.toString(); + } + + return stackTrace; } /** * Create a dialog for showing the exception. */ - @NotNull - private static Alert createErrorAlert(@NotNull final Exception e, @Nullable final String localizedMessage, + @FXThread + private static @NotNull Alert createErrorAlert(@NotNull final Exception e, @Nullable final String localizedMessage, @Nullable final String stackTrace) { final TextArea textArea = new TextArea(stackTrace); @@ -443,6 +466,7 @@ private static Alert createErrorAlert(@NotNull final Exception e, @Nullable fina * * @param path the path */ + @FromAnyThread public static void openFileInExternalEditor(@NotNull final Path path) { final Platform platform = JmeSystem.getPlatform(); @@ -485,6 +509,7 @@ public static void openFileInExternalEditor(@NotNull final Path path) { * * @param path the path */ + @FromAnyThread public static void openFileInSystemExplorer(@NotNull Path path) { final Platform platform = JmeSystem.getPlatform(); @@ -530,6 +555,7 @@ public static void openFileInSystemExplorer(@NotNull Path path) { } } + @FromAnyThread private static boolean isAppExists(@NotNull final String command) { final Runtime runtime = Runtime.getRuntime(); @@ -548,10 +574,10 @@ private static boolean isAppExists(@NotNull final String command) { * Convert the object to byte array. * * @param object the object - * @return the byte [ ] + * @return the byte array. */ - @NotNull - public static byte[] serialize(@NotNull final Serializable object) { + @FromAnyThread + public static @NotNull byte[] serialize(@NotNull final Serializable object) { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); @@ -568,11 +594,11 @@ public static byte[] serialize(@NotNull final Serializable object) { * Convert the byte array to object. * * @param the type parameter - * @param bytes the bytes - * @return the t + * @param bytes the byte array. + * @return the result object. */ - @NotNull - public static T deserialize(@NotNull final byte[] bytes) { + @FromAnyThread + public static @NotNull T deserialize(@NotNull final byte[] bytes) { final ByteArrayInputStream bin = new ByteArrayInputStream(bytes); @@ -590,6 +616,7 @@ public static T deserialize(@NotNull final byte[] bytes) { * @param mod the mod * @return the float */ + @FromAnyThread public static float clipNumber(float value, float mod) { return (int) (value * mod) / mod; } @@ -621,8 +648,8 @@ public static void decrementLoading() { * @param value the enum value. * @return the array of enum values. */ - @NotNull - public static > E[] getAvailableValues(@NotNull final E value) { + @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(); @@ -638,9 +665,9 @@ public static > E[] getAvailableValues(@NotNull final E value) * @param resultType the result type. * @return the new instance or null. */ - @Nullable - public static T tryToCreateUserObject(@NotNull final Object owner, @NotNull final String className, - @NotNull final Class resultType) { + @FromAnyThread + public static @Nullable T tryToCreateUserObject(@NotNull final Object owner, @NotNull final String className, + @NotNull final Class resultType) { final ResourceManager resourceManager = ResourceManager.getInstance(); final ClasspathManager classpathManager = ClasspathManager.getInstance(); @@ -681,8 +708,8 @@ public static T tryToCreateUserObject(@NotNull final Object owner, @NotNull * @param consumer the change consumer. * @return the default layer or null. */ - @Nullable - public static SceneLayer getDefaultLayer(@NotNull final ChangeConsumer consumer) { + @FromAnyThread + public static @Nullable SceneLayer getDefaultLayer(@NotNull final ChangeConsumer consumer) { if (!(consumer instanceof SceneChangeConsumer)) { return null; diff --git a/src/main/java/com/ss/editor/util/GLSLType.java b/src/main/java/com/ss/editor/util/GLSLType.java new file mode 100644 index 00000000..dec0f06d --- /dev/null +++ b/src/main/java/com/ss/editor/util/GLSLType.java @@ -0,0 +1,116 @@ +package com.ss.editor.util; + +import static com.ss.rlib.util.ObjectUtils.notNull; +import com.ss.editor.annotation.FromAnyThread; +import com.ss.rlib.util.dictionary.DictionaryFactory; +import com.ss.rlib.util.dictionary.ObjectDictionary; +import org.jetbrains.annotations.NotNull; + +/** + * The list of all GLSL types. + * + * @author JavaSaBr + */ +public enum GLSLType { + BOOL("bool", "Boolean"), + BOOL_VEC_2("bvec2", "Boolean vector x 2"), + BOOL_VEC_3("bvec3", "Boolean vector x 3"), + BOOL_VEC_4("bvec4", "Boolean vector x 4"), + INT("int", "Integer"), + INT_VEC_2("ivec2", "Integer vector x 2"), + INT_VEC_3("ivec3", "Integer vector x 3"), + INT_VEC_4("ivec4", "Integer vector x 4"), + UNSIGNED_INT("uint", "Unsigned integer"), + UNSIGNED_INT_VEC_2("uvec2", "Unsigned integer vector x 2"), + UNSIGNED_INT_VEC_3("uvec3", "Unsigned integer vector x 3"), + UNSIGNED_INT_VEC_4("uvec4", "Unsigned integer vector x 4"), + FLOAT("float", "Float"), + VEC_2("vec2", "Float vector x 2"), + VEC_3("vec3", "Float vector x 3"), + VEC_4("vec4", "Float vector x 4"), + MAT_2("mat2", "Matrix x 2"), + MAT_3("mat3", "Matrix x 3"), + MAT_4("mat4", "Matrix x 4"), + 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) { + RAW_TYPE_TO_ENUM.put(glslType.getRawType(), glslType); + UI_NAME_TO_ENUM.put(glslType.getUIName(), glslType); + } + } + + /** + * Get the enum value for the raw type. + * + * @param rawType the raw type. + * @return the enum value. + */ + @FromAnyThread + public static @NotNull GLSLType ofRawType(@NotNull final String rawType) { + return notNull(RAW_TYPE_TO_ENUM.get(rawType)); + } + + /** + * Get the enum value for the UI name. + * + * @param uiName the UI name. + * @return the enum value. + */ + @FromAnyThread + public static @NotNull GLSLType ofUIName(@NotNull final String uiName) { + return notNull(RAW_TYPE_TO_ENUM.get(uiName)); + } + + /** + * The type to use in a shader. + */ + @NotNull + private String rawType; + + /** + * The name for UI. + */ + @NotNull + private String uiName; + + GLSLType(@NotNull final String rawType, @NotNull final String uiName) { + this.rawType = rawType; + this.uiName = uiName; + } + + /** + * Get the type to use in a shader. + * + * @return the type to use in a shader. + */ + @FromAnyThread + public @NotNull String getRawType() { + return rawType; + } + + /** + * Get the name for UI. + * + * @return the name for UI. + */ + @FromAnyThread + public @NotNull String getUIName() { + return uiName; + } + + @Override + public String toString() { + return getUIName(); + } +} diff --git a/src/main/java/com/ss/editor/util/NodeUtils.java b/src/main/java/com/ss/editor/util/NodeUtils.java index 2876b744..7040a782 100644 --- a/src/main/java/com/ss/editor/util/NodeUtils.java +++ b/src/main/java/com/ss/editor/util/NodeUtils.java @@ -9,10 +9,10 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.Spatial; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import com.ss.rlib.util.StringUtils; import com.ss.rlib.util.array.Array; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; import java.util.function.Predicate; @@ -236,8 +236,9 @@ public static void visitSpatial(@NotNull final Spatial spati if (type.isInstance(spatial)) { consumer.accept(type.cast(spatial)); - return; - } else if (!(spatial instanceof Node)) { + } + + if (!(spatial instanceof Node)) { return; } diff --git a/src/main/resources/credits/icons.txt b/src/main/resources/credits/icons.txt index c705d602..4eb5f496 100644 --- a/src/main/resources/credits/icons.txt +++ b/src/main/resources/credits/icons.txt @@ -79,4 +79,6 @@ ui/icons/svg/draws.svg icon made by http://www.flaticon.com/authors/freepik from ui/icons/svg/scale-symbol.svg icon made by https://www.flaticon.com/authors/popcic from www.flaticon.com ui/icons/svg/font-selection-editor.svg made by https://www.flaticon.com/authors/dave-gandy from www.flaticon.com ui/icons/svg/inbox.svg icon made by http://www.flaticon.com/authors/freepik from www.flaticon.com -ui/icons/svg/debug.svg icon made by http://www.flaticon.com/authors/freepik from www.flaticon.com \ No newline at end of file +ui/icons/svg/debug.svg icon made by http://www.flaticon.com/authors/freepik from www.flaticon.com +ui/icons/filetypes/vector.svg icon made by https://www.flaticon.com/authors/freepik from www.flaticon.com +ui/icons/svg/import.svg icon made by https://www.flaticon.com/authors/anatoly from www.flaticon.com \ No newline at end of file diff --git a/src/main/resources/messages/messages.properties b/src/main/resources/messages/messages.properties index d13573a3..5cdcc976 100644 --- a/src/main/resources/messages/messages.properties +++ b/src/main/resources/messages/messages.properties @@ -215,6 +215,7 @@ ModelNodeTreeActionSpotLight=Spot light ModelNodeTreeActionAnimationPlay=Play ModelNodeTreeActionAnimationPlaySettings=Play settings ModelNodeTreeActionAnimationStop=Stop +ModelNodeTreeActionAnimationPause=Pause ModelNodeTreeActionAnimationManualExtractSubAnimation=Extract sub-animation manually ModelNodeTreeActionCreateAudioNode=Audio node ModelNodeTreeActionAudioPlay=Play diff --git a/src/main/resources/messages/messages_de.properties b/src/main/resources/messages/messages_de.properties index a6187954..8db421cf 100644 --- a/src/main/resources/messages/messages_de.properties +++ b/src/main/resources/messages/messages_de.properties @@ -215,6 +215,7 @@ ModelNodeTreeActionSpotLight=Projizierende Lichtquelle ModelNodeTreeActionAnimationPlay=Abspielen ModelNodeTreeActionAnimationPlaySettings=Abspieleinstellungen ModelNodeTreeActionAnimationStop=Stoppen +ModelNodeTreeActionAnimationPause=Pause ModelNodeTreeActionAnimationManualExtractSubAnimation=Manuelles Entnehmen der Animation ModelNodeTreeActionCreateAudioNode=Audioknoten ModelNodeTreeActionAudioPlay=Abspielen diff --git a/src/main/resources/messages/messages_ru.properties b/src/main/resources/messages/messages_ru.properties index b09f0a06..bd595971 100644 --- a/src/main/resources/messages/messages_ru.properties +++ b/src/main/resources/messages/messages_ru.properties @@ -217,6 +217,7 @@ ModelNodeTreeActionSpotLight=Световое пятно ModelNodeTreeActionAnimationPlay=Воспроизвести ModelNodeTreeActionAnimationPlaySettings=Настройки воспроизведения ModelNodeTreeActionAnimationStop=Остановить +ModelNodeTreeActionAnimationPause=Пауза ModelNodeTreeActionAnimationManualExtractSubAnimation=Извлечь вручную анимацию ModelNodeTreeActionCreateAudioNode=Аудио узел ModelNodeTreeActionAudioPlay=Проиграть diff --git a/src/main/resources/ui/css/custom_classes.css b/src/main/resources/ui/css/custom_classes.css index a461f3f3..d74aeffd 100644 --- a/src/main/resources/ui/css/custom_classes.css +++ b/src/main/resources/ui/css/custom_classes.css @@ -147,6 +147,29 @@ -fx-opacity: -var-disabled-opacity; } +.text-input-container-without-padding { + -fx-background: -var-button-background-color; + -fx-background-color: -fx-background; + -fx-background-insets: 0px; + -fx-background-radius: 2px; + -fx-border-color: -var-border-color; + -fx-border-width: 1px; + -fx-border-radius: 1px; + -fx-padding: 1px 1px 1px 1px; + -fx-min-height: -var-default-field-height; +} + +.text-input-container-without-padding:focused { + -fx-border-color: -var-border-color, -fx-focus-color; + -fx-border-width: 1px, 1px; + -fx-border-insets: 0 0 0 0, 1 1 1 1; + -fx-padding: 0px 0px 0px 0px; +} + +.text-input-container-without-padding:disabled { + -fx-opacity: -var-disabled-opacity; +} + /******************************************************************************* * * * Transparent Text Area * diff --git a/src/main/resources/ui/icons/filetypes/vector.svg b/src/main/resources/ui/icons/filetypes/vector.svg new file mode 100644 index 00000000..b4dd7cc7 --- /dev/null +++ b/src/main/resources/ui/icons/filetypes/vector.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/ui/icons/svg/import.svg b/src/main/resources/ui/icons/svg/import.svg new file mode 100644 index 00000000..a702b113 --- /dev/null +++ b/src/main/resources/ui/icons/svg/import.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +