Merge pull request #1940 from hcraigmiller/Rename-and-re-order-examples
Rename and re-order example designs
This commit is contained in:
commit
ede9dfe700
Binary file not shown.
BIN
swing/resources/datafiles/examples/Airstart timing.ork
Normal file
BIN
swing/resources/datafiles/examples/Airstart timing.ork
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
swing/resources/datafiles/examples/Chute release.ork
Normal file
BIN
swing/resources/datafiles/examples/Chute release.ork
Normal file
Binary file not shown.
BIN
swing/resources/datafiles/examples/Clustered motors.ork
Normal file
BIN
swing/resources/datafiles/examples/Clustered motors.ork
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
swing/resources/datafiles/examples/Dual parachute deployment.ork
Normal file
BIN
swing/resources/datafiles/examples/Dual parachute deployment.ork
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
swing/resources/datafiles/examples/Parallel booster staging.ork
Normal file
BIN
swing/resources/datafiles/examples/Parallel booster staging.ork
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
swing/resources/datafiles/examples/Presets.ork
Normal file
BIN
swing/resources/datafiles/examples/Presets.ork
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
swing/resources/datafiles/examples/Simulation extensions.ork
Normal file
BIN
swing/resources/datafiles/examples/Simulation extensions.ork
Normal file
Binary file not shown.
Binary file not shown.
BIN
swing/resources/datafiles/examples/TARC payload rocket.ork
Normal file
BIN
swing/resources/datafiles/examples/TARC payload rocket.ork
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
swing/resources/datafiles/examples/Tube fin rocket.ork
Normal file
BIN
swing/resources/datafiles/examples/Tube fin rocket.ork
Normal file
Binary file not shown.
BIN
swing/resources/datafiles/examples/Two-stage rocket.ork
Normal file
BIN
swing/resources/datafiles/examples/Two-stage rocket.ork
Normal file
Binary file not shown.
@ -1,6 +1,8 @@
|
||||
package net.sf.openrocket.gui.main;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
@ -18,6 +20,35 @@ public final class ExampleDesignFileAction extends JMenu {
|
||||
*/
|
||||
private final BasicFrame parent;
|
||||
|
||||
/**
|
||||
* Order in which the example files should be displayed in the menu.
|
||||
* A null items means there should be a separator.
|
||||
* <p>
|
||||
* NOTE: update this list if you add a new example file, or update the name of an existing one!!.
|
||||
*/
|
||||
private static final String[] exampleFileOrder = {
|
||||
// Examples of basic rockets
|
||||
"A simple model rocket",
|
||||
"Two-stage rocket",
|
||||
"Three-stage rocket",
|
||||
"TARC payload rocket",
|
||||
"Tube fin rocket",
|
||||
null,
|
||||
// Examples demonstrating complex rocket features
|
||||
"Airstart timing",
|
||||
"Chute release",
|
||||
"Dual parachute deployment",
|
||||
"Clustered motors",
|
||||
"Parallel booster staging",
|
||||
"Pods--airframes and winglets",
|
||||
"Pods--powered with recovery deployment",
|
||||
null,
|
||||
// Examples demonstrating customized functionality
|
||||
"Presets",
|
||||
"Simulation extensions",
|
||||
"Simulation extensions and scripting"
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@ -38,11 +69,37 @@ public final class ExampleDesignFileAction extends JMenu {
|
||||
private void updateMenu() {
|
||||
removeAll();
|
||||
ExampleDesignFile[] examples = ExampleDesignFile.getExampleDesigns();
|
||||
List<JMenuItem> itemList = new ArrayList<>();
|
||||
|
||||
// First create the menu items
|
||||
for (ExampleDesignFile file : examples) {
|
||||
Action action = createAction(file);
|
||||
action.putValue(Action.NAME, file.toString());
|
||||
JMenuItem menuItem = new JMenuItem(action);
|
||||
add(menuItem);
|
||||
itemList.add(menuItem);
|
||||
}
|
||||
|
||||
// Then add them according to their order
|
||||
for (String s : exampleFileOrder) {
|
||||
if (s == null) {
|
||||
addSeparator();
|
||||
} else {
|
||||
for (JMenuItem item : itemList) {
|
||||
if (item.getText().equals(s)) {
|
||||
add(item);
|
||||
itemList.remove(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the remaining (unordered) items to the end
|
||||
if (itemList.size() > 0) {
|
||||
addSeparator();
|
||||
for (JMenuItem item : itemList) {
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user