Removed the "include decals" storage option - they will always be

included when saving as ork file.  Fixed saving rocksim files - they are
just plain files and have no references to decals.
This commit is contained in:
kruland2607 2012-12-16 21:25:23 -06:00
parent 7db51b9b65
commit e516f99a8f
6 changed files with 24 additions and 30 deletions

View File

@ -1061,8 +1061,6 @@ StorageOptChooser.lbl.seconds = seconds
StorageOptChooser.rdbut.Onlyprimfig = Only primary figures
StorageOptChooser.lbl.longC1 = <html>Store only the values shown in the summary table.<br>
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:

View File

@ -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;
}

View File

@ -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]$")) {

View File

@ -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<String,InputStream> decalMap = new HashMap<String,InputStream>();
for( Map.Entry<String, InputStream> 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<String,InputStream> 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<String, InputStream> 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();

View File

@ -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

View File

@ -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);
}