source: aedes_viewprocpar.m @ 145

Last change on this file since 145 was 145, checked in by tjniskan, 9 years ago
  • aedes_viewprocpar.m works now in Matlab R2007b (may work also with

older versions but not tested...)

M aedes_viewprocpar.m
M aedes_revision.m

File size: 20.7 KB
Line 
1function aedes_viewprocpar(procpar)
2% AEDES_VIEWPROCPAR - VNMR Procpar-file viewer
3%   
4%
5% Synopsis:
6%       aedes_viewprocpar(procpar)
7%
8% Description:
9%
10% Examples:
11%
12% See also:
13%       AEDES
14
15% This function is a part of Aedes - A graphical tool for analyzing
16% medical images
17%
18% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
19%
20% Department of Physics, Department of Neurobiology
21% University of Kuopio, FINLAND
22%
23% This program may be used under the terms of the GNU General Public
24% License version 2.0 as published by the Free Software Foundation
25% and appearing in the file LICENSE.TXT included in the packaging of
26% this program.
27%
28% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30
31% Public variables
32H = [];    % Handles structure
33Dat = [];  % Internal data structure
34
35
36% Do some error checking
37if nargin ~= 1
38  error('Invalid number of input arguments!')
39end
40
41% Check if input is a Aedes data structure
42if isfield(procpar,'PROCPAR') && isfield(procpar,'FTDATA') && ...
43    isfield(procpar,'HDR')
44  ProcparFileName = [procpar.HDR.fpath,'procpar'];
45  procpar = procpar.PROCPAR;
46else
47  ProcparFileName = '';
48end
49
50if ~isstruct(procpar) || ~isfield(procpar,'console')
51  error('Input argument is not a valid Varian PROCPAR structure!')
52end
53
54% Draw main GUI
55[H,Dat]=l_DrawGui();
56
57% Default favourites
58%FavouriteList = {};
59%FavouriteList = {'tr','te','kakka','lpe','lro'};
60%set(H.FavListBox,'string',FavouriteList);
61
62% Parse PROCPAR structure
63l_ParseProcparStructure(procpar)
64
65% Update Data Table
66l_UpdateDataTable([],[]);
67
68% Set initial focus to search editbox
69uicontrol(H.SearchEdit);
70
71  function [H,Dat]=l_DrawGui()
72
73    % Load default font and colors
74    Dat.GD=aedes_gui_defaults;
75   
76    % Get Matlab version
77    Dat.MatlabVersion = aedes_getmatlabversion;
78
79    % Position figure to the center of the screen
80    scrsz = get(0,'screensize');
81    fig_w = 600;
82    fig_h = 700;
83    fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 fig_w fig_h];
84   
85   
86    % Main Figure ----------------------------
87    H.fh = figure('Units','Pixel', ...
88      'position',fig_pos,...
89      'Name','VNMR PROCPAR Viewer', ...
90      'Numbertitle','off', ...
91      'Tag','procpar_viewer_fig', ...
92      'Color',Dat.GD.col.mainfig, ...
93      'Toolbar','none', ...
94      'Menubar','none', ...
95      'DoubleBuffer','on', ...
96      'DockControls','off',...
97      'renderer','painters',...
98      'resize','off',...
99      'Handlevisibility','off',...
100      'KeyPressFcn',@l_EscapeCloseFig,...
101      'CloseReq',@l_CloseFig);
102   
103    % File name
104    fname_txh = 0;
105    if ~isempty(ProcparFileName)
106      fname_txh = 70;
107      H.FileNameUipanel = uipanel('parent',H.fh,...
108        'units','pixel',...
109        'position',[10 fig_h-fname_txh fig_w-20 fname_txh-10],...
110        'title','File Name',...
111        'backgroundcolor',Dat.GD.col.mainfig);
112     
113      tmp_pos=get(H.FileNameUipanel,'position');
114      H.FileNameText = uicontrol('parent',H.FileNameUipanel,...
115        'style','text',...
116        'string',ProcparFileName,...
117        'units','pixel',...
118        'position',[10 5 tmp_pos(3)-20 fname_txh-35],...
119        'horizontalalign','left',...
120        'backgroundcolor',Dat.GD.col.mainfig);
121    end
122   
123    % Search uipanel ----------------------
124    up_height = 80;
125    H.SearchUipanel = uipanel('parent',H.fh,...
126      'units','pixel',...
127      'position',[10 fig_h-up_height-10-fname_txh fig_w-20 up_height],...
128      'title','Search Options',...
129      'backgroundcolor',Dat.GD.col.mainfig);
130
131    % Search text
132    pos=get(H.SearchUipanel,'position');
133    H.SearchText = uicontrol('parent',H.SearchUipanel,...
134      'style','text',...
135      'string','Parameter:',...
136      'units','pixel',...
137      'position',[10 pos(4)-45 100 19],...
138      'horizontalalign','left',...
139      'backgroundcolor',Dat.GD.col.mainfig);
140
141    % Search type popupmenu
142    try
143      val = getpref('Aedes','ViewProcparSearchHow');
144    catch
145      val = 1;
146    end
147    tmp_pos = get(H.SearchText,'position');
148    H.SearchHowPopup = uicontrol('parent',H.SearchUipanel,...
149      'style','popup',...
150      'string',{'contains...',...
151      'is exactly...','begins with...',...
152      'ends with...'},...
153      'units','pixel',...
154      'position',[tmp_pos(1)+tmp_pos(3)+5 tmp_pos(2) ...
155      150 22],...
156      'value',val,...
157      'tag','',...
158      'backgroundcolor',Dat.GD.col.popup,...
159      'callback',@l_SearchParams,...
160      'KeyPressFcn',@l_EscapeCloseFig);
161
162    % Search editbox
163    tmp_pos = get(H.SearchHowPopup,'position');
164    H.SearchEdit = uicontrol('parent',H.SearchUipanel,...
165      'style','edit',...
166      'units','pixel',...
167      'position',[tmp_pos(1)+tmp_pos(3)+5 tmp_pos(2) pos(3)-tmp_pos(1)-tmp_pos(3)-15 tmp_pos(4)],...
168      'Callback',@l_SearchParams,...
169      'backgroundcolor',Dat.GD.col.edit,...
170      'KeyPressFcn',@l_SearchParams);
171   
172    % If other procpar viewer windows are currently open, the figure name
173    % has to be unique for finding the correct javaFrame.
174    figs=findall(0,'tag','procpar_viewer_fig');
175    if length(figs)>1
176      set(H.fh,'Name',['VNMR PROCPAR Viewer (',num2str(H.fh),')']);
177      drawnow,pause(0.02);
178    end
179    H.jh=l_GetEditboxJavaHandle(H.fh);
180    if isempty(H.jh)
181      % Fall back to basic matlab code -> no search as you type... :-(
182      Dat.SearchEditUseJava = false;
183      set(H.SearchEdit,'KeyPressFcn','')
184    else
185      Dat.SearchEditUseJava = true;
186    end
187    set(H.fh,'Name','VNMR PROCPAR Viewer'); % Set Figure name back to original...
188   
189   
190    % Case sensitive
191    try
192      val = getpref('Aedes','ViewProcparCaseSensitivity');
193    catch
194      val = 1;
195    end
196    tmp_pos = get(H.SearchEdit,'position');
197    H.SearchCaseSens = uicontrol('parent',H.SearchUipanel,...
198      'style','checkbox',...
199      'units','pixel',...
200      'string','Case sensitive',...
201      'position',[tmp_pos(1) tmp_pos(2)-25 tmp_pos(3) tmp_pos(4)],...
202      'Callback',@l_SearchParams,...
203      'value',val,...
204      'backgroundcolor',Dat.GD.col.mainfig,...
205      'KeyPressFcn',@l_EscapeCloseFig);
206   
207    % --------------------------------------
208    % Favourite params list
209    favup_height = 150;
210    tmp_pos = get(H.SearchUipanel,'position');
211    H.FavUipanel = uipanel('parent',H.fh,...
212      'units','pixel',...
213      'position',[10 fig_h-up_height-favup_height-fname_txh-15 fig_w-20 favup_height],...
214      'title','Favourite parameters',...
215      'backgroundcolor',Dat.GD.col.mainfig);
216   
217    tmp_pos = get(H.FavUipanel,'position');
218    InfoTx = {['The parameter names entered here will be searched ',...
219      'automatically. The matching parameters are placed on top of the parameter list ',...
220      'in boldface. This automatic search is case sensitive and only returns exact matches.']};
221    H.FavInfoText = uicontrol('parent',H.FavUipanel,...
222      'style','text',...
223      'units','pixel',...
224      'string','',...
225      'position',[10 10 250 120],...
226      'horizontalalign','left',...
227      'fontsize',10,...
228      'backgroundcolor',[0.85 0.85 0.85]);%Dat.GD.col.mainfig);
229    InfoTx=textwrap(H.FavInfoText,InfoTx);
230    set(H.FavInfoText,'string',InfoTx)
231   
232    tmp_pos = get(H.FavInfoText,'position');
233    H.FavAdd = uicontrol('parent',H.FavUipanel,...
234      'style','pushbutton',...
235      'units','pixels',...
236      'position',[tmp_pos(1)+tmp_pos(3)+5 ...
237      tmp_pos(2)+tmp_pos(4)-25 70 25],...
238      'String','Add',...
239      'callback',@l_AddFavourite,...
240      'KeyPressFcn',@l_EscapeCloseFig);
241   
242    H.FavRem = uicontrol('parent',H.FavUipanel,...
243      'style','pushbutton',...
244      'units','pixels',...
245      'position',[tmp_pos(1)+tmp_pos(3)+5 ...
246      tmp_pos(2)+tmp_pos(4)-2*25-5 70 25],...
247      'String','Remove',...
248      'callback',@l_RemFavourite,...
249      'KeyPressFcn',@l_EscapeCloseFig);
250   
251    try
252      Dat.FavouriteList = getpref('Aedes','ViewProcparFavourites');
253    catch
254      Dat.FavouriteList = {''};
255    end
256    tmp_pos = get(H.FavInfoText,'position');
257    H.FavListBox = uicontrol('parent',H.FavUipanel,...
258      'style','listbox',...
259      'units','pixels',...
260      'min',1,...
261      'max',3,...
262      'position',[tmp_pos(1)+tmp_pos(3)+80 ...
263      tmp_pos(2) fig_w-30-tmp_pos(3)-90 tmp_pos(4)],...
264      'String',Dat.FavouriteList,...
265      'value',[],...
266      'backgroundcolor','w',...
267      'KeyPressFcn',@l_EscapeCloseFig);
268   
269    % Close & Export to workspace btns -------
270    tmp_pos = get(H.FavUipanel,'position');
271    btn_w = 200;
272    btn_h = 25;
273    H.ExportBtn = uicontrol('parent',H.fh,...
274      'style','pushbutton',...
275      'units','pixels',...
276      'position',[tmp_pos(1) ...
277      tmp_pos(2)-btn_h-5 btn_w btn_h],...
278      'string','Export to workspace',...
279      'callback',@l_ExportToWorkspace,...
280      'KeyPressFcn',@l_EscapeCloseFig);
281   
282    btn_w = 200;
283    btn_h = 25;
284    H.CloseBtn = uicontrol('parent',H.fh,...
285      'style','pushbutton',...
286      'units','pixels',...
287      'position',[tmp_pos(1)+tmp_pos(3)-btn_w ...
288      tmp_pos(2)-btn_h-5 btn_w btn_h],...
289      'string','Close',...
290      'callback',@l_CloseFig,...
291      'KeyPressFcn',@l_EscapeCloseFig);
292   
293    % Data Table -----------------------------
294    pos=get(H.FavUipanel,'position');
295    if Dat.MatlabVersion>=7.06
296      H.restable = uitable('Parent',H.fh,...
297        'units','pixel',...
298        'position',[10 10 fig_w-20 pos(2)-20-btn_h-5],...
299        'KeyPressFcn',@l_EscapeCloseFig);
300    else
301      H.restable = uitable('Parent',H.fh,...
302        'position',[10 10 fig_w-20 pos(2)-20-btn_h-5],...
303        'Data',{'loading...','loading...'},...
304        'ColumnWidth',250,...
305        'ColumnNames',{'Parameter','Value(s)'});
306    end
307  end
308
309%% --------------------------------------------------------
310  function l_ParseProcparStructure(procpar)
311
312    %% Read procpar and construct a cell array
313    DataTable = {};
314    fldnames=fieldnames(procpar);
315    fldnames=sort(fldnames);
316    for ii=1:length(fldnames)
317      DataTable{end+1,1}=fldnames{ii};
318      val=procpar.(fldnames{ii});
319      if length(val)>1
320        if iscell(val)
321          if strcmpi(fldnames{ii},'array')
322            if iscell(val{1})
323              str='(';
324              for jj=1:length(val{1})
325                val{1}{jj}=strrep(val{1}{jj},'''','''''');
326                str = [str,', ''',val{1}{jj},''''];
327              end
328              str=[str,')'];
329              DataTable{end,2}=str;
330            else
331              for jj=1:length(val)
332                val{jj}=strrep(val{jj},'''','''''');
333                str = [str,', ''',val{jj},''''];
334              end
335              DataTable{end,2}=str;
336            end
337          else
338            DataTable{end,2}=val{1};
339          end
340        else
341          str='[ ';
342          for ii=1:length(val)
343            str=[str,' ',num2str(val(ii)),' '];
344          end
345          str=[str,' ]'];
346          DataTable{end,2}=str;
347        end
348      else
349        if iscell(val)
350          DataTable{end,2}=val{1};
351        else
352          DataTable{end,2}=val;
353        end
354      end
355    end
356
357    % Save the full table
358    Dat.FullTable = DataTable;
359
360    % Put favourites on top
361    Dat.DataTable = l_PutFavouritesOnTop(Dat.FullTable);
362
363  end
364
365%% ---------------------------------------------
366  function l_SearchParams(fh,evd)
367
368    if ~isempty(evd) && isfield(evd,'Key') && ...
369        strcmpi(evd.Key,'escape')
370      l_EscapeCloseFig(fh,evd);
371      return
372    end
373   
374    % Get the search string
375    if Dat.SearchEditUseJava
376      SearchStr = get(H.jh,'Text');
377    else
378      SearchStr = get(H.SearchEdit,'string');
379    end
380   
381    % Get case sensitivity
382    CaseSens = get(H.SearchCaseSens,'value');
383    if CaseSens==0
384      RegExpOpt = 'ignorecase';
385    else
386      RegExpOpt = 'matchcase';
387    end
388   
389    if isempty(SearchStr)
390      % If the search string is empty, show full table
391      Dat.DataTable = l_PutFavouritesOnTop(Dat.FullTable);
392    else
393      switch get(H.SearchHowPopup,'value')
394        case 1
395          % Search contains
396          RegExpStr = SearchStr;
397        case 2
398          % Search is exactly
399          RegExpStr = ['^',SearchStr,'$'];
400        case 3
401          % Search begins with
402          RegExpStr = ['^',SearchStr];
403        case 4
404          % Search ends with
405          RegExpStr = [SearchStr,'$'];
406      end
407     
408      % Regexp the full table parameters
409      ind=find(~cellfun('isempty',regexp(Dat.FullTable(:,1),RegExpStr,RegExpOpt)));
410     
411      % Update DataTable
412      if isempty(ind)
413        if Dat.MatlabVersion>=7.06
414          Dat.DataTable = {'<html><b>No matches!</b></html>',''};
415          %set(H.SearchEdit,'string',['<html><font color="red">',SearchStr,'</font></html>']);
416        else
417          Dat.DataTable = {'<html><b>No matches!</b></html>','<html><b>No matches!</b></html>';...
418            '=============','============='};
419        end
420      else
421        Dat.DataTable = Dat.FullTable(ind,:);
422        Dat.DataTable(:,1)=regexprep(Dat.DataTable(:,1),['(',SearchStr,')'],['<b>$1</b>'],RegExpOpt);
423        Dat.DataTable(:,1)=regexprep(Dat.DataTable(:,1),'(^.*$)','<html>$1</html>',RegExpOpt);
424      end
425    end
426
427    % Update Data Table
428    l_UpdateDataTable([],[])
429   
430  end
431
432%% ---------------------------------------------
433  function l_UpdateDataTable(fh,evd)
434   
435    if Dat.MatlabVersion>=7.06
436      set(H.restable,'Data',Dat.DataTable,...
437        'ColumnFormat',{'char','char'},...
438        'ColumnWidth',{200,350},...
439        'RowName',[],...
440        'ColumnName',{'Parameter','Value(s)'})
441    else
442      set(H.restable,'Data',Dat.DataTable)
443    end
444   
445  end
446
447%% ---------------------------------------------
448  function l_AddFavourite(fh,evd)
449   
450    % Prompt for a favourite search string
451    resp = aedes_inputdlg('Search text to be added:');
452    if isempty(resp) || isempty(resp{1})
453      return
454    end
455   
456    % Add search string to list
457    Dat.FavouriteList{end+1} = resp{1};
458%     ListBoxStr = get(H.FavListBox,'string');
459%     ListBoxStr{end+1} = resp{1};
460    set(H.FavListBox,'string',Dat.FavouriteList,...
461      'value',[]);
462   
463    % Run search
464    l_SearchParams([],[]);
465   
466  end
467
468%% ---------------------------------------------
469  function l_RemFavourite(fh,evd)
470   
471    % Get selected indices
472    ind = get(H.FavListBox,'value');
473    if isempty(ind)
474      return
475    end
476   
477    % Ask for confirmation
478    resp = questdlg('Remove selected favourites?',...
479      'Remove favourites','Yes','No','No');
480    if strcmpi(resp,'No')
481      return
482    end
483    Dat.FavouriteList(ind)=[];
484%     ListBoxStr = get(H.FavListBox,'string');
485%     ListBoxStr(ind)=[];
486    set(H.FavListBox,'string',Dat.FavouriteList,...
487      'value',[]);
488   
489   
490    % Run search to update changes
491    l_SearchParams([],[]);
492   
493  end
494
495
496%% ---------------------------------------------
497  function TableOut = l_PutFavouritesOnTop(TableIn)
498   
499    FavouriteList = get(H.FavListBox,'string');
500   
501    % Put favourite list matches on top of the search list and bold face
502    ind = [];
503    for ii=1:length(FavouriteList)
504      tmp_ind=find(~cellfun('isempty',regexp(TableIn(:,1),['^',FavouriteList{ii},'$'])));
505      ind = [ind tmp_ind];
506      if isempty(tmp_ind)
507        % If favourite is not found, color it red in the listbox
508        ListboxStr=get(H.FavListBox,'string');
509        ListboxStr = regexprep(ListboxStr,['(^',FavouriteList{ii},'$)'],...
510          '<html><font color="red"><b>$1 (not found)</b></font></html>');
511        set(H.FavListBox,'string',ListboxStr)
512      end
513    end
514    if ~isempty(ind)
515      ind2 = setdiff(1:size(TableIn,1),ind);
516      FavList = TableIn(ind,:);
517      FavList(:,1)=regexprep(FavList(:,1),'(\w+)',...
518        '<html><b>$1</b></html>');
519      TableOut = cat(1,...
520        FavList,...
521        {'<html><b>============</b></html>','<html><b>============</b></html>'},...
522        TableIn(ind2,:));
523    else
524      TableOut = TableIn;
525    end
526  end
527
528%% --------------------------------------
529  function l_ExportToWorkspace(fh,evd)
530   
531    assignin('base','procpar',procpar);
532    msgstr = sprintf('PROCPAR exported to variable "%s".','procpar');
533   
534    % Print notification to workspace
535    fprintf(1,['AEDES_VIEWPROCPAR: ',msgstr,'\n']);
536   
537    % Nag with a dialog...
538    helpdlg(msgstr,'PROCPAR exported!')
539   
540  end
541
542%% --------------------------------------------
543  function l_EscapeCloseFig(fh,evd)
544   
545    % Call l_CloseFig if ESC is pressed
546    if ~isempty(evd) && isfield(evd,'Key') && ...
547        strcmpi(evd.Key,'escape')
548      l_CloseFig([],[])
549    end
550   
551  end
552
553%% --------------------------------------------
554  function l_CloseFig(fh,evd)
555   
556    % Try to save preferences to disk before exiting
557    try
558      CaseSens = get(H.SearchCaseSens,'value');
559      setpref('Aedes','ViewProcparCaseSensitivity',CaseSens);
560     
561      val = get(H.SearchHowPopup,'value');
562      setpref('Aedes','ViewProcparSearchHow',val);
563     
564      setpref('Aedes','ViewProcparFavourites',Dat.FavouriteList);
565    catch
566      disp('Warning: Could not save AEDES_VIEWPROCPAR preferences!');
567    end
568    delete(H.fh)
569   
570  end
571
572%% -----------------------------------------------
573  function jhEditBox=l_GetEditboxJavaHandle(hFig)
574    % Parts of this code are originally written by Yair Altman, whose
575    % wizardry in Java programming in Matlab has been of great help in many
576    % occasions. Please see http://undocumentedmatlab.com and the
577    % comp.soft-sys.matlab news group for further information. The
578    % following license notice is for findjobj.m (by Yair Altman, available
579    % in the Matlab File Exchange,
580    % http://www.mathworks.com/matlabcentral/fileexchange/14317) from which
581    % I have used code snippets in this subfunction.
582    %
583    %
584    % Copyright (c) 2009, Yair Altman All rights reserved.
585    %
586    % Redistribution and use in source and binary forms, with or without
587    % modification, are permitted provided that the following conditions
588    % are met:
589    %
590    %   * Redistributions of source code must retain the above copyright
591    %     notice, this list of conditions and the following disclaimer.
592    %   * Redistributions in binary form must reproduce the above copyright
593    %     notice, this list of conditions and the following disclaimer in
594    %     the documentation and/or other materials provided with the
595    %     distribution
596    %
597    % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
598    % "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
599    % LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
600    % A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
601    % OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
602    % SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
603    % LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
604    % DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
605    % THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
606    % (INCLUDING NEGLIGENCE OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE
607    % OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
608   
609    % Allocate handle
610    jhEditBox = handle([]);
611   
612    % Ensure that objects have been drawn
613    drawnow;
614    pause(0.01);
615   
616    % Get figure's root pane
617     try
618       figName = get(hFig,'Name');
619       mde = com.mathworks.mde.desk.MLDesktop.getInstance;
620       jFigPanel = mde.getClient(figName);
621       jRootPane = jFigPanel;
622       jRootPane = jFigPanel.getRootPane;
623     catch
624       try
625         warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');  % R2008b compatibility
626         jFrame = get(hFig,'JavaFrame');
627         jFigPanel = get(jFrame,'FigurePanelContainer');
628         jRootPane = jFigPanel;
629         jRootPane = jFigPanel.getComponent(0).getRootPane;
630       catch
631         % Never mind
632       end
633     end
634     try
635      % If invalid RootPane - try another method...
636      warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');  % R2008b compatibility
637      jFrame = get(hFig,'JavaFrame');
638      jAxisComponent = get(jFrame,'AxisComponent');
639      jRootPane = jAxisComponent.getParent.getParent.getRootPane;
640     catch
641      % Never mind
642     end
643     %jRootPane=handle(jRootPane,'callbackproperties');
644     
645     % Find java handle to Search editbox recursively
646     Dat.javaHandleFound = false;
647     jhEditBox=l_FindJavaHandle(jRootPane);
648  end
649
650% Recursion function for finding java handle for search editbox
651  function jhout=l_FindJavaHandle(jhin)
652    jhout = handle([]);
653    jhin=handle(jhin,'callbackproperties');
654   
655    if ~isempty(regexp(char(jhin.toString),'EditTextPeer\$hgTextField'))
656      jhout = jhin;
657      Dat.javaHandleFound=true;
658      return;
659    else
660      try
661        compCount = jhin.getComponentCount;
662        for ii=0:compCount-1
663          childComp = jhin.getComponent(ii);
664          if ~Dat.javaHandleFound
665            jhout=l_FindJavaHandle(childComp);
666          else
667            break;
668          end
669        end
670      catch
671        % Nothing to do here...
672      end
673    end
674   
675  end
676     
677
678end
679
680 
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008