blob: 82738304c4f3d0552d9d5353005ee4e7e13a9d9d [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2004, 2010 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
****************************************************************************/
package org.eclipse.gmf.runtime.notation.provider;
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.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.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.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.NotationPackage;
/**
* This is the item provider adapter for a {@link org.eclipse.gmf.runtime.notation.Edge} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class EdgeItemProvider
extends ViewItemProvider
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EdgeItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Source feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSourcePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Edge_source_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_Edge_source_feature", "_UI_Edge_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
NotationPackage.Literals.EDGE__SOURCE,
true,
false,
true,
null,
null,
null));
}
/**
* This adds a property descriptor for the Target feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addTargetPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Edge_target_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_Edge_target_feature", "_UI_Edge_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
NotationPackage.Literals.EDGE__TARGET,
true,
false,
true,
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
*/
public Collection getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(NotationPackage.Literals.EDGE__BENDPOINTS);
childrenFeatures.add(NotationPackage.Literals.EDGE__SOURCE_ANCHOR);
childrenFeatures.add(NotationPackage.Literals.EDGE__TARGET_ANCHOR);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
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 adds a property descriptor for the Source Anchor feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected void addSourceAnchorPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(new ItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getString("_UI_Edge_sourceAnchor_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_Edge_sourceAnchor_feature", "_UI_Edge_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
NotationPackage.Literals.EDGE__SOURCE_ANCHOR,
true));
}
/**
* This adds a property descriptor for the Target Anchor feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected void addTargetAnchorPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(new ItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getString("_UI_Edge_targetAnchor_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_Edge_targetAnchor_feature", "_UI_Edge_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
NotationPackage.Literals.EDGE__TARGET_ANCHOR,
true));
}
/**
* This adds a property descriptor for the Bendpoints feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected void addBendpointsPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(new ItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getString("_UI_Edge_bendpoints_feature"), //$NON-NLS-1$
getString("_UI_PropertyDescriptor_description", "_UI_Edge_bendpoints_feature", "_UI_Edge_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
NotationPackage.Literals.EDGE__BENDPOINTS,
false));
}
/**
* This returns Edge.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/Edge")); //$NON-NLS-1$
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getText(Object object) {
Edge edge = (Edge)object;
return getString("_UI_Edge_type") + " " + edge.isVisible(); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* 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);
switch (notification.getFeatureID(Edge.class)) {
case NotationPackage.EDGE__BENDPOINTS:
case NotationPackage.EDGE__SOURCE_ANCHOR:
case NotationPackage.EDGE__TARGET_ANCHOR:
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
*/
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
newChildDescriptors.add
(createChildParameter
(NotationPackage.Literals.EDGE__BENDPOINTS,
NotationFactory.eINSTANCE.createRelativeBendpoints()));
newChildDescriptors.add
(createChildParameter
(NotationPackage.Literals.EDGE__SOURCE_ANCHOR,
NotationFactory.eINSTANCE.createIdentityAnchor()));
newChildDescriptors.add
(createChildParameter
(NotationPackage.Literals.EDGE__TARGET_ANCHOR,
NotationFactory.eINSTANCE.createIdentityAnchor()));
}
/**
* This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getCreateChildText(Object owner, Object feature, Object child, Collection selection) {
Object childFeature = feature;
Object childObject = child;
boolean qualify =
childFeature == NotationPackage.Literals.VIEW__PERSISTED_CHILDREN ||
childFeature == NotationPackage.Literals.VIEW__TRANSIENT_CHILDREN ||
childFeature == NotationPackage.Literals.VIEW__STYLES ||
childFeature == NotationPackage.Literals.EDGE__SOURCE_ANCHOR ||
childFeature == NotationPackage.Literals.EDGE__TARGET_ANCHOR;
if (qualify) {
return getString
("_UI_CreateChild_text2", //$NON-NLS-1$
new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) });
}
return super.getCreateChildText(owner, feature, child, selection);
}
}