blob: df62410940bf1643d50eadeccc1f815bdec9dbff [file] [log] [blame]
/*
* 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 - initial API and implementation
*
* $Id: CommunicationPathItemProvider.java,v 1.10 2005/09/23 20:14:53 khussey Exp $
*/
package org.eclipse.uml2.provider;
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.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.uml2.CommunicationPath;
import org.eclipse.uml2.Property;
import org.eclipse.uml2.Type;
/**
* This is the item provider adapter for a {@link org.eclipse.uml2.CommunicationPath} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class CommunicationPathItemProvider
extends AssociationItemProvider
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = "Copyright (c) IBM Corporation and others."; //$NON-NLS-1$
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CommunicationPathItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
}
return itemPropertyDescriptors;
}
/**
* This returns CommunicationPath.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object getImage(Object object) {
return getResourceLocator().getImage("full/obj16/CommunicationPath"); //$NON-NLS-1$
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public String getText(Object object) {
StringBuffer text = appendType(appendKeywords(new StringBuffer(),
object), "_UI_CommunicationPath_type"); //$NON-NLS-1$
CommunicationPath communicationPath = (CommunicationPath) object;
String label = communicationPath.getLabel(shouldTranslate());
if (label.length() > 0) {
appendString(text, label);
} else {
List memberEnds = communicationPath.getMemberEnds();
if (!memberEnds.isEmpty()) {
appendString(text, "A"); //$NON-NLS-1$
for (Iterator i = memberEnds.iterator(); i.hasNext();) {
Property memberEnd = (Property) i.next();
String memberEndName = memberEnd.getName();
text.append('_');
if (memberEndName.length() > 0) {
text.append(memberEndName);
} else {
Type type = memberEnd.getType();
if (null != type) {
String typeName = type.getName();
if (typeName.length() > 0) {
memberEndName = Character.toLowerCase(typeName
.charAt(0))
+ typeName.substring(1);
}
}
if (memberEndName.length() > 0) {
text.append(memberEndName);
} else {
text.append('<');
text.append(getTypeText(memberEnd));
text.append('>');
}
}
}
}
}
return text.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
*/
public void notifyChanged(Notification notification) {
updateChildren(notification);
super.notifyChanged(notification);
}
/**
* This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
* describing all of the children that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ResourceLocator getResourceLocator() {
return UML2EditPlugin.INSTANCE;
}
}