diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 9225aff7d..f42b3c968 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -2148,11 +2148,11 @@ Warning.RECOVERY_DEPLOYMENT_WHILE_BURNING = Warning.FILE_INVALID_PARAMETER = Invalid parameter encountered, ignoring. Warning.PARALLEL_FINS = Too many parallel fins Warning.SUPERSONIC = Body calculations may not be entirely accurate at supersonic speeds. -Warning.RECOVERY_LAUNCH_ROD = Recovery device device deployed while on the launch guide. +Warning.RECOVERY_LAUNCH_ROD = Recovery device deployed while on the launch guide. Warning.RECOVERY_HIGH_SPEED = Recovery device deployment at high speed Warning.NO_RECOVERY_DEVICE = No recovery device defined in the simulation. Warning.TUMBLE_UNDER_THRUST = Stage began to tumble under thrust. -Warning.EVENT_AFTER_LANDING = Flight Event occurred after landing: +Warning.EVENT_AFTER_LANDING = Flight Event occurred after landing: Warning.ZERO_VOLUME_BODY = Zero-volume bodies may not simulate accurately Warning.TUBE_SEPARATION = Space between tube fins may not simulate accurately. Warning.TUBE_OVERLAP = Overlapping tube fins may not simulate accurately. diff --git a/core/src/net/sf/openrocket/logging/Message.java b/core/src/net/sf/openrocket/logging/Message.java index e0b6ba3eb..2216b0f4d 100644 --- a/core/src/net/sf/openrocket/logging/Message.java +++ b/core/src/net/sf/openrocket/logging/Message.java @@ -10,12 +10,7 @@ public abstract class Message implements Cloneable { /** The rocket component(s) that are the source of this message **/ private RocketComponent[] sources = null; - /** - * @return a Message with the specific text. - */ - public static Message fromString(String text) { - return new Warning.Other(text); - } + private MessagePriority priority = MessagePriority.NORMAL; /** * Returns the message text + message source objects. @@ -75,6 +70,21 @@ public abstract class Message implements Cloneable { this.sources = sources; } + /** + * Return the priority of this message. + * @return the priority of this message. + */ + public MessagePriority getPriority() { + return priority; + } + + /** + * Set the priority of this message. + * @param priority the priority of this message. + */ + public void setPriority(MessagePriority priority) { + this.priority = priority; + } /** * Two Messages are by default considered equal if they are of @@ -84,7 +94,8 @@ public abstract class Message implements Cloneable { */ @Override public boolean equals(Object o) { - return o != null && (o.getClass() == this.getClass() && sourcesEqual(((Message) o).sources, sources)); + return o != null && (o.getClass() == this.getClass() && sourcesEqual(((Message) o).sources, sources)) + && ((Message) o).priority == priority; } /** @@ -109,6 +120,7 @@ public abstract class Message implements Cloneable { protected Object clone() throws CloneNotSupportedException { Message clone = (Message) super.clone(); clone.sources = this.sources; + clone.priority = this.priority; return clone; } } diff --git a/core/src/net/sf/openrocket/logging/MessagePriority.java b/core/src/net/sf/openrocket/logging/MessagePriority.java new file mode 100644 index 000000000..8c3f01f0e --- /dev/null +++ b/core/src/net/sf/openrocket/logging/MessagePriority.java @@ -0,0 +1,10 @@ +package net.sf.openrocket.logging; + +/** + * The priority of a message. + */ +public enum MessagePriority { + LOW, + NORMAL, + HIGH +} diff --git a/core/src/net/sf/openrocket/logging/Warning.java b/core/src/net/sf/openrocket/logging/Warning.java index 0f085fb8d..020660cd5 100644 --- a/core/src/net/sf/openrocket/logging/Warning.java +++ b/core/src/net/sf/openrocket/logging/Warning.java @@ -16,10 +16,17 @@ public abstract class Warning extends Message { private static final Translator trans = Application.getTranslator(); /** - * @return a Warning with the specific text. + * @return a Message with the specific text and priority. + */ + public static Warning fromString(String text, MessagePriority priority) { + return new Warning.Other(text, priority); + } + + /** + * @return a Message with the specific text. */ public static Warning fromString(String text) { - return new Warning.Other(text); + return fromString(text, MessagePriority.NORMAL); } @@ -42,6 +49,7 @@ public abstract class Warning extends Message { */ public LargeAOA(double aoa) { this.aoa = aoa; + setPriority(MessagePriority.NORMAL); } @Override @@ -93,6 +101,7 @@ public abstract class Warning extends Message { */ public HighSpeedDeployment(double speed) { this.recoverySpeed = speed; + setPriority(MessagePriority.NORMAL); } @Override @@ -135,6 +144,7 @@ public abstract class Warning extends Message { */ public EventAfterLanding(FlightEvent _event) { this.event = _event; + setPriority(MessagePriority.HIGH); } // I want a warning on every event that occurs after we land, @@ -172,7 +182,11 @@ public abstract class Warning extends Message { private double diameter = Double.NaN; private double length = Double.NaN; private double delay = Double.NaN; - + + public MissingMotor() { + setPriority(MessagePriority.HIGH); + } + @Override public String getMessageDescription() { String str = "No motor with designation '" + designation + "'"; @@ -345,8 +359,13 @@ public abstract class Warning extends Message { public static class Other extends Warning { private String description; - public Other(String description) { + public Other(String description, MessagePriority priority) { this.description = description; + setPriority(priority); + } + + public Other(String description) { + this(description, MessagePriority.NORMAL); } @Override @@ -379,68 +398,75 @@ public abstract class Warning extends Message { /** A Warning that the body diameter is discontinuous. */ - ////Discontinuity in rocket body diameter. - public static final Warning DIAMETER_DISCONTINUITY = new Other(trans.get("Warning.DISCONTINUITY")); + public static final Warning DIAMETER_DISCONTINUITY = new Other(trans.get("Warning.DISCONTINUITY"), MessagePriority.NORMAL); /** A Warning that a ComponentAssembly has an open forward end */ - public static final Warning OPEN_AIRFRAME_FORWARD = new Other(trans.get("Warning.OPEN_AIRFRAME_FORWARD")); + public static final Warning OPEN_AIRFRAME_FORWARD = new Other(trans.get("Warning.OPEN_AIRFRAME_FORWARD"), MessagePriority.NORMAL); /** A Warning that there is a gap in the airframe */ - public static final Warning AIRFRAME_GAP = new Other(trans.get("Warning.AIRFRAME_GAP")); + public static final Warning AIRFRAME_GAP = new Other(trans.get("Warning.AIRFRAME_GAP"), MessagePriority.NORMAL); /** A Warning that there are overlapping airframe components */ - public static final Warning AIRFRAME_OVERLAP = new Other(trans.get("Warning.AIRFRAME_OVERLAP")); + public static final Warning AIRFRAME_OVERLAP = new Other(trans.get("Warning.AIRFRAME_OVERLAP"), MessagePriority.NORMAL); /** A Warning that an inline podset is completely forward of its parent component */ - public static final Warning PODSET_FORWARD = new Other(trans.get("Warning.PODSET_FORWARD")); + public static final Warning PODSET_FORWARD = new Other(trans.get("Warning.PODSET_FORWARD"), MessagePriority.NORMAL); /** A Warning that an inline podset overlaps its parent component */ - public static final Warning PODSET_OVERLAP = new Other(trans.get("Warning.PODSET_OVERLAP")); + public static final Warning PODSET_OVERLAP = new Other(trans.get("Warning.PODSET_OVERLAP"), MessagePriority.NORMAL); /** A Warning that the fins are thick compared to the rocket body. */ ////Thick fins may not be modeled accurately. - public static final Warning THICK_FIN = new Other(trans.get("Warning.THICK_FIN")); + public static final Warning THICK_FIN = new Other(trans.get("Warning.THICK_FIN"), MessagePriority.NORMAL); /** A Warning that the fins have jagged edges. */ - ////Jagged-edged fin predictions may be inaccurate. - public static final Warning JAGGED_EDGED_FIN = new Other(trans.get("Warning.JAGGED_EDGED_FIN")); + public static final Warning JAGGED_EDGED_FIN = new Other(trans.get("Warning.JAGGED_EDGED_FIN"), MessagePriority.NORMAL); /** A Warning that the fins have a zero area. */ - ////Fins with no area will not affect aerodynamics - public static final Warning ZERO_AREA_FIN = new Other(trans.get("Warning.ZERO_AREA_FIN")); + public static final Warning ZERO_AREA_FIN = new Other(trans.get("Warning.ZERO_AREA_FIN"), MessagePriority.NORMAL); /** A Warning that simulation listeners have affected the simulation */ - ////Listeners modified the flight simulation - public static final Warning LISTENERS_AFFECTED = new Other(trans.get("Warning.LISTENERS_AFFECTED")); + public static final Warning LISTENERS_AFFECTED = new Other(trans.get("Warning.LISTENERS_AFFECTED"), MessagePriority.LOW); - ////No recovery device for simulation - public static final Warning NO_RECOVERY_DEVICE = new Other(trans.get("Warning.NO_RECOVERY_DEVICE")); + /** No recovery device defined in the simulation. */ + public static final Warning NO_RECOVERY_DEVICE = new Other(trans.get("Warning.NO_RECOVERY_DEVICE"), MessagePriority.HIGH); - //// Invalid parameter encountered, ignoring. - public static final Warning FILE_INVALID_PARAMETER = new Other(trans.get("Warning.FILE_INVALID_PARAMETER")); - - public static final Warning PARALLEL_FINS = new Other(trans.get("Warning.PARALLEL_FINS")); + /** Invalid parameter encountered, ignoring. */ + public static final Warning FILE_INVALID_PARAMETER = new Other(trans.get("Warning.FILE_INVALID_PARAMETER"), MessagePriority.NORMAL); - public static final Warning SUPERSONIC = new Other(trans.get("Warning.SUPERSONIC")); - - public static final Warning RECOVERY_LAUNCH_ROD = new Other(trans.get("Warning.RECOVERY_LAUNCH_ROD")); - - public static final Warning TUMBLE_UNDER_THRUST = new Other(trans.get("Warning.TUMBLE_UNDER_THRUST")); + /** Too many parallel fins */ + public static final Warning PARALLEL_FINS = new Other(trans.get("Warning.PARALLEL_FINS"), MessagePriority.NORMAL); - public static final Warning EVENT_AFTER_LANDING = new Other(trans.get("Warning.EVENT_AFTER_LANDING")); + /** Body calculations may not be entirely accurate at supersonic speeds. */ + public static final Warning SUPERSONIC = new Other(trans.get("Warning.SUPERSONIC"), MessagePriority.NORMAL); - public static final Warning ZERO_VOLUME_BODY = new Other(trans.get("Warning.ZERO_VOLUME_BODY")); + /** Recovery device deployed while on the launch guide. */ + public static final Warning RECOVERY_LAUNCH_ROD = new Other(trans.get("Warning.RECOVERY_LAUNCH_ROD"), MessagePriority.HIGH); - public static final Warning TUBE_SEPARATION = new Other(trans.get("Warning.TUBE_SEPARATION")); - public static final Warning TUBE_OVERLAP = new Other(trans.get("Warning.TUBE_OVERLAP")); + /** Stage began to tumble under thrust. */ + public static final Warning TUMBLE_UNDER_THRUST = new Other(trans.get("Warning.TUMBLE_UNDER_THRUST"), MessagePriority.HIGH); - public static final Warning OBJ_ZERO_THICKNESS = new Other(trans.get("Warning.OBJ_ZERO_THICKNESS")); + /** Flight Event occurred after landing: */ + public static final Warning EVENT_AFTER_LANDING = new Other(trans.get("Warning.EVENT_AFTER_LANDING"), MessagePriority.NORMAL); + + /** Zero-volume bodies may not simulate accurately */ + public static final Warning ZERO_VOLUME_BODY = new Other(trans.get("Warning.ZERO_VOLUME_BODY"), MessagePriority.NORMAL); + + /** Space between tube fins may not simulate accurately. */ + public static final Warning TUBE_SEPARATION = new Other(trans.get("Warning.TUBE_SEPARATION"), MessagePriority.NORMAL); + + /** Overlapping tube fins may not simulate accurately. */ + public static final Warning TUBE_OVERLAP = new Other(trans.get("Warning.TUBE_OVERLAP"), MessagePriority.NORMAL); + + /** Zero-thickness component can cause issues for 3D printing */ + public static final Warning OBJ_ZERO_THICKNESS = new Other(trans.get("Warning.OBJ_ZERO_THICKNESS"), MessagePriority.NORMAL); /** A Warning that stage separation occurred at other than the last stage */ - public static final Warning SEPARATION_ORDER = new Other(trans.get("Warning.SEPARATION_ORDER")); + public static final Warning SEPARATION_ORDER = new Other(trans.get("Warning.SEPARATION_ORDER"), MessagePriority.NORMAL); /** A Warning that stage separation occurred before the rocket cleared the launch rod or rail */ - public static final Warning EARLY_SEPARATION = new Other(trans.get("Warning.EARLY_SEPARATION")); + public static final Warning EARLY_SEPARATION = new Other(trans.get("Warning.EARLY_SEPARATION"), MessagePriority.HIGH); - public static final Warning EMPTY_BRANCH = new Other(trans.get("Warning.EMPTY_BRANCH")); + /** Simulation branch contains no data */ + public static final Warning EMPTY_BRANCH = new Other(trans.get("Warning.EMPTY_BRANCH"), MessagePriority.HIGH); }