Move error messages to translation keys

This commit is contained in:
SiboVG 2023-04-04 14:55:07 +02:00
parent bcaf345bec
commit 0d1a5e84f8
10 changed files with 137 additions and 52 deletions

View File

@ -1368,6 +1368,51 @@ saveAs.openrocket.title = Save as OpenRocket ork file
saveAs.rocksim.title = Export as RockSim rkt file
saveAs.rasaero.title = Export as RASAero CDX1 file
! RASAero exporting
RASAeroExport.warning1 = Nose cone may not be flipped.
RASAeroExport.warning2 = First component of booster must be body tube.
RASAeroExport.warning3 = Already added a rail button, ignoring launch lug '%s'.
RASAeroExport.warning4 = Already added a launch shoe, ignoring launch lug '%s'.
RASAeroExport.warning5 = Instance count of '%s' not set to 2, defaulting to 2 and adjusting launch lug length accordingly.
RASAeroExport.warning6 = Already added a launch lug, ignoring rail button '%s'.
RASAeroExport.warning7 = Already added a launch shoe, ignoring rail button '%s'.
RASAeroExport.warning8 = Instance count of '%s' equals %d, defaulting to 2.
RASAeroExport.warning9 = Unsupported component '%s', ignoring.
RASAeroExport.warning10 = Stage '%s' can only contain a body tube, ignoring other %d components.
RASAeroExport.warning11 = Stage '%s' can only contain a body tube and transition shoulder, ignoring other %d components.
RASAeroExport.warning12 = Rocket should have no more then 3 stages (excl. boosters) in total.\nIgnoring other stages.
RASAeroExport.warning13 = Empty simulation '%s', ignoring.
RASAeroExport.warning14 = No motors found in simulation '%s', ignoring.
RASAeroExport.warning15 = <html>Stage %s has no motor.<br>&nbsp --> When adding a motor in RASAero, don't forget to update the stage mass and CG.</html>
RASAeroExport.error1 = Unsupported component: %s.
RASAeroExport.error2 = Length of '%s' must be greater than 0.
RASAeroExport.error3 = Diameter of '%s' must be greater than 0.
RASAeroExport.error4 = Launch lug diameter can not be 0.
RASAeroExport.error5 = Launch lug length can not be 0.
RASAeroExport.error6 = Rail button diameter can not be 0.
RASAeroExport.error7 = Rail button height can not be 0.
RASAeroExport.error8 = Launch shoe area can not be 0.
RASAeroExport.error9 = Invalid stage number '%d' for booster stage '%s'.
RASAeroExport.error10 = Stage '%s' may not be empty.
RASAeroExport.error11 = First component of stage '%s' must be a body tube or transition.
RASAeroExport.error12 = When the first component of stage '%s' is a transition, the second one must be a body tube.
RASAeroExport.error13 = No previous component for '%s' in stage '%s'.
RASAeroExport.error14 = Transition '%s' in stage '%s' must have the same fore radius as the aft radius of its previous component '%s'.
RASAeroExport.error15 = Radius of '%s' in stage '%s' must be the same as the aft radius of '%s'.
RASAeroExport.error16 = Body tube '%s' in stage '%s' must have a TrapezoidFinSet.
RASAeroExport.error17 = Length of '%s' must be greater than 0.
RASAeroExport.error18 = Diameter of '%s' must be greater than 0.
RASAeroExport.error19 = Inside diameter of '%s' must be greater than 0.
RASAeroExport.error20 = Fin set '%s' must have a fin count between 3 and 8.
RASAeroExport.error21 = RASAero only supports apogee and altitude deployment events for parachute '%s', not '%s'
RASAeroExport.error22 = First component of the sustainer must be a nose cone.
RASAeroExport.error23 = Second component of the sustainer must be a body tube.
RASAeroExport.error24 = A nose cone can only be the first component of the rocket.
RASAeroExport.error25 = Invalid stage number '%d' for simulation '%s'
RASAeroExport.error26 = RASAero only supports conical transitions.
RASAeroExport.error27 = Transition '%s' has no previous component.
RASAeroExport.error28 = Transition '%s' should have the same fore radius as the aft radius (%f) of its previous component, not %f.
! SaveAsFileChooser
SaveAsFileChooser.illegalFilename.title = Illegal filename
SaveAsFileChooser.illegalFilename.message = The filename '%s' may not contain the character ' %c '. Please remove it.

