Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 56d14af1cf3111c40b5ccef99f5754ed57adfc1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*******************************************************************************
 * Copyright (c) 2007 Symbian Software Limited and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Bala Torati (Symbian) - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.ui.templateengine.uitree;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;


/**
 * 
 * The GenericUIElementGroup extends UIElement, implements the default behaviour
 * expected from UIElementGroup. This gives behaviour expected for PAGES-ONLY
 * type. Any other type of UIElement groups can override the definitions given
 * to methods in this class.
 * 
 */

public class GenericUIElementGroup extends UIElement {

	/**
	 * Type of UIElement group. The possible values are PAGES_ONLY, PAGES_TAB,
	 * PAGES_TREE, PAGES_TREE_TREE, PAGES_TAB_TREE.
	 */
	public static String PAGES_ONLY = "PAGES-ONLY"; //$NON-NLS-1$
	public static String PAGES_TAB = "PAGES-TAB"; //$NON-NLS-1$
	public static String LOGTYPE = "UIElement"; //$NON-NLS-1$

	UIGroupTypeEnum type = null;


	/**
	 * child list for this UIElement
	 */
	private List/*<UIElement>*/ childList;

	/**
	 * Call UIElement constructor by passing Attributes as param.
	 * 
	 * @param attribute
	 */
	public GenericUIElementGroup(UIGroupTypeEnum type, UIAttributes/*<String, String>*/ attribute) {
		super(attribute);
		this.type = type;
		this.childList = new ArrayList/*<UIElement>*/();
	}

	/**
	 * @see UIElement
	 */
	public void setValues(Map/*<String, String>*/ valueMap) {
		int childCount = getChildCount();

		for (int i = 0; i < childCount; i++) {
			getChild(i).setValues(valueMap);
		}
	}

	/**
	 * @see UIElement
	 */
	public Map/*<String, String>*/ getValues() {

		HashMap/*<String, String>*/ valueMap = new HashMap/*<String, String>*/();
		int childCount = getChildCount();

		for (int i = 0; i < childCount; i++) {
			valueMap.putAll(getChild(i).getValues());
		}

		return valueMap;
	}

	/**
	 * @see UIElement
	 */
	public void createWidgets(UIComposite uiComposite) {
		int childCount = getChildCount();

		// call createWidgets on all the contained
		// UI wigets.
		if (uiComposite != null) {
			for (int i = 0; i < childCount; i++) {
				getChild(i).createWidgets(uiComposite);
			}
			uiComposite.setData(".uid", getAttributes().get(UIElement.ID)); //$NON-NLS-1$
		}
	}

	/**
	 * dispose the Widget, releasing any resources occupied by this widget. The
	 * same is called on the child list.
	 * 
	 * @see UIElement
	 */
	public void disposeWidget() {
		int childCount = getChildCount();

		for (int i = 0; i < childCount; i++)
			getChild(i).disposeWidget();
	}

	/**
	 * getThe child UIElement at the given index. This method throws
	 * SimpleElementException, if invoked on a InputUIElement.
	 * 
	 * @see UIElement
	 * @param index
	 * @return child uiElement
	 */
	public UIElement getChild(int index) {
		return (UIElement) childList.get(index);
	}

	/**
	 * add the given UIElement to the childList. This method throws
	 * SimpleElementException, if invoked on a InputUIElement.
	 * 
	 * @see UIElement
	 * @param aUIElement
	 */
	public void addToChildList(UIElement aUIElement) {

		childList.add(aUIElement);
	}

	/**
	 * returns the child count of UIElement. This method throws
	 * SimpleElementException, if invoked on a InputUIElement.
	 * 
	 * @see UIElement
	 * @return the child count of UIElement
	 */
	public int getChildCount() {

		return childList.size();
	}

	/**
	 * gets the type of this group. This is not used as of now. but can be used
	 * during UIPage construction.
	 */
	public UIGroupTypeEnum getType() {

		return type;
	}

	// @see UIElement
	public boolean isValid() {

		boolean retVal = true;

		int childCount = getChildCount();
		for (int i = 0; i < childCount; i++)
			if (!getChild(i).isValid()) {
				retVal = false;
				break;
			}

		return retVal;
	}

}

Back to the top