Skip to content

Commit 74bfd7e

Browse files
committed
updated API.
1 parent a0fd282 commit 74bfd7e

13 files changed

Lines changed: 18 additions & 37 deletions

src/main/java/com/ss/editor/file/converter/impl/AbstractFileConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.jetbrains.annotations.NotNull;
1919
import org.jetbrains.annotations.Nullable;
2020

21+
import java.io.IOException;
2122
import java.nio.file.Files;
2223
import java.nio.file.Path;
2324

@@ -119,7 +120,8 @@ public void convert(@NotNull final Path source, @NotNull final Path destination)
119120
* @param destination the target file.
120121
* @param overwrite is need to overwrite.
121122
*/
122-
protected void convertImpl(@NotNull final Path source, @NotNull final Path destination, final boolean overwrite) {
123+
protected void convertImpl(@NotNull final Path source, @NotNull final Path destination, final boolean overwrite)
124+
throws IOException {
123125
}
124126

125127
/**

src/main/java/com/ss/editor/file/converter/impl/AbstractModelFileConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private void convert(@NotNull final Path source, @NotNull final ModelConverterDi
7676
* Convert a file using settings from the dialog.
7777
*/
7878
@BackgroundThread
79-
private void convertImpl(@NotNull final Path source, @NotNull final ModelConverterDialog dialog) {
79+
private void convertImpl(@NotNull final Path source, @NotNull final ModelConverterDialog dialog) throws IOException {
8080

8181
final String filename = dialog.getFilename();
8282
final Path destinationFolder = dialog.getDestinationFolder();
@@ -110,8 +110,6 @@ private void convertImpl(@NotNull final Path source, @NotNull final ModelConvert
110110

111111
try (final OutputStream out = Files.newOutputStream(destination, WRITE, TRUNCATE_EXISTING, CREATE)) {
112112
exporter.save(model, out);
113-
} catch (final IOException e) {
114-
LOGGER.warning(this, e);
115113
}
116114

117115
if (isOverwrite) {

src/main/java/com/ss/editor/plugin/api/file/creator/GenericFileCreator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.jetbrains.annotations.NotNull;
1818
import org.jetbrains.annotations.Nullable;
1919

20+
import java.io.IOException;
2021
import java.nio.file.Path;
2122

2223
/**
@@ -95,7 +96,7 @@ protected boolean validate(@NotNull final VarTable vars) {
9596

9697
@Override
9798
@BackgroundThread
98-
protected void writeData(@NotNull final Path resultFile) {
99+
protected void writeData(@NotNull final Path resultFile) throws IOException {
99100
writeData(getVars(), resultFile);
100101
}
101102

@@ -106,7 +107,7 @@ protected void writeData(@NotNull final Path resultFile) {
106107
* @param resultFile the result file.
107108
*/
108109
@BackgroundThread
109-
protected void writeData(@NotNull final VarTable vars, @NotNull final Path resultFile) {
110+
protected void writeData(@NotNull final VarTable vars, @NotNull final Path resultFile) throws IOException {
110111
}
111112

112113
@FromAnyThread

src/main/java/com/ss/editor/ui/component/creator/impl/AbstractFileCreator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ protected void processOk() {
230230
try {
231231

232232
writeData(tempFile);
233-
234233
try {
235234
Files.move(tempFile, fileToCreate, REPLACE_EXISTING, ATOMIC_MOVE);
236235
} catch (final AtomicMoveNotSupportedException ex) {
@@ -254,7 +253,7 @@ protected void processOk() {
254253
* @param resultFile the result file.
255254
*/
256255
@BackgroundThread
257-
protected void writeData(@NotNull final Path resultFile) {
256+
protected void writeData(@NotNull final Path resultFile) throws IOException {
258257
}
259258

260259
@Override

src/main/java/com/ss/editor/ui/component/creator/impl/EmptyModelCreator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,14 @@ protected String getFileExtension() {
4848

4949
@Override
5050
@BackgroundThread
51-
protected void writeData(@NotNull final Path resultFile) {
51+
protected void writeData(@NotNull final Path resultFile) throws IOException {
5252
super.writeData(resultFile);
5353

5454
final BinaryExporter exporter = BinaryExporter.getInstance();
5555
final Node newNode = new Node("Model root");
5656

5757
try (final OutputStream out = Files.newOutputStream(resultFile, WRITE, TRUNCATE_EXISTING, CREATE)) {
5858
exporter.save(newNode, out);
59-
} catch (final IOException e) {
60-
LOGGER.warning(this, e);
6159
}
6260
}
6361
}

src/main/java/com/ss/editor/ui/component/creator/impl/EmptySceneCreator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ protected String getFileExtension() {
4949

5050
@Override
5151
@BackgroundThread
52-
protected void writeData(@NotNull final Path resultFile) {
52+
protected void writeData(@NotNull final Path resultFile) throws IOException {
5353
super.writeData(resultFile);
5454

5555
final BinaryExporter exporter = BinaryExporter.getInstance();
5656
final SceneNode newNode = createScene();
5757

5858
try (final OutputStream out = Files.newOutputStream(resultFile, WRITE, TRUNCATE_EXISTING, CREATE)) {
5959
exporter.save(newNode, out);
60-
} catch (final IOException e) {
61-
LOGGER.warning(this, e);
6260
}
6361
}
6462

src/main/java/com/ss/editor/ui/component/creator/impl/material/MaterialFileCreator.java

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

33
import static com.ss.editor.FileExtensions.JME_MATERIAL;
44
import static com.ss.rlib.util.ObjectUtils.notNull;
5-
import static java.nio.file.StandardOpenOption.CREATE;
6-
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
7-
import static java.nio.file.StandardOpenOption.WRITE;
5+
import static java.nio.file.StandardOpenOption.*;
86
import com.jme3.asset.AssetManager;
97
import com.jme3.material.Material;
108
import com.ss.editor.Messages;
@@ -17,7 +15,6 @@
1715
import com.ss.editor.plugin.api.property.PropertyDefinition;
1816
import com.ss.editor.serializer.MaterialSerializer;
1917
import com.ss.editor.ui.component.creator.FileCreatorDescription;
20-
import com.ss.editor.util.EditorUtil;
2118
import com.ss.rlib.util.StringUtils;
2219
import com.ss.rlib.util.VarTable;
2320
import com.ss.rlib.util.array.Array;
@@ -125,7 +122,7 @@ protected boolean validate(@NotNull final VarTable vars) {
125122

126123
@Override
127124
@BackgroundThread
128-
protected void writeData(@NotNull final VarTable vars, @NotNull final Path resultFile) {
125+
protected void writeData(@NotNull final VarTable vars, @NotNull final Path resultFile) throws IOException {
129126
super.writeData(vars, resultFile);
130127

131128
final AssetManager assetManager = EDITOR.getAssetManager();
@@ -138,8 +135,6 @@ protected void writeData(@NotNull final VarTable vars, @NotNull final Path resul
138135

139136
try (final PrintWriter out = new PrintWriter(Files.newOutputStream(resultFile, WRITE, TRUNCATE_EXISTING, CREATE))) {
140137
out.print(materialContent);
141-
} catch (final IOException e) {
142-
EditorUtil.handleException(LOGGER, this, e);
143138
}
144139
}
145140
}

src/main/java/com/ss/editor/ui/component/creator/impl/texture/SingleColorTextureFileCreator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected boolean validate(@NotNull final VarTable vars) {
140140

141141
@Override
142142
@BackgroundThread
143-
protected void writeData(@NotNull final VarTable vars, final @NotNull Path resultFile) {
143+
protected void writeData(@NotNull final VarTable vars, final @NotNull Path resultFile) throws IOException {
144144
super.writeData(vars, resultFile);
145145

146146
final Color color = UIUtils.from(vars.get(PROP_COLOR, ColorRGBA.class));
@@ -161,8 +161,6 @@ protected void writeData(@NotNull final VarTable vars, final @NotNull Path resul
161161

162162
try (final OutputStream out = Files.newOutputStream(resultFile)) {
163163
ImageIO.write(bufferedImage, "png", out);
164-
} catch (final IOException e) {
165-
throw new RuntimeException(e);
166164
}
167165
}
168166
}

src/main/java/com/ss/editor/ui/component/editor/impl/AbstractFileEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public void save(@Nullable final Consumer<@NotNull FileEditor> callback) {
394394
* @param toStore the file to store.
395395
*/
396396
@BackgroundThread
397-
protected void doSave(@NotNull final Path toStore) {
397+
protected void doSave(@NotNull final Path toStore) throws IOException {
398398
}
399399

400400
/**

src/main/java/com/ss/editor/ui/component/editor/impl/CodeAreaFileEditor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,14 @@ private void setOriginalContent(@NotNull final String originalContent) {
126126

127127
@Override
128128
@BackgroundThread
129-
public void doSave(@NotNull final Path toStore) {
129+
public void doSave(@NotNull final Path toStore) throws IOException {
130130
super.doSave(toStore);
131131

132132
final CodeArea codeArea = getCodeArea();
133133
final String newContent = codeArea.getText();
134134

135135
try (final PrintWriter out = new PrintWriter(Files.newOutputStream(toStore))) {
136136
out.print(newContent);
137-
} catch (final IOException e) {
138-
LOGGER.warning(this, e);
139137
}
140138
}
141139

0 commit comments

Comments
 (0)