create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / preset / loader / StreamerLoader.java
index b66e27b2d99a87d2b1b9998a1c8f4ea366e5d876..403ea0f6e28b980e0a59a28b10ef51be0070af3c 100644 (file)
@@ -5,13 +5,25 @@ import net.sf.openrocket.preset.ComponentPreset;
 import net.sf.openrocket.preset.ComponentPreset.Type;
 import net.sf.openrocket.preset.TypedPropertyMap;
 
+import java.io.File;
+
 public class StreamerLoader extends BaseComponentLoader {
 
        private final MaterialHolder materials;
-       
-       public StreamerLoader(MaterialHolder materials) {
-               super(materials);
-               this.materials = materials;
+
+       public StreamerLoader(MaterialHolder theMaterials, File theBasePath) {
+               super(theMaterials, theBasePath);
+               materials = theMaterials;
+
+        //The base component loader adds a bulk material loader, which is incompatible with the surface loader
+        //for a streamer.  Remove the file column parser here so we can set your own in the code that follows.
+        for (int i = 0; i < fileColumns.size(); i++) {
+            RocksimComponentFileColumnParser rocksimComponentFileColumnParser = fileColumns.get(i);
+            if (rocksimComponentFileColumnParser instanceof MaterialColumnParser) {
+                fileColumns.remove(rocksimComponentFileColumnParser);
+            }
+        }
+
                fileColumns.add(new SurfaceMaterialColumnParser(materials,"Material",ComponentPreset.MATERIAL));
                fileColumns.add(new DoubleUnitColumnParser("Length","Units",ComponentPreset.LENGTH));
                fileColumns.add(new DoubleUnitColumnParser("Width","Units",ComponentPreset.WIDTH));
@@ -34,14 +46,14 @@ public class StreamerLoader extends BaseComponentLoader {
        @Override
        protected void postProcess(TypedPropertyMap props) {
                super.postProcess(props);
-               
+
                // Fix the material since some files use bulk materials for streamers.
                Double thickness = props.get( ComponentPreset.THICKNESS );
-               Material.Surface material = (Material.Surface) props.get( ComponentPreset.MATERIAL );
-               
-               material = materials.getSurfaceMaterial(material, thickness);
-               
-               props.put(ComponentPreset.MATERIAL, material);
+               Material.Surface myMaterial = (Material.Surface) props.get( ComponentPreset.MATERIAL );
+
+               Material.Surface m = materials.getSurfaceMaterial(myMaterial, thickness);
+
+               props.put(ComponentPreset.MATERIAL, m!=null? m : myMaterial);
        }
 
 }