View File

@ -2,6 +2,7 @@ package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.AxialStage;
@ -20,6 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
/**
@ -49,6 +51,8 @@ public class BasePartDTO {
private final WarningSet warnings;
@XmlTransient
private final ErrorSet errors;
@XmlTransient
private static final Translator trans = Application.getTranslator();
/**
* We need a default no-args constructor.
@ -71,7 +75,7 @@ public class BasePartDTO {
setPartType(RASAeroCommonConstants.NOSE_CONE);
NoseCone noseCone = (NoseCone) component;
if (noseCone.isFlipped()) {
throw new RASAeroExportException("Nose cone may not be flipped.");
throw new RASAeroExportException(trans.get("RASAeroExport.warning1"));
}
setDiameter(((NoseCone) component).getAftRadius() * 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
} else if (component instanceof Transition) {
@ -83,11 +87,11 @@ public class BasePartDTO {
setPartType(RASAeroCommonConstants.BOOSTER);
AxialStage stage = (AxialStage) component;
if (stage.getChildCount() == 0 || !(stage.getChild(0) instanceof BodyTube)) {
throw new RASAeroExportException("First component of booster must be body tube.");
throw new RASAeroExportException(trans.get("RASAeroExport.warning2"));
}
setDiameter(stage.getBoundingRadius() * 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
} else {
throw new RASAeroExportException("Unsupported component: ." + component.getComponentName());
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error1"), component.getComponentName()));
}
setLength(component.getLength() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
@ -109,7 +113,7 @@ public class BasePartDTO {
public void setLength(Double length) throws RASAeroExportException {
if (MathUtil.equals(length, 0)) {
throw new RASAeroExportException(String.format("Length of '%s' must be greater than 0.", component.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error2"), component.getName()));
}
this.length = length;
}
@ -120,7 +124,7 @@ public class BasePartDTO {
public void setDiameter(Double diameter) throws RASAeroExportException {
if (MathUtil.equals(diameter, 0)) {
throw new RASAeroExportException(String.format("Diameter of '%s' must be greater than 0.", component.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error3"), component.getName()));
}
this.diameter = diameter;
}

View File

@ -2,6 +2,7 @@ package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.BodyTube;
@ -15,6 +16,7 @@ import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
@XmlRootElement(name = RASAeroCommonConstants.BODY_TUBE)
@ -57,6 +59,8 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
private final WarningSet warnings;
@XmlTransient
private final ErrorSet errors;
@XmlTransient
private static final Translator trans = Application.getTranslator();
/**
* We need a default no-args constructor.
@ -79,7 +83,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setLaunchLugDiameter(Double launchLugDiameter) throws RASAeroExportException {
if (MathUtil.equals(launchLugDiameter, 0)) {
throw new RASAeroExportException("Launch lug diameter can not be 0.");
throw new RASAeroExportException(trans.get("RASAeroExport.error4"));
}
this.launchLugDiameter = launchLugDiameter;
}
@ -90,7 +94,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setLaunchLugLength(Double launchLugLength) throws RASAeroExportException {
if (MathUtil.equals(launchLugLength, 0)) {
throw new RASAeroExportException("Launch lug length can not be 0.");
throw new RASAeroExportException(trans.get("RASAeroExport.error5"));
}
this.launchLugLength = launchLugLength;
}
@ -101,7 +105,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setRailGuideDiameter(Double railGuideDiameter) throws RASAeroExportException {
if (MathUtil.equals(railGuideDiameter, 0)) {
throw new RASAeroExportException("Rail button diameter can not be 0.");
throw new RASAeroExportException(trans.get("RASAeroExport.error6"));
}
this.railGuideDiameter = railGuideDiameter;
}
@ -112,7 +116,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setRailGuideHeight(Double railGuideHeight) throws RASAeroExportException {
if (MathUtil.equals(railGuideHeight, 0)) {
throw new RASAeroExportException("Rail button height can not be 0.");
throw new RASAeroExportException(trans.get("RASAeroExport.error7"));
}
this.railGuideHeight = railGuideHeight;
}
@ -123,7 +127,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setLaunchShoeArea(Double launchShoeArea) throws RASAeroExportException {
if (MathUtil.equals(launchShoeArea, 0)) {
throw new RASAeroExportException("Launch shoe area can not be 0.");
throw new RASAeroExportException(trans.get("RASAeroExport.error8"));
}
this.launchShoeArea = launchShoeArea;
}

View File

@ -1,6 +1,7 @@
package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.BodyTube;
@ -9,21 +10,27 @@ import net.sf.openrocket.rocketcomponent.Parachute;
import net.sf.openrocket.rocketcomponent.RailButton;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
import javax.xml.bind.annotation.XmlTransient;
public interface BodyTubeDTOAdapter {
@XmlTransient
Translator trans = Application.getTranslator();
default void applyBodyTubeSettings(BodyTube bodyTube, WarningSet warnings, ErrorSet errors) throws RASAeroExportException {
for (RocketComponent child : bodyTube.getChildren()) {
if (child instanceof TrapezoidFinSet) {
setFin(new FinDTO((TrapezoidFinSet) child, warnings, errors));
} else if (child instanceof LaunchLug) {
if (!MathUtil.equals(getRailGuideDiameter(), 0) || !MathUtil.equals(getRailGuideHeight(), 0)) { // only one check on diameter or length should be sufficient, but just to be safe
warnings.add(String.format("Already added a rail button, ignoring launch lug '%s'.", child.getName()));
warnings.add(String.format(trans.get("RASAeroExport.warning3"), child.getName()));
continue;
}
if (!MathUtil.equals(getLaunchShoeArea(), 0)) {
warnings.add(String.format("Already added a launch shoe, ignoring launch lug '%s'.", child.getName()));
warnings.add(String.format(trans.get("RASAeroExport.warning4"), child.getName()));
continue;
}
@ -32,18 +39,16 @@ public interface BodyTubeDTOAdapter {
if (lug.getInstanceCount() == 2) {
setLaunchLugLength(lug.getLength() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
} else {
warnings.add(String.format(
"Instance count of '%s' not set to 2, defaulting to 2 and adjusting launch lug length accordingly.",
lug.getName()));
warnings.add(String.format(trans.get("RASAeroExport.warning5"), lug.getName()));
setLaunchLugLength(lug.getLength() * lug.getInstanceCount() / 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
}
} else if (child instanceof RailButton) {
if (!MathUtil.equals(getLaunchLugDiameter(), 0) || !MathUtil.equals(getLaunchLugLength(), 0)) { // only one check on diameter or length should be sufficient, but just to be safe
warnings.add(String.format("Already added a launch lug, ignoring rail button '%s'.", child.getName()));
warnings.add(String.format(trans.get("RASAeroExport.warning6"), child.getName()));
continue;
}
if (!MathUtil.equals(getLaunchShoeArea(), 0)) {
warnings.add(String.format("Already added a launch shoe, ignoring rail button '%s'.", child.getName()));
warnings.add(String.format(trans.get("RASAeroExport.warning7"), child.getName()));
continue;
}
@ -52,13 +57,12 @@ public interface BodyTubeDTOAdapter {
setRailGuideHeight(button.getTotalHeight() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
if (button.getInstanceCount() != 2) {
warnings.add(String.format("Instance count of '%s' equals %d, defaulting to 2.",
button.getName(), button.getInstanceCount()));
warnings.add(String.format(trans.get("RASAeroExport.warning8"), button.getName(), button.getInstanceCount()));
}
} else if (child instanceof Parachute) {
// Do nothing, is handled by RecoveryDTO
} else {
warnings.add(String.format("Unsupported component '%s', ignoring.", child.getComponentName()));
warnings.add(String.format(trans.get("RASAeroExport.warning9"), child.getComponentName()));
}
}
}

View File

@ -2,6 +2,7 @@ package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.AxialStage;
@ -23,6 +24,7 @@ import net.sf.openrocket.rocketcomponent.SymmetricComponent;
import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
@XmlRootElement(name = RASAeroCommonConstants.BOOSTER)
@ -83,6 +85,8 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
private final WarningSet warnings;
@XmlTransient
private final ErrorSet errors;
@XmlTransient
private static final Translator trans = Application.getTranslator();
/**
@ -101,44 +105,43 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
int stageNr = rocket.getChildPosition(stage); // Use this instead of stage.getStageNumber() in case there are parallel stages in the design
if (stageNr != 1 && stageNr != 2) {
throw new RASAeroExportException(String.format("Invalid stage number '%d' for booster stage '%s'.", stageNr, stage.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error9"), stageNr, stage.getName()));
}
if (stage.getChildCount() == 0) {
throw new RASAeroExportException(String.format("Stage '%s' may not be empty.", stage.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error10"), stage.getName()));
}
RocketComponent firstChild = stage.getChild(0);
if (!(firstChild instanceof BodyTube) &&
!(firstChild instanceof Transition && !(firstChild instanceof NoseCone))) {
throw new RASAeroExportException(String.format("First component of stage '%s' must be a body tube or transition.", stage.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error11"), stage.getName()));
}
final BodyTube firstTube;
if (firstChild instanceof Transition) {
if (stage.getChildCount() == 1 || !(stage.getChild(1) instanceof BodyTube)) {
throw new RASAeroExportException(
String.format("When the first component of stage '%s' is a transition, the second one must be a body tube.",
stage.getName()));
String.format(trans.get("RASAeroExport.error12"), stage.getName()));
}
Transition transition = (Transition) firstChild;
SymmetricComponent previousComponent = transition.getPreviousSymmetricComponent();
if (previousComponent == null) {
throw new RASAeroExportException(String.format("No previous component for '%s' in stage '%s'.",
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error13"),
firstChild.getName(), stage.getName()));
}
if (!MathUtil.equals(transition.getForeRadius(), previousComponent.getAftRadius())) {
throw new RASAeroExportException(
String.format("Transition '%s' in stage '%s' must have the same fore radius as the aft radius of its previous component '%s'.",
String.format(trans.get("RASAeroExport.error14"),
transition.getName(), stage.getName(), previousComponent.getName()));
}
firstTube = (BodyTube) stage.getChild(1);
if (!MathUtil.equals(firstTube.getOuterRadius(), transition.getAftRadius())) {
throw new RASAeroExportException(
String.format("Radius of '%s' in stage '%s' must be the same as the aft radius of '%s'.",
String.format(trans.get("RASAeroExport.error15"),
firstTube.getName(), stage.getName(), transition.getName()));
}
@ -167,12 +170,12 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
} else {
// Case: normal body tube
if (stage.getChildPosition(firstTube) == 0) {
warnings.add(String.format("Stage '%s' can only contain a body tube, ignoring other %d components.",
warnings.add(String.format(trans.get("RASAeroExport.warning10"),
stage.getName(), stage.getChildCount() - i - 1));
}
// Case: body tube with transition shoulder
else {
warnings.add(String.format("Stage '%s' can only contain a body tube and transition shoulder, ignoring other %d components.",
warnings.add(String.format(trans.get("RASAeroExport.warning11"),
stage.getName(), stage.getChildCount() - i - 1));
}
}
@ -182,7 +185,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
if (finSet == null) {
throw new RASAeroExportException(
String.format("Body tube '%s' in stage '%s' must have a TrapezoidFinSet.",
String.format(trans.get("RASAeroExport.error16"),
firstTube.getName(), stage.getName()));
}
setFin(new FinDTO(finSet, warnings, errors));
@ -217,7 +220,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
public void setLength(Double length) {
if (MathUtil.equals(length, 0)) {
errors.add(String.format("Length of '%s' must be greater than 0.", component.getName()));
errors.add(String.format(trans.get("RASAeroExport.error17"), component.getName()));
return;
}
this.length = length;
@ -229,7 +232,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
public void setDiameter(Double diameter) throws RASAeroExportException {
if (MathUtil.equals(diameter, 0)) {
throw new RASAeroExportException(String.format("Diameter of '%s' must be greater than 0.", component.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error18"), component.getName()));
}
this.diameter = diameter;
}
@ -240,7 +243,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
public void setInsideDiameter(Double insideDiameter) throws RASAeroExportException {
if (MathUtil.equals(insideDiameter, 0)) {
throw new RASAeroExportException(String.format("Inside diameter of '%s' must be greater than 0.", component.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error19"), component.getName()));
}
this.insideDiameter = insideDiameter;
}

View File

@ -2,16 +2,19 @@ package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
import net.sf.openrocket.startup.Application;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@XmlRootElement(name = RASAeroCommonConstants.FIN)
@ -49,6 +52,9 @@ public class FinDTO {
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
private Double FX3 = 0d;
@XmlTransient
private static final Translator trans = Application.getTranslator();
/**
* We need a default no-args constructor.
*/
@ -59,7 +65,7 @@ public class FinDTO {
int finCount = fin.getFinCount();
if (finCount < 3 || finCount > 8) {
throw new RASAeroExportException(
String.format("Fin set '%s' must have a fin count between 3 and 8.", fin.getName()));
String.format(trans.get("RASAeroExport.error20"), fin.getName()));
}
setCount(fin.getFinCount());

