function addconstr(Editor, Constr)
%ADDCONSTR  Add constraint to editor.

%   Author(s): P. Gahinet
%   Copyright 1986-2002 The MathWorks, Inc. 
%   $Revision: 1.6.4.1.2.1 $  $Date: 2005/01/08 23:41:13 $

% REVISIT: should call grapheditor::addconstr to perform generic init
Axes = Editor.Axes;

% Generic init (includes generic interface editor/constraint)
initconstr(Editor,Constr)

% Add related listeners 
L = handle.listener(Axes,Axes.findprop('XUnits'),...
   'PropertyPostSet', {@LocalSetUnits,Constr});
Constr.addlisteners(L);

% Activate (initializes graphics and targets constr. editor)
Constr.Activated = 1;

% Update limits
updateview(Editor)

% --------------------------- Local Functions ----------------------------------%

function LocalSetUnits(eventSrc,eventData,Constr)
% Syncs constraint props with related Editor props
Constr.setDisplayUnits(eventSrc.Name,eventData.NewValue)
% Update constraint display (and notify observers)
update(Constr)

