uidesigner/com.nokia.sdt.test.componentlibrary/components/testing/containerWithExtensions.js
changeset 0 fb279309251b
equal deleted inserted replaced
-1:000000000000 0:fb279309251b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 function ContainerExtPropertyExtender() {
       
    18 }
       
    19 
       
    20 	// Return instances that may provide extension properties
       
    21 	// The target instance parameter is the instance to receive the
       
    22 	// additional properties
       
    23 ContainerExtPropertyExtender.prototype.getPropertyExtenders = function(instance, targetInstance) {
       
    24 	var result = null;
       
    25 	if (targetInstance == instance) {
       
    26 		result = [instance.parent];
       
    27 	}
       
    28 	else if (targetInstance.parent == instance) {
       
    29 		// Add container's extension properties and those of a known child component, if present
       
    30 		var extendingInstance = findImmediateChildByComponentID(instance.children, "com.nokia.examples.extensionChild");
       
    31 		if (extendingInstance == null)
       
    32 			extendingInstance = findImmediateChildByComponentID(instance.children, "com.nokia.examples.extensionChildMultiple");
       
    33 		if (targetInstance != extendingInstance) {
       
    34 			result = [instance];
       
    35 			if (extendingInstance != null) {
       
    36 				result[1] = extendingInstance;
       
    37 			}
       
    38 		}
       
    39 	}
       
    40 	return result;
       
    41 }
       
    42 	
       
    43 ContainerExtPropertyExtender.prototype.getExtensionSetNames = function(thisInstance, targetInstance) {
       
    44 	if (thisInstance.properties.controlConditionalExtensions)
       
    45 		return [ "default", "extra"];
       
    46 	else 
       
    47 		return [ "default" ];
       
    48 }
       
    49 
       
    50 function findImmediateChildByComponentID(children, componentID) {
       
    51     var result = null;
       
    52 	for (var i in children) {
       
    53 		if (children[i].componentId == componentID) {
       
    54 			result = children[i];
       
    55 			break;
       
    56 		}
       
    57 	}
       
    58 	return result;
       
    59 }
       
    60 
       
    61 ContainerExtPropertyExtender.prototype.propertyChanged = function(instance, propertyID, laf) {
       
    62 	if (propertyID == "controlConditionalExtensions" && instance.children != null) {
       
    63 	    var children = instance.children;
       
    64 	    for (var i in children) {
       
    65 	    	var child = children[i];
       
    66 	    	child.updatePropertySource();
       
    67 	    }
       
    68 	}
       
    69 }