Mercurial > hg > ltpda
diff m-toolbox/m/gui/gltpda/g_editNameCallback.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/m/gui/gltpda/g_editNameCallback.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,41 @@ +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 \ No newline at end of file