[fixes #1166] Use [{motors}] for flight config motors placeholder
This commit is contained in:
parent
a1c7986eb8
commit
d3ec4f66eb
@ -55,7 +55,7 @@ public class RocketSaver extends RocketComponentSaver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flightConfig.isNameOverridden()){
|
if (flightConfig.isNameOverridden()){
|
||||||
str += "><name>" + net.sf.openrocket.util.TextUtil.escapeXML(flightConfig.getName())
|
str += "><name>" + net.sf.openrocket.util.TextUtil.escapeXML(flightConfig.getNameRaw())
|
||||||
+ "</name></motorconfiguration>";
|
+ "</name></motorconfiguration>";
|
||||||
} else {
|
} else {
|
||||||
str += "/>";
|
str += "/>";
|
||||||
|
@ -34,7 +34,8 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class);
|
private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class);
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
private String configurationName=null;
|
private String configurationName;
|
||||||
|
public static String DEFAULT_CONFIG_NAME = "[{motors}]";
|
||||||
|
|
||||||
protected final Rocket rocket;
|
protected final Rocket rocket;
|
||||||
protected final FlightConfigurationId fcid;
|
protected final FlightConfigurationId fcid;
|
||||||
@ -94,7 +95,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
this.fcid = _fcid;
|
this.fcid = _fcid;
|
||||||
}
|
}
|
||||||
this.rocket = rocket;
|
this.rocket = rocket;
|
||||||
this.configurationName = null;
|
this.configurationName = DEFAULT_CONFIG_NAME;
|
||||||
this.configurationInstanceId = configurationInstanceCount++;
|
this.configurationInstanceId = configurationInstanceCount++;
|
||||||
|
|
||||||
updateStages();
|
updateStages();
|
||||||
@ -414,15 +415,31 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNameOverridden(){
|
public boolean isNameOverridden(){
|
||||||
return (null != this.configurationName );
|
return (!DEFAULT_CONFIG_NAME.equals(this.configurationName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of this configuration, with DEFAULT_CONFIG_NAME replaced by a one line motor description.
|
||||||
|
* If configurationName is null, the one line motor description is returned.
|
||||||
|
* @return the flight configuration name
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if( null == configurationName){
|
if (configurationName == null) {
|
||||||
return this.getOneLineMotorDescription();
|
return getOneLineMotorDescription();
|
||||||
}else{
|
|
||||||
return configurationName;
|
|
||||||
}
|
}
|
||||||
|
return configurationName.replace(DEFAULT_CONFIG_NAME, getOneLineMotorDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the raw configuration name, without replacing DEFAULT_CONFIG_NAME.
|
||||||
|
* If the configurationName is null, DEFAULT_CONFIG_NAME is returned.
|
||||||
|
* @return raw flight configuration name
|
||||||
|
*/
|
||||||
|
public String getNameRaw() {
|
||||||
|
if (configurationName == null) {
|
||||||
|
return DEFAULT_CONFIG_NAME;
|
||||||
|
}
|
||||||
|
return configurationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOneLineMotorDescription(){
|
private String getOneLineMotorDescription(){
|
||||||
@ -713,9 +730,9 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName( final String newName) {
|
public void setName(final String newName) {
|
||||||
if(( null == newName ) ||( "".equals(newName))){
|
if ((newName == null) || ("".equals(newName))) {
|
||||||
this.configurationName = null;
|
this.configurationName = DEFAULT_CONFIG_NAME;
|
||||||
return;
|
return;
|
||||||
}else if( ! this.getId().isValid()){
|
}else if( ! this.getId().isValid()){
|
||||||
return;
|
return;
|
||||||
|
@ -861,7 +861,7 @@ public class Rocket extends ComponentAssembly {
|
|||||||
if( this.selectedConfiguration.equals( config)){
|
if( this.selectedConfiguration.equals( config)){
|
||||||
shortKey = "=>" + shortKey;
|
shortKey = "=>" + shortKey;
|
||||||
}
|
}
|
||||||
buf.append(String.format(fmt, shortKey, config.getName() ));
|
buf.append(String.format(fmt, shortKey, config.getNameRaw() ));
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class RenameConfigDialog extends JDialog {
|
|||||||
|
|
||||||
panel.add(new JLabel(trans.get("RenameConfigDialog.lbl.name")), "span, wrap rel");
|
panel.add(new JLabel(trans.get("RenameConfigDialog.lbl.name")), "span, wrap rel");
|
||||||
|
|
||||||
final JTextField textbox = new JTextField(rocket.getFlightConfiguration(fcid).getName());
|
final JTextField textbox = new JTextField(rocket.getFlightConfiguration(fcid).getNameRaw());
|
||||||
panel.add(textbox, "span, w 200lp, growx, wrap para");
|
panel.add(textbox, "span, w 200lp, growx, wrap para");
|
||||||
|
|
||||||
panel.add(new JPanel(), "growx");
|
panel.add(new JPanel(), "growx");
|
||||||
|
@ -220,7 +220,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
if (fcIds == null) return;
|
if (fcIds == null) return;
|
||||||
FlightConfigurationId initFcId = fcIds.get(0);
|
FlightConfigurationId initFcId = fcIds.get(0);
|
||||||
new RenameConfigDialog(SwingUtilities.getWindowAncestor(this), rocket, initFcId).setVisible(true);
|
new RenameConfigDialog(SwingUtilities.getWindowAncestor(this), rocket, initFcId).setVisible(true);
|
||||||
String newName = rocket.getFlightConfiguration(initFcId).getName();
|
String newName = rocket.getFlightConfiguration(initFcId).getNameRaw();
|
||||||
for (int i = 1; i < fcIds.size(); i++) {
|
for (int i = 1; i < fcIds.size(); i++) {
|
||||||
rocket.getFlightConfiguration(fcIds.get(i)).setName(newName);
|
rocket.getFlightConfiguration(fcIds.get(i)).setName(newName);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user