function this = OptionsDialog(SimOptionForm, OptimOptionForm, parent, model, varargin)
% OPTIONSDIALOG 

% Author(s): Bora Eryilmaz
% Revised: 
% Copyright 1986-2004 The MathWorks, Inc.
% $Revision: 1.1.6.3 $ $Date: 2004/11/18 23:44:23 $

% Create class instance
this = slcontrol.OptionsDialog;

% Store model and option objects
this.Model           = model;
this.SimOptionForm   = SimOptionForm;
this.OptimOptionForm = OptimOptionForm;

% Create the options dialog
switch class(OptimOptionForm)
case 'srogui.OptimOptionForm'
  type = 'SRO';
case 'speforms.OptimOptionForm'
  type = 'SPE';
end

% If the parent is a Figure, 
if isjava(parent)
  this.Dialog = com.mathworks.toolbox.control.settings.OptionsDialog(parent, type);
else
  this.Dialog = com.mathworks.toolbox.control.settings.OptionsDialog([], type);
  centerfig(this.Dialog, parent)
end

% Configure callbacks & listeners
configurePanels(this);
configureButtons(this);

% Update the GUI content with the new data
setViewData(this);

% Listeners
L(1) = handle.listener(this, 'ObjectBeingDestroyed', @(x,y) LocalDestroy(this));
if ~isempty(varargin)
  L(2) = handle.listener(varargin{1}, 'ObjectBeingDestroyed', ...
                         @(x,y) LocalDelete(this) );
end
this.Listeners = [ this.Listeners; L(:) ];

% --------------------------------------------------------------------------
function LocalDestroy(this)
% Delete dialog
dispose(this.Dialog)

% --------------------------------------------------------------------------
function LocalDelete(this)
% Delete dialog
delete(this);
