[Mathlib-commitlog] SF.net SVN: mathlib:[798] JMathLib/trunk/src/jmathlib/core/interpreter
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-01-30 19:04:30
|
Revision: 798
http://mathlib.svn.sourceforge.net/mathlib/?rev=798&view=rev
Author: st_mueller
Date: 2009-01-30 19:04:24 +0000 (Fri, 30 Jan 2009)
Log Message:
-----------
changed handling of preferences/properties
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
Removed Paths:
-------------
JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2009-01-30 19:03:54 UTC (rev 797)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2009-01-30 19:04:24 UTC (rev 798)
@@ -11,6 +11,7 @@
import java.io.*;
import java.util.Locale;
+import java.util.Properties;
import java.applet.Applet;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
@@ -47,6 +48,9 @@
/**stores the number format for displaying the number*/
public NumberFormat numFormat = new DecimalFormat("0.0000", new DecimalFormatSymbols(Locale.ENGLISH));
+ /** global properties */
+ private static Properties props = new Properties();
+
/**Initialises the global values
* @param _interpreter = the Interpreter object
* @param _runningStandalone = true if this was run from an application
@@ -204,4 +208,71 @@
numFormat = _numFormat;
}
+ /**
+ *
+ *
+ */
+ public void loadPropertiesFromFile()
+ {
+
+ // load global properties from disc
+ try
+ {
+ props.load(new FileInputStream(new File("JMathLib.properties")));
+ }
+ catch (Exception e)
+ {
+ System.out.println("Properties global error");
+ }
+ //System.out.println("Properties loaded");
+
+ // display properties
+ //Enumeration propnames = props.propertyNames();
+ //while (globalPropnames.hasMoreElements())
+ //{
+ // String propname = (String)globalPropnames.nextElement();
+ // System.out.println("Property: "+propname+" = "+globalProps.getProperty(propname));
+ //}
+
+
+ }
+
+ /**
+ *
+ */
+ public void storePropertiesToFile()
+ {
+
+ // store properties back to file
+ try
+ {
+ props.store(new FileOutputStream(new File("JMathLib.properties")),
+ "JMathLib property file" );
+ }
+ catch (Exception e)
+ {
+ System.out.println("Property: Error");
+ }
+ }
+
+ /**
+ *
+ * @param property
+ * @return
+ */
+ public String getProperty(String property)
+ {
+ return props.getProperty(property);
+ }
+
+ /**
+ *
+ * @param property
+ * @param value
+ */
+ public void setProperty(String property, String value)
+ {
+ props.setProperty(property, value);
+ }
+
}
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-30 19:03:54 UTC (rev 797)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-30 19:04:24 UTC (rev 798)
@@ -30,9 +30,6 @@
/**for testing purposes additional throwing of errors can be enables */
public boolean throwErrorsB = false;
- /** list of preferences */
- public Preferences prefs = new Preferences();
-
/**Constructs the interpreter and sets the constants
* @param _runningStandalone = true if this is being used from an application
*/
@@ -59,7 +56,7 @@
outputPanel = null;
// read preferences from a file on the disc or on the web
- prefs.loadPropertiesFromFile();
+ globals.loadPropertiesFromFile();
}
@@ -98,7 +95,7 @@
executeExpression("finish");
// store current properties to file
- prefs.storeLocalPropertiesToFile();
+ globals.storePropertiesToFile();
}
}
Deleted: JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java 2009-01-30 19:03:54 UTC (rev 797)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java 2009-01-30 19:04:24 UTC (rev 798)
@@ -1,123 +0,0 @@
-package jmathlib.core.interpreter;
-
-//import MathLib.Tokens.*;
-import java.util.*;
-import java.io.*;
-
-/**
- *
- */
-public class Preferences
-{
-
- Properties globalProps = new Properties(); // global properties
- Properties localProps = new Properties(); // local properties
-
- //SwingUI KEYS
- public static final String MFUNCTION_FILE_HISTORY = "MathLib.UI.Swing.MFunctionFileHistory";
- /**
- *
- */
- public Preferences()
- {
- }
-
- /**
- *
- *
- */
- public void loadPropertiesFromFile()
- {
-
- // load globa properties from disc
- try
- {
- globalProps.load(new FileInputStream(new File("JMathLib.properties")));
- }
- catch (Exception e)
- {
- System.out.println("Properties error");
- }
- //System.out.println("Properties loaded");
-
- // display properties
- Enumeration globalPropnames = globalProps.propertyNames();
- //while (globalPropnames.hasMoreElements())
- //{
- // String propname = (String)globalPropnames.nextElement();
- // System.out.println("Property: "+propname+" = "+globalProps.getProperty(propname));
- //}
-
-
- // load local properties from disc
- try
- {
- localProps.load(new FileInputStream(new File("JMathLib.local.properties")));
- }
- catch (Exception e)
- {
- System.out.println("Properties local error");
- }
-
- // display properties
- Enumeration localPropnames = localProps.propertyNames();
- //while (localPropnames.hasMoreElements())
- //{
- // String propname = (String)localPropnames.nextElement();
- // System.out.println("Property (local): "+propname+" = "+localProps.getProperty(propname));
- //}
-
- // check if all global properties are also set in local properties
- // -> in case global property not available in local property, copy global to local property
- globalPropnames = globalProps.propertyNames();
- while (globalPropnames.hasMoreElements())
- {
- String propname = (String)globalPropnames.nextElement();
- if (localProps.getProperty(propname)== null)
- {
- System.out.println("global Property: "+propname+" not local yet");
- localProps.setProperty(propname, (String)globalProps.getProperty(propname));
- }
- }
-
- }
-
- /**
- *
- */
- public void storeLocalPropertiesToFile()
- {
-
- // only store local properties back to file
- try
- {
- localProps.store(new FileOutputStream(new File("JMathLib.local.properties")),
- "JMathLib local property file" );
- }
- catch (Exception e)
- {
- System.out.println("Property: Error");
- }
- }
-
- public String getGlobalProperty(String property)
- {
- return globalProps.getProperty(property);
- }
-
- public void setGlobalProperty(String property, String value)
- {
- globalProps.setProperty(property, value);
- }
-
- public String getLocalProperty(String property)
- {
- return localProps.getProperty(property);
- }
-
- public void setLocalProperty(String property, String value)
- {
- localProps.setProperty(property, value);
- }
-
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|