Skip to content

Commit 70beef1

Browse files
committed
refactoring controls.
1 parent 17030e5 commit 70beef1

19 files changed

+199
-141
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ junitPlatform {
7676
repositories {
7777
mavenCentral()
7878
jcenter()
79+
mavenLocal()
7980
maven {
8081
url 'https://jitpack.io'
8182
}
@@ -131,7 +132,7 @@ dependencies {
131132
compile group: 'org.fxmisc.richtext', name: 'richtextfx', version: '1.0.0-SNAPSHOT'
132133
compile 'org.controlsfx:controlsfx:9.0.0'
133134
compile 'com.spaceshift:rlib.fx:4.2.1-Final'
134-
compile 'com.spaceshift:rlib:6.8.5-Final'
135+
compile 'com.spaceshift:rlib:6.9.1.Final'
135136
compile ('com.jme3x:jme-jfx:1.7.5-Final') {
136137
exclude group: 'org.jmonkeyengine'
137138
}

src/main/java/com/ss/editor/ui/control/property/builder/impl/AudioNodePropertyBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.ss.editor.ui.control.property.impl.AudioKeyPropertyControl;
1414
import com.ss.editor.ui.control.property.impl.BooleanPropertyControl;
1515
import com.ss.editor.ui.control.property.impl.FloatPropertyControl;
16-
import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl;
16+
import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl;
1717
import com.ss.editor.util.AudioNodeUtils;
1818
import com.ss.editor.util.EditorUtil;
1919
import com.ss.rlib.ui.util.FXUtils;
@@ -189,14 +189,14 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
189189
audioKeyControl.setSyncHandler(AudioNodeUtils::getAudioKey);
190190
audioKeyControl.setEditObject(audioNode);
191191

192-
final Vector3FPropertyControl<ModelChangeConsumer, AudioNode> velocityControl = new Vector3FPropertyControl<>(velocity,
192+
final Vector3fPropertyControl<ModelChangeConsumer, AudioNode> velocityControl = new Vector3fPropertyControl<>(velocity,
193193
Messages.MODEL_PROPERTY_VELOCITY, changeConsumer);
194194

195195
velocityControl.setApplyHandler(AudioNode::setVelocity);
196196
velocityControl.setSyncHandler(AudioNode::getVelocity);
197197
velocityControl.setEditObject(audioNode);
198198

199-
final Vector3FPropertyControl<ModelChangeConsumer, AudioNode> directionControl = new Vector3FPropertyControl<>(direction,
199+
final Vector3fPropertyControl<ModelChangeConsumer, AudioNode> directionControl = new Vector3fPropertyControl<>(direction,
200200
Messages.MODEL_PROPERTY_DIRECTION, changeConsumer);
201201

202202
directionControl.setApplyHandler(AudioNode::setDirection);

src/main/java/com/ss/editor/ui/control/property/builder/impl/EditableObjectPropertyBuilder.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.jme3.texture.Texture2D;
77
import com.ss.editor.annotation.FxThread;
88
import com.ss.editor.extension.property.EditableProperty;
9-
import com.ss.editor.extension.property.EditablePropertyType;
109
import com.ss.editor.model.undo.editor.ChangeConsumer;
1110
import com.ss.editor.ui.control.property.PropertyControl;
1211
import com.ss.editor.ui.control.property.impl.*;
@@ -146,8 +145,8 @@ protected void buildFor(
146145
final EditableProperty<Vector2f, ?> property = cast(description);
147146
final Vector2f currentValue = property.getValue();
148147

149-
final Vector2FPropertyControl<C, EditableProperty<Vector2f, ?>> propertyControl =
150-
new Vector2FPropertyControl<>(currentValue, property.getName(), changeConsumer);
148+
final Vector2fPropertyControl<C, EditableProperty<Vector2f, ?>> propertyControl =
149+
new Vector2fPropertyControl<>(currentValue, property.getName(), changeConsumer);
151150

152151
addControl(container, property, propertyControl);
153152
break;
@@ -157,8 +156,8 @@ protected void buildFor(
157156
final EditableProperty<Vector3f, ?> property = cast(description);
158157
final Vector3f currentValue = property.getValue();
159158

160-
final Vector3FPropertyControl<C, EditableProperty<Vector3f, ?>> propertyControl =
161-
new Vector3FPropertyControl<>(currentValue, property.getName(), changeConsumer);
159+
final Vector3fPropertyControl<C, EditableProperty<Vector3f, ?>> propertyControl =
160+
new Vector3fPropertyControl<>(currentValue, property.getName(), changeConsumer);
162161

163162
addControl(container, property, propertyControl);
164163
break;

src/main/java/com/ss/editor/ui/control/property/builder/impl/EmitterShapePropertyBuilder.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import com.ss.editor.model.undo.editor.ModelChangeConsumer;
1212
import com.ss.editor.ui.control.property.builder.PropertyBuilder;
1313
import com.ss.editor.ui.control.property.impl.FloatPropertyControl;
14-
import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl;
14+
import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl;
1515
import com.ss.rlib.ui.util.FXUtils;
1616
import javafx.scene.layout.VBox;
1717
import org.jetbrains.annotations.NotNull;
@@ -72,8 +72,8 @@ private void createControls(@NotNull final VBox container, @NotNull final ModelC
7272

7373
final Vector3f point = shape.getPoint();
7474

75-
final Vector3FPropertyControl<ModelChangeConsumer, EmitterPointShape> pointControl =
76-
new Vector3FPropertyControl<>(point, Messages.MODEL_PROPERTY_POINT, changeConsumer);
75+
final Vector3fPropertyControl<ModelChangeConsumer, EmitterPointShape> pointControl =
76+
new Vector3fPropertyControl<>(point, Messages.MODEL_PROPERTY_POINT, changeConsumer);
7777

7878
pointControl.setSyncHandler(EmitterPointShape::getPoint);
7979
pointControl.setApplyHandler(EmitterPointShape::setPoint);
@@ -96,15 +96,15 @@ private void createControls(@NotNull final VBox container, @NotNull final ModelC
9696
final Vector3f length = shape.getLen();
9797
final Vector3f min = shape.getMin();
9898

99-
final Vector3FPropertyControl<ModelChangeConsumer, EmitterBoxShape> lengthControl =
100-
new Vector3FPropertyControl<>(length, Messages.MODEL_PROPERTY_LENGTH, changeConsumer);
99+
final Vector3fPropertyControl<ModelChangeConsumer, EmitterBoxShape> lengthControl =
100+
new Vector3fPropertyControl<>(length, Messages.MODEL_PROPERTY_LENGTH, changeConsumer);
101101

102102
lengthControl.setSyncHandler(EmitterBoxShape::getLen);
103103
lengthControl.setApplyHandler(EmitterBoxShape::setLen);
104104
lengthControl.setEditObject(shape);
105105

106-
final Vector3FPropertyControl<ModelChangeConsumer, EmitterBoxShape> minControl =
107-
new Vector3FPropertyControl<>(min, Messages.MODEL_PROPERTY_MIN, changeConsumer);
106+
final Vector3fPropertyControl<ModelChangeConsumer, EmitterBoxShape> minControl =
107+
new Vector3fPropertyControl<>(min, Messages.MODEL_PROPERTY_MIN, changeConsumer);
108108

109109
minControl.setSyncHandler(EmitterBoxShape::getMin);
110110
minControl.setApplyHandler(EmitterBoxShape::setMin);
@@ -135,8 +135,8 @@ private void createControls(@NotNull final VBox container, @NotNull final ModelC
135135
radiusControl.setApplyHandler(EmitterSphereShape::setRadius);
136136
radiusControl.setEditObject(shape);
137137

138-
final Vector3FPropertyControl<ModelChangeConsumer, EmitterSphereShape> centerControl =
139-
new Vector3FPropertyControl<>(center, Messages.MODEL_PROPERTY_CENTER, changeConsumer);
138+
final Vector3fPropertyControl<ModelChangeConsumer, EmitterSphereShape> centerControl =
139+
new Vector3fPropertyControl<>(center, Messages.MODEL_PROPERTY_CENTER, changeConsumer);
140140

141141
centerControl.setSyncHandler(EmitterSphereShape::getCenter);
142142
centerControl.setApplyHandler(EmitterSphereShape::setCenter);

src/main/java/com/ss/editor/ui/control/property/builder/impl/LightPropertyBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.ss.editor.ui.control.property.builder.PropertyBuilder;
1616
import com.ss.editor.ui.control.property.impl.ColorPropertyControl;
1717
import com.ss.editor.ui.control.property.impl.FloatPropertyControl;
18-
import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl;
18+
import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl;
1919
import com.ss.rlib.ui.util.FXUtils;
2020
import javafx.scene.layout.VBox;
2121
import org.jetbrains.annotations.NotNull;
@@ -87,8 +87,8 @@ private void buildForPointLight(@NotNull final PointLight light, @NotNull final
8787
final Vector3f position = light.getPosition().clone();
8888
final float radius = light.getRadius();
8989

90-
final Vector3FPropertyControl<ModelChangeConsumer, PointLight> positionControl =
91-
new Vector3FPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);
90+
final Vector3fPropertyControl<ModelChangeConsumer, PointLight> positionControl =
91+
new Vector3fPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);
9292
positionControl.setApplyHandler(PointLight::setPosition);
9393
positionControl.setSyncHandler(PointLight::getPosition);
9494
positionControl.setEditObject(light);
@@ -122,8 +122,8 @@ private void buildForSpotLight(@NotNull final SpotLight light, @NotNull final VB
122122
directionControl.setSyncHandler(SpotLight::getDirection);
123123
directionControl.setEditObject(light);
124124

125-
final Vector3FPropertyControl<ModelChangeConsumer, SpotLight> positionControl =
126-
new Vector3FPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);
125+
final Vector3fPropertyControl<ModelChangeConsumer, SpotLight> positionControl =
126+
new Vector3fPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);
127127
positionControl.setApplyHandler(SpotLight::setPosition);
128128
positionControl.setSyncHandler(SpotLight::getPosition);
129129
positionControl.setEditObject(light);

src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleEmitterPropertyBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ private void buildFor(@NotNull final VBox container, @NotNull final ModelChangeC
202202
imagesControl.setSyncHandler(SYNC_IMAGES_HANDLER);
203203
imagesControl.setEditObject(emitter);
204204

205-
final Vector3FPropertyControl<ModelChangeConsumer, ParticleEmitter> gravityControl =
206-
new Vector3FPropertyControl<>(gravity, Messages.MODEL_PROPERTY_GRAVITY, changeConsumer);
205+
final Vector3fPropertyControl<ModelChangeConsumer, ParticleEmitter> gravityControl =
206+
new Vector3fPropertyControl<>(gravity, Messages.MODEL_PROPERTY_GRAVITY, changeConsumer);
207207
gravityControl.setApplyHandler(ParticleEmitter::setGravity);
208208
gravityControl.setSyncHandler(ParticleEmitter::getGravity);
209209
gravityControl.setEditObject(emitter);
210210

211-
final Vector3FPropertyControl<ModelChangeConsumer, ParticleEmitter> faceNormalControl =
212-
new Vector3FPropertyControl<>(faceNormal, Messages.MODEL_PROPERTY_FACE_NORMAL, changeConsumer);
211+
final Vector3fPropertyControl<ModelChangeConsumer, ParticleEmitter> faceNormalControl =
212+
new Vector3fPropertyControl<>(faceNormal, Messages.MODEL_PROPERTY_FACE_NORMAL, changeConsumer);
213213
faceNormalControl.setApplyHandler(ParticleEmitter::setFaceNormal);
214214
faceNormalControl.setSyncHandler(SYNC_FACE_NORMAL_HANDLER);
215215
faceNormalControl.setEditObject(emitter);

src/main/java/com/ss/editor/ui/control/property/builder/impl/ParticleInfluencerPropertyBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import com.ss.editor.ui.control.property.builder.PropertyBuilder;
1212
import com.ss.editor.ui.control.property.impl.BooleanPropertyControl;
1313
import com.ss.editor.ui.control.property.impl.FloatPropertyControl;
14-
import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl;
14+
import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl;
1515
import com.ss.rlib.ui.util.FXUtils;
1616
import javafx.scene.layout.VBox;
1717
import org.jetbrains.annotations.NotNull;
@@ -48,8 +48,8 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
4848

4949
final float velocityVariation = influencer.getVelocityVariation();
5050

51-
final Vector3FPropertyControl<ModelChangeConsumer, ParticleInfluencer> initialVelocityControl =
52-
new Vector3FPropertyControl<>(initialVelocity, Messages.MODEL_PROPERTY_INITIAL_VELOCITY, changeConsumer);
51+
final Vector3fPropertyControl<ModelChangeConsumer, ParticleInfluencer> initialVelocityControl =
52+
new Vector3fPropertyControl<>(initialVelocity, Messages.MODEL_PROPERTY_INITIAL_VELOCITY, changeConsumer);
5353

5454
initialVelocityControl.setSyncHandler(ParticleInfluencer::getInitialVelocity);
5555
initialVelocityControl.setApplyHandler(ParticleInfluencer::setInitialVelocity);
@@ -106,8 +106,8 @@ private void createControls(@NotNull final VBox container, final @NotNull ModelC
106106
horizontalControl.setApplyHandler(RadialParticleInfluencer::setHorizontal);
107107
horizontalControl.setEditObject(influencer);
108108

109-
final Vector3FPropertyControl<ModelChangeConsumer, RadialParticleInfluencer> originControl =
110-
new Vector3FPropertyControl<>(origin, Messages.MODEL_PROPERTY_ORIGIN, changeConsumer);
109+
final Vector3fPropertyControl<ModelChangeConsumer, RadialParticleInfluencer> originControl =
110+
new Vector3fPropertyControl<>(origin, Messages.MODEL_PROPERTY_ORIGIN, changeConsumer);
111111

112112
originControl.setSyncHandler(RadialParticleInfluencer::getOrigin);
113113
originControl.setApplyHandler(RadialParticleInfluencer::setOrigin);

src/main/java/com/ss/editor/ui/control/property/builder/impl/PrimitivePropertyBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.ss.editor.model.undo.editor.ModelChangeConsumer;
88
import com.ss.editor.ui.control.property.builder.PropertyBuilder;
99
import com.ss.editor.ui.control.property.impl.DefaultSinglePropertyControl;
10-
import com.ss.editor.ui.control.property.impl.Vector3FPropertyControl;
10+
import com.ss.editor.ui.control.property.impl.Vector3fPropertyControl;
1111
import com.ss.rlib.ui.util.FXUtils;
1212
import javafx.scene.layout.VBox;
1313
import org.jetbrains.annotations.NotNull;
@@ -48,8 +48,8 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
4848
final Vector3f position = (Vector3f) object;
4949
final Vector3f value = position.clone();
5050

51-
final Vector3FPropertyControl<ModelChangeConsumer, Vector3f> control =
52-
new Vector3FPropertyControl<>(value, Messages.MODEL_PROPERTY_VALUE, changeConsumer);
51+
final Vector3fPropertyControl<ModelChangeConsumer, Vector3f> control =
52+
new Vector3fPropertyControl<>(value, Messages.MODEL_PROPERTY_VALUE, changeConsumer);
5353
control.setApplyHandler(Vector3f::set);
5454
control.setSyncHandler(Vector3f::clone);
5555
control.setEditObject(position);

src/main/java/com/ss/editor/ui/control/property/impl/DirectionLightPropertyControl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import org.jetbrains.annotations.NotNull;
77

88
/**
9-
* The implementation of the {@link Vector3FPropertyControl} to edit direction's vector of the {@link Light}.
9+
* The implementation of the {@link Vector3fPropertyControl} to edit direction's vector of the {@link Light}.
1010
*
1111
* @param <T> the light's type.
1212
* @author JavaSaBr
1313
*/
14-
public class DirectionLightPropertyControl<T extends Light> extends Vector3FPropertyControl<ModelChangeConsumer, T> {
14+
public class DirectionLightPropertyControl<T extends Light> extends Vector3fPropertyControl<ModelChangeConsumer, T> {
1515

1616
public DirectionLightPropertyControl(@NotNull final Vector3f element, @NotNull final String paramName,
1717
@NotNull final ModelChangeConsumer modelChangeConsumer) {

src/main/java/com/ss/editor/ui/control/property/impl/FloatPropertyControl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ss.editor.ui.control.property.impl;
22

3+
import static com.ss.rlib.util.NumberUtils.zeroIfNull;
34
import static com.ss.rlib.util.ObjectUtils.notNull;
45
import com.ss.editor.annotation.FromAnyThread;
56
import com.ss.editor.annotation.FxThread;
@@ -8,6 +9,7 @@
89
import com.ss.editor.ui.css.CssClasses;
910
import com.ss.rlib.ui.control.input.FloatTextField;
1011
import com.ss.rlib.ui.util.FXUtils;
12+
import com.ss.rlib.util.NumberUtils;
1113
import javafx.scene.layout.HBox;
1214
import org.jetbrains.annotations.NotNull;
1315
import org.jetbrains.annotations.Nullable;
@@ -124,19 +126,16 @@ protected boolean isSingleRow() {
124126
@Override
125127
@FxThread
126128
protected void reload() {
127-
var value = getPropertyValue();
128129
var valueField = getValueField();
129130
var caretPosition = valueField.getCaretPosition();
130-
valueField.setValue(value == null ? 0F : value);
131+
valueField.setValue(zeroIfNull(getPropertyValue()));
131132
valueField.positionCaret(caretPosition);
132133
}
133134

134-
@FxThread
135135
@Override
136+
@FxThread
136137
public boolean isDirty() {
137-
var currentValue = getValueField().getValue();
138-
var storedValue = getPropertyValue();
139-
return !Objects.equals(storedValue, currentValue);
138+
return !Objects.equals(getValueField().getValue(), getPropertyValue());
140139
}
141140

142141
/**
@@ -150,6 +149,7 @@ private void updateValue() {
150149
}
151150

152151
@Override
152+
@FxThread
153153
protected void apply() {
154154
super.apply();
155155

0 commit comments

Comments
 (0)