blob: 7800540a4cde9f9ad11de66894caae3bae5a459d [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 by SAP AG, Walldorf.
* 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:
* SAP AG - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.ws.jaxws.dom.ui;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.jst.ws.jaxws.dom.runtime.api.DomFactory;
import org.eclipse.jst.ws.jaxws.dom.runtime.api.DomPackage;
import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebMethod;
import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebParam;
import org.eclipse.jst.ws.jaxws.dom.ui.internal.plugin.DomUi;
/**
* This is the item provider adapter for a {@link org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebMethod} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class IWebMethodItemProvider extends IJavaWebServiceElementItemProvider
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IWebMethodItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object)
{
if (itemPropertyDescriptors != null) {
return itemPropertyDescriptors;
}
super.getPropertyDescriptors(object);
addExcludedPropertyDescriptor(object);
addSoapBindingStylePropertyDescriptor(object);
addSoapBindingUsePropertyDescriptor(object);
addSoapBindingParameterStylePropertyDescriptor(object);
return itemPropertyDescriptors;
}
@Override
protected void addImplementationPropertyDescriptor(Object object)
{
itemPropertyDescriptors.add(
new ItemPropertyDescriptor(
((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_IJavaWebServiceElement_implementation_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_IJavaWebServiceElement_implementation_feature", "_UI_IJavaWebServiceElement_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DomPackage.Literals.IJAVA_WEB_SERVICE_ELEMENT__IMPLEMENTATION,
false,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null)
{
@Override
protected Object getValue(EObject object, EStructuralFeature feature)
{
String returnString = ""; //$NON-NLS-1$
String parameters = ""; //$NON-NLS-1$
IWebMethod webMethod = (IWebMethod)getTarget();
for(IWebParam webParam : webMethod.getParameters())
{
if(webParam.getName().equals("return")) //$NON-NLS-1$
{
returnString = getTypeName(webParam.getTypeName()) + " "; //$NON-NLS-1$
}
else
{
parameters = parameters + getTypeName(webParam.getTypeName()) + ", "; //$NON-NLS-1$
}
}
if (parameters.length() > 0) {
parameters = parameters.substring(0, parameters.lastIndexOf(','));
}
String methodName = webMethod.getImplementation();
int pos = methodName.indexOf('(');
if (pos > -1) {
methodName = methodName.substring(0, pos);
}
return returnString + methodName + '(' + parameters + ')';
}
protected String getTypeName(String typeName)
{
return typeName.substring(typeName.lastIndexOf('.') + 1);
}
});
}
/**
* This adds a property descriptor for the Excluded feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected void addExcludedPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_IWebMethod_excluded_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_IWebMethod_excluded_feature", "_UI_IWebMethod_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DomPackage.Literals.IWEB_METHOD__EXCLUDED,
false,
false,
false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
getNameCategory(),
null));
}
/**
* This adds a property descriptor for the Soap Binding Style feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected void addSoapBindingStylePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_IWebMethod_soapBindingStyle_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_IWebMethod_soapBindingStyle_feature", "_UI_IWebMethod_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DomPackage.Literals.IWEB_METHOD__SOAP_BINDING_STYLE,
false,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
getString("_UI_IServiceEndpointInterface_soapBinding"), //$NON-NLS-1$
null));
}
/**
* This adds a property descriptor for the Soap Binding Use feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected void addSoapBindingUsePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_IWebMethod_soapBindingUse_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_IWebMethod_soapBindingUse_feature", "_UI_IWebMethod_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DomPackage.Literals.IWEB_METHOD__SOAP_BINDING_USE,
false,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
getString("_UI_IServiceEndpointInterface_soapBinding"), //$NON-NLS-1$
null));
}
/**
* This adds a property descriptor for the Soap Binding Parameter Style feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected void addSoapBindingParameterStylePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_IWebMethod_soapBindingParameterStyle_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_IWebMethod_soapBindingParameterStyle_feature", "_UI_IWebMethod_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DomPackage.Literals.IWEB_METHOD__SOAP_BINDING_PARAMETER_STYLE,
false,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
getString("_UI_IServiceEndpointInterface_soapBinding"), //$NON-NLS-1$
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(DomPackage.Literals.IWEB_METHOD__PARAMETERS);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This returns Web_Method.gif.
*/
@Override
public Object getImage(Object object) {
return overlayImage(object, Images.INSTANCE.getImage(Images.IMG_WEB_METHOD));
}
/**
* This returns the label text for the adapted class.
*/
@Override
public String getText(Object object) {
String label = ((IWebMethod)object).getName();
return label == null || label.length() == 0 ?
getString("_UI_IWebMethod_type") : //$NON-NLS-1$
label;
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(IWebMethod.class)) {
case DomPackage.IWEB_METHOD__EXCLUDED:
case DomPackage.IWEB_METHOD__SOAP_BINDING_STYLE:
case DomPackage.IWEB_METHOD__SOAP_BINDING_USE:
case DomPackage.IWEB_METHOD__SOAP_BINDING_PARAMETER_STYLE:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case DomPackage.IWEB_METHOD__PARAMETERS:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
newChildDescriptors.add
(createChildParameter
(DomPackage.Literals.IWEB_METHOD__PARAMETERS,
DomFactory.eINSTANCE.createIWebParam()));
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return DomUi.INSTANCE;
}
@Override
public String getNameCategory()
{
return getString("_UI_WebMethodAnnotationCategory"); //$NON-NLS-1$
}
}