view m-toolbox/m/gui/gltpda/g_functionNameSet.m @ 39:11e3ed9d2115 database-connection-manager

Implement databases listing in database connection dialog
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

function g_functionNameSet(hObject, varargin)
   % Setting the name of the function in the 'generic' block.
   
   functionName2 = get(hObject,'String');
   classes = utils.helper.ltpda_userclasses;
   for i=1:numel(classes)
      if ismethod(eval(classes{i}),functionName2)
         currSel = utils.prog.gcbsh;
         for j=1:numel(currSel), set(currSel(j),'Tag',['method ',classes{i}]); end
         break
      else
         currSel = utils.prog.gcbsh;
         for j=1:numel(currSel), set(currSel(j),'Tag','function'); end
      end
   end
   paramcommand = g_RetrievePlist(functionName2);
   
   if ~isempty(paramcommand)
      functionName = functionName2;
      paramcommand = strcat(paramcommand,'functionName=''',functionName2,''';');
      for i=1:1000
         try
            for kk=1:length(selBlocks), set_param(selBlocks(kk),'Name',functionName2); end
            break;
         catch
            functionName2 = strcat(functionName,'_',num2str(i));
         end
      end
      for kk=1:length(selBlocks), set_param(selBlocks(kk),'Description',paramcommand); end
      delete(findobj(gcf,'Parent',currPanel))
      buildplistFigureParam([],[],get(findobj('Tag','paramsPage'),'UserData'))
      
   else % the functionName inserted it's not valid
      description = get_param(gcbh,'Description');
      funcname = findstr('functionName=',description);
      if funcname
         i = funcname+14;
         while ~strcmp(description(i),';'), i=i+1; end
         functionName = description(funcname+14:i-2);
      end
      set(hObject,'String',functionName);
   end
   
   ltpdagui('Redraw',2)
   
end