uidesigner/com.nokia.sdt.series60.componentlibrary/components/controls/setting-items/CAknEnumeratedTextPopup.js
author Frank Turovich <frank.turovich@nokia.com>
Thu, 02 Apr 2009 15:09:04 -0500
changeset 24 f2ad263823f3
parent 2 d760517a8095
permissions -rw-r--r--
added DS_Store to hgignore list
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
cawthron
parents:
diff changeset
     1
/*
cawthron
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
cawthron
parents:
diff changeset
     3
* All rights reserved.
cawthron
parents:
diff changeset
     4
* This component and the accompanying materials are made available
cawthron
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
cawthron
parents:
diff changeset
     6
* which accompanies this distribution, and is available
cawthron
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
cawthron
parents:
diff changeset
     8
*
cawthron
parents:
diff changeset
     9
* Initial Contributors:
cawthron
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
cawthron
parents:
diff changeset
    11
*
cawthron
parents:
diff changeset
    12
* Contributors:
cawthron
parents:
diff changeset
    13
*
cawthron
parents:
diff changeset
    14
* Description: 
cawthron
parents:
diff changeset
    15
*
cawthron
parents:
diff changeset
    16
*/
cawthron
parents:
diff changeset
    17
cawthron
parents:
diff changeset
    18
cawthron
parents:
diff changeset
    19
include("../../embeddedControlImplLibrary.js")
cawthron
parents:
diff changeset
    20
include("../editors/editorLibrary.js")
cawthron
parents:
diff changeset
    21
cawthron
parents:
diff changeset
    22
function CAknEnumeratedTextPopup() {
cawthron
parents:
diff changeset
    23
}
cawthron
parents:
diff changeset
    24
cawthron
parents:
diff changeset
    25
//////////////
cawthron
parents:
diff changeset
    26
cawthron
parents:
diff changeset
    27
		// note that laf will be null if a display model was not created
cawthron
parents:
diff changeset
    28
CAknEnumeratedTextPopup.prototype.validate = function(instance, laf) {
cawthron
parents:
diff changeset
    29
	var properties = instance.properties;
cawthron
parents:
diff changeset
    30
cawthron
parents:
diff changeset
    31
	var messages = null;
cawthron
parents:
diff changeset
    32
	if (properties.items.length == 0) {
cawthron
parents:
diff changeset
    33
		messages = new java.util.ArrayList();	
cawthron
parents:
diff changeset
    34
		messages.add(createSimpleModelError(instance, 
cawthron
parents:
diff changeset
    35
			"items", 
cawthron
parents:
diff changeset
    36
			lookupString("ErrorEmptyList"), 
cawthron
parents:
diff changeset
    37
				[instance.name]));
cawthron
parents:
diff changeset
    38
	} else if (properties.active >= properties.items.length) {
cawthron
parents:
diff changeset
    39
 		messages = new java.util.ArrayList();	
cawthron
parents:
diff changeset
    40
		messages.add(createSimpleModelError(instance, 
cawthron
parents:
diff changeset
    41
			"active", 
cawthron
parents:
diff changeset
    42
			lookupString("ErrorInvalidValue"), 
cawthron
parents:
diff changeset
    43
				[instance.name, properties.active, properties.items.length]));
cawthron
parents:
diff changeset
    44
	}
cawthron
parents:
diff changeset
    45
	
cawthron
parents:
diff changeset
    46
	return messages;
cawthron
parents:
diff changeset
    47
}
cawthron
parents:
diff changeset
    48
cawthron
parents:
diff changeset
    49
	// note that laf will be null if a display model was not created
cawthron
parents:
diff changeset
    50
CAknEnumeratedTextPopup.prototype.queryPropertyChange = function(instance, propertyPath,
cawthron
parents:
diff changeset
    51
				newVal, laf) {
cawthron
parents:
diff changeset
    52
				
cawthron
parents:
diff changeset
    53
	var properties = instance.properties;
cawthron
parents:
diff changeset
    54
	var message = null;
cawthron
parents:
diff changeset
    55
cawthron
parents:
diff changeset
    56
	// Don't toss away any list changes at this point; otherwise,
cawthron
parents:
diff changeset
    57
	// the user will endure a dialog and have it all thrown away.
cawthron
parents:
diff changeset
    58
	// Better to let them go back and re-edit.
cawthron
parents:
diff changeset
    59
 
cawthron
parents:
diff changeset
    60
 	if (propertyPath == "active" 
cawthron
parents:
diff changeset
    61
 		&& properties.active >= properties.items.length) {
cawthron
parents:
diff changeset
    62
 		message = formatString(lookupString("ErrorInvalidValue"), 
cawthron
parents:
diff changeset
    63
				[instance.name, properties.active, properties.items.length]);
cawthron
parents:
diff changeset
    64
 	}
cawthron
parents:
diff changeset
    65
 	
cawthron
parents:
diff changeset
    66
	return message;		
cawthron
parents:
diff changeset
    67
}
cawthron
parents:
diff changeset
    68