Skip to main content
aboutsummaryrefslogblamecommitdiffstats
blob: 814f4c00672fcf61cab76d11fb4ad00f75b7083a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                                
                            
                             
                              
                       
                                


                                                     
                                                    
                                      
                                                                
                                                    





                                                                     
                                                                      
                                                          
                                                          
                                                       

                                                                          
                                                           



                                                     

    


                                                                                                             


              


                                                                                                                                                                                                                    




                                                                                                   
 













                                                                                                                                                   
 
                                                                                        

            
                                                                      

                                   







                                                                             
                                                                        

                                   




                                                                                     


                                                                      
 

                                                                             
                  




                                                                       
                                                                                                         




                                                                                                                                                                               






                                                                                                                     




                                                                    



                                                
                                                                           

                                   



                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                            


            






















                                                                                                                                                                                                                                                                                      
                                              

                                   




                                                





                                                                                                                           


            


                                                              




                                               



















                                                                                                                                                                                                  




                                                                                                    
                                                                                                          

                                   





                                                               











                                                                                                                                                                       



                                                   

                                                                                                    

                                   








                                                                                                           
                                                                           

                                   






                                                      
 
  
/*****************************************************************************
 * Copyright (c) 2009 CEA LIST.
 *
 *    
 * 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:
 *  Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.sysml.blocks.provider;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;

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.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedImage;
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.ItemPropertyDescriptorDecorator;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.papyrus.sysml.blocks.BindingConnector;
import org.eclipse.papyrus.sysml.blocks.BlocksPackage;
import org.eclipse.papyrus.sysml.edit.provider.IComposableAdapterFactory;
import org.eclipse.papyrus.sysml.edit.provider.SysMLItemProviderAdapter;
import org.eclipse.papyrus.sysml.provider.SysmlEditPlugin;
import org.eclipse.papyrus.sysml.util.SysmlResource;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLPackage;

/**
 * This is the item provider adapter for a {@link org.eclipse.papyrus.sysml.blocks.BindingConnector} object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
public class BindingConnectorItemProvider extends SysMLItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource

{

	/**
	 * This is used to store all the property descriptors for aclass stereotyped with a block.
	 * Derived classes should add descriptors to this vector.
	 */

	protected List<IItemPropertyDescriptor> itemPropertyDescriptorsForconnector;

	/**
	 * Pattern prefix of bindingConnector
	 * 
	 * @generated
	 */
	private static Pattern BINDING_CONNECTOR_PREFIX_PATTERN = Pattern.compile("(bindingConnector, |<<bindingConnector>>|, bindingConnector)");

	/**
	 * Get the prefix pattern of CONNECTOR_PREFIX_PATTERN
	 * 
	 * @generated
	 */

	private static Pattern CONNECTOR_PREFIX_PATTERN = Pattern.compile("Connector");

	/**
	 * This constructs an instance from a factory and a notifier.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public BindingConnectorItemProvider(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(object instanceof BindingConnector) {
			if(itemPropertyDescriptors == null) {
				super.getPropertyDescriptors(object);

				addBase_ConnectorPropertyDescriptor(object);
			}
		}

		/**
		 * Handle Connector stereotyped by BindingConnector
		 */
		if(object instanceof org.eclipse.uml2.uml.Connector) {
			org.eclipse.uml2.uml.Connector element = (org.eclipse.uml2.uml.Connector)object;
			if(itemPropertyDescriptorsForconnector == null) {
				ItemProviderAdapter ite = ((IComposableAdapterFactory)adapterFactory).getIRootAdapterFactory().getItemProvider(UMLPackage.Literals.CONNECTOR);
				final List<IItemPropertyDescriptor> propertyDescriptors = ite.getPropertyDescriptors(this);
				itemPropertyDescriptorsForconnector = new ArrayList<IItemPropertyDescriptor>();
				itemPropertyDescriptorsForconnector.addAll(propertyDescriptors);
				Stereotype ste = (element).getAppliedStereotype(SysmlResource.BINDING_CONNECTOR_ID);
				if(ste != null) {
					EObject steApplication = (element).getStereotypeApplication(ste);

					addBase_ConnectorPropertyDescriptorForConnector(steApplication);

				}
			}
			return itemPropertyDescriptorsForconnector;

		}

		return itemPropertyDescriptors;
	}

	/**
	 * This adds a property descriptor for the Base Connector feature.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected void addBase_ConnectorPropertyDescriptor(Object object) {
		itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_BindingConnector_base_Connector_feature"), getString("_UI_PropertyDescriptor_description", "_UI_BindingConnector_base_Connector_feature", "_UI_BindingConnector_type"), BlocksPackage.Literals.BINDING_CONNECTOR__BASE_CONNECTOR, true, false, true, null, null, null));
	}

	/**
	 * This adds a property descriptor for the Base Connector feature for the UML element Connector.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected void addBase_ConnectorPropertyDescriptorForConnector(Object object) {

		itemPropertyDescriptorsForconnector.add(new ItemPropertyDescriptorDecorator(object, createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_BindingConnector_base_Connector_feature"),

		getString("_UI_PropertyDescriptor_description", "_UI_BindingConnector_base_Connector_feature", "_UI_BindingConnector_type"),

		BlocksPackage.Literals.BINDING_CONNECTOR__BASE_CONNECTOR, true, false, true,

		null,

		null,

		null)));

	}

	/**
	 * This returns BindingConnector.gif.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public Object getImage(Object object) {
		Object composedImage = overlayImage(object, getResourceLocator().getImage("full/obj16/BindingConnector"));
		if(object instanceof NamedElement) {
			ComposedImage aux = new ComposedImage(Collections.singletonList(composedImage));
			return (Object)composeVisibilityImage(object, aux);
		}
		return composedImage;
	}

	/**
	 * This returns the label text for the adapted class.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public String getText(Object object) {
		/**
		 * Handle Stereotype item and stereoted element
		 */
		BindingConnector bindingConnector_ = null;

		if(object instanceof org.eclipse.uml2.uml.Connector) {
			Stereotype ste = ((org.eclipse.uml2.uml.Connector)object).getAppliedStereotype(SysmlResource.BINDING_CONNECTOR_ID);
			if(ste != null) {
				IItemLabelProvider ite = (IItemLabelProvider)((IComposableAdapterFactory)adapterFactory).getIRootAdapterFactory().getItemProvider(UMLPackage.Literals.CONNECTOR);
				String result = ite.getText(object);
				result = BINDING_CONNECTOR_PREFIX_PATTERN.matcher(result).replaceFirst("");
				return CONNECTOR_PREFIX_PATTERN.matcher(result).replaceFirst("BindingConnector");
			}

		}

		if(bindingConnector_ == null) {
			bindingConnector_ = (BindingConnector)object;
		}

		return getString("_UI_BindingConnector_type");
	}

	/**
	 * 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);

		/**
		 * Handle Connector stereotyped by BindingConnector
		 */

		if(notification.getFeatureID(org.eclipse.uml2.uml.Connector.class) != Notification.NO_FEATURE_ID) {
			ItemProviderAdapter ite = ((IComposableAdapterFactory)adapterFactory).getIRootAdapterFactory().getItemProvider(UMLPackage.Literals.CONNECTOR);
			ite.notifyChanged(notification);
			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);
	}

	/**
	 * Return the resource locator for this item provider's resources.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public ResourceLocator getResourceLocator() {
		return SysmlEditPlugin.INSTANCE;
	}

}

Back to the top