www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/+xregdatagui/SweepNoteListView.m
classdef SweepNoteListView < xregdatagui.AbstractListView %xregdatagui.SweepNoteListView class % xregdatagui.SweepNoteListView extends xregdatagui.AbstractListView. % % xregdatagui.SweepNoteListView properties: % Parent - Property is of type 'MATLAB array' % Position - Property is of type 'rect' % Enable - Property is of type 'on/off' % Visible - Property is of type 'on/off' % Userdata - Property is of type 'MATLAB array' % Tag - Property is of type 'string' % MessageService - Property is of type 'handle' (read only) % Container - Property is of type 'handle' % UIContextMenu - Property is of type 'MATLAB array' % Listeners - Property is of type 'handle vector' (read only) % ListHandle - Property is of type 'MATLAB array' (read only) % COMListeners - Property is of type 'handle vector' (read only) % ContainerListeners - Property is of type 'handle vector' (read only) % Strings - Property is of type 'MATLAB array' % Widths - Property is of type 'MATLAB array' % % xregdatagui.SweepNoteListView methods: % gettitle - A short description of the function % pUpdateDisplay - complete update of the view display % pssfSweepNotesChangedUpdate - respond to a change in the sweep notes % Copyright 2015 The MathWorks, Inc. and Ford Global Technologies, Inc. methods % constructor block function obj = SweepNoteListView(varargin) %SWEEPNOTELISTVIEW constructor % OUT = SWEEPNOTELISTVIEW(VARARGIN) % Create one of these objects! % obj = xregdatagui.sweepnotelistview; % What are the column names and widths columnNames = {'Note Expression' 'Test Note' 'Results'}; columnWidths = [250 250 350]; % Do the setup stuff from inside the abstractDataView constructor obj@xregdatagui.AbstractListView(varargin{ : },... 'Type','sweepNotes',... 'Strings',columnNames,... 'Widths',columnWidths); % converted super class constructor call set(obj.ListHandle,'EditableColumns',[1 2]); end % sweepnotelistview end % constructor block methods (Hidden) % possibly private or hidden %---------------------------------------- function pPostSetDataMessageService(obj, ~,~) %PPOSTSETDATAMESSAGESERVICE setup MessageService listeners % PPOSTSETDATAMESSAGESERVICE(OBJ, SRC, EVT) % Call the super pPostSetDataMessageService pPostSetDataMessageService@xregdatagui.AbstractListView(obj); dms = obj.MessageService; dmsListeners = [... event.listener(dms, 'dmsDataTypeChanged', @obj.pdmsDataTypeChangedUpdate);... event.listener(dms, 'ssfSweepNotesChanged', @obj.updateListview),... ]; obj.Listeners = [obj.Listeners; dmsListeners]; end % pPostSetDataMessageService function removeExpression(obj,index) %removeExpression remove expression implementation ssf = obj.MessageService.SweepsetFilter; % Remove them ssf = removeSweepNote(ssf, index); % Flush the event queue obj.MessageService.flushEventQueue(ssf); end function modifyExpression(obj,index,noteExp,noteString,noteColor) %modifyExpression modify expression implementation ssf = obj.MessageService.SweepsetFilter; ssf = modifySweepNote(ssf, index, noteExp,noteString,noteColor); obj.MessageService.flushEventQueue(ssf); end function [Data,OK] = getDisplayData(obj) %getDisplayData display data and status for listview ssf = obj.MessageService.SweepsetFilter; expr = get(ssf, obj.Type); Data = {expr.noteExp expr.noteString expr.result}'; OK = [expr.OK]'; end function onEditListview(obj,~, evt) %onEditListview edit expression from listview % is overloading for sweepnotes % Get the currently selected item index = evt.data.Rows; rowData = obj.ListHandle.Data(index,:); switch evt.data.Columns case 1 noteExp = evt.data.NewValue; noteString = rowData{2}; case 2 noteExp = rowData{1}; noteString = evt.data.NewValue; end if ~isempty(evt.data.NewValue) ssf = obj.MessageService.SweepsetFilter; notes = get(ssf, obj.Type); noteColor = notes(index).noteColor; modifyExpression(obj, index, noteExp,noteString,noteColor); end end % onEditListview %---------------------------------------- function updateListview(obj, ~,~) %updateListview respond to a change in the sweep notes % % updateListview(OBJ, SRC EVENT) % updateListview@xregdatagui.AbstractListView(obj) ssf = obj.MessageService.SweepsetFilter; notes = get(ssf, 'sweepnotes'); Colors = zeros(length(notes),3); for i = 1:length(notes) Colors(i,:)= round(notes(i).noteColor*255); end obj.ListHandle.Peer.setRowColors(Colors(:,1),Colors(:,2),Colors(:,3)) % disable add and edit for one-stage data s = size(obj.MessageService.SweepsetFilter); set(obj.Options.Actions(1:2),'Enabled',~obj.MessageService.isOneStage || (s(1)==0 && s(2)>0)); end % updateListview end % possibly private or hidden end % classdef