function c=attribute(c,action,varargin)
%ATTRIBUTE launches the setup file editor options page

%   Copyright (c) 1997-2000 by The MathWorks, Inc.
%   $Revision: 1.12 $  $Date: 2000/03/23 19:35:32 $

c=feval(action,c,varargin{:});

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=start(c)

%since we are using this component from the GUI,
%assume we're taking the cell table from the workspace
%c.att.isArrayFromWorkspace=logical(1);


c=controlsmake(c,{'repMinChildren', 'addAnchor'});

filterList = rgsf( 'get_filter_list' );
filterIndex=find(strcmp(filterList,c.att.typeString));
if isempty(filterIndex)
	filterIndex=1;
else
	filterIndex=filterIndex(1);
end

for i=length(filterList):-1:1
   c.x.typeString(i)=uicontrol(c.x.all,...
      'style','radiobutton',...
      'HorizontalAlignment','left',...
      'UserData',filterList{i},...
      'String',filterList{i},...
      'value',0,...
      'Callback',[c.x.getobj '''Update'',''typeString'',' num2str(i) ');']);
end

set(c.x.typeString(filterIndex),'Value',1);

c.x.typeStringTitle=uicontrol(c.x.all,...
	'style','text',...
	'HorizontalAlignment','right',...
   'String','Object type  ');


c.x.LayoutManager={[5]
	{c.x.typeStringTitle num2cell(c.x.typeString')}
	[15]
	{c.x.repMinChildrenTitle ''}
   c.x.repMinChildren
   [10]
   c.x.addAnchor
	};

LocHandleValidity(c);

c=resize(c);
refresh(c);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=resize(c)

c=controlsresize(c);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=Update(c,whichControl,varargin);

c=controlsupdate(c,whichControl,varargin{:});

LocHandleValidity(c);

rptcp(c);

% ask to update my csf_snapshot and SF name children outlinestrings
myHandle=c.ref.ID;
if isa(myHandle,'rptcp')
   objList=findall(myHandle.h,...
      'type','uimenu',...
      'tag','csf_snapshot');
   
   if ~isempty(objList)
      outlinestring(rptcp(objList),2);
   end
   
   objList=findall(myHandle.h,...
      'type','uimenu',...
      'tag','csfobjname');
   
   if ~isempty(objList)
      outlinestring(rptcp(objList),2);
   end
end
refresh(c);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function LocHandleValidity(c)

childrenSelObjs = [c.x.repMinChildrenTitle, c.x.repMinChildren ];
set(childrenSelObjs,...
	'Enable',LocOnOff(rgsf('can_have_children',c.att.typeString)));


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=refresh(c)

typeStr = c.att.typeString;
typeStr(1) = upper( typeStr(1) );
titleString=[typeStr char(32) 'Report'];

[validity, errMsg] = rgsf( 'is_parent_valid', c );
if ~validity
   titleString=sprintf('%s (invalid parent)',xlate(titleString));
   errString=sprintf('Error: this component %s', xlate(errMsg));
   errType=1;
else
   errString='';
   errType=0;
end

statbar(c,errString,errType);
set(c.x.title,'String',titleString);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function strOnOff=LocOnOff(logOnOff)

if logOnOff
   strOnOff='on';
else
   strOnOff='off';
end
