/**************************************************************************
*
*  @@@BUILDINFO@@@ 94helpPrefs-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 helpPrefs = {};

helpPrefs.create = function (parentPane)
{
	this.pane = parentPane.add (
	"group {											\
		orientation:'column', alignChildren:'left', visible:false, alignment: ['left','top'], \
		dynamicHelp:	Checkbox {												\
			text:'$$$/ESToolkit/PreferencesDlg/dynamichelp=&Display JavaScript Variables',\
			helpTip:'$$$/ESToolkit/PreferencesDlg/hiDynamichelp=Show types and values of variables when you hover the cursor over them.' }, \
		autoComplete:		Checkbox {												\
			text:'$$$/ESToolkit/PreferencesDlg/autocomplete=&Enable Auto Completion',	\
			helpTip:'$$$/ESToolkit/PreferencesDlg/htAutocompletion=Display list box with code hints based of the Object Model dictionary of selected target application.' }	\
		fields			: Group {						\
			orientation		: 'column',					\
				alignment		: 'fill',					\
				alignChildren	: 'left',					\
				auto			: Group {					\
					orientation		: 'row',				\
					alignChildren	: ['right','center'],	\
					lbl				: StaticText {			\
						text			: '$$$/ESToolkit/PreferencesDlg/AutoComplete=&Auto-Completion Delay:' \
					},										\
				edit			: EditText {		\
					preferredSize	: [100, 20],		\
					helpTip			: '$$$/ESToolkit/PreferencesDlg/htAutoComplete=Delay for the auto-completion list box to appear.', \
				},										\
				lbl2			: StaticText {			\
					text			: '$$$/ESToolkit/PreferencesDlg/Seconds=Seconds' \
				},										\
			},											\
		}												\
	}");
	this.pane.autoEdit	 = this.pane.fields.auto.edit;

	this.pane.autoEdit.preferredSize.width = 50;

	this.pane.autoComplete.autoGrp = this.pane.fields.auto;
	this.pane.autoComplete.onClick = function()
	{
		this.autoGrp.lbl.enabled	=
		this.autoGrp.lbl2.enabled	=
		this.autoGrp.edit.enabled	= (this.value != 0);
	}

	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.dynamicHelp.value  = PrefUtils.getDefaultValue( 'prefs.dynamicHelp',     'Boolean' );
		this.autoComplete.value = PrefUtils.getDefaultValue( 'prefs.autocompletion', 'Boolean' );
		var i = PrefUtils.getDefaultValue( 'prefs.autotime', 'Number' );
		this.autoEdit.text = i;
		// Set the enabled state of the autocomplete time field
		this.autoComplete.onClick();
	}

	return this.pane;
}

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

	with (this.pane) {
		//	Load the current help preferences
		dynamicHelp.value = prefs.dynamicHelp.valueOf();
		autoComplete.value = PrefUtils.getValue( 'prefs.autocompletion', 'Boolean' );
		var i = PrefUtils.getValue( 'prefs.autotime', 'Number' );
		autoEdit.text = i;
		// Set the enabled state of the autocomplete time field
		autoComplete.onClick();
	}
}

helpPrefs.store = function()
{
	if (!this.loaded)
		return false;
	with (this.pane) 
	{
		prefs.dynamicHelp = dynamicHelp.value == 1;

		var n = Number (autoEdit.text);
		var autoChanged =  (autoComplete.value != PrefUtils.getValue( 'prefs.autocompletion', 'Boolean' ))
						|| (n > 0 && n != PrefUtils.getValue( 'prefs.autotime', 'Number' ));
		prefs.autocompletion = autoComplete.value;
		if (n > 0)
			prefs.autotime = n;
		if (autoChanged)
			globalBroadcaster.notifyClients ('autoCompletionPrefsChanged');
	}
	return false;
}
