Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2007 Symbian Software Limited and others. |
|
|
3 |
* All rights reserved. This program and the accompanying materials |
2 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
3 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
4 |
* which accompanies this distribution, and is available at |
Lines 10-16
Link Here
|
10 |
*******************************************************************************/ |
9 |
*******************************************************************************/ |
11 |
package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets; |
10 |
package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets; |
12 |
|
11 |
|
|
|
12 |
import java.util.ArrayList; |
13 |
import java.util.Arrays; |
13 |
import java.util.HashMap; |
14 |
import java.util.HashMap; |
|
|
15 |
import java.util.List; |
14 |
import java.util.Map; |
16 |
import java.util.Map; |
15 |
import java.util.StringTokenizer; |
17 |
import java.util.StringTokenizer; |
16 |
|
18 |
|
Lines 25-30
Link Here
|
25 |
import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes; |
27 |
import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes; |
26 |
import org.eclipse.cdt.ui.templateengine.uitree.UIElement; |
28 |
import org.eclipse.cdt.ui.templateengine.uitree.UIElement; |
27 |
import org.eclipse.cdt.utils.ui.controls.FileListControl; |
29 |
import org.eclipse.cdt.utils.ui.controls.FileListControl; |
|
|
30 |
import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener; |
28 |
|
31 |
|
29 |
|
32 |
|
30 |
/** |
33 |
/** |
Lines 37-58
Link Here
|
37 |
/** |
40 |
/** |
38 |
* Attributes associated with this widget. |
41 |
* Attributes associated with this widget. |
39 |
*/ |
42 |
*/ |
40 |
UIAttributes/*<String, String>*/ uiAttribute; |
43 |
protected UIAttributes/*<String, String>*/ uiAttribute; |
41 |
|
44 |
|
42 |
/** |
45 |
/** |
43 |
* StringList widget. |
46 |
* StringList widget. |
44 |
*/ |
47 |
*/ |
45 |
FileListControl fileListControl; |
48 |
protected FileListControl fileListControl; |
46 |
|
49 |
|
47 |
/** |
50 |
/** |
48 |
* Label of this widget. |
51 |
* Label of this widget. |
49 |
*/ |
52 |
*/ |
50 |
Label label; |
53 |
protected Label label; |
51 |
|
54 |
|
52 |
/** |
55 |
/** |
53 |
* Composite to which this widget control is added. |
56 |
* Composite to which this widget control is added. |
54 |
*/ |
57 |
*/ |
55 |
UIComposite uiComposite; |
58 |
protected UIComposite uiComposite; |
|
|
59 |
|
60 |
protected List itemsList; |
56 |
|
61 |
|
57 |
/** |
62 |
/** |
58 |
* Constructor. |
63 |
* Constructor. |
Lines 63-68
Link Here
|
63 |
public UIStringListWidget(UIAttributes/*<String, String>*/ attribute) { |
68 |
public UIStringListWidget(UIAttributes/*<String, String>*/ attribute) { |
64 |
super(attribute); |
69 |
super(attribute); |
65 |
uiAttribute = attribute; |
70 |
uiAttribute = attribute; |
|
|
71 |
itemsList = new ArrayList(); |
66 |
} |
72 |
} |
67 |
|
73 |
|
68 |
/** |
74 |
/** |
Lines 70-81
Link Here
|
70 |
*/ |
76 |
*/ |
71 |
public Map/*<String, String>*/ getValues() { |
77 |
public Map/*<String, String>*/ getValues() { |
72 |
Map/*<String, String>*/ retMap = new HashMap/*<String, String>*/(); |
78 |
Map/*<String, String>*/ retMap = new HashMap/*<String, String>*/(); |
73 |
String[] items = fileListControl.getItems(); |
|
|
74 |
String itemString = new String(); |
79 |
String itemString = new String(); |
75 |
|
80 |
for (int i = 0; i < itemsList.size(); i++) { |
76 |
for (int i = 0; i < items.length; i++) |
81 |
itemString = itemString + itemsList.get(i) + "|"; //$NON-NLS-1$ |
77 |
itemString = itemString + items[i] + "|"; //$NON-NLS-1$ |
82 |
} |
78 |
|
|
|
79 |
retMap.put(uiAttribute.get(InputUIElement.ID), itemString); |
83 |
retMap.put(uiAttribute.get(InputUIElement.ID), itemString); |
80 |
|
84 |
|
81 |
return retMap; |
85 |
return retMap; |
Lines 87-105
Link Here
|
87 |
* @param valueMap |
91 |
* @param valueMap |
88 |
*/ |
92 |
*/ |
89 |
public void setValues(Map/*<String, String>*/ valueMap) { |
93 |
public void setValues(Map/*<String, String>*/ valueMap) { |
90 |
|
|
|
91 |
String items = (String) valueMap.get(uiAttribute.get(InputUIElement.ID)); |
94 |
String items = (String) valueMap.get(uiAttribute.get(InputUIElement.ID)); |
92 |
|
95 |
|
93 |
if (items != null) { |
96 |
if (items != null) { |
94 |
items = items.trim(); |
97 |
items = items.trim(); |
95 |
StringTokenizer st = new StringTokenizer(items, "|"); //$NON-NLS-1$ |
98 |
StringTokenizer st = new StringTokenizer(items, "|"); //$NON-NLS-1$ |
96 |
String[] itemList = new String[st.countTokens()]; |
99 |
for (int i = 0; st.hasMoreTokens(); i++) { |
97 |
|
100 |
itemsList.add(st.nextToken()); |
98 |
for (int i = 0; st.hasMoreTokens(); i++) |
101 |
} |
99 |
itemList[i] = st.nextToken(); |
|
|
100 |
|
101 |
fileListControl.setList(itemList); |
102 |
fileListControl.setSelection(0); |
103 |
} |
102 |
} |
104 |
} |
103 |
} |
105 |
|
104 |
|
Lines 133-138
Link Here
|
133 |
flcComposite.setLayoutData(gridData); |
132 |
flcComposite.setLayoutData(gridData); |
134 |
|
133 |
|
135 |
fileListControl = new FileListControl(flcComposite, (String) uiAttribute.get(InputUIElement.WIDGETLABEL), 0); |
134 |
fileListControl = new FileListControl(flcComposite, (String) uiAttribute.get(InputUIElement.WIDGETLABEL), 0); |
|
|
135 |
fileListControl.setList((String[])itemsList.toArray()); |
136 |
fileListControl.setSelection(0); |
137 |
fileListControl.addChangeListener(new IFileListChangeListener(){ |
138 |
public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) { |
139 |
itemsList.addAll(Arrays.asList(newValue)); |
140 |
} |
141 |
}); |
142 |
|
136 |
} |
143 |
} |
137 |
|
144 |
|
138 |
/** |
145 |
/** |
Lines 147-154
Link Here
|
147 |
boolean retVal = true; |
154 |
boolean retVal = true; |
148 |
String mandatory = (String) uiAttribute.get(InputUIElement.MANDATORY); |
155 |
String mandatory = (String) uiAttribute.get(InputUIElement.MANDATORY); |
149 |
|
156 |
|
150 |
if ((fileListControl.getItems() == null) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) { |
157 |
if ((itemsList == null || itemsList.size() == 0) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) { |
151 |
|
|
|
152 |
retVal = false; |
158 |
retVal = false; |
153 |
} |
159 |
} |
154 |
return retVal; |
160 |
return retVal; |