/** * This file is protected by Copyright. * Please refer to the COPYRIGHT file distributed with this source distribution. * * This file is part of REDHAWK IDE. * * 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. * */ // BEGIN GENERATED CODE package gov.redhawk.eclipsecorba.idl.operations.provider; import gov.redhawk.eclipsecorba.idl.IdlException; import gov.redhawk.eclipsecorba.idl.IdlPackage; import gov.redhawk.eclipsecorba.idl.operations.Operation; import gov.redhawk.eclipsecorba.idl.operations.OperationsFactory; import gov.redhawk.eclipsecorba.idl.operations.OperationsPackage; import gov.redhawk.eclipsecorba.idl.operations.Parameter; import gov.redhawk.eclipsecorba.idl.provider.ExportItemProvider; import gov.redhawk.eclipsecorba.idl.provider.IdlEditPlugin; import gov.redhawk.eclipsecorba.idl.types.VoidType; import java.util.Collection; import java.util.Iterator; 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.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; /** * This is the item provider adapter for a {@link gov.redhawk.eclipsecorba.idl.operations.Operation} object. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public class OperationItemProvider extends ExportItemProvider implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { /** * This constructs an instance from a factory and a notifier. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public OperationItemProvider(AdapterFactory adapterFactory) { super(adapterFactory); } /** * This returns the property descriptors for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { if (itemPropertyDescriptors == null) { super.getPropertyDescriptors(object); addCommentPropertyDescriptor(object); addOnewayPropertyDescriptor(object); addExceptionsPropertyDescriptor(object); addContextPropertyDescriptor(object); } return itemPropertyDescriptors; } /** * This adds a property descriptor for the Comment feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addCommentPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Commentable_comment_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Commentable_comment_feature", "_UI_Commentable_type"), IdlPackage.Literals.COMMENTABLE__COMMENT, false, true, false, null, null, null)); } /** * This adds a property descriptor for the Oneway feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addOnewayPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Operation_oneway_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Operation_oneway_feature", "_UI_Operation_type"), OperationsPackage.Literals.OPERATION__ONEWAY, false, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Exceptions feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addExceptionsPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Operation_exceptions_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Operation_exceptions_feature", "_UI_Operation_type"), OperationsPackage.Literals.OPERATION__EXCEPTIONS, false, false, true, null, null, null)); } /** * This adds a property descriptor for the Context feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addContextPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Operation_context_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Operation_context_feature", "_UI_Operation_type"), OperationsPackage.Literals.OPERATION__CONTEXT, false, false, false, null, null, 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(OperationsPackage.Literals.OPERATION__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 Operation.gif. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getImage(Object object) { return overlayImage(object, getResourceLocator().getImage("full/obj16/Operation")); } /** * This returns the label text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ @Override public String getText(final Object object) { final Operation op = (Operation) object; final StringBuilder label = new StringBuilder(); label.append(op.getName()); label.append('('); for (final Iterator<Parameter> i = op.getParameters().iterator(); i.hasNext();) { final Parameter param = i.next(); final IItemLabelProvider lp = (IItemLabelProvider) getRootAdapterFactory().adapt(param.getType(), IItemLabelProvider.class); label.append(lp.getText(param.getType())); if (i.hasNext()) { label.append(", "); } } label.append(')'); if (op.getExceptions().size() > 0) { label.append(" throws "); for (final Iterator<IdlException> i = op.getExceptions().iterator(); i.hasNext();) { final IdlException exception = i.next(); final IItemLabelProvider lp = (IItemLabelProvider) getRootAdapterFactory().adapt(exception, IItemLabelProvider.class); label.append(lp.getText(exception)); if (i.hasNext()) { label.append(", "); } } } if (op.getType() != null && false == op.getType() instanceof VoidType) { label.append(" : "); final IItemLabelProvider lp = (IItemLabelProvider) getRootAdapterFactory().adapt(op.getType(), IItemLabelProvider.class); label.append(lp.getText(op.getType())); } return label.toString(); } /** * 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(Operation.class)) { case OperationsPackage.OPERATION__COMMENT: case OperationsPackage.OPERATION__ONEWAY: case OperationsPackage.OPERATION__CONTEXT: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; case OperationsPackage.OPERATION__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 (OperationsPackage.Literals.OPERATION__PARAMETERS, OperationsFactory.eINSTANCE.createParameter())); } /** * Return the resource locator for this item provider's resources. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public ResourceLocator getResourceLocator() { return IdlEditPlugin.INSTANCE; } }