view m-toolbox/classes/@LTPDAprefs/loadPrefs.m @ 5:5a49956df427 database-connection-manager

LTPDAPreferences panel for new LTPDADatabaseConnectionManager
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children 4be5f7a5316f
line wrap: on
line source

% LOADPREFS a static method which loads the preferences from a XML file.
%
% Call:        LTPDAprefs.loadPrefs()
%
% Parameters:
%        -
%
% Version:
%     $Id: loadPrefs.m,v 1.3 2011/04/27 12:45:49 hewitson Exp $
%

function loadPrefs(varargin)
  fprintf('Loading LTPDA preferences from %s ...\n', LTPDAprefs.preffile);
  v = ver('LTPDA');
  nv = utils.helper.ver2num(v(1).Version);
  prefs = mpipeline.ltpdapreferences.LTPDAPreferences.loadFromDisk(LTPDAprefs.preffile, nv);
  
  % Version 2.4 drops support for built-in model directories.
  if (nv >= 2.04) 
    % we drop support for 'models' here, so check for non-empty models path
    % and warn the user to make an extension
    searchPaths = prefs.getModelsPrefs.getSearchPaths;
    paths = {};
    for kk=0:searchPaths.size-1
      paths = [paths {char(searchPaths.get(kk))}];
    end    
    if ~isempty(paths)
      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');
      utils.helper.warnDlg(message, 'Built-in model directories not supported');
      prefs.getModelsPrefs.getSearchPaths.clear();
    end
  end
    
  setappdata(0, 'LTPDApreferences', prefs);
  LTPDAprefs.setApplicationData();
  prefs.writeToDisk;
end