Added special Warning object for when the system does not have motors for the ork...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Mon, 23 Jan 2012 01:01:38 +0000 (01:01 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Mon, 23 Jan 2012 01:01:38 +0000 (01:01 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@365 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/aerodynamics/Warning.java
core/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java

index 52911df091269c9098df6b9eb38a6655fa2c0d39..355a2b8762fcab3eba0c2573e5f677b341e6f8dc 100644 (file)
@@ -1,6 +1,7 @@
 package net.sf.openrocket.aerodynamics;
 
 import net.sf.openrocket.l10n.Translator;
+import net.sf.openrocket.motor.Motor;
 import net.sf.openrocket.startup.Application;
 import net.sf.openrocket.unit.UnitGroup;
 
@@ -91,6 +92,100 @@ public abstract class Warning {
                }
        }
        
+       public static class MissingMotor extends Warning {
+
+               private Motor.Type type = null;
+               private String manufacturer = null;
+               private String designation = null;
+               private String digest = null;
+               private double diameter = Double.NaN;
+               private double length = Double.NaN;
+               private double delay = Double.NaN;
+
+               public String toString() {
+                       String str = "No motor with designation '" + designation + "'";
+                       if (manufacturer != null)
+                               str += " for manufacturer '" + manufacturer + "'";
+                       str += " found.";
+                       return str;
+               }
+
+               public Motor.Type getType() {
+                       return type;
+               }
+
+
+               public void setType(Motor.Type type) {
+                       this.type = type;
+               }
+
+
+               public String getManufacturer() {
+                       return manufacturer;
+               }
+
+
+               public void setManufacturer(String manufacturer) {
+                       this.manufacturer = manufacturer;
+               }
+
+
+               public String getDesignation() {
+                       return designation;
+               }
+
+
+               public void setDesignation(String designation) {
+                       this.designation = designation;
+               }
+
+
+               public String getDigest() {
+                       return digest;
+               }
+
+
+               public void setDigest(String digest) {
+                       this.digest = digest;
+               }
+
+
+               public double getDiameter() {
+                       return diameter;
+               }
+
+
+               public void setDiameter(double diameter) {
+                       this.diameter = diameter;
+               }
+
+
+               public double getLength() {
+                       return length;
+               }
+
+
+               public void setLength(double length) {
+                       this.length = length;
+               }
+
+
+               public double getDelay() {
+                       return delay;
+               }
+
+
+               public void setDelay(double delay) {
+                       this.delay = delay;
+               }
+
+
+               @Override
+               public boolean replaceBy(Warning other) {
+                       return false;
+               }
+               
+       }
        
        
        /**
index c300744be2e8d5469580ca45a55e019efbb9c1a5..f8d6bed5e3f315af7a51fd90821bae0f6b24c09f 100644 (file)
@@ -1002,11 +1002,14 @@ class MotorHandler extends ElementHandler {
                
                // No motors
                if (motors.size() == 0) {
-                       String str = "No motor with designation '" + designation + "'";
-                       if (manufacturer != null)
-                               str += " for manufacturer '" + manufacturer + "'";
-                       str += " found.";
-                       warnings.add(str);
+                       Warning.MissingMotor mmw = new Warning.MissingMotor();
+                       mmw.setDesignation(designation);
+                       mmw.setDigest(digest);
+                       mmw.setDiameter(diameter);
+                       mmw.setLength(length);
+                       mmw.setManufacturer(manufacturer);
+                       mmw.setType(type);
+                       warnings.add(mmw);
                        return null;
                }