diff m-toolbox/classes/@LTPDAprefs/upgradeFromPlist.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@LTPDAprefs/upgradeFromPlist.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,55 @@
+% UPGRADEFROMPLIST upgrades the old preference strucure to the new structure.
+%
+% Call:        prefs = LTPDAprefs.upgradeFromPlist(prefs, pl)
+%
+% Parameters:
+%       prefs - preferences object with the new structure
+%       pl    - a PLIST with the old preferences object. The old
+%               preferences object must have the key 'LTPDAPREFERENCES'
+%
+% Version:
+%     $Id: upgradeFromPlist.m,v 1.1 2010/11/30 17:37:13 ingo Exp $
+%
+
+function prefs = upgradeFromPlist(prefs, pl)
+  
+  oldprefs = pl.find('LTPDAPREFERENCES');
+  
+  disp('*** upgrading preferences ...');
+  
+  % update display settings
+  prefs.getDisplayPrefs.setDisplayVerboseLevel(java.lang.Integer(oldprefs.display.verboseLevel));
+  prefs.getDisplayPrefs.setDisplayWrapStrings(java.lang.Integer(oldprefs.display.wrapstrings));
+  prefs.getDisplayPrefs.setDisplayWrapLegendStrings(java.lang.Integer(oldprefs.display.wraplegendstring));
+  
+  % update models
+  for kk=1:numel(oldprefs.models.paths)
+    path = oldprefs.models.paths{kk};
+    prefs.getModelsPrefs.addSearchPath(path);
+  end
+  
+  % update time prefs
+  prefs.getTimePrefs.setTimeTimezone(oldprefs.time.timezone);
+  prefs.getTimePrefs.setTimestringFormat(oldprefs.time.format);
+  
+  % update repository prefs
+  for kk=1:numel(oldprefs.repository.servers)
+    server = oldprefs.repository.servers{kk};
+    prefs.getRepoPrefs.addHostname(server);
+  end
+  prefs.getRepoPrefs.setExpiry(java.lang.Integer(oldprefs.repository.loginExpiry));
+  
+  % update external prefs
+  prefs.getExternalPrefs.setDotBinaryPath(oldprefs.external.dotbin);
+  prefs.getExternalPrefs.setDotOutputFormat(oldprefs.external.dotformat);
+  
+  % update misc prefs
+  prefs.getMiscPrefs.setDefaultWindow(oldprefs.misc.default_window.type);
+  for kk=1:numel(oldprefs.misc.units)
+    unit = oldprefs.misc.units{kk};
+    prefs.getMiscPrefs.addUnit(unit);
+  end
+  
+  oldprefs = [];
+  
+end