view m-toolbox/m/gui/gltpda/g_editNameCallback.m @ 27:29276498ebdb database-connection-manager

Remove LTPDARepositoryManager implementation * * * Remove GUI helper
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_editNameCallback(hObject, varargin)
   
   global params
   
   if strcmp(get(gcbh,'Tag'),'arithmetic')
      currParamIndex = get(hObject,'UserData');
      newName  = get(hObject,'String');
      oldName  = params.params(currParamIndex).key;
      params.params(currParamIndex).setKey(newName);
      paramcommand = BuildParamCommand(params);
      for kk=1:length(selBlocks)
         set_param(selBlocks(kk),'Description',paramcommand);
      end
      block2change = find_system(gcb,'SearchDepth',1,'LookUnderMasks','all','Name',lower(oldName));
      while ~isempty(find_system(gcb,'SearchDepth',1,'LookUnderMasks','all','Name',lower(newName))),  newName = [newName,'x']; end
      set_param(block2change{1},'Name',lower(newName))
      UpdateInports(lower(newName),2);
      return;
   end
   
   currParamIndex = get(hObject,'UserData');
   newName  = get(hObject,'String');
   oldName  = params.params(currParamIndex).key;
   addedPar = 0;
   try if strcmpi(oldName(1:7),'addPar_'), addedPar = 1; oldName(1:7)=[]; end; catch, end
   
   if strcmp(params.params(currParamIndex).val,'-->')
      block2change = find_system(gcb,'SearchDepth',1,'LookUnderMasks','all','Name',lower(oldName));
      while ~isempty(find_system(gcb,'SearchDepth',1,'LookUnderMasks','all','Name',lower(newName))),  newName = [newName,'x']; end
      set_param(block2change{1},'Name',lower(newName))
   end
   
   if addedPar, newName = ['addPar_',newName]; end
   setKey(params.params(currParamIndex),newName);
   % To change the drawing command:
   if strcmp(params.params(currParamIndex).val,'-->'), UpdateInports(lower(newName),2); end
   
   set(findobj('Tag','apply'),'Enable','on');
   set(findobj('Tag','undo'),'Enable','on');
   
end