1
/*******************************************************************************
2
* Copyright (c) 2007, 2008 Symbian Software Limited and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Bala Torati (Symbian) - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
14
import java.util.Vector;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.layout.GridLayout;
19
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
22
import org.eclipse.cdt.ui.templateengine.event.PatternEventListener;
23
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
27
* By extending Composite we can create our own Container. UIComposite can act
28
* as the bridge between the UIPage and the UIWidgets contained in that page.
29
* The PatternEvents generated by the UIWidgets will be fired to the UIPage
30
* which is a PatternEventListener.
33
public class UIComposite extends Composite {
36
* The group UIElement corresponding to this UIPage.
38
private UIElement uiElement;
41
* The list of PatternEventListeners.
43
private Vector<PatternEventListener> vector;
46
* parent Composite, and The UIElement corresponding to this page.
51
public UIComposite(Composite parent, UIElement uiElement, Map<String, String> valueStore) {
52
super(parent, SWT.NONE);
54
vector = new Vector<PatternEventListener>();
55
GridLayout layout = new GridLayout(2, false);
56
layout.marginWidth = 10;
57
layout.marginHeight = 5;
58
this.setLayout(layout);
59
this.setLayoutData(new GridData(GridData.FILL_BOTH));
61
this.uiElement = uiElement;
65
* add a PatternListener to the list.
67
* @param patternListener
69
public void addPatternListener(PatternEventListener patternListener) {
70
vector.add(patternListener);
74
* remove the PatternListener from the list.
76
* @param patternListener
78
public void removePatternListener(PatternEventListener patternListener) {
79
vector.remove(patternListener);
83
* On occurrence of PatternEvent this method is called to invoke
84
* patternPerformed on all the registered listeners. In our application, we
85
* will have just one registered listener.
88
public void firePatternEvent(PatternEvent patternEvent) {
89
for (int i = 0; i < vector.size(); i++) {
90
vector.get(i).patternPerformed(patternEvent);
95
* This method will invoke the getValues on UIElement (group Element), which
96
* in turn will invoke the getValues on the UIElement (widgets). This
97
* returns an HashMap of Values.
99
public Map<String, String> getPageData() {
100
return uiElement.getValues();
104
* return the UIElement(group UI Element) represented by this UIComposite.
108
public UIElement getUIElement() {
113
* This information is used by UIPages to enable or disable the next button.
115
public boolean isValid() {
116
return uiElement.isValid();