Skip to content

Commit ea2672e

Browse files
committed
updated property controls
1 parent 422a48b commit ea2672e

5 files changed

Lines changed: 49 additions & 27 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,12 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
200200
directionControl.setSyncHandler(AudioNode::getDirection);
201201
directionControl.setEditObject(audioNode);
202202

203+
buildSplitLine(container);
204+
203205
FXUtils.addToPane(audioKeyControl, container);
204206
FXUtils.addToPane(velocityControl, container);
205207
FXUtils.addToPane(directionControl, container);
208+
209+
buildSplitLine(container);
206210
}
207211
}

src/com/ss/editor/ui/control/model/property/builder/impl/DefaultControlPropertyBuilder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public class DefaultControlPropertyBuilder extends AbstractPropertyBuilder<Model
3535
@NotNull
3636
private static final PropertyBuilder INSTANCE = new DefaultControlPropertyBuilder();
3737

38+
@NotNull
3839
private static final MotionEvent.Direction[] DIRECTIONS = MotionEvent.Direction.values();
40+
41+
@NotNull
3942
private static final LoopMode[] LOOP_MODES = LoopMode.values();
4043

4144
/**
@@ -175,6 +178,9 @@ private void build(@NotNull final MotionEvent control, @NotNull final VBox conta
175178
rotationControl.setEditObject(control);
176179

177180
FXUtils.addToPane(directionTypeControl, container);
181+
182+
buildSplitLine(container);
183+
178184
FXUtils.addToPane(directionControl, container);
179185
FXUtils.addToPane(rotationControl, container);
180186
}
@@ -264,6 +270,9 @@ private void build(@NotNull final CharacterControl control, @NotNull final VBox
264270
FXUtils.addToPane(gravityControl, container);
265271
FXUtils.addToPane(jumpSpeedControl, container);
266272
FXUtils.addToPane(maxSlopeControl, container);
273+
274+
buildSplitLine(container);
275+
267276
FXUtils.addToPane(viewDirectionControl, container);
268277
FXUtils.addToPane(walkDirectionControl, container);
269278
}
@@ -619,6 +628,9 @@ private void build(@NotNull final PhysicsRigidBody control, @NotNull final VBox
619628
}
620629

621630
FXUtils.addToPane(restitutionControl, container);
631+
632+
buildSplitLine(container);
633+
622634
FXUtils.addToPane(angularVelocityControl, container);
623635
FXUtils.addToPane(gravityControl, container);
624636
FXUtils.addToPane(linearFactorControl, container);

src/com/ss/editor/ui/control/model/property/builder/impl/EditableControlPropertyBuilder.java

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

3+
import static com.ss.rlib.util.ObjectUtils.notNull;
34
import com.jme3.math.ColorRGBA;
45
import com.jme3.math.Vector2f;
56
import com.jme3.math.Vector3f;
7+
import com.ss.editor.extension.property.EditableProperty;
8+
import com.ss.editor.extension.property.EditablePropertyType;
9+
import com.ss.editor.extension.scene.control.EditableControl;
610
import com.ss.editor.model.undo.editor.ModelChangeConsumer;
711
import com.ss.editor.ui.control.model.property.control.*;
812
import com.ss.editor.ui.control.property.AbstractPropertyControl;
913
import com.ss.editor.ui.control.property.builder.impl.AbstractPropertyBuilder;
10-
import com.ss.editor.extension.property.EditableProperty;
11-
import com.ss.editor.extension.property.EditablePropertyType;
12-
import com.ss.editor.extension.scene.control.EditableControl;
13-
import javafx.scene.layout.VBox;
14-
import org.jetbrains.annotations.NotNull;
15-
import org.jetbrains.annotations.Nullable;
1614
import com.ss.rlib.ui.util.FXUtils;
1715
import com.ss.rlib.util.ClassUtils;
1816
import com.ss.rlib.util.array.Array;
19-
20-
import java.util.Objects;
17+
import javafx.scene.layout.VBox;
18+
import org.jetbrains.annotations.NotNull;
19+
import org.jetbrains.annotations.Nullable;
2120

2221
/**
2322
* The property builder to build property controls of editable controls.
@@ -62,7 +61,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
6261
case BOOLEAN: {
6362

6463
final EditableProperty<Boolean, ?> property = cast(editableProperty);
65-
final Boolean value = Objects.requireNonNull(property.getValue(), "Boolean value can't be null.");
64+
final Boolean value = notNull(property.getValue(), "Boolean value can't be null.");
6665

6766
final BooleanModelPropertyControl<EditableProperty<Boolean, ?>> propertyControl =
6867
new BooleanModelPropertyControl<>(value, property.getName(), changeConsumer);
@@ -73,7 +72,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
7372
case FLOAT: {
7473

7574
final EditableProperty<Float, ?> property = cast(editableProperty);
76-
final Float value = Objects.requireNonNull(property.getValue(), "Float value can't be null.");
75+
final Float value = notNull(property.getValue(), "Float value can't be null.");
7776

7877
final FloatModelPropertyControl<EditableProperty<Float, ?>> propertyControl =
7978
new FloatModelPropertyControl<>(value, property.getName(), changeConsumer);
@@ -101,7 +100,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
101100
case INTEGER: {
102101

103102
final EditableProperty<Integer, ?> property = cast(editableProperty);
104-
final Integer value = Objects.requireNonNull(property.getValue(), "Integer value can't be null.");
103+
final Integer value = notNull(property.getValue(), "Integer value can't be null.");
105104

106105
final IntegerModelPropertyControl<EditableProperty<Integer, ?>> propertyControl =
107106
new IntegerModelPropertyControl<>(value, property.getName(), changeConsumer);
@@ -123,7 +122,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
123122
case VECTOR_2F: {
124123

125124
final EditableProperty<Vector2f, ?> property = cast(editableProperty);
126-
final Vector2f value = Objects.requireNonNull(property.getValue(), "Vector2f value can't be null.");
125+
final Vector2f value = notNull(property.getValue(), "Vector2f value can't be null.");
127126

128127
final Vector2fModelPropertyControl<EditableProperty<Vector2f, ?>> propertyControl =
129128
new Vector2fModelPropertyControl<>(value, property.getName(), changeConsumer);
@@ -134,7 +133,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
134133
case VECTOR_3F: {
135134

136135
final EditableProperty<Vector3f, ?> property = cast(editableProperty);
137-
final Vector3f value = Objects.requireNonNull(property.getValue(), "Vector3f value can't be null.");
136+
final Vector3f value = notNull(property.getValue(), "Vector3f value can't be null.");
138137

139138
final Vector3fModelPropertyControl<EditableProperty<Vector3f, ?>> propertyControl =
140139
new Vector3fModelPropertyControl<>(value, property.getName(), changeConsumer);
@@ -145,7 +144,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
145144
case ENUM: {
146145

147146
final EditableProperty<Enum<?>, ?> property = cast(editableProperty);
148-
final Enum<?> value = Objects.requireNonNull(property.getValue(), "Enum value can't be null.");
147+
final Enum<?> value = notNull(property.getValue(), "Enum value can't be null.");
149148

150149
final EnumControlPropertyControl<Enum<?>, EditableProperty<Enum<?>, ?>> propertyControl =
151150
new EnumControlPropertyControl<>(value, property.getName(), changeConsumer);
@@ -178,6 +177,7 @@ protected <T> void addControl(final @NotNull VBox container, @NotNull final Edit
178177
FXUtils.addToPane(propertyControl, container);
179178
}
180179

180+
@NotNull
181181
private <T> EditableProperty<T, ?> cast(@NotNull final EditableProperty<?, ?> property) {
182182
return ClassUtils.unsafeCast(property);
183183
}

src/com/ss/editor/ui/control/model/property/builder/impl/GeometryPropertyBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected void buildForImpl(@NotNull final Object object, @Nullable final Object
149149
* @param geometry the geometry
150150
* @return the boolean
151151
*/
152-
protected boolean canEditMaterial(final Geometry geometry) {
152+
private boolean canEditMaterial(final Geometry geometry) {
153153
return !(geometry instanceof ParticleGeometry);
154154
}
155155
}

