comparison m-toolbox/classes/@LTPDAModelBrowser/LTPDAModelBrowser.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % LTPDAModelBrowser is a graphical user interface for browsing the
2 % available built-in models.
3 %
4 % CALL: LTPDAModelBrowser
5 %
6 %
7 % M Hewitson 18-10-10
8 %
9 % $Id: LTPDAModelBrowser.m,v 1.1 2010/10/23 11:14:08 hewitson Exp $
10 %
11 classdef LTPDAModelBrowser < handle
12
13 properties
14 gui = [];
15 end
16
17
18 methods
19 function mainfig = LTPDAModelBrowser(varargin)
20
21 % generate model data
22 modelClasses = LTPDAModelBrowser.generateModelData();
23
24 % make a gui
25 mainfig.gui = javaObjectEDT('mpipeline.ltpdamodelbrowser.JModelBrowser', [], false, modelClasses);
26
27 %--- called when window is closed
28 h = handle(mainfig.gui, 'callbackproperties');
29 set(h, 'WindowClosedCallback', {@mainfig.cb_guiClosed});
30
31 %--- Run button
32 h = handle(mainfig.gui.getDocBtn, 'callbackproperties');
33 set(h, 'ActionPerformedCallback', {@mainfig.cb_getDoc});
34
35 % Make gui visible
36 mainfig.gui.setVisible(true);
37
38
39 end % End constructor
40
41 function display(varargin)
42 end
43
44 end % End public methods
45
46 methods (Access = private)
47
48 function cb_getDoc(varargin)
49 browser = varargin{1};
50 jbrowser = browser.gui;
51 model = jbrowser.getSelectedModel();
52 if ~isempty(model)
53 mdl = char(model.fullname());
54 cmd = [ mdl '(''info'')'];
55 info = eval(cmd);
56 web(modelOverview(info),'-helpbrowser');
57 end
58 end
59
60 end
61
62 methods (Access = private, Static=true)
63
64 function modelClasses = generateModelData()
65
66 classes = utils.helper.ltpda_userclasses;
67 modelClasses = java.util.ArrayList();
68 for kk=1:numel(classes)
69 cl = classes{kk};
70
71 % get models for this class
72 if ~strcmp(cl, 'plist') && ~strcmp(cl, 'time')
73 models = eval([cl '.getBuiltInModels()']);
74 models = [{models{:,1}}];
75 modelClass = mpipeline.ltpdamodelbrowser.JModelClass(cl);
76
77 for jj=1:numel(models)
78 model = models{jj};
79 try
80 cmd = [cl '_model_' model '(''describe'')'];
81 info = eval(cmd);
82 cmd = [cl '_model_' model '(''doc'')'];
83 doc = eval(cmd);
84 html = ['<html><body>' info sprintf('\n\n') doc '</body></html>'];
85 jmodel = mpipeline.ltpdamodelbrowser.JModel(modelClass, model, html);
86 modelClass.addModel(jmodel);
87 catch
88 warning('Model %s does not respond to the <info> call', model)
89 end
90 end
91
92 if modelClass.getModels.size>0
93 modelClasses.add(modelClass);
94 end
95 end
96 end
97 end
98
99 end
100
101 methods (Access = public)
102
103 function cb_guiClosed(varargin)
104 disp('*** Goodbye from LTPDAModelBrowser');
105 browser = varargin{1};
106
107 %--- called when window is closed
108 h = handle(browser.gui, 'callbackproperties');
109 set(h, 'WindowClosedCallback', []);
110
111 h = handle(browser.gui.getDocBtn, 'callbackproperties');
112 set(h, 'ActionPerformedCallback', []);
113
114 end
115
116 end
117
118 end
119
120 % END