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
|
/*******************************************************************************
* Copyright (c) 2003, 2005 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
*******************************************************************************/
/*
* Created on Jan 21, 2004
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package org.eclipse.jst.j2ee.internal.webservice.adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jem.java.JavaClass;
import org.eclipse.jst.j2ee.internal.webservice.command.CommandModifySEI;
import org.eclipse.jst.j2ee.internal.webservice.command.CommandModifyText;
import org.eclipse.jst.j2ee.webservice.wsclient.PortComponentRef;
import org.eclipse.jst.j2ee.webservice.wsclient.Webservice_clientPackage;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wst.common.componentcore.ArtifactEdit;
/**
* @author rsinha
*
* To change the template for this generated type comment go to Window - Preferences - Java - Code
* Generation - Code and Comments
*/
public class AdapterPCRefText extends AdapterText {
public AdapterPCRefText(ArtifactEdit anArtifactEdit, EStructuralFeature feature, Text text, boolean nillable) {
super(anArtifactEdit, feature, text, nillable);
}
public AdapterPCRefText(ArtifactEdit anArtifactEdit, EObject eObject, EStructuralFeature feature, Text text, boolean nillable) {
super(anArtifactEdit, eObject, feature, text, nillable);
}
@Override
public void notifyChanged(Notification msg) {
int type = msg.getEventType();
if ((type == Notification.SET || type == Notification.UNSET) && syncTextAndModel() && msg.getFeature() == feature_) {
Object obj = eObject_.eGet(feature_);
String objStringValue = ""; //$NON-NLS-1$
if (obj instanceof String) {
objStringValue = (String) obj;
} else if (obj instanceof JavaClass) {
JavaClass javaClass = (JavaClass) obj;
objStringValue = javaClass.getQualifiedNameForReflection();
}
setText(objStringValue);
}
}
@Override
public void modifyText(ModifyEvent e) {
if (syncTextAndModel()) {
//Handle PortComponentRef_ServiceEndpointInterface feature in a special way.
String SEIFeatureName = Webservice_clientPackage.eINSTANCE.getPortComponentRef_ServiceEndpointInterface().getName();
if ((eObject_ instanceof PortComponentRef) && (feature_.getName().equals(SEIFeatureName))) {
CommandModifySEI command = new CommandModifySEI(null, null, (PortComponentRef) eObject_, text_.getText(), nillable_);
artifactEdit.getContentModelRoot().eResource().setModified(true);
artifactEdit.getCommandStack().execute(command);
} else {
CommandModifyText command = new CommandModifyText(null, null, eObject_, feature_, text_.getText(), nillable_);
artifactEdit.getContentModelRoot().eResource().setModified(true);
artifactEdit.getCommandStack().execute(command);
}
}
}
@Override
public void adapt(EObject eObject) {
if (eObject_ != null)
eObject_.eAdapters().remove(this);
eObject_ = eObject;
if (eObject_ != null) {
eObject_.eAdapters().add(this);
Object obj = eObject_.eGet(feature_);
String objStringValue = ""; //$NON-NLS-1$
if (obj instanceof String) {
objStringValue = (String) obj;
} else if (obj instanceof JavaClass) {
JavaClass javaClass = (JavaClass) obj;
objStringValue = javaClass.getQualifiedNameForReflection();
}
setText(objStringValue);
} else
setText(null);
}
@Override
protected boolean syncTextAndModel() {
if (eObject_ != null) {
String modelValue;
//Handle PortComponentRef_ServiceEndpointInterface feature in a special way.
String SEIFeatureName = Webservice_clientPackage.eINSTANCE.getPortComponentRef_ServiceEndpointInterface().getName();
if ((eObject_ instanceof PortComponentRef) && (feature_.getName().equals(SEIFeatureName))) {
modelValue = ((PortComponentRef) eObject_).getServiceEndpointInterface().getQualifiedNameForReflection();
} else {
modelValue = (String) eObject_.eGet(feature_);
}
String textValue = text_.getText();
if (modelValue == null || modelValue.length() <= 0)
return !(textValue == null || textValue.length() <= 0);
return !(modelValue.equals(textValue));
}
return false;
}
}
|