src/com/ss/editor/ui/control/model/property/control/AudioKeyModelPropertyEditor.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static com.ss.editor.util.EditorUtil.*;
44
import static com.ss.rlib.util.ClassUtils.unsafeCast;
5+
import static com.ss.rlib.util.ObjectUtils.notNull;
56
import com.jme3.audio.AudioData;
67
import com.jme3.audio.AudioKey;
78
import com.jme3.audio.AudioNode;
@@ -23,7 +24,6 @@
2324
import com.ss.rlib.util.StringUtils;
2425
import com.ss.rlib.util.array.Array;
2526
import com.ss.rlib.util.array.ArrayFactory;
26-
import javafx.geometry.Insets;
2727
import javafx.scene.control.Button;
2828
import javafx.scene.control.Label;
2929
import javafx.scene.image.ImageView;
@@ -40,7 +40,6 @@
4040
import java.nio.file.Path;
4141
import java.nio.file.Paths;
4242
import java.util.List;
43-
import java.util.Objects;
4443
import java.util.Set;
4544
import java.util.function.Predicate;
4645

@@ -51,26 +50,33 @@
5150
*/
5251
public class AudioKeyModelPropertyEditor extends ModelPropertyControl<AudioNode, AudioKey> {
5352

53+
@NotNull
5454
private static final Predicate<Class<?>> ACTION_TESTER = type -> type == NewFileAction.class ||
5555
type == DeleteFileAction.class ||
5656
type == RenameFileAction.class;
5757

58+
@NotNull
5859
private static final String NO_AUDIO = Messages.AUDIO_KEY_PROPERTY_CONTROL_NO_AUDIO;
59-
private static final Insets BUTTON_OFFSET = new Insets(0, 0, 0, 3);
6060

6161
/**
6262
* The constant FX_EVENT_MANAGER.
6363
*/
64+
@NotNull
6465
protected static final FXEventManager FX_EVENT_MANAGER = FXEventManager.getInstance();
66+
6567
/**
6668
* The constant JFX_APPLICATION.
6769
*/
70+
@NotNull
6871
protected static final JFXApplication JFX_APPLICATION = JFXApplication.getInstance();
72+
6973
/**
7074
* The constant EDITOR.
7175
*/
76+
@NotNull
7277
protected static final Editor EDITOR = Editor.getInstance();
7378

79+
@NotNull
7480
private static final Array<String> AUDIO_EXTENSIONS = ArrayFactory.newArray(String.class);
7581

7682
static {
@@ -82,6 +88,7 @@ public class AudioKeyModelPropertyEditor extends ModelPropertyControl<AudioNode,
8288
/**
8389
* The label with name of the audio key.
8490
*/
91+
@Nullable
8592
private Label audioKeyLabel;
8693

8794
/**
@@ -171,16 +178,14 @@ protected void createComponents(@NotNull final HBox container) {
171178

172179
audioKeyLabel.prefWidthProperty().bind(widthProperty()
173180
.subtract(changeButton.widthProperty())
174-
.subtract(openButton.widthProperty())
175-
.subtract(BUTTON_OFFSET.getLeft() * 2));
181+
.subtract(openButton.widthProperty()));
176182

177183
FXUtils.addToPane(audioKeyLabel, container);
178184
FXUtils.addToPane(changeButton, container);
179185
FXUtils.addToPane(openButton, container);
180186

181-
HBox.setMargin(changeButton, BUTTON_OFFSET);
182-
HBox.setMargin(openButton, BUTTON_OFFSET);
183-
187+
FXUtils.addClassesTo(container, CSSClasses.TEXT_INPUT_CONTAINER,
188+
CSSClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER);
184189
FXUtils.addClassTo(audioKeyLabel, CSSClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL);
185190
FXUtils.addClassesTo(changeButton, openButton, CSSClasses.FLAT_BUTTON,
186191
CSSClasses.INPUT_CONTROL_TOOLBAR_BUTTON);
@@ -195,7 +200,7 @@ protected void processChange() {
195200

196201
private void addAudioData(@NotNull final Path file) {
197202

198-
final Path assetFile = Objects.requireNonNull(getAssetFile(file));
203+
final Path assetFile = notNull(getAssetFile(file));
199204
final AudioKey audioKey = new AudioKey(toAssetPath(assetFile));
200205

201206
changed(audioKey, getPropertyValue());
@@ -219,7 +224,7 @@ protected void processOpen() {
219224
if (StringUtils.isEmpty(assetPath)) return;
220225

221226
final Path assetFile = Paths.get(assetPath);
222-
final Path realFile = Objects.requireNonNull(getRealFile(assetFile));
227+
final Path realFile = notNull(getRealFile(assetFile));
223228
if (!Files.exists(realFile)) return;
224229

225230
final RequestedOpenFileEvent event = new RequestedOpenFileEvent();
@@ -233,8 +238,9 @@ protected void processOpen() {
233238
*
234239
* @return the label with name of the audio key.
235240
*/
236-
protected Label getAudioKeyLabel() {
237-
return audioKeyLabel;
241+
@NotNull
242+
private Label getAudioKeyLabel() {
243+
return notNull(audioKeyLabel);
238244
}
239245

240246
@Override

0 commit comments

Comments
 (0)