View File

@ -3,6 +3,7 @@ package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.CustomBooleanAdapter;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.AxialStage;
@ -11,6 +12,7 @@ import net.sf.openrocket.rocketcomponent.DeploymentConfiguration;
import net.sf.openrocket.rocketcomponent.Parachute;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -62,6 +64,8 @@ public class RecoveryDTO {
@XmlTransient
private static final Logger log = LoggerFactory.getLogger(RecoveryDTO.class);
@XmlTransient
private static final Translator trans = Application.getTranslator();
/**
* We need a default, no-args constructor.
@ -119,7 +123,7 @@ public class RecoveryDTO {
} else if (deployConfig.getDeployEvent() == DeploymentConfiguration.DeployEvent.ALTITUDE) {
setEventType1(RASAeroCommonConstants.RECOVERY_ALTITUDE);
} else {
errors.add(String.format("RASAero only supports apogee and altitude deployment events for parachute '%s', not '%s'",
errors.add(String.format(trans.get("RASAeroExport.error21"),
device1.getName(), deployConfig.getDeployEvent().toString()));
}
setEvent1(true);
@ -136,7 +140,7 @@ public class RecoveryDTO {
} else if (deployConfig.getDeployEvent() == DeploymentConfiguration.DeployEvent.ALTITUDE) {
setEventType2(RASAeroCommonConstants.RECOVERY_ALTITUDE);
} else {
errors.add(String.format("RASAero only supports apogee and altitude deployment events for parachute '%s', not '%s'",
errors.add(String.format(trans.get("RASAeroExport.error21"),
device2.getName(), deployConfig.getDeployEvent().toString()));
}
setEvent2(true);

View File

@ -3,6 +3,7 @@ package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.CustomBooleanAdapter;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.AxialStage;
@ -11,6 +12,7 @@ import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.ArrayList;
import javax.xml.bind.annotation.XmlAccessType;
@ -18,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.List;
@ -67,10 +70,13 @@ public class RocketDesignDTO {
@XmlElement(name = RASAeroCommonConstants.COMMENTS)
private String comments = "";
public RocketDesignDTO(Rocket rocket, WarningSet warnings, ErrorSet errors) throws RASAeroExportException {
@XmlTransient
private static final Translator trans = Application.getTranslator();
public RocketDesignDTO(Rocket rocket, WarningSet warnings, ErrorSet errors) {
setComments(rocket.getComment());
if (rocket.getChildCount() > 3) {
warnings.add("Rocket should have no more then 3 stages (excl. boosters) in total.\nIgnoring other stages.");
warnings.add(trans.get("RASAeroExport.warning12"));
}
setUseBooster1(rocket.getStageCount() >= 2);
setUseBooster2(rocket.getStageCount() == 3);
@ -82,17 +88,17 @@ public class RocketDesignDTO {
try {
RocketComponent component = sustainer.getChild(i);
if (i == 0 && !(component instanceof NoseCone)) {
errors.add("First component of the sustainer must be a nose cone.");
errors.add(trans.get("RASAeroExport.error22"));
return;
} else if (i == 1 && !(component instanceof BodyTube)) {
errors.add("Second component of the sustainer must be a body tube.");
errors.add(trans.get("RASAeroExport.error23"));
return;
}
if (component instanceof BodyTube) {
addExternalPart(new BodyTubeDTO((BodyTube) component, warnings, errors));
} else if (component instanceof NoseCone) {
if (i != 0) {
errors.add("A nose cone can only be the first component of the rocket.");
errors.add(trans.get("RASAeroExport.error24"));
return;
}
addExternalPart(new NoseConeDTO((NoseCone) component, warnings, errors));

View File

@ -4,6 +4,7 @@ import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.file.rasaero.CustomBooleanAdapter;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.masscalc.MassCalculator;
@ -17,11 +18,13 @@ import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
import net.sf.openrocket.startup.Application;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.List;
import java.util.Map;
@ -102,6 +105,9 @@ public class SimulationDTO {
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
private Double optimumMaxAlt = 0d;
@XmlTransient
private static final Translator trans = Application.getTranslator();
/**
* We need a default, no-args constructor.
*/
@ -124,12 +130,12 @@ public class SimulationDTO {
FlightConfigurationId fcid = simulation != null ? simulation.getFlightConfigurationId() : null;
if (simulation != null && fcid == null) {
warnings.add(String.format("Empty simulation '%s', ignoring.", simulationName));
warnings.add(String.format(trans.get("RASAeroExport.warning13"), simulationName));
return;
}
if (mounts.isEmpty()) {
warnings.add(String.format("No motors found in simulation '%s', ignoring.", simulationName));
warnings.add(String.format(trans.get("RASAeroExport.warning14"), simulationName));
return;
}
@ -164,9 +170,7 @@ public class SimulationDTO {
// Add friendly reminder to user
if (motor == null) {
warnings.add(String.format("<html>Stage %s has no motor.<br>" +
"&nbsp --> When adding a motor in RASAero, don't forget to update the stage mass and CG.</html>",
stage.getName()));
warnings.add(String.format(trans.get("RASAeroExport.warning15"), stage.getName()));
}
// Add the simulation info for each stage
@ -269,8 +273,7 @@ public class SimulationDTO {
break;
// Invalid
default:
errors.add(String.format("Invalid stage number '%d' for simulation '%s'",
stageNr, simulationName));
errors.add(String.format(trans.get("RASAeroExport.error25"), stageNr, simulationName));
}
}
}

View File

@ -2,6 +2,7 @@ package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
@ -9,11 +10,13 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
import java.util.Objects;
@ -26,6 +29,9 @@ public class TransitionDTO extends BasePartDTO {
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
private Double rearDiameter;
@XmlTransient
private static final Translator trans = Application.getTranslator();
/**
* We need a default no-args constructor.
*/
@ -36,16 +42,16 @@ public class TransitionDTO extends BasePartDTO {
super(transition, warnings, errors);
if (!transition.getShapeType().equals(Transition.Shape.CONICAL)) {
throw new RASAeroExportException("RASAero only supports conical transitions.");
throw new RASAeroExportException(trans.get("RASAeroExport.error26"));
}
SymmetricComponent previousComp = transition.getPreviousSymmetricComponent();
if (previousComp == null) {
throw new RASAeroExportException(String.format("Transition '%s' has no previous component.", transition.getName()));
throw new RASAeroExportException(String.format(trans.get("RASAeroExport.error27"), transition.getName()));
}
if (!MathUtil.equals(transition.getForeRadius(), previousComp.getAftRadius())) {
throw new RASAeroExportException(
String.format("Transition '%s' should have the same fore radius as the aft radius (%f) of its previous component, not %f.",
String.format(trans.get("RASAeroExport.error28"),
transition.getName(), previousComp.getAftRadius(), transition.getForeRadius()));
}