function h = respedit
%RESPEDIT  Constructor for the Response Property Editor

%   Author(s): A. DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.5 $  $Date: 2000/08/02 16:05:46 $

pkg = findpackage('cstprefs');

if nargout==0
   %---Register class
    c = schema.class(pkg,'respedit');
   %---Define properties
    schema.prop(c,'Target',          'handle');  %---Handle to the target response object
    schema.prop(c,'Data',            'handle');  %---Handle to the data object storing property values
    schema.prop(c,'Java',            'mxArray'); %---Structure to store java objects
    schema.prop(c,'GUI',             'mxArray'); %---Java handle to the GUI used to edit Data
    schema.prop(c,'Line',            'mxArray'); %---Handle to line showing plot selection
    schema.prop(c,'enable_readprops','mxArray'); %---Switch to enable/disable readprops
   %---Listeners
    schema.prop(c,'LastChangeListener',             'handle'); %---Property change (triggers apply)
    schema.prop(c,'TargetPreSetListener',           'handle'); %---Target PreSet
    schema.prop(c,'TargetPostSetListener',          'handle'); %---Target PostSet
    schema.prop(c,'TargetUserDataListener',         'handle'); %---Target UserData change (RespObj update)
    schema.prop(c,'TargetDestroyedListener',        'handle'); %---Target destroyed (clf will do this)
    schema.prop(c,'BackgroundAxesDestroyedListener','handle'); %---BackgroundAxes destroyed (cla will do this)
else
    %---Watch on
    fig = watchon;
    %---Create class instance
    h = cstprefs.respedit;
    %---Initialize
    h.Target = [];
    h.Data = cstprefs.respprop;
    s = h.create;
    h.Java = s;
    h.GUI = s.Frame;
    h.Line = [];
    h.enable_readprops = 1;
    %---Install listeners for the Target property
    respeditC = pkg.findclass('respedit');
    PointOfAttachment = h;
    EventSrc = respeditC.findprop('Target');
    %---PreSet
    EventType = 'PropertyPreSet';
    Callback = {@localTPreSet,h};
    h.TargetPreSetListener = handle.listener(PointOfAttachment,EventSrc,EventType,Callback);
    %---PostSet
    EventType = 'PropertyPostSet';
    Callback = {@localTPostSet,h};
    h.TargetPostSetListener = handle.listener(PointOfAttachment,EventSrc,EventType,Callback);
    %---Install a listener for the LastChange property
    dataC = pkg.findclass('respprop');
    PointOfAttachment = h.Data;
    EventSrc = dataC.findprop('LastChange');
    EventType = 'PropertyPostSet';
    Callback = {@localApply,h};
    h.LastChangeListener = handle.listener(PointOfAttachment,EventSrc,EventType,Callback);
    % Turn off watch
    watchoff(fig);
    
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pass these callbacks to class methods %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function localTPreSet(eventSrc,eventData,h)
h.tpreset;

function localTPostSet(eventSrc,eventData,h)
h.tpostset;

function localApply(eventSrc,eventData,h)
h.apply;
