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