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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
/*******************************************************************************
* Copyright (c) 2008 IONA Technologies PLC
* 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:
* IONA Technologies PLC - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.ws.internal.cxf.consumption.ui.widgets;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICellEditorListener;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jst.ws.internal.cxf.core.model.WSDL2JavaDataModel;
import org.eclipse.jst.ws.internal.cxf.ui.viewers.PackageNameEditingSupport;
import org.eclipse.jst.ws.internal.cxf.ui.viewers.PackageNameTableContentProvider;
import org.eclipse.jst.ws.internal.cxf.ui.widgets.WSDL2JavaWidgetFactory;
import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
@SuppressWarnings("restriction")
public class WSDL2JavaClientConfigWidget extends SimpleWidgetDataContributor {
private IStatus status = Status.OK_STATUS;
private Listener statusListener;
private WSDL2JavaDataModel model;
private Composite namespaceCompositeHolder;
private Composite namespaceComposite;
private int namespaceCompositeHeight = -1;
public WSDL2JavaClientConfigWidget() {
}
public void setWSDL2JavaDataModel(WSDL2JavaDataModel model) {
this.model = model;
}
@Override
public WidgetDataEvents addControls(final Composite parent, final Listener statusListener) {
this.statusListener = statusListener;
final Composite mainComposite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(3, false);
mainComposite.setLayout(gridLayout);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
mainComposite.setLayoutData(gridData);
// Output Dir
WSDL2JavaWidgetFactory.createOutputDirectoryLabel(mainComposite);
Combo outputDirCombo = WSDL2JavaWidgetFactory.createOutputDirectoryCombo(mainComposite, model);
gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
gridData.horizontalSpan = 2;
outputDirCombo.setLayoutData(gridData);
// Package Name:
WSDL2JavaWidgetFactory.createPackageNameLabel(mainComposite);
final Text packageNameText = WSDL2JavaWidgetFactory.createPackageNameText(mainComposite, model);
gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
gridData.horizontalSpan = 2;
packageNameText.setLayoutData(gridData);
packageNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String packageName = packageNameText.getText();
status = JDTUtils.validatePackageName(model.getProjectName(), packageName);
statusListener.handleEvent(null);
}
});
final Button namespaceMappingButton = WSDL2JavaWidgetFactory.createNamespacePackageMappingButton(mainComposite);
gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
gridData.horizontalSpan = 3;
namespaceMappingButton.setLayoutData(gridData);
namespaceMappingButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (namespaceMappingButton.getSelection()) {
if (namespaceComposite == null) {
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
gridData.horizontalSpan = 3;
gridData.verticalSpan = 7;
namespaceCompositeHolder.setLayoutData(gridData);
namespaceCompositeHolder.pack();
namespaceComposite = getNamespaceMappingComposite(namespaceCompositeHolder);
if (namespaceCompositeHeight == -1) {
Point groupSize = namespaceComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
namespaceCompositeHeight = groupSize.y;
}
Shell shell = parent.getShell();
Point shellSize = shell.getSize();
shell.setSize(shellSize.x, shellSize.y + namespaceCompositeHeight);
namespaceCompositeHolder.layout();
}
} else {
if (namespaceComposite != null) {
GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
gridData.horizontalSpan = 3;
namespaceCompositeHolder.setLayoutData(gridData);
namespaceCompositeHolder.pack();
namespaceComposite.dispose();
namespaceComposite = null;
namespaceCompositeHolder.layout();
Shell shell = parent.getShell();
Point shellSize = shell.getSize();
shell.setSize(shellSize.x, shellSize.y - namespaceCompositeHeight);
}
}
}
});
namespaceCompositeHolder = new Composite(mainComposite, SWT.NONE);
gridLayout = new GridLayout(1, true);
namespaceCompositeHolder.setLayout(gridLayout);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
gridData.horizontalSpan = 3;
namespaceCompositeHolder.setLayoutData(gridData);
// Service Name:
// WSDL2JavaWidgetFactory.createServiceNameLabel(mainComposite);
//
// Combo serviceNameCombo = WSDL2JavaWidgetFactory.createServiceNameCombo(mainComposite, model);
// gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
// gridData.horizontalSpan = 2;
// serviceNameCombo.setLayoutData(gridData);
Label bindingFilesLabel = WSDL2JavaWidgetFactory.createBindingFilesLabel(mainComposite);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
gridData.verticalSpan = 3;
bindingFilesLabel.setLayoutData(gridData);
List bindingFilesList = WSDL2JavaWidgetFactory.createBindingFilesList(mainComposite);
gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
gridData.verticalSpan = 3;
bindingFilesList.setLayoutData(gridData);
Button addBindingFileButton = WSDL2JavaWidgetFactory.createAddBindingFileButton(mainComposite, model,
bindingFilesList);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
addBindingFileButton.setLayoutData(gridData);
Button removeBindingFileButton = WSDL2JavaWidgetFactory.createRemoveBindingFileButton(mainComposite,
model, bindingFilesList);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
removeBindingFileButton.setLayoutData(gridData);
WSDL2JavaWidgetFactory.createPaddingLabel(mainComposite);
/*
WSDL2JavaWidgetFactory.createXMLCatalogLabel(mainComposite);
Text xmlCatalogText = WSDL2JavaWidgetFactory.createXMLCatalogText(mainComposite, model);
gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
xmlCatalogText.setLayoutData(gridData);
WSDL2JavaWidgetFactory.createXMLCatalogBrowseButton(mainComposite);
*/
return this;
}
public Table createNamespaceMappingTable(Composite parent) {
TableViewer packageNameTableViewer = new TableViewer(parent, SWT.CHECK | SWT.MULTI | SWT.BORDER
| SWT.FULL_SELECTION);
final Table packageNameTable = packageNameTableViewer.getTable();
packageNameTable.setLinesVisible(true);
packageNameTable.setHeaderVisible(true);
TableLayout tableLayout = new TableLayout();
packageNameTable.setLayout(tableLayout);
WSDL2JavaWidgetFactory.createWSDLNamespaceViewerColumn(packageNameTableViewer);
ColumnWeightData columnWeightData = new ColumnWeightData(100, 100, true);
tableLayout.addColumnData(columnWeightData);
TableViewerColumn packageNameViewerColumn = WSDL2JavaWidgetFactory.createPackageNameColumn(
packageNameTableViewer, model);
TextCellEditor textCellEditor = new TextCellEditor(packageNameTableViewer.getTable());
textCellEditor.addListener( new ICellEditorListener() {
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
statusListener.handleEvent(null);
}
public void cancelEditor() {
}
public void applyEditorValue() {
}
});
textCellEditor.setValidator(new ICellEditorValidator() {
public String isValid(Object packageName) {
status = JDTUtils.validatePackageName(model.getProjectName(), packageName.toString());
if (status.getSeverity() == IStatus.OK) {
return null;
}
return status.getMessage();
}
});
packageNameViewerColumn.setEditingSupport(new PackageNameEditingSupport(packageNameTableViewer,
textCellEditor, model));
columnWeightData = new ColumnWeightData(100, 100, true);
tableLayout.addColumnData(columnWeightData);
packageNameTableViewer.setContentProvider(new PackageNameTableContentProvider());
packageNameTableViewer.setInput(model.getWsdlDefinition());
TableItem[] tableItems = packageNameTableViewer.getTable().getItems();
for (int i = 0; i < tableItems.length; i++) {
TableItem tableItem = tableItems[i];
if (model.getIncludedNamespaces().containsKey(tableItem.getText(0))) {
tableItem.setChecked(true);
}
}
return packageNameTable;
}
private Composite getNamespaceMappingComposite(Composite parent) {
namespaceComposite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, true);
namespaceComposite.setLayout(gridLayout);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
namespaceComposite.setLayoutData(gridData);
Table packageNameTable = createNamespaceMappingTable(namespaceComposite);
gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalSpan = 3;
gridData.verticalSpan = 6;
packageNameTable.setLayoutData(gridData);
return namespaceComposite;
}
@Override
public IStatus getStatus() {
return status;
}
}
|