create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / preset / loader / StreamerLoader.java
index 4a2f38a92f2598dd94c1d5111b4950c0d4a18805..403ea0f6e28b980e0a59a28b10ef51be0070af3c 100644 (file)
@@ -11,9 +11,19 @@ public class StreamerLoader extends BaseComponentLoader {
 
        private final MaterialHolder materials;
 
-       public StreamerLoader(MaterialHolder materials, File theBasePath) {
-               super(materials, theBasePath);
-               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));
@@ -39,11 +49,11 @@ public class StreamerLoader extends BaseComponentLoader {
 
                // 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.Surface myMaterial = (Material.Surface) props.get( ComponentPreset.MATERIAL );
 
-               material = materials.getSurfaceMaterial(material, thickness);
+               Material.Surface m = materials.getSurfaceMaterial(myMaterial, thickness);
 
-               props.put(ComponentPreset.MATERIAL, material);
+               props.put(ComponentPreset.MATERIAL, m!=null? m : myMaterial);
        }
 
 }