uidesigner/com.nokia.carbide.cpp.uiq.components/components/layoutDataLibrary.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) 2008 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("containerLibrary.js")
cawthron
parents:
diff changeset
    20
cawthron
parents:
diff changeset
    21
/**
cawthron
parents:
diff changeset
    22
 *	Get the layout data.
cawthron
parents:
diff changeset
    23
 *
cawthron
parents:
diff changeset
    24
 *  If Layout Data is different than "Inherit", then the layout data is returned,
cawthron
parents:
diff changeset
    25
 *	if not, iterate over all parent relationship.
cawthron
parents:
diff changeset
    26
 *
cawthron
parents:
diff changeset
    27
 *	@param instance the instance where look in the layout data.
cawthron
parents:
diff changeset
    28
 *	@param propertyPath the name of the property to analize.
cawthron
parents:
diff changeset
    29
 *	@param propertyDefaultValue the default value of propertyPath which will 
cawthron
parents:
diff changeset
    30
 *	determine if the parent layout data should be reviewed or not.
cawthron
parents:
diff changeset
    31
 *	@return the layout data.
cawthron
parents:
diff changeset
    32
 */
cawthron
parents:
diff changeset
    33
function getLayoutData ( instance, propertyPath, propertyDefaultValue ) {
cawthron
parents:
diff changeset
    34
cawthron
parents:
diff changeset
    35
	var container = "com.nokia.carbide.uiq.CQikContainer";
cawthron
parents:
diff changeset
    36
	var sbb = "com.nokia.carbide.uiq.SystemBuildingBlock";
cawthron
parents:
diff changeset
    37
	var slot = "com.nokia.carbide.uiq.ItemSlot";
cawthron
parents:
diff changeset
    38
	var viewPage = "com.nokia.carbide.uiq.ViewPage";
cawthron
parents:
diff changeset
    39
	var containersGroup = "com.nokia.carbide.uiq.ContainersGroup";
cawthron
parents:
diff changeset
    40
cawthron
parents:
diff changeset
    41
	var parentInstance = instance.parent;
cawthron
parents:
diff changeset
    42
	var parentID = instance.parent.component.id;
cawthron
parents:
diff changeset
    43
	var properties = instance.properties;
cawthron
parents:
diff changeset
    44
	var layoutManagerInstance = null; 
cawthron
parents:
diff changeset
    45
	var layoutData = null;
cawthron
parents:
diff changeset
    46
cawthron
parents:
diff changeset
    47
	while ((parentInstance != null) && (parentID != viewPage) && (parentID != containersGroup)) {
cawthron
parents:
diff changeset
    48
		if (parentID == container) {
cawthron
parents:
diff changeset
    49
			//println("**************** parent: container");
cawthron
parents:
diff changeset
    50
			layoutManagerInstance = findImmediateChildByAttributeValue( parentInstance.children, "is-layout-manager", "true");
cawthron
parents:
diff changeset
    51
			if ( layoutManagerInstance == null ) {
cawthron
parents:
diff changeset
    52
				return propertyDefaultValue;
cawthron
parents:
diff changeset
    53
			}
cawthron
parents:
diff changeset
    54
			layoutData = instance.properties.layoutData[propertyPath];
cawthron
parents:
diff changeset
    55
			if ( layoutData != propertyDefaultValue ) {
cawthron
parents:
diff changeset
    56
				return layoutData
cawthron
parents:
diff changeset
    57
			}
cawthron
parents:
diff changeset
    58
			return getLayoutData ( parentInstance, propertyPath, propertyDefaultValue );
cawthron
parents:
diff changeset
    59
		}
cawthron
parents:
diff changeset
    60
		if (parentID == slot) {
cawthron
parents:
diff changeset
    61
			//println("**************** parent: slot");
cawthron
parents:
diff changeset
    62
			return getLayoutData ( parentInstance, propertyPath, propertyDefaultValue );
cawthron
parents:
diff changeset
    63
		}
cawthron
parents:
diff changeset
    64
		if (parentID == sbb) {
cawthron
parents:
diff changeset
    65
			//println("**************** parent: SBB");
cawthron
parents:
diff changeset
    66
			layoutManagerInstance = findImmediateChildByAttributeValue( parentInstance.parent.children, "is-layout-manager", "true");
cawthron
parents:
diff changeset
    67
			if ( layoutManagerInstance == null ) {
cawthron
parents:
diff changeset
    68
				return propertyDefaultValue;
cawthron
parents:
diff changeset
    69
			}
cawthron
parents:
diff changeset
    70
			layoutData = parentInstance.properties.layoutData[propertyPath];
cawthron
parents:
diff changeset
    71
			if ( layoutData != propertyDefaultValue ) {
cawthron
parents:
diff changeset
    72
				return layoutData
cawthron
parents:
diff changeset
    73
			}
cawthron
parents:
diff changeset
    74
			return getLayoutData ( parentInstance, propertyPath, propertyDefaultValue );
cawthron
parents:
diff changeset
    75
		}
cawthron
parents:
diff changeset
    76
		return propertyDefaultValue;
cawthron
parents:
diff changeset
    77
	}
cawthron
parents:
diff changeset
    78
cawthron
parents:
diff changeset
    79
	return getLayoutManagerLayoutData( instance.children, propertyPath, propertyDefaultValue );
cawthron
parents:
diff changeset
    80
}
cawthron
parents:
diff changeset
    81
cawthron
parents:
diff changeset
    82
cawthron
parents:
diff changeset
    83
/**
cawthron
parents:
diff changeset
    84
 *	Get the layout data of LayoutManager.
cawthron
parents:
diff changeset
    85
 *
cawthron
parents:
diff changeset
    86
 *  If Layout Manager is null, then the default value of the property will be
cawthron
parents:
diff changeset
    87
 *	returned.
cawthron
parents:
diff changeset
    88
 *
cawthron
parents:
diff changeset
    89
 *	@param children the children where look in the layout data.
cawthron
parents:
diff changeset
    90
 *	@param propertyPath the name of the property to analize.
cawthron
parents:
diff changeset
    91
 *	@param propertyDefaultValue the default value of propertyPath.
cawthron
parents:
diff changeset
    92
 *	@return the layout data of LayoutManager or propertyDefaultValue if 
cawthron
parents:
diff changeset
    93
 *	LayoutManager is null .
cawthron
parents:
diff changeset
    94
 */
cawthron
parents:
diff changeset
    95
function getLayoutManagerLayoutData( children, propertyPath, propertyDefaultValue ) {
cawthron
parents:
diff changeset
    96
	var layoutManager = findImmediateChildByAttributeValue( children, "is-layout-manager", "true");
cawthron
parents:
diff changeset
    97
	if (layoutManager != null) {
cawthron
parents:
diff changeset
    98
		//println("**************** sister: layout Manager");
cawthron
parents:
diff changeset
    99
		return layoutManager.properties.defaultLayoutData[propertyPath];
cawthron
parents:
diff changeset
   100
	}
cawthron
parents:
diff changeset
   101
	return propertyDefaultValue;
cawthron
parents:
diff changeset
   102
}