1 package net.sf.openrocket.android;
\r
4 import java.io.IOException;
\r
6 import net.sf.openrocket.aerodynamics.WarningSet;
\r
7 import net.sf.openrocket.document.OpenRocketDocument;
\r
8 import net.sf.openrocket.document.Simulation;
\r
9 import net.sf.openrocket.file.openrocket.OpenRocketSaver;
\r
10 import net.sf.openrocket.rocketcomponent.Rocket;
\r
11 import android.net.Uri;
\r
13 public class CurrentRocket {
\r
15 private Uri fileUri;
\r
17 private OpenRocketDocument rocketDocument;
\r
18 private WarningSet warnings;
\r
20 private RocketChangedEventHandler handler;
\r
22 public void setHandler( RocketChangedEventHandler handler ) {
\r
23 this.handler = handler;
\r
27 * @return the rocketDocument
\r
29 public OpenRocketDocument getRocketDocument() {
\r
30 return rocketDocument;
\r
33 public void notifySimsChanged() {
\r
34 if ( handler != null ) {
\r
35 handler.simsChangedMessage();
\r
39 public void addNewSimulation() {
\r
40 Rocket rocket = rocketDocument.getRocket();
\r
41 // FIXME - hopefully the change to the Simulation object will be reverted soon.
\r
42 Simulation newSim = new Simulation(rocketDocument, rocket);
\r
43 newSim.setName(rocketDocument.getNextSimulationName());
\r
44 rocketDocument.addSimulation(newSim);
\r
45 notifySimsChanged();
\r
48 public void deleteSimulation( int simulationPos ) {
\r
49 rocketDocument.removeSimulation( simulationPos );
\r
50 notifySimsChanged();
\r
53 public String addNewMotorConfig() {
\r
54 String configId = rocketDocument.getRocket().newMotorConfigurationID();
\r
55 if ( handler != null ) {
\r
56 handler.configsChangedMessage();
\r
61 * @param rocketDocument the rocketDocument to set
\r
63 public void setRocketDocument(OpenRocketDocument rocketDocument) {
\r
64 this.rocketDocument = rocketDocument;
\r
67 public WarningSet getWarnings() {
\r
71 public void setWarnings(WarningSet warnings) {
\r
72 this.warnings = warnings;
\r
75 public Uri getFileUri() {
\r
79 public void setFileUri(Uri fileUri) {
\r
80 this.fileUri = fileUri;
\r
83 public void saveOpenRocketDocument() throws IOException {
\r
84 OpenRocketSaver saver = new OpenRocketSaver();
\r
85 saver.save(new File(fileUri.getPath()),rocketDocument);
\r