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