001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id: ElementItemProvider.java 23333 2006-12-08 19:40:41Z jeichar $
006: */package net.refractions.udig.printing.model.provider;
007:
008: import java.util.Collection;
009: import java.util.List;
010:
011: import net.refractions.udig.printing.model.Element;
012: import net.refractions.udig.printing.model.ModelPackage;
013:
014: import org.eclipse.draw2d.geometry.Point;
015: import org.eclipse.emf.common.notify.AdapterFactory;
016: import org.eclipse.emf.common.notify.Notification;
017: import org.eclipse.emf.common.util.ResourceLocator;
018: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
019: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
020: import org.eclipse.emf.edit.provider.IItemLabelProvider;
021: import org.eclipse.emf.edit.provider.IItemPropertySource;
022: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
023: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
024: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
025: import org.eclipse.emf.edit.provider.ItemProviderAdapter;
026: import org.eclipse.emf.edit.provider.ViewerNotification;
027:
028: /**
029: * This is the item provider adapter for a {@link net.refractions.udig.printing.model.Element} object.
030: * <!-- begin-user-doc -->
031: * <!-- end-user-doc -->
032: * @generated
033: */
034: public class ElementItemProvider extends ItemProviderAdapter implements
035: IEditingDomainItemProvider, IStructuredItemContentProvider,
036: ITreeItemContentProvider, IItemLabelProvider,
037: IItemPropertySource {
038: /**
039: * This constructs an instance from a factory and a notifier.
040: * <!-- begin-user-doc -->
041: * <!-- end-user-doc -->
042: * @generated
043: */
044: public ElementItemProvider(AdapterFactory adapterFactory) {
045: super (adapterFactory);
046: }
047:
048: /**
049: * This returns the property descriptors for the adapted class.
050: * <!-- begin-user-doc -->
051: * <!-- end-user-doc -->
052: * @generated
053: */
054: public List getPropertyDescriptors(Object object) {
055: if (itemPropertyDescriptors == null) {
056: super .getPropertyDescriptors(object);
057:
058: addLocationPropertyDescriptor(object);
059: addSizePropertyDescriptor(object);
060: }
061: return itemPropertyDescriptors;
062: }
063:
064: /**
065: * This adds a property descriptor for the Location feature.
066: * <!-- begin-user-doc -->
067: * <!-- end-user-doc -->
068: * @generated
069: */
070: protected void addLocationPropertyDescriptor(Object object) {
071: itemPropertyDescriptors
072: .add(createItemPropertyDescriptor(
073: ((ComposeableAdapterFactory) adapterFactory)
074: .getRootAdapterFactory(),
075: getResourceLocator(),
076: getString("_UI_Element_location_feature"), //$NON-NLS-1$
077: getString(
078: "_UI_PropertyDescriptor_description", "_UI_Element_location_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
079: ModelPackage.eINSTANCE.getElement_Location(),
080: true,
081: ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
082: null, null));
083: }
084:
085: /**
086: * This adds a property descriptor for the Size feature.
087: * <!-- begin-user-doc -->
088: * <!-- end-user-doc -->
089: * @generated
090: */
091: protected void addSizePropertyDescriptor(Object object) {
092: itemPropertyDescriptors
093: .add(createItemPropertyDescriptor(
094: ((ComposeableAdapterFactory) adapterFactory)
095: .getRootAdapterFactory(),
096: getResourceLocator(),
097: getString("_UI_Element_size_feature"), //$NON-NLS-1$
098: getString(
099: "_UI_PropertyDescriptor_description", "_UI_Element_size_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
100: ModelPackage.eINSTANCE.getElement_Size(), true,
101: ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
102: null, null));
103: }
104:
105: /**
106: * This returns Element.gif.
107: * <!-- begin-user-doc -->
108: * <!-- end-user-doc -->
109: * @generated
110: */
111: public Object getImage(Object object) {
112: return getResourceLocator().getImage("full/obj16/Element"); //$NON-NLS-1$
113: }
114:
115: /**
116: * This returns the label text for the adapted class.
117: * <!-- begin-user-doc -->
118: * <!-- end-user-doc -->
119: * @generated
120: */
121: public String getText(Object object) {
122: Point labelValue = ((Element) object).getLocation();
123: String label = labelValue == null ? null : labelValue
124: .toString();
125: return label == null || label.length() == 0 ? getString("_UI_Element_type") : //$NON-NLS-1$
126: getString("_UI_Element_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
127: }
128:
129: /**
130: * This handles model notifications by calling {@link #updateChildren} to update any cached
131: * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
132: * <!-- begin-user-doc -->
133: * <!-- end-user-doc -->
134: * @generated
135: */
136: public void notifyChanged(Notification notification) {
137: updateChildren(notification);
138:
139: switch (notification.getFeatureID(Element.class)) {
140: case ModelPackage.ELEMENT__LOCATION:
141: case ModelPackage.ELEMENT__SIZE:
142: fireNotifyChanged(new ViewerNotification(notification,
143: notification.getNotifier(), false, true));
144: return;
145: }
146: super .notifyChanged(notification);
147: }
148:
149: /**
150: * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
151: * describing all of the children that can be created under this object.
152: * <!-- begin-user-doc -->
153: * <!-- end-user-doc -->
154: * @generated
155: */
156: protected void collectNewChildDescriptors(
157: Collection newChildDescriptors, Object object) {
158: super .collectNewChildDescriptors(newChildDescriptors, object);
159: }
160:
161: /**
162: * Return the resource locator for this item provider's resources.
163: * <!-- begin-user-doc -->
164: * <!-- end-user-doc -->
165: * @generated
166: */
167: public ResourceLocator getResourceLocator() {
168: return PageEditPlugin.INSTANCE;
169: }
170:
171: }
|