diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties
index 46eac5375..7f75f02f5 100644
--- a/core/resources/l10n/messages.properties
+++ b/core/resources/l10n/messages.properties
@@ -1061,8 +1061,6 @@ StorageOptChooser.lbl.seconds = seconds
StorageOptChooser.rdbut.Onlyprimfig = Only primary figures
StorageOptChooser.lbl.longC1 = Store only the values shown in the summary table.
StorageOptChooser.lbl.longC2 = This results in the smallest files.
-StorageOptChooser.checkbox.IncludeDecals = Include decals
-StorageOptChooser.lbl.IncludeDecals = "Including decals will produce a compressed zip file"
StorageOptChooser.lbl.longD1 = An estimate on how large the resulting file would be with the present options.
StorageOptChooser.ttip.Saveopt = Save options
StorageOptChooser.lbl.Estfilesize = Estimated file size:
diff --git a/core/src/net/sf/openrocket/document/StorageOptions.java b/core/src/net/sf/openrocket/document/StorageOptions.java
index 5ecb38b1c..4618aa5d2 100644
--- a/core/src/net/sf/openrocket/document/StorageOptions.java
+++ b/core/src/net/sf/openrocket/document/StorageOptions.java
@@ -14,8 +14,6 @@ public class StorageOptions implements Cloneable {
private FileType fileType = FileType.OPENROCKET;
- private boolean includeDecals = false;
-
private double simulationTimeSkip = SIMULATION_DATA_NONE;
private boolean explicitlySet = false;
@@ -28,14 +26,6 @@ public class StorageOptions implements Cloneable {
this.fileType = fileType;
}
- public boolean isIncludeDecals() {
- return includeDecals;
- }
-
- public void setIncludeDecals(boolean includeDecals) {
- this.includeDecals = includeDecals;
- }
-
public double getSimulationTimeSkip() {
return simulationTimeSkip;
}
diff --git a/core/src/net/sf/openrocket/file/GeneralRocketLoader.java b/core/src/net/sf/openrocket/file/GeneralRocketLoader.java
index 18974131c..0211f5064 100644
--- a/core/src/net/sf/openrocket/file/GeneralRocketLoader.java
+++ b/core/src/net/sf/openrocket/file/GeneralRocketLoader.java
@@ -121,7 +121,6 @@ public class GeneralRocketLoader {
}
if (entry.getName().matches(".*\\.[oO][rR][kK]$")) {
OpenRocketDocument doc = loadFromStream(in, motorFinder);
- doc.getDefaultStorageOptions().setIncludeDecals(true);
doc.getDecalRegistry().setIsZipFile(true);
return doc;
} else if ( entry.getName().matches(".*\\.[rR][kK][tT]$")) {
diff --git a/core/src/net/sf/openrocket/file/GeneralRocketSaver.java b/core/src/net/sf/openrocket/file/GeneralRocketSaver.java
index e8a1bad52..da1e7e7cf 100644
--- a/core/src/net/sf/openrocket/file/GeneralRocketSaver.java
+++ b/core/src/net/sf/openrocket/file/GeneralRocketSaver.java
@@ -18,6 +18,7 @@ import net.sf.openrocket.appearance.AppearanceBuilder;
import net.sf.openrocket.appearance.Decal;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.StorageOptions;
+import net.sf.openrocket.document.StorageOptions.FileType;
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
import net.sf.openrocket.file.rocksim.export.RocksimSaver;
import net.sf.openrocket.rocketcomponent.RocketComponent;
@@ -229,6 +230,11 @@ public class GeneralRocketSaver {
}
// Now we have to loop through all the components and update their names.
+ // FIXME - we probably don't want to modify the existing document.
+ // Suppose the user has been using a couple of decal files from the file system.
+ // He currently is editing some decal files, but decides to do an itermediate save.
+ // The saved file should contain references to the decal copied into the zip container,
+ // however, the currently open document should still be looking at the filesystem copy.
for( RocketComponent c : document.getRocket() ) {
if ( c.getAppearance() == null ) {
@@ -248,7 +254,23 @@ public class GeneralRocketSaver {
c.setAppearance(builder.getAppearance());
}
+
+ Map decalMap = new HashMap();
+ for( Map.Entry image : decals.entrySet() ) {
+ String newName = decalNameNormalization.get(image.getKey());
+ decalMap.put(newName, image.getValue());
+ }
+ if ( options.getFileType() == FileType.OPENROCKET ) {
+ saveAllPartsZipFile(fileName, output, document, options, decalMap);
+ } else {
+ saveInternal(output, document, options);
+ output.close();
+ }
+ }
+
+ public void saveAllPartsZipFile(String fileName, OutputStream output, OpenRocketDocument document, StorageOptions options, Map decals) throws IOException {
+
// Open a zip stream to write to.
ZipOutputStream zos = new ZipOutputStream(output);
zos.setLevel(9);
@@ -265,8 +287,8 @@ public class GeneralRocketSaver {
for( Map.Entry image : decals.entrySet() ) {
- String newName = decalNameNormalization.get(image.getKey());
- ZipEntry decal = new ZipEntry(newName);
+ String name = image.getKey();
+ ZipEntry decal = new ZipEntry(name);
zos.putNextEntry(decal);
InputStream is = image.getValue();
diff --git a/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java b/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java
index 87af02831..eff692e2a 100644
--- a/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java
+++ b/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java
@@ -62,7 +62,6 @@ public class RocksimSaver extends RocketSaver {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8"));
writer.write(marshalToRocksim(doc));
writer.flush();
- writer.close();
}
@Override
diff --git a/core/src/net/sf/openrocket/gui/StorageOptionChooser.java b/core/src/net/sf/openrocket/gui/StorageOptionChooser.java
index 62f605f1d..eac318011 100644
--- a/core/src/net/sf/openrocket/gui/StorageOptionChooser.java
+++ b/core/src/net/sf/openrocket/gui/StorageOptionChooser.java
@@ -39,8 +39,6 @@ public class StorageOptionChooser extends JPanel {
private JSpinner timeSpinner;
- private JCheckBox decalButton;
-
private JLabel estimateLabel;
@@ -122,14 +120,6 @@ public class StorageOptionChooser extends JPanel {
noneButton.addActionListener(actionUpdater);
this.add(noneButton, "spanx, wrap 20lp");
- //// Save decals
- // FIXME - should we hide this if there are no decals?
- decalButton = new JCheckBox(trans.get("StorageOptChooser.checkbox.IncludeDecals"));
- decalButton.setToolTipText(trans.get("StorageOptChooser.lbl.IncludeDecals"));
- decalButton.addActionListener(actionUpdater);
- this.add(decalButton, "spanx, wrap para");
-
-
// Estimate is updated in loadOptions(opts)
estimateLabel = new JLabel("");
//// An estimate on how large the resulting file would
@@ -167,8 +157,6 @@ public class StorageOptionChooser extends JPanel {
timeSpinner.setValue(t);
artificialEvent = false;
- decalButton.setSelected(opts.isIncludeDecals());
-
updateEstimate();
}
@@ -186,8 +174,6 @@ public class StorageOptionChooser extends JPanel {
opts.setSimulationTimeSkip(t);
- opts.setIncludeDecals(decalButton.isSelected());
-
opts.setExplicitlySet(true);
}