www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgdatasetgui/@table/pasteRequest.m
function pasteRequest(obj, SelObject) %PASTEREQUEST Execute a paste operation on the table selection % % PASTEREQUEST(OBJ, ROWSEL, COLSEL) pastes the data specified by the rows % and columns in the AsyncTableModelEvent object SELOBJECT. % Copyright 2000-2009 The MathWorks, Inc. and Ford Global Technologies, Inc. if ~isempty(obj.DatasetPointer) pDataset = obj.DatasetPointer; hDataset = pDataset.info; % The appropriate-ness of the data to be pasted should already have % been checked. The isNumeric check here is just the last hurdle prior % to performing the paste if mbcutils.Clipboard.isNumeric() % Set a watch pointer to fill the time before the table visibly updates P = xregGui.PointerRepository; ptrID = P.stackSetPointer(obj.Parent, 'watch'); new_data = mbcutils.Clipboard.paste(); row_selection = SelObject.getRowIndices+1; col_selection = SelObject.getColumnIndices+1; if length(row_selection)==1 && size(new_data, 1)>1 % Expand the row selection from the single cell selection row_selection = row_selection : (row_selection + size(new_data, 1) - 1); end if length(col_selection)==1 && size(new_data, 2)>1 % Expand the column selection from the single cell selection col_selection = col_selection : (col_selection + size(new_data, 2) - 1); end % Convert the column indices to the dataset ordering col_selection = obj.pConvertDisplayToDataset(col_selection); hDataset = setValueAt(hDataset, ... row_selection, ... col_selection, ... new_data); pDataset.info = hDataset; % Tell table to reload its data obj.refresh; P.stackRemovePointer(obj.Parent, ptrID); data = struct('Row', row_selection, ... 'Column', col_selection, ... 'NewValue', new_data); obj.send('DataChanged', xregGui.xregEventData(obj, 'DataChanged', data)); end end