Skip to content

Commit 87a651b

Browse files
committed
рефакторинг кода
1 parent 8a549f6 commit 87a651b

37 files changed

+250
-214
lines changed

src/com/ss/editor/Editor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public void simpleInitApp() {
268268
InitializeManager.register(FileIconManager.class);
269269
InitializeManager.initialize();
270270

271-
if(Config.ENABLE_PBR) {
271+
if (Config.ENABLE_PBR) {
272272
environmentCamera = new EnvironmentCamera(64, new Vector3f(0, 0, 0));
273273
stateManager.attach(environmentCamera);
274274
}
@@ -362,7 +362,7 @@ private void createProbe() {
362362

363363
final EnvironmentCamera environmentCamera = getEnvironmentCamera();
364364

365-
if(environmentCamera == null) {
365+
if (environmentCamera == null) {
366366
return;
367367
}
368368

@@ -383,7 +383,7 @@ public void updateProbe(final JobProgressAdapter<LightProbe> progressAdapter) {
383383

384384
final LightProbe lightProbe = getLightProbe();
385385

386-
if(lightProbe == null) {
386+
if (lightProbe == null) {
387387
progressAdapter.done(null);
388388
return;
389389
}

src/com/ss/editor/config/CommandLineConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
public class CommandLineConfig {
99

1010
public static void args(String[] args) {
11-
1211
}
1312
}

src/com/ss/editor/manager/ResourceManager.java

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import rlib.logging.Logger;
2121
import rlib.logging.LoggerManager;
2222
import rlib.manager.InitializeManager;
23+
import rlib.util.FileUtils;
2324
import rlib.util.StringUtils;
2425
import rlib.util.array.Array;
2526
import rlib.util.array.ArrayComparator;
@@ -108,19 +109,20 @@ public ResourceManager() {
108109
private void processEvent(final DeletedFileEvent event) {
109110

110111
final Path file = event.getFile();
111-
final String filename = file.getFileName().toString();
112+
final String extension = FileUtils.getExtension(file);
112113

113-
if (filename.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) {
114+
if (!extension.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) {
115+
return;
116+
}
114117

115-
final Path assetFile = EditorUtil.getAssetFile(file);
118+
final Path assetFile = EditorUtil.getAssetFile(file);
116119

117-
final Array<String> materialDefinitions = getMaterialDefinitions();
118-
materialDefinitions.writeLock();
119-
try {
120-
materialDefinitions.fastRemove(toClasspath(assetFile));
121-
} finally {
122-
materialDefinitions.writeUnlock();
123-
}
120+
final Array<String> materialDefinitions = getMaterialDefinitions();
121+
materialDefinitions.writeLock();
122+
try {
123+
materialDefinitions.fastRemove(toClasspath(assetFile));
124+
} finally {
125+
materialDefinitions.writeUnlock();
124126
}
125127
}
126128

@@ -130,25 +132,26 @@ private void processEvent(final DeletedFileEvent event) {
130132
private void processEvent(final CreatedFileEvent event) {
131133

132134
final Path file = event.getFile();
133-
final String filename = file.getFileName().toString();
134-
135-
if (filename.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) {
135+
final String extension = FileUtils.getExtension(file);
136136

137-
final Path assetFile = EditorUtil.getAssetFile(file);
137+
if (!extension.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) {
138+
return;
139+
}
138140

139-
final Array<String> materialDefinitions = getMaterialDefinitions();
140-
materialDefinitions.writeLock();
141-
try {
141+
final Path assetFile = EditorUtil.getAssetFile(file);
142142

143-
final String resource = toClasspath(assetFile);
143+
final Array<String> materialDefinitions = getMaterialDefinitions();
144+
materialDefinitions.writeLock();
145+
try {
144146

145-
if (!materialDefinitions.contains(resource)) {
146-
materialDefinitions.add(resource);
147-
}
147+
final String resource = toClasspath(assetFile);
148148

149-
} finally {
150-
materialDefinitions.writeUnlock();
149+
if (!materialDefinitions.contains(resource)) {
150+
materialDefinitions.add(resource);
151151
}
152+
153+
} finally {
154+
materialDefinitions.writeUnlock();
152155
}
153156
}
154157

@@ -237,9 +240,9 @@ private void reload() {
237240
return;
238241
}
239242

240-
final String filename = file.getFileName().toString();
243+
final String extension = FileUtils.getExtension(file);
241244

242-
if (filename.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) {
245+
if (extension.endsWith(FileExtensions.JME_MATERIAL_DEFINITION)) {
243246
final Path assetFile = EditorUtil.getAssetFile(file);
244247
materialDefinitions.add(toClasspath(assetFile));
245248
}

src/com/ss/editor/serializer/PostFilterViewSerializer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ public static PostFilterViewFile deserialize(final Path file) {
3838
final String stringContent = new String(content);
3939

4040
final Gson gson = GSON_LOCAL.get();
41-
final PostFilterViewFile result = gson.fromJson(stringContent, PostFilterViewFile.class);
4241

43-
return result;
42+
return gson.fromJson(stringContent, PostFilterViewFile.class);
4443
}
4544

4645
/**

src/com/ss/editor/state/editor/impl/model/ModelEditorState.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private ActionListener getActionListener() {
164164
*/
165165
private void processClick(final boolean isPressed) {
166166

167-
if(!isPressed) {
167+
if (!isPressed) {
168168
return;
169169
}
170170

@@ -186,14 +186,14 @@ private void processClick(final boolean isPressed) {
186186

187187
final ModelFileEditor editor = getEditor();
188188

189-
if(results.size() < 1) {
189+
if (results.size() < 1) {
190190
EXECUTOR_MANAGER.addFXTask(() -> editor.notifySelected(null));
191191
return;
192192
}
193193

194194
final CollisionResult collision = results.getClosestCollision();
195195

196-
if(collision == null) {
196+
if (collision == null) {
197197
EXECUTOR_MANAGER.addFXTask(() -> editor.notifySelected(null));
198198
return;
199199
}
@@ -347,7 +347,7 @@ public void initialize(final AppStateManager stateManager, final Application app
347347

348348
final InputManager inputManager = EDITOR.getInputManager();
349349

350-
if(!inputManager.hasMapping(mappingName)) {
350+
if (!inputManager.hasMapping(mappingName)) {
351351
inputManager.addMapping(mappingName, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
352352
}
353353

@@ -377,7 +377,7 @@ public void update(float tpf) {
377377
final Spatial selected = getSelected();
378378
final Spatial selectionShape = getSelectionShape();
379379

380-
if(selected != null && selectionShape != null) {
380+
if (selected != null && selectionShape != null) {
381381
selectionShape.setLocalTranslation(selected.getWorldTranslation());
382382
selectionShape.setLocalRotation(selected.getWorldRotation());
383383
selectionShape.setLocalScale(selected.getWorldScale());
@@ -444,11 +444,11 @@ private void changeFastSkyImpl(Spatial fastSky) {
444444
final Node stateNode = getStateNode();
445445
final Spatial currentFastSky = getCurrentFastSky();
446446

447-
if(currentFastSky != null) {
447+
if (currentFastSky != null) {
448448
stateNode.detachChild(currentFastSky);
449449
}
450450

451-
if(fastSky == null) {
451+
if (fastSky == null) {
452452
return;
453453
}
454454

@@ -508,24 +508,24 @@ public void updateSelection(final Spatial spatial) {
508508
*/
509509
private void updateSelectionImpl(final Spatial spatial) {
510510

511-
if(getSelected() == spatial) {
511+
if (getSelected() == spatial) {
512512
return;
513513
}
514514

515515
final Node toolNode = getToolNode();
516516
final Spatial selectionShape = getSelectionShape();
517517

518-
if(spatial == null && selectionShape != null) {
518+
if (spatial == null && selectionShape != null) {
519519
toolNode.detachChild(selectionShape);
520520
setSelectionShape(null);
521521
setSelected(null);
522522
return;
523-
} else if(spatial == null) {
523+
} else if (spatial == null) {
524524
setSelected(null);
525525
return;
526526
}
527527

528-
if(selectionShape != null) {
528+
if (selectionShape != null) {
529529
toolNode.detachChild(selectionShape);
530530
}
531531

@@ -539,13 +539,13 @@ private void updateSelectionImpl(final Spatial spatial) {
539539
shape = buildBoxSelection(spatial);
540540
}
541541

542-
if(shape == null) {
542+
if (shape == null) {
543543
setSelectionShape(null);
544544
setSelected(null);
545545
return;
546546
}
547547

548-
if(isShowSelection()) {
548+
if (isShowSelection()) {
549549
toolNode.attachChild(shape);
550550
}
551551

@@ -575,7 +575,7 @@ private Spatial buildBoxSelection(final Spatial spatial) {
575575

576576
return geometry;
577577

578-
} else if(bound instanceof BoundingSphere) {
578+
} else if (bound instanceof BoundingSphere) {
579579

580580
final BoundingSphere boundingSphere = (BoundingSphere) bound;
581581

@@ -653,16 +653,16 @@ public void updateShowSelection(final boolean showSelection) {
653653
*/
654654
private void updateShowSelectionImpl(boolean showSelection) {
655655

656-
if(isShowSelection() == showSelection) {
656+
if (isShowSelection() == showSelection) {
657657
return;
658658
}
659659

660660
final Spatial selectionShape = getSelectionShape();
661661
final Node toolNode = getToolNode();
662662

663-
if(showSelection && selectionShape != null) {
663+
if (showSelection && selectionShape != null) {
664664
toolNode.attachChild(selectionShape);
665-
} else if(!showSelection && selectionShape != null) {
665+
} else if (!showSelection && selectionShape != null) {
666666
toolNode.detachChild(selectionShape);
667667
}
668668

@@ -681,14 +681,14 @@ public void updateShowGrid(final boolean showGrid) {
681681
*/
682682
private void updateShowGridImpl(final boolean showGrid) {
683683

684-
if(isShowGrid() == showGrid) {
684+
if (isShowGrid() == showGrid) {
685685
return;
686686
}
687687

688688
final Node toolNode = getToolNode();
689689
final Geometry grid = getGrid();
690690

691-
if(showGrid) {
691+
if (showGrid) {
692692
toolNode.attachChild(grid);
693693
} else {
694694
toolNode.detachChild(grid);

src/com/ss/editor/state/editor/impl/post/filter/PostFilterEditorState.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ public void addFilter(final Material material) {
106106
EXECUTOR_MANAGER.addEditorThreadTask(() -> addFilterImpl(material));
107107
}
108108

109-
private void addFilterImpl(Material material) {
109+
/**
110+
* Процесс добавление нового материала.
111+
*/
112+
private void addFilterImpl(final Material material) {
110113

111114
final GenericFilter genericFilter = new GenericFilter(material, false, true);
112115
final FilterPostProcessor postProcessor = EDITOR.getPostProcessor();
@@ -139,7 +142,10 @@ public void removeFilter(final Material material) {
139142
EXECUTOR_MANAGER.addEditorThreadTask(() -> removeFilterImpl(material));
140143
}
141144

142-
private void removeFilterImpl(Material material) {
145+
/**
146+
* Процесс удаления материала.
147+
*/
148+
private void removeFilterImpl(final Material material) {
143149

144150
final FilterPostProcessor postProcessor = EDITOR.getPostProcessor();
145151

src/com/ss/editor/ui/component/asset/AssetBarComponent.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.ss.editor.ui.component.asset;
22

33
import com.ss.editor.ui.Icons;
4+
import com.ss.editor.ui.css.CSSClasses;
45
import com.ss.editor.ui.css.CSSIds;
56
import com.ss.editor.ui.event.FXEventManager;
67
import com.ss.editor.ui.event.impl.RequestedRefreshAssetEvent;
@@ -10,9 +11,6 @@
1011
import javafx.scene.layout.HBox;
1112
import rlib.ui.util.FXUtils;
1213

13-
import static com.ss.editor.ui.css.CSSClasses.TOOLBAR_BUTTON;
14-
import static com.ss.editor.ui.css.CSSIds.ASSET_COMPONENT_BAR_BUTTON;
15-
1614
/**
1715
* Компонент для реализации тулбара с акшенами.
1816
*
@@ -26,11 +24,11 @@ public AssetBarComponent() {
2624
setId(CSSIds.ASSET_COMPONENT_BAR);
2725

2826
final Button refreshAction = new Button();
29-
refreshAction.setId(ASSET_COMPONENT_BAR_BUTTON);
27+
refreshAction.setId(CSSIds.ASSET_COMPONENT_BAR_BUTTON);
3028
refreshAction.setGraphic(new ImageView(Icons.REFRESH_18));
3129
refreshAction.setOnAction(event -> FX_EVENT_MANAGER.notify(new RequestedRefreshAssetEvent()));
3230

33-
FXUtils.addClassTo(refreshAction, TOOLBAR_BUTTON);
31+
FXUtils.addClassTo(refreshAction, CSSClasses.TOOLBAR_BUTTON);
3432
FXUtils.addToPane(refreshAction, this);
3533
}
3634
}

src/com/ss/editor/ui/component/asset/tree/ResourceTree.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class ResourceTree extends TreeView<ResourceElement> {
6262
final int firstLevel = getLevel(first);
6363
final int secondLevel = getLevel(second);
6464

65-
if(firstLevel != secondLevel) {
65+
if (firstLevel != secondLevel) {
6666
return firstLevel - secondLevel;
6767
}
6868

@@ -83,7 +83,7 @@ public class ResourceTree extends TreeView<ResourceElement> {
8383
final int firstLevel = getLevel(firstElement);
8484
final int secondLevel = getLevel(secondElement);
8585

86-
if(firstLevel != secondLevel) {
86+
if (firstLevel != secondLevel) {
8787
return firstLevel - secondLevel;
8888
}
8989

@@ -92,7 +92,7 @@ public class ResourceTree extends TreeView<ResourceElement> {
9292

9393
private static int getLevel(final ResourceElement element) {
9494

95-
if(element instanceof FolderElement) {
95+
if (element instanceof FolderElement) {
9696
return 1;
9797
}
9898

src/com/ss/editor/ui/component/bar/EditorBarComponent.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.ss.editor.ui.component.ScreenComponent;
55
import com.ss.editor.ui.component.bar.action.OpenAssetAction;
66
import com.ss.editor.ui.component.bar.action.OpenSettingsAction;
7+
import com.ss.editor.ui.css.CSSClasses;
78
import com.ss.editor.ui.css.CSSIds;
89
import com.ss.editor.ui.util.UIUtils;
910

@@ -14,9 +15,6 @@
1415
import rlib.ui.util.FXUtils;
1516
import rlib.util.array.Array;
1617

17-
import static com.ss.editor.ui.css.CSSClasses.MAIN_FONT_13;
18-
import static com.ss.editor.ui.css.CSSClasses.TRANSPARENT_MENU_ITEM;
19-
2018
/**
2119
* Реализация меню бара для редактора.
2220
*
@@ -39,8 +37,8 @@ private void createItems() {
3937
menus.add(createSettingsMenu());
4038

4139
final Array<MenuItem> allItems = UIUtils.getAllItems(this);
42-
allItems.forEach(menuItem -> FXUtils.addClassTo(menuItem, MAIN_FONT_13));
43-
allItems.forEach(menuItem -> FXUtils.addClassTo(menuItem, TRANSPARENT_MENU_ITEM));
40+
allItems.forEach(menuItem -> FXUtils.addClassTo(menuItem, CSSClasses.MAIN_FONT_13));
41+
allItems.forEach(menuItem -> FXUtils.addClassTo(menuItem, CSSClasses.TRANSPARENT_MENU_ITEM));
4442
}
4543

4644
private Menu createAssetMenu() {

0 commit comments

Comments
 (0)