/**************************************************************************
*
*  @@@BUILDINFO@@@ 97debugPrefs-2.jsx 2.0.0.54  08-Feb-2007
*  Copyright 2006-2007 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains the property of
* Adobe Systems Incorporated  and its suppliers,  if any.  The intellectual 
* and technical concepts contained herein are proprietary to  Adobe Systems 
* Incorporated  and its suppliers  and may be  covered by U.S.  and Foreign 
* Patents,patents in process,and are protected by trade secret or copyright 
* law.  Dissemination of this  information or reproduction of this material
* is strictly  forbidden  unless prior written permission is  obtained from 
* Adobe Systems Incorporated.
**************************************************************************/

// Each Prefs object needs five methods:
// prefsObject.create (parentPane)  - create the pane and return the Pane object.
// prefsObject.preProcess()         - preprocess the pane just before being shown.
// prefsObject.postProcess()        - do any work just before the pane is being hidden.
// prefsObject.store()              - store the preferences. Return true if the Next Time dialog is needed.
// prefsObject.toDefault()          - set back to default values

var debugPrefs = {};

debugPrefs.create = function (parentPane)
{
	this.pane = parentPane.add (
	"group {													                                                                                        \
		orientation		: 'column',								                                                                                        \
		alignChildren	: 'fill',								                                                                                        \
		visible			: false,								                                                                                        \
		alignment		: 'fill',								                                                                                        \
		dataBrowser		: Panel {								                                                                                        \
			text			: '$$$/ESToolkit/Panes/Variables/Title=Display in Data Browser',                                                            \
			alignChildren	: 'fill',							                                                                                        \
			alignment		: 'fill',							                                                                                        \
			showUndefined	:	Checkbox {						                                                                                        \
				text			: '$$$/ESToolkit/PreferencesDlg/Debugger/ShowUndefined=&Undefined Variables',                                           \
				helpTip			: '$$$/ESToolkit/PreferencesDlg/Debugger/htShowUndefined=Display variables that are present, but do not have a value.'  \
			},													                                                                                        \
			showFunctions	:	Checkbox {						                                                                                        \
				text			: '$$$/ESToolkit/PreferencesDlg/Debugger/ShowFunctions=&Functions',	                                                    \
				helpTip			: '$$$/ESToolkit/PreferencesDlg/Debugger/htShowFunctions=Display JavaScript functions.'                                 \
			},													                                                                                        \
			showCore		:	Checkbox {						                                                                                        \
				text			: '$$$/ESToolkit/PreferencesDlg/Debugger/ShowCore=&Core JavaScript Elements',	                                        \
				helpTip			: '$$$/ESToolkit/PreferencesDlg/Debugger/htShowCore=Display elements that are part of the JavaScript language.'         \
			},													                                                                                        \
			showPrototype	:	Checkbox {						                                                                                        \
				text			: '$$$/ESToolkit/PreferencesDlg/Debugger/ShowPrototype=All &Prototype Elements',	                                    \
				helpTip			: '$$$/ESToolkit/PreferencesDlg/Debugger/htShowPrototype=Display elements that are defined along the prototype chain.'  \
			},													                                                                                        \
			fields			: Group {							                                                                                        \
			orientation		: 'column',							                                                                                        \
				alignment		: 'fill',						                                                                                        \
				maxElements			: Group {					                                                                                        \
					orientation		: 'row',					                                                                                        \
					alignment		: 'fill',					                                                                                        \
					alignChildren	: ['left','center'],		                                                                                        \
					lbl				: StaticText {				                                                                                        \
						text			: '$$$/ESToolkit/PreferencesDlg/Debugger/MaxElements1=&Display Up To:'                                          \
					},		                                                                                                                            \
					edit			: EditText {				                                                                                        \
						preferredSize	: [40, 20],				                                                                                        \
						helpTip			: '$$$/ESToolkit/PreferencesDlg/Debugger/htMaxElements=Enter the maximum number of array elements to display',  \
					},											                                                                                        \
					lbl2			: StaticText {				                                                                                        \
						text			: '$$$/ESToolkit/PreferencesDlg/Debugger/MaxElements2=Array Elements'                                           \
					},		                                                                                                                            \
				},												                                                                                        \
			}													                                                                                        \
		}														                                                                                        \
	}");
	this.pane.showUndefined = this.pane.dataBrowser.showUndefined;
	this.pane.showCore		= this.pane.dataBrowser.showCore;
	this.pane.showFunctions	= this.pane.dataBrowser.showFunctions;
	this.pane.showPrototype	= this.pane.dataBrowser.showPrototype;
	this.pane.maxElementsEdit = this.pane.dataBrowser.fields.maxElements.edit;
	this.loaded = false;
	this.pane.prefsObj = this;
	this.pane.preProcess = function()
	{
		if (!this.prefsObj.loaded)
			this.prefsObj.load();
	}
	this.pane.postProcess = function()
	{}

	this.pane.toDefault = function()
	{
		this.showUndefined.value    = PrefUtils.getDefaultValue( 'prefs.databrowser.showUndefined',     'Boolean' );
		this.showFunctions.value    = PrefUtils.getDefaultValue( 'prefs.databrowser.showFunctions',     'Boolean' );
		this.showCore.value	        = PrefUtils.getDefaultValue( 'prefs.databrowser.showCore',	        'Boolean' );
		this.showPrototype.value    = PrefUtils.getDefaultValue( 'prefs.databrowser.showPrototype',	    'Boolean' );
		this.maxElementsEdit.text   = PrefUtils.getDefaultValue( 'prefs.databrowser.maxArrayElements',  'Number' );
	}

	return this.pane;
}

debugPrefs.load = function()
{
 	if (this.loaded)
		return;
	this.loaded = true;

	with (this.pane) 
	{
		showUndefined.value  = PrefUtils.getValue( 'prefs.databrowser.showUndefined',    'Boolean' );
		showFunctions.value  = PrefUtils.getValue( 'prefs.databrowser.showFunctions',    'Boolean' );
		showCore.value	     = PrefUtils.getValue( 'prefs.databrowser.showCore',	     'Boolean' );
		showPrototype.value	 = PrefUtils.getValue( 'prefs.databrowser.showPrototype',	 'Boolean' );
		maxElementsEdit.text = PrefUtils.getValue( 'prefs.databrowser.maxArrayElements', 'Number' );
	}
}

debugPrefs.store = function()
{
	if (!this.loaded)
		return false;
	with (this.pane) 
	{
		var n = Number (maxElementsEdit.text);
		if (n < 0)
			n > 0;
		prefs.databrowser.showUndefined		= (showUndefined.value == 1);
		prefs.databrowser.showFunctions		= (showFunctions.value == 1);
		prefs.databrowser.showCore			= (showCore.value == 1);	
		prefs.databrowser.showPrototype		= (showPrototype.value == 1);	
		prefs.databrowser.maxArrayElements	= n;
	}
	globalBroadcaster.notifyClients( 'newDebugPrefs' );
	return false;
}
