~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIComposite.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 * Bala Torati (Symbian) - Initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
 
12
 
 
13
import java.util.Map;
 
14
import java.util.Vector;
 
15
 
 
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;
 
20
 
 
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;
 
24
 
 
25
 
 
26
/**
 
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.
 
31
 */
 
32
 
 
33
public class UIComposite extends Composite {
 
34
 
 
35
        /**
 
36
         * The group UIElement corresponding to this UIPage.
 
37
         */
 
38
        private UIElement uiElement;
 
39
 
 
40
        /**
 
41
         * The list of PatternEventListeners.
 
42
         */
 
43
        private Vector<PatternEventListener> vector;
 
44
 
 
45
        /**
 
46
         * parent Composite, and The UIElement corresponding to this page.
 
47
         * 
 
48
         * @param parent
 
49
         * @param uiElement
 
50
         */
 
51
        public UIComposite(Composite parent, UIElement uiElement, Map<String, String> valueStore) {
 
52
                super(parent, SWT.NONE);
 
53
 
 
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));
 
60
 
 
61
                this.uiElement = uiElement;
 
62
        }
 
63
 
 
64
        /**
 
65
         * add a PatternListener to the list.
 
66
         * 
 
67
         * @param patternListener
 
68
         */
 
69
        public void addPatternListener(PatternEventListener patternListener) {
 
70
                vector.add(patternListener);
 
71
        }
 
72
 
 
73
        /**
 
74
         * remove the PatternListener from the list.
 
75
         * 
 
76
         * @param patternListener
 
77
         */
 
78
        public void removePatternListener(PatternEventListener patternListener) {
 
79
                vector.remove(patternListener);
 
80
        }
 
81
 
 
82
        /**
 
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.
 
86
         */
 
87
 
 
88
        public void firePatternEvent(PatternEvent patternEvent) {
 
89
                for (int i = 0; i < vector.size(); i++) {
 
90
                        vector.get(i).patternPerformed(patternEvent);
 
91
                }
 
92
        }
 
93
 
 
94
        /**
 
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.
 
98
         */
 
99
        public Map<String, String> getPageData() {
 
100
                return uiElement.getValues();
 
101
        }
 
102
 
 
103
        /**
 
104
         * return the UIElement(group UI Element) represented by this UIComposite.
 
105
         * 
 
106
         * @return UIElement.
 
107
         */
 
108
        public UIElement getUIElement() {
 
109
                return uiElement;
 
110
        }
 
111
 
 
112
        /**
 
113
         * This information is used by UIPages to enable or disable the next button.
 
114
         */
 
115
        public boolean isValid() {
 
116
                return uiElement.isValid();
 
117
        }
 
118
 
 
119
}