001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id: ConnectionItemProvider.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.Connection;
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.ViewerNotification;
026:
027: /**
028: * This is the item provider adapter for a {@link net.refractions.udig.printing.model.Connection} object.
029: * <!-- begin-user-doc -->
030: * <!-- end-user-doc -->
031: * @generated
032: */
033: public class ConnectionItemProvider extends ElementItemProvider
034: implements IEditingDomainItemProvider,
035: IStructuredItemContentProvider, ITreeItemContentProvider,
036: IItemLabelProvider, IItemPropertySource {
037: /**
038: * This constructs an instance from a factory and a notifier.
039: * <!-- begin-user-doc -->
040: * <!-- end-user-doc -->
041: * @generated
042: */
043: public ConnectionItemProvider(AdapterFactory adapterFactory) {
044: super (adapterFactory);
045: }
046:
047: /**
048: * This returns the property descriptors for the adapted class.
049: * <!-- begin-user-doc -->
050: * <!-- end-user-doc -->
051: * @generated
052: */
053: public List getPropertyDescriptors(Object object) {
054: if (itemPropertyDescriptors == null) {
055: super .getPropertyDescriptors(object);
056:
057: addConnectedPropertyDescriptor(object);
058: addSourcePropertyDescriptor(object);
059: addTargetPropertyDescriptor(object);
060: }
061: return itemPropertyDescriptors;
062: }
063:
064: /**
065: * This adds a property descriptor for the Connected feature.
066: * <!-- begin-user-doc -->
067: * <!-- end-user-doc -->
068: * @generated
069: */
070: protected void addConnectedPropertyDescriptor(Object object) {
071: itemPropertyDescriptors
072: .add(createItemPropertyDescriptor(
073: ((ComposeableAdapterFactory) adapterFactory)
074: .getRootAdapterFactory(),
075: getResourceLocator(),
076: getString("_UI_Connection_connected_feature"), //$NON-NLS-1$
077: getString(
078: "_UI_PropertyDescriptor_description", "_UI_Connection_connected_feature", "_UI_Connection_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
079: ModelPackage.eINSTANCE
080: .getConnection_Connected(), true,
081: ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
082: null, null));
083: }
084:
085: /**
086: * This adds a property descriptor for the Source feature.
087: * <!-- begin-user-doc -->
088: * <!-- end-user-doc -->
089: * @generated
090: */
091: protected void addSourcePropertyDescriptor(Object object) {
092: itemPropertyDescriptors
093: .add(createItemPropertyDescriptor(
094: ((ComposeableAdapterFactory) adapterFactory)
095: .getRootAdapterFactory(),
096: getResourceLocator(),
097: getString("_UI_Connection_source_feature"), //$NON-NLS-1$
098: getString(
099: "_UI_PropertyDescriptor_description", "_UI_Connection_source_feature", "_UI_Connection_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
100: ModelPackage.eINSTANCE.getConnection_Source(),
101: true, null, null, null));
102: }
103:
104: /**
105: * This adds a property descriptor for the Target feature.
106: * <!-- begin-user-doc -->
107: * <!-- end-user-doc -->
108: * @generated
109: */
110: protected void addTargetPropertyDescriptor(Object object) {
111: itemPropertyDescriptors
112: .add(createItemPropertyDescriptor(
113: ((ComposeableAdapterFactory) adapterFactory)
114: .getRootAdapterFactory(),
115: getResourceLocator(),
116: getString("_UI_Connection_target_feature"), //$NON-NLS-1$
117: getString(
118: "_UI_PropertyDescriptor_description", "_UI_Connection_target_feature", "_UI_Connection_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
119: ModelPackage.eINSTANCE.getConnection_Target(),
120: true, null, null, null));
121: }
122:
123: /**
124: * This returns Connection.gif.
125: * <!-- begin-user-doc -->
126: * <!-- end-user-doc -->
127: * @generated
128: */
129: public Object getImage(Object object) {
130: return getResourceLocator().getImage("full/obj16/Connection"); //$NON-NLS-1$
131: }
132:
133: /**
134: * This returns the label text for the adapted class.
135: * <!-- begin-user-doc -->
136: * <!-- end-user-doc -->
137: * @generated
138: */
139: public String getText(Object object) {
140: Point labelValue = ((Connection) object).getLocation();
141: String label = labelValue == null ? null : labelValue
142: .toString();
143: return label == null || label.length() == 0 ? getString("_UI_Connection_type") : //$NON-NLS-1$
144: getString("_UI_Connection_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
145: }
146:
147: /**
148: * This handles model notifications by calling {@link #updateChildren} to update any cached
149: * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
150: * <!-- begin-user-doc -->
151: * <!-- end-user-doc -->
152: * @generated
153: */
154: public void notifyChanged(Notification notification) {
155: updateChildren(notification);
156:
157: switch (notification.getFeatureID(Connection.class)) {
158: case ModelPackage.CONNECTION__CONNECTED:
159: fireNotifyChanged(new ViewerNotification(notification,
160: notification.getNotifier(), false, true));
161: return;
162: }
163: super .notifyChanged(notification);
164: }
165:
166: /**
167: * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
168: * describing all of the children that can be created under this object.
169: * <!-- begin-user-doc -->
170: * <!-- end-user-doc -->
171: * @generated
172: */
173: protected void collectNewChildDescriptors(
174: Collection newChildDescriptors, Object object) {
175: super .collectNewChildDescriptors(newChildDescriptors, object);
176: }
177:
178: /**
179: * Return the resource locator for this item provider's resources.
180: * <!-- begin-user-doc -->
181: * <!-- end-user-doc -->
182: * @generated
183: */
184: public ResourceLocator getResourceLocator() {
185: return PageEditPlugin.INSTANCE;
186: }
187:
188: }
|