www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevproject/sendObjectToDataEditor.m
function h = sendObjectToDataEditor(MP, pSSF,fProcessData,EditData) %SENDOBJECTTODATAEDITOR push a data object to the data editor % h = sendObjectToDataEditor(MP, pSSF,fProcessData,EditData) % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<3 fProcessData = @applyChanges; end if nargin<4 % Is this testplan data IS_TESTPLAN_DATA = isTestplanData(MP, pSSF); EditData = ~IS_TESTPLAN_DATA; else IS_TESTPLAN_DATA = false; end if EditData % set up a callback to process data if it is editable fCloseEditor = mbcutils.callback(@i_DataEditCheckClose, MP,fProcessData); else fCloseEditor = []; end hData = xregdatagui.Editor.open(pSSF,EditData,IS_TESTPLAN_DATA,fCloseEditor); if ~isempty(hData) % Register as a subfigure of the browser h = MBrowser; h.RegisterSubFigure(hData.Figure); end function i_DataEditCheckClose(hData, evt, MP,fProcessData) %i_DataEditClose close data editor and process data % Make sure that MP is up-to-date MP = info(MP); % Which data pointer is being edited pSSF = hData.UserData.ObjectBeingEdited; % Is the pointer location to copy back to still valid? if isvalid(pSSF) % Get the old and new data oldData = pSSF.info; newData = hData.NewData; newData = setCacheState(newData, false); % Did the old data have anything in it? if isempty(oldData) OK = 'yes'; else dispStr = 'Accept changes to data?'; % Should we ask the user to confirm changes if isequal(oldData, newData) OK = 'yes'; else OK = questdlg(dispStr, 'Data Changed', 'Yes', 'No', 'Cancel', 'No'); end end switch lower(OK) case 'yes' fProcessData(MP,pSSF,newData); case 'no' % No updating required case {'cancel', ''} % Signal to the Application that it should not close evt.CancelClose = true; end end function applyChanges(MP,pSSF,newData) %applyChanges default method to apply data changes modifyData(MP, pSSF, newData); % Update the view mbh = MBrowser; if mbh.CurrentNode == address(MP) ViewNode(mbh); % select edited data set View = GetViewData(MBrowser); dp = dataptrs(MP); selectCell(View.dataList, find(pSSF==dp),1); end