001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id$
006: */package newprocess.provider;
007:
008: import java.util.Collection;
009: import java.util.List;
010:
011: import newprocess.Expression;
012: import newprocess.NewprocessFactory;
013: import newprocess.NewprocessPackage;
014:
015: import org.eclipse.emf.common.notify.AdapterFactory;
016: import org.eclipse.emf.common.notify.Notification;
017:
018: import org.eclipse.emf.common.util.ResourceLocator;
019:
020: import org.eclipse.emf.ecore.EStructuralFeature;
021:
022: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
023: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
024: import org.eclipse.emf.edit.provider.IItemLabelProvider;
025: import org.eclipse.emf.edit.provider.IItemPropertySource;
026: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
027: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
028: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
029: import org.eclipse.emf.edit.provider.ItemProviderAdapter;
030: import org.eclipse.emf.edit.provider.ViewerNotification;
031:
032: /**
033: * This is the item provider adapter for a {@link newprocess.Expression} object.
034: * <!-- begin-user-doc -->
035: * <!-- end-user-doc -->
036: * @generated
037: */
038: public class ExpressionItemProvider extends ItemProviderAdapter
039: implements IEditingDomainItemProvider,
040: IStructuredItemContentProvider, ITreeItemContentProvider,
041: IItemLabelProvider, IItemPropertySource {
042: /**
043: * This constructs an instance from a factory and a notifier.
044: * <!-- begin-user-doc -->
045: * <!-- end-user-doc -->
046: * @generated
047: */
048: public ExpressionItemProvider(AdapterFactory adapterFactory) {
049: super (adapterFactory);
050: }
051:
052: /**
053: * This returns the property descriptors for the adapted class.
054: * <!-- begin-user-doc -->
055: * <!-- end-user-doc -->
056: * @generated
057: */
058: public List getPropertyDescriptors(Object object) {
059: if (itemPropertyDescriptors == null) {
060: super .getPropertyDescriptors(object);
061:
062: addExpressionPropertyDescriptor(object);
063: }
064: return itemPropertyDescriptors;
065: }
066:
067: /**
068: * This adds a property descriptor for the Expression feature.
069: * <!-- begin-user-doc -->
070: * <!-- end-user-doc -->
071: * @generated
072: */
073: protected void addExpressionPropertyDescriptor(Object object) {
074: itemPropertyDescriptors
075: .add(createItemPropertyDescriptor(
076: ((ComposeableAdapterFactory) adapterFactory)
077: .getRootAdapterFactory(),
078: getResourceLocator(),
079: getString("_UI_Expression_expression_feature"),
080: getString("_UI_PropertyDescriptor_description",
081: "_UI_Expression_expression_feature",
082: "_UI_Expression_type"),
083: NewprocessPackage.Literals.EXPRESSION__EXPRESSION,
084: false, false, false,
085: ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
086: null, null));
087: }
088:
089: /**
090: * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
091: * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
092: * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
093: * <!-- begin-user-doc -->
094: * <!-- end-user-doc -->
095: * @generated
096: */
097: public Collection getChildrenFeatures(Object object) {
098: if (childrenFeatures == null) {
099: super .getChildrenFeatures(object);
100: childrenFeatures
101: .add(NewprocessPackage.Literals.EXPRESSION__HAS_TERMS);
102: childrenFeatures
103: .add(NewprocessPackage.Literals.EXPRESSION__HAS_ROOT);
104: }
105: return childrenFeatures;
106: }
107:
108: /**
109: * <!-- begin-user-doc -->
110: * <!-- end-user-doc -->
111: * @generated
112: */
113: protected EStructuralFeature getChildFeature(Object object,
114: Object child) {
115: // Check the type of the specified child object and return the proper feature to use for
116: // adding (see {@link AddCommand}) it as a child.
117:
118: return super .getChildFeature(object, child);
119: }
120:
121: /**
122: * This returns Expression.gif.
123: * <!-- begin-user-doc -->
124: * <!-- end-user-doc -->
125: * @generated
126: */
127: public Object getImage(Object object) {
128: return overlayImage(object, getResourceLocator().getImage(
129: "full/obj16/Expression"));
130: }
131:
132: /**
133: * This returns the label text for the adapted class.
134: * <!-- begin-user-doc -->
135: * <!-- end-user-doc -->
136: * @generated
137: */
138: public String getText(Object object) {
139: String label = ((Expression) object).getExpression();
140: return label == null || label.length() == 0 ? getString("_UI_Expression_type")
141: : getString("_UI_Expression_type") + " " + label;
142: }
143:
144: /**
145: * This handles model notifications by calling {@link #updateChildren} to update any cached
146: * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
147: * <!-- begin-user-doc -->
148: * <!-- end-user-doc -->
149: * @generated
150: */
151: public void notifyChanged(Notification notification) {
152: updateChildren(notification);
153:
154: switch (notification.getFeatureID(Expression.class)) {
155: case NewprocessPackage.EXPRESSION__EXPRESSION:
156: fireNotifyChanged(new ViewerNotification(notification,
157: notification.getNotifier(), false, true));
158: return;
159: case NewprocessPackage.EXPRESSION__HAS_TERMS:
160: case NewprocessPackage.EXPRESSION__HAS_ROOT:
161: fireNotifyChanged(new ViewerNotification(notification,
162: notification.getNotifier(), true, false));
163: return;
164: }
165: super .notifyChanged(notification);
166: }
167:
168: /**
169: * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
170: * describing all of the children that can be created under this object.
171: * <!-- begin-user-doc -->
172: * <!-- end-user-doc -->
173: * @generated
174: */
175: protected void collectNewChildDescriptors(
176: Collection newChildDescriptors, Object object) {
177: super .collectNewChildDescriptors(newChildDescriptors, object);
178:
179: newChildDescriptors.add(createChildParameter(
180: NewprocessPackage.Literals.EXPRESSION__HAS_TERMS,
181: NewprocessFactory.eINSTANCE.createTerm()));
182:
183: newChildDescriptors.add(createChildParameter(
184: NewprocessPackage.Literals.EXPRESSION__HAS_TERMS,
185: NewprocessFactory.eINSTANCE.createConditionTerm()));
186:
187: newChildDescriptors.add(createChildParameter(
188: NewprocessPackage.Literals.EXPRESSION__HAS_TERMS,
189: NewprocessFactory.eINSTANCE.createOperatorTerm()));
190:
191: newChildDescriptors.add(createChildParameter(
192: NewprocessPackage.Literals.EXPRESSION__HAS_TERMS,
193: NewprocessFactory.eINSTANCE.createOrOperator()));
194:
195: newChildDescriptors.add(createChildParameter(
196: NewprocessPackage.Literals.EXPRESSION__HAS_TERMS,
197: NewprocessFactory.eINSTANCE.createAndOperator()));
198:
199: newChildDescriptors.add(createChildParameter(
200: NewprocessPackage.Literals.EXPRESSION__HAS_ROOT,
201: NewprocessFactory.eINSTANCE.createRoot()));
202: }
203:
204: /**
205: * Return the resource locator for this item provider's resources.
206: * <!-- begin-user-doc -->
207: * <!-- end-user-doc -->
208: * @generated
209: */
210: public ResourceLocator getResourceLocator() {
211: return New_processEditPlugin.INSTANCE;
212: }
213:
214: }
|