uidesigner/com.nokia.sdt.series60.componentlibrary/components/controls/setting-items/CAknEnumeratedTextPopup.js
author timkelly
Thu, 29 Jul 2010 10:44:19 -0500
branchC3_BUILDER_WORK
changeset 1719 c55d4b8f7373
parent 0 fb279309251b
permissions -rw-r--r--
fixing SBSv2QueryTests.

/*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


include("../../embeddedControlImplLibrary.js")
include("../editors/editorLibrary.js")

function CAknEnumeratedTextPopup() {
}

//////////////

		// note that laf will be null if a display model was not created
CAknEnumeratedTextPopup.prototype.validate = function(instance, laf) {
	var properties = instance.properties;

	var messages = null;
	if (properties.items.length == 0) {
		messages = new java.util.ArrayList();	
		messages.add(createSimpleModelError(instance, 
			"items", 
			lookupString("ErrorEmptyList"), 
				[instance.name]));
	} else if (properties.active >= properties.items.length) {
 		messages = new java.util.ArrayList();	
		messages.add(createSimpleModelError(instance, 
			"active", 
			lookupString("ErrorInvalidValue"), 
				[instance.name, properties.active, properties.items.length]));
	}
	
	return messages;
}

	// note that laf will be null if a display model was not created
CAknEnumeratedTextPopup.prototype.queryPropertyChange = function(instance, propertyPath,
				newVal, laf) {
				
	var properties = instance.properties;
	var message = null;

	// Don't toss away any list changes at this point; otherwise,
	// the user will endure a dialog and have it all thrown away.
	// Better to let them go back and re-edit.
 
 	if (propertyPath == "active" 
 		&& properties.active >= properties.items.length) {
 		message = formatString(lookupString("ErrorInvalidValue"), 
				[instance.name, properties.active, properties.items.length]);
 	}
 	
	return message;		
}