0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 1 % LOADPREFS a static method which loads the preferences from a XML file.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 2 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 3 % Call: LTPDAprefs.loadPrefs()
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 4 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 5 % Parameters:
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 6 % -
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 7 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 8 % Version:
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 9 % $Id: loadPrefs.m,v 1.3 2011/04/27 12:45:49 hewitson Exp $
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 10 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 11
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 12 function loadPrefs(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 13 fprintf('Loading LTPDA preferences from %s ...\n', LTPDAprefs.preffile);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 14 v = ver('LTPDA');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 15 nv = utils.helper.ver2num(v(1).Version);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 16 prefs = mpipeline.ltpdapreferences.LTPDAPreferences.loadFromDisk(LTPDAprefs.preffile, nv);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 17
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 18 % Version 2.4 drops support for built-in model directories.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 19 if (nv >= 2.04)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 20 % we drop support for 'models' here, so check for non-empty models path
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 21 % and warn the user to make an extension
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 22 searchPaths = prefs.getModelsPrefs.getSearchPaths;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 23 paths = {};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 24 for kk=0:searchPaths.size-1
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 25 paths = [paths {char(searchPaths.get(kk))}];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 26 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 27 if ~isempty(paths)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 28 message = sprintf('Directories of built-in models are no longer supported. \nPlease make an LTPDA Extension module for your models. \n(See document section "LTPDA Extension Modules").\n');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 29 utils.helper.warnDlg(message, 'Built-in model directories not supported');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 30 prefs.getModelsPrefs.getSearchPaths.clear();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 31 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 32 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 33
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 34 setappdata(0, 'LTPDApreferences', prefs);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 35 LTPDAprefs.setApplicationData();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 36 prefs.writeToDisk;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 37 end