blob: dcbae2e37c04ebc0f9b8f2c5e6c7cfbf6eaacbd9 (
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
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
|
/*******************************************************************************
* Copyright (c) 2001, 2008 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.wst.wsdl.ui.internal.adapters.basic;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.gef.commands.Command;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.wst.wsdl.Part;
import org.eclipse.wst.wsdl.ui.internal.Messages;
import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
import org.eclipse.wst.wsdl.ui.internal.actions.OpenInNewEditor;
import org.eclipse.wst.wsdl.ui.internal.adapters.WSDLBaseAdapter;
import org.eclipse.wst.wsdl.ui.internal.adapters.actions.W11AddPartAction;
import org.eclipse.wst.wsdl.ui.internal.adapters.actions.W11SetExistingElementAction;
import org.eclipse.wst.wsdl.ui.internal.adapters.actions.W11SetExistingTypeAction;
import org.eclipse.wst.wsdl.ui.internal.adapters.actions.W11SetNewElementAction;
import org.eclipse.wst.wsdl.ui.internal.adapters.actions.W11SetNewTypeAction;
import org.eclipse.wst.wsdl.ui.internal.adapters.commands.W11SetElementCommand;
import org.eclipse.wst.wsdl.ui.internal.adapters.commands.W11SetTypeCommand;
import org.eclipse.wst.wsdl.ui.internal.asd.actions.ASDAddFaultAction;
import org.eclipse.wst.wsdl.ui.internal.asd.actions.ASDAddOperationAction;
import org.eclipse.wst.wsdl.ui.internal.asd.actions.ASDDeleteAction;
import org.eclipse.wst.wsdl.ui.internal.asd.actions.BaseSelectionAction;
import org.eclipse.wst.wsdl.ui.internal.asd.design.figures.ModelDiagnosticInfo;
import org.eclipse.wst.wsdl.ui.internal.asd.facade.IMessageReference;
import org.eclipse.wst.wsdl.ui.internal.asd.facade.IOperation;
import org.eclipse.wst.wsdl.ui.internal.asd.facade.IParameter;
import org.eclipse.wst.wsdl.ui.internal.asd.outline.ITreeElement;
import org.eclipse.wst.xsd.ui.internal.adt.editor.ProductCustomizationProvider;
import org.eclipse.xsd.XSDComplexTypeDefinition;
public class W11ParameterForPart extends WSDLBaseAdapter implements IParameter
{
protected Part getPart()
{
return (Part) target;
}
public String getName()
{
return getPart().getName();
}
public String getComponentName()
{
if (getPart().getElementDeclaration() != null)
{
return getPart().getElementDeclaration().getName();
}
else if (getPart().getTypeDefinition() != null)
{
return getPart().getTypeDefinition().getName();
}
else
{
return getNoNameSpecifiedString();
}
}
private String getNoNameSpecifiedString() {
return ""; //$NON-NLS-1$
}
public String getComponentNameQualifier()
{
if (getPart().getElementDeclaration() != null)
{
return getPart().getElementDeclaration().getTargetNamespace();
}
else if (getPart().getTypeDefinition() != null)
{
return getPart().getTypeDefinition().getTargetNamespace();
}
else
{
return ""; //$NON-NLS-1$
}
}
public String[] getActions(Object object) {
if (object instanceof MultiPageEditorPart) {
IOperation operation = ((IMessageReference) getOwner()).getOwnerOperation();
List actions = new ArrayList();
actions.add(W11AddPartAction.ID);
actions.add(ASDAddOperationAction.ID);
actions.addAll(((W11Operation) operation).getValidInputOutpuActions());
actions.add(ASDAddFaultAction.ID);
actions.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_TYPE); //$NON-NLS-1$
actions.add(W11SetNewTypeAction.ID);
actions.add(W11SetExistingTypeAction.ID);
actions.add(BaseSelectionAction.SUBMENU_END_ID);
actions.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_ELEMENT); //$NON-NLS-1$
actions.add(W11SetNewElementAction.ID);
actions.add(W11SetExistingElementAction.ID);
actions.add(BaseSelectionAction.SUBMENU_END_ID);
actions.add(ASDDeleteAction.ID);
if (isReadOnly()) {
actions.add(OpenInNewEditor.ID);
}
String[] actionIDs = new String[actions.size()];
for (int index = 0; index < actions.size(); index++) {
actionIDs[index] = (String) actions.get(index);
}
return actionIDs;
}
if (object instanceof ContentOutline) {
String[] actionIDs = new String[2];
actionIDs[0] = W11AddPartAction.ID;
actionIDs[1] = ASDDeleteAction.ID;
return actionIDs;
}
return new String[0];
}
public Object getOwner()
{
return owner;
}
public Image getImage() {
return WSDLEditorPlugin.getInstance().getImage("icons/part_obj.gif"); //$NON-NLS-1$
}
public Image getSecondaryImage() {
if (getPart().getElementDeclaration() != null)
{
return WSDLEditorPlugin.getInstance().getImage("icons/element_obj.gif"); //$NON-NLS-1$
}
else if (getPart().getTypeDefinition() != null)
{
if (getPart().getTypeDefinition() instanceof XSDComplexTypeDefinition)
{
return WSDLEditorPlugin.getInstance().getImage("icons/complextype_obj.gif"); //$NON-NLS-1$
}
else
{
return WSDLEditorPlugin.getInstance().getImage("icons/simpletype_obj.gif"); //$NON-NLS-1$
}
}
else
{
return WSDLEditorPlugin.getInstance().getImage("icons/part_obj.gif"); //$NON-NLS-1$
}
}
public String getText() {
return "part"; //$NON-NLS-1$
}
public ITreeElement[] getChildren() {
return new ITreeElement[0];
}
public boolean hasChildren() {
return false;
}
public ITreeElement getParent() {
return null;
}
public Command getSetTypeCommand(String actionId) {
return new W11SetTypeCommand((Part) this.getTarget(), actionId);
}
public Command getSetElementCommand(String actionId) {
return new W11SetElementCommand((Part) this.getTarget(), actionId);
}
// TODO: We should move the isType() method to the IParameter Interface........
public boolean isType() {
Part part = (Part) target;
if (part.getTypeDefinition() != null) {
return true;
}
return false;
}
public List getDiagnosticMessages() {
List errors = new ArrayList();
Part part = (Part) getTarget();
if (part.getElementDeclaration() == null && part.getTypeDefinition() == null) {
String[] args = new String[2];
args[0] = "element"; //$NON-NLS-1$
args[1] = "type"; //$NON-NLS-1$
String string = NLS.bind(Messages._UI_LABEL_OR_UNDEFINED_ARG2, args);
String customizedMessage = getProductCustomizedMessage("_UI_LABEL_OR_UNDEFINED_ARG2", args); //$NON-NLS-1$
if (customizedMessage != null && !customizedMessage.equals("")) //$NON-NLS-1$
string = customizedMessage;
ModelDiagnosticInfo info = new ModelDiagnosticInfo(string, ModelDiagnosticInfo.ERROR_TYPE, null);
errors.add(info);
}
return errors;
}
/**
* Returns a customed product-based message for the given key and arguments
* or null if none exists.
* @param key
* @param args
* @return String customized message or null if none exists
*/
private String getProductCustomizedMessage(String key, Object[] args) {
String productMessage = null;
Object object = WSDLEditorPlugin.getInstance().getProductCustomizationProvider();
if (object instanceof ProductCustomizationProvider) {
ProductCustomizationProvider productCustomizationProvider = (ProductCustomizationProvider)object;
String customizedString = null;
if (args == null) {
customizedString = productCustomizationProvider.getProductString(key);
}
else {
customizedString = productCustomizationProvider.getProductString(key, args);
}
if (customizedString != null && !customizedString.equals("")) { //$NON-NLS-1$
productMessage = customizedString;
}
}
return productMessage;
}
}
|