uidesigner/com.nokia.sdt.test.componentlibrary/components/testing/containerWithExtensions.js
author tzelaw
Tue, 14 Apr 2009 15:03:19 -0500
changeset 94 d74b720418db
parent 2 d760517a8095
permissions -rw-r--r--
Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
cawthron
parents:
diff changeset
     1
/*
cawthron
parents:
diff changeset
     2
* Copyright (c) 2009 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
function ContainerExtPropertyExtender() {
cawthron
parents:
diff changeset
    18
}
cawthron
parents:
diff changeset
    19
cawthron
parents:
diff changeset
    20
	// Return instances that may provide extension properties
cawthron
parents:
diff changeset
    21
	// The target instance parameter is the instance to receive the
cawthron
parents:
diff changeset
    22
	// additional properties
cawthron
parents:
diff changeset
    23
ContainerExtPropertyExtender.prototype.getPropertyExtenders = function(instance, targetInstance) {
cawthron
parents:
diff changeset
    24
	var result = null;
cawthron
parents:
diff changeset
    25
	if (targetInstance == instance) {
cawthron
parents:
diff changeset
    26
		result = [instance.parent];
cawthron
parents:
diff changeset
    27
	}
cawthron
parents:
diff changeset
    28
	else if (targetInstance.parent == instance) {
cawthron
parents:
diff changeset
    29
		// Add container's extension properties and those of a known child component, if present
cawthron
parents:
diff changeset
    30
		var extendingInstance = findImmediateChildByComponentID(instance.children, "com.nokia.examples.extensionChild");
cawthron
parents:
diff changeset
    31
		if (extendingInstance == null)
cawthron
parents:
diff changeset
    32
			extendingInstance = findImmediateChildByComponentID(instance.children, "com.nokia.examples.extensionChildMultiple");
cawthron
parents:
diff changeset
    33
		if (targetInstance != extendingInstance) {
cawthron
parents:
diff changeset
    34
			result = [instance];
cawthron
parents:
diff changeset
    35
			if (extendingInstance != null) {
cawthron
parents:
diff changeset
    36
				result[1] = extendingInstance;
cawthron
parents:
diff changeset
    37
			}
cawthron
parents:
diff changeset
    38
		}
cawthron
parents:
diff changeset
    39
	}
cawthron
parents:
diff changeset
    40
	return result;
cawthron
parents:
diff changeset
    41
}
cawthron
parents:
diff changeset
    42
	
cawthron
parents:
diff changeset
    43
ContainerExtPropertyExtender.prototype.getExtensionSetNames = function(thisInstance, targetInstance) {
cawthron
parents:
diff changeset
    44
	if (thisInstance.properties.controlConditionalExtensions)
cawthron
parents:
diff changeset
    45
		return [ "default", "extra"];
cawthron
parents:
diff changeset
    46
	else 
cawthron
parents:
diff changeset
    47
		return [ "default" ];
cawthron
parents:
diff changeset
    48
}
cawthron
parents:
diff changeset
    49
cawthron
parents:
diff changeset
    50
function findImmediateChildByComponentID(children, componentID) {
cawthron
parents:
diff changeset
    51
    var result = null;
cawthron
parents:
diff changeset
    52
	for (var i in children) {
cawthron
parents:
diff changeset
    53
		if (children[i].componentId == componentID) {
cawthron
parents:
diff changeset
    54
			result = children[i];
cawthron
parents:
diff changeset
    55
			break;
cawthron
parents:
diff changeset
    56
		}
cawthron
parents:
diff changeset
    57
	}
cawthron
parents:
diff changeset
    58
	return result;
cawthron
parents:
diff changeset
    59
}
cawthron
parents:
diff changeset
    60
cawthron
parents:
diff changeset
    61
ContainerExtPropertyExtender.prototype.propertyChanged = function(instance, propertyID, laf) {
cawthron
parents:
diff changeset
    62
	if (propertyID == "controlConditionalExtensions" && instance.children != null) {
cawthron
parents:
diff changeset
    63
	    var children = instance.children;
cawthron
parents:
diff changeset
    64
	    for (var i in children) {
cawthron
parents:
diff changeset
    65
	    	var child = children[i];
cawthron
parents:
diff changeset
    66
	    	child.updatePropertySource();
cawthron
parents:
diff changeset
    67
	    }
cawthron
parents:
diff changeset
    68
	}
cawthron
parents:
diff changeset
    69
}