KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > change > provider > FeatureChangeItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2003-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: FeatureChangeItemProvider.java,v 1.7 2005/06/08 06:17:29 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.change.provider;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.eclipse.emf.common.notify.AdapterFactory;
24 import org.eclipse.emf.common.notify.Notification;
25 import org.eclipse.emf.common.util.ResourceLocator;
26 import org.eclipse.emf.ecore.change.ChangePackage;
27 import org.eclipse.emf.ecore.change.FeatureChange;
28 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
29 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
30 import org.eclipse.emf.edit.provider.IItemLabelProvider;
31 import org.eclipse.emf.edit.provider.IItemPropertySource;
32 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
33 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
34 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
35 import org.eclipse.emf.edit.provider.ItemProviderAdapter;
36
37 import org.eclipse.emf.edit.provider.ViewerNotification;
38
39 /**
40  * This is the item provider adapter for a {@link org.eclipse.emf.ecore.change.FeatureChange} object.
41  * <!-- begin-user-doc -->
42  * <!-- end-user-doc -->
43  * @generated
44  */

45 public class FeatureChangeItemProvider
46   extends ItemProviderAdapter
47   implements
48     IEditingDomainItemProvider,
49     IStructuredItemContentProvider,
50     ITreeItemContentProvider,
51     IItemLabelProvider,
52     IItemPropertySource
53 {
54   /**
55    * This constructs an instance from a factory and a notifier.
56    * <!-- begin-user-doc -->
57    * <!-- end-user-doc -->
58    * @generated
59    */

60   public FeatureChangeItemProvider(AdapterFactory adapterFactory)
61   {
62     super(adapterFactory);
63   }
64
65   /**
66    * This returns the property descriptors for the adapted class.
67    * <!-- begin-user-doc -->
68    * <!-- end-user-doc -->
69    * @generated
70    */

71   public List JavaDoc getPropertyDescriptors(Object JavaDoc object)
72   {
73     if (itemPropertyDescriptors == null)
74     {
75       super.getPropertyDescriptors(object);
76
77       addSetPropertyDescriptor(object);
78       addValuePropertyDescriptor(object);
79       addFeaturePropertyDescriptor(object);
80     }
81     return itemPropertyDescriptors;
82   }
83
84   /**
85    * This adds a property descriptor for the Set feature.
86    * <!-- begin-user-doc -->
87    * <!-- end-user-doc -->
88    * @generated
89    */

90   protected void addSetPropertyDescriptor(Object JavaDoc object)
91   {
92     itemPropertyDescriptors.add
93       (createItemPropertyDescriptor
94         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
95          getResourceLocator(),
96          getString("_UI_FeatureChange_set_feature"),
97          getString("_UI_PropertyDescriptor_description", "_UI_FeatureChange_set_feature", "_UI_FeatureChange_type"),
98          ChangePackage.eINSTANCE.getFeatureChange_Set(),
99          true,
100          ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
101          null,
102          null));
103   }
104
105   /**
106    * This adds a property descriptor for the Value feature.
107    * <!-- begin-user-doc -->
108    * <!-- end-user-doc -->
109    * @generated
110    */

111   protected void addValuePropertyDescriptor(Object JavaDoc object)
112   {
113     itemPropertyDescriptors.add
114       (createItemPropertyDescriptor
115         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
116          getResourceLocator(),
117          getString("_UI_FeatureChange_value_feature"),
118          getString("_UI_PropertyDescriptor_description", "_UI_FeatureChange_value_feature", "_UI_FeatureChange_type"),
119          ChangePackage.eINSTANCE.getFeatureChange_Value(),
120          true,
121          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
122          null,
123          null));
124   }
125
126   /**
127    * This adds a property descriptor for the Feature feature.
128    * <!-- begin-user-doc -->
129    * <!-- end-user-doc -->
130    * @generated
131    */

132   protected void addFeaturePropertyDescriptor(Object JavaDoc object)
133   {
134     itemPropertyDescriptors.add
135       (createItemPropertyDescriptor
136         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
137          getResourceLocator(),
138          getString("_UI_FeatureChange_feature_feature"),
139          getString("_UI_PropertyDescriptor_description", "_UI_FeatureChange_feature_feature", "_UI_FeatureChange_type"),
140          ChangePackage.eINSTANCE.getFeatureChange_Feature(),
141          true,
142          null,
143          null,
144          null));
145   }
146
147   /**
148    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
149    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
150    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
151    * <!-- begin-user-doc -->
152    * <!-- end-user-doc -->
153    * @generated
154    */

155   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
156   {
157     if (childrenFeatures == null)
158     {
159       super.getChildrenFeatures(object);
160       childrenFeatures.add(ChangePackage.eINSTANCE.getFeatureChange_ListChanges());
161     }
162     return childrenFeatures;
163   }
164
165   /**
166    * This returns FeatureChange.gif.
167    * <!-- begin-user-doc -->
168    * <!-- end-user-doc -->
169    * @generated
170    */

171   public Object JavaDoc getImage(Object JavaDoc object)
172   {
173     return getResourceLocator().getImage("full/obj16/FeatureChange");
174   }
175
176   /**
177    * This returns the label text for the adapted class.
178    * <!-- begin-user-doc -->
179    * <!-- end-user-doc -->
180    * @generated
181    */

182   public String JavaDoc getText(Object JavaDoc object)
183   {
184     String JavaDoc label = ((FeatureChange)object).getFeatureName();
185     return label == null || label.length() == 0 ?
186       getString("_UI_FeatureChange_type") :
187       getString("_UI_FeatureChange_type") + " " + label;
188   }
189
190   /**
191    * This handles model notifications by calling {@link #updateChildren} to update any cached
192    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
193    * <!-- begin-user-doc -->
194    * <!-- end-user-doc -->
195    * @generated
196    */

197   public void notifyChanged(Notification notification)
198   {
199     updateChildren(notification);
200
201     switch (notification.getFeatureID(FeatureChange.class))
202     {
203       case ChangePackage.FEATURE_CHANGE__SET:
204       case ChangePackage.FEATURE_CHANGE__VALUE:
205         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
206         return;
207       case ChangePackage.FEATURE_CHANGE__LIST_CHANGES:
208         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
209         return;
210     }
211     super.notifyChanged(notification);
212   }
213
214   /**
215    * Return the resource locator for this item provider's resources.
216    * <!-- begin-user-doc -->
217    * <!-- end-user-doc -->
218    * @generated
219    */

220   public ResourceLocator getResourceLocator()
221   {
222     return ChangeEditPlugin.INSTANCE;
223   }
224
225 }
226
Popular Tags