From b64836ac057c860e0aae27249d17879cccf19a0e Mon Sep 17 00:00:00 2001 From: kruland2607 Date: Mon, 23 Jan 2012 01:01:38 +0000 Subject: [PATCH] Added special Warning object for when the system does not have motors for the ork file. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@365 180e2498-e6e9-4542-8430-84ac67f01cd8 --- .../sf/openrocket/aerodynamics/Warning.java | 95 +++++++++++++++++++ .../file/openrocket/OpenRocketLoader.java | 13 ++- 2 files changed, 103 insertions(+), 5 deletions(-) diff --git a/core/src/net/sf/openrocket/aerodynamics/Warning.java b/core/src/net/sf/openrocket/aerodynamics/Warning.java index 52911df0..355a2b87 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -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; + } + + } /** diff --git a/core/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java b/core/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java index c300744b..f8d6bed5 100644 --- a/core/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java +++ b/core/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java @@ -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; } -- 2.47.2