import net.sf.openrocket.database.Databases;
import net.sf.openrocket.document.Simulation;
+import net.sf.openrocket.gui.main.ExceptionHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.BodyComponent;
import net.sf.openrocket.rocketcomponent.FinSet;
private static final String BUILD_VERSION;
private static final String BUILD_SOURCE;
public static final String DEFAULT_BUILD_SOURCE = "default";
+ private static final boolean DEFAULT_CHECK_UPDATES;
static {
try {
InputStream is = ClassLoader.getSystemResourceAsStream("build.properties");
if (is == null) {
throw new MissingResourceException(
- "build.properties not found, distribution built wrong",
+ "build.properties not found, distribution built wrong" +
+ " path:"+System.getProperty("java.class.path"),
"build.properties", "build.version");
}
BUILD_SOURCE = props.getProperty("build.source");
+ String value = props.getProperty("build.checkupdates");
+ if (value != null)
+ DEFAULT_CHECK_UPDATES = Boolean.parseBoolean(value);
+ else
+ DEFAULT_CHECK_UPDATES = true;
+
} catch (IOException e) {
throw new MissingResourceException(
"Error reading build.properties",
public static final String PLOT_SHOW_POINTS = "ShowPlotPoints";
+ private static final String CHECK_UPDATES = "CheckUpdates";
+
/**
* Node to this application's preferences.
* @deprecated Use the static methods instead.
}
- private static final Material DEFAULT_LINE_MATERIAL =
- Databases.findMaterial(Material.Type.LINE, "Elastic cord (round 2mm, 1/16 in)",
- 0.0018, false);
- private static final Material DEFAULT_SURFACE_MATERIAL =
- Databases.findMaterial(Material.Type.SURFACE, "Ripstop nylon", 0.067, false);
- private static final Material DEFAULT_BULK_MATERIAL =
- Databases.findMaterial(Material.Type.BULK, "Cardboard", 680, false);
-
+ /*
+ * Within a holder class so they will load only when needed.
+ */
+ private static class DefaultMaterialHolder {
+ private static final Material DEFAULT_LINE_MATERIAL =
+ Databases.findMaterial(Material.Type.LINE, "Elastic cord (round 2mm, 1/16 in)",
+ 0.0018, false);
+ private static final Material DEFAULT_SURFACE_MATERIAL =
+ Databases.findMaterial(Material.Type.SURFACE, "Ripstop nylon", 0.067, false);
+ private static final Material DEFAULT_BULK_MATERIAL =
+ Databases.findMaterial(Material.Type.BULK, "Cardboard", 680, false);
+ }
//////////////////////
}
+ public static String getUniqueID() {
+ String id = PREFNODE.get("id", null);
+ if (id == null) {
+ id = UniqueID.generateHashedID();
+ PREFNODE.put("id", id);
+ }
+ return id;
+ }
+
+
public static void storeVersion() {
PREFNODE.put("OpenRocketVersion", getVersion());
+ public static boolean getCheckUpdates() {
+ return PREFNODE.getBoolean(CHECK_UPDATES, DEFAULT_CHECK_UPDATES);
+ }
+
+ public static void setCheckUpdates(boolean check) {
+ PREFNODE.putBoolean(CHECK_UPDATES, check);
+ storeVersion();
+ }
+
+
//////////////////
public static File getDefaultDirectory() {
switch (type) {
case LINE:
- return DEFAULT_LINE_MATERIAL;
+ return DefaultMaterialHolder.DEFAULT_LINE_MATERIAL;
case SURFACE:
- return DEFAULT_SURFACE_MATERIAL;
+ return DefaultMaterialHolder.DEFAULT_SURFACE_MATERIAL;
case BULK:
- return DEFAULT_BULK_MATERIAL;
+ return DefaultMaterialHolder.DEFAULT_BULK_MATERIAL;
}
throw new IllegalArgumentException("Unknown material type: "+type);
}
}
} catch (BackingStoreException e) {
- System.err.println("BackingStoreException:");
- e.printStackTrace();
+ ExceptionHandler.handleErrorCondition(e);
}
}