KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * <copyright>
3  * </copyright>
4  *
5  * $Id: ResourceChangeItemProvider.java,v 1.6 2005/05/10 11:19:58 emerks Exp $
6  */

7 package org.eclipse.emf.ecore.change.provider;
8
9
10 import java.util.Collection JavaDoc;
11 import java.util.List JavaDoc;
12
13 import org.eclipse.emf.common.notify.AdapterFactory;
14 import org.eclipse.emf.common.notify.Notification;
15 import org.eclipse.emf.common.util.ResourceLocator;
16 import org.eclipse.emf.ecore.change.ChangePackage;
17 import org.eclipse.emf.ecore.change.ResourceChange;
18 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
19 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
20 import org.eclipse.emf.edit.provider.IItemLabelProvider;
21 import org.eclipse.emf.edit.provider.IItemPropertySource;
22 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
23 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
24 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
25 import org.eclipse.emf.edit.provider.ItemProviderAdapter;
26
27 import org.eclipse.emf.edit.provider.ViewerNotification;
28
29 /**
30  * This is the item provider adapter for a {@link org.eclipse.emf.ecore.change.ResourceChange} object.
31  * <!-- begin-user-doc -->
32  * <!-- end-user-doc -->
33  * @generated
34  */

35 public class ResourceChangeItemProvider
36   extends ItemProviderAdapter
37   implements
38     IEditingDomainItemProvider,
39     IStructuredItemContentProvider,
40     ITreeItemContentProvider,
41     IItemLabelProvider,
42     IItemPropertySource
43 {
44   /**
45    * This constructs an instance from a factory and a notifier.
46    * <!-- begin-user-doc -->
47    * <!-- end-user-doc -->
48    * @generated
49    */

50   public ResourceChangeItemProvider(AdapterFactory adapterFactory)
51   {
52     super(adapterFactory);
53   }
54
55   /**
56    * This returns the property descriptors for the adapted class.
57    * <!-- begin-user-doc -->
58    * <!-- end-user-doc -->
59    * @generated
60    */

61   public List JavaDoc getPropertyDescriptors(Object JavaDoc object)
62   {
63     if (itemPropertyDescriptors == null)
64     {
65       super.getPropertyDescriptors(object);
66
67       addResourceURIPropertyDescriptor(object);
68       addResourcePropertyDescriptor(object);
69       addValuePropertyDescriptor(object);
70     }
71     return itemPropertyDescriptors;
72   }
73
74   /**
75    * This adds a property descriptor for the Resource URI feature.
76    * <!-- begin-user-doc -->
77    * <!-- end-user-doc -->
78    * @generated
79    */

80   protected void addResourceURIPropertyDescriptor(Object JavaDoc object)
81   {
82     itemPropertyDescriptors.add
83       (createItemPropertyDescriptor
84         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
85          getResourceLocator(),
86          getString("_UI_ResourceChange_resourceURI_feature"),
87          getString("_UI_PropertyDescriptor_description", "_UI_ResourceChange_resourceURI_feature", "_UI_ResourceChange_type"),
88          ChangePackage.eINSTANCE.getResourceChange_ResourceURI(),
89          true,
90          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
91          null,
92          null));
93   }
94
95   /**
96    * This adds a property descriptor for the Resource feature.
97    * <!-- begin-user-doc -->
98    * <!-- end-user-doc -->
99    * @generated
100    */

101   protected void addResourcePropertyDescriptor(Object JavaDoc object)
102   {
103     itemPropertyDescriptors.add
104       (createItemPropertyDescriptor
105         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
106          getResourceLocator(),
107          getString("_UI_ResourceChange_resource_feature"),
108          getString("_UI_PropertyDescriptor_description", "_UI_ResourceChange_resource_feature", "_UI_ResourceChange_type"),
109          ChangePackage.eINSTANCE.getResourceChange_Resource(),
110          true,
111          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
112          null,
113          null));
114   }
115
116   /**
117    * This adds a property descriptor for the Value feature.
118    * <!-- begin-user-doc -->
119    * <!-- end-user-doc -->
120    * @generated
121    */

122   protected void addValuePropertyDescriptor(Object JavaDoc object)
123   {
124     itemPropertyDescriptors.add
125       (createItemPropertyDescriptor
126         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
127          getResourceLocator(),
128          getString("_UI_ResourceChange_value_feature"),
129          getString("_UI_PropertyDescriptor_description", "_UI_ResourceChange_value_feature", "_UI_ResourceChange_type"),
130          ChangePackage.eINSTANCE.getResourceChange_Value(),
131          true,
132          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
133          null,
134          null));
135   }
136
137   /**
138    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
139    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
140    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
141    * <!-- begin-user-doc -->
142    * <!-- end-user-doc -->
143    * @generated
144    */

145   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
146   {
147     if (childrenFeatures == null)
148     {
149       super.getChildrenFeatures(object);
150       childrenFeatures.add(ChangePackage.eINSTANCE.getResourceChange_ListChanges());
151     }
152     return childrenFeatures;
153   }
154
155   /**
156    * This returns ResourceChange.gif.
157    * <!-- begin-user-doc -->
158    * <!-- end-user-doc -->
159    * @generated
160    */

161   public Object JavaDoc getImage(Object JavaDoc object)
162   {
163     return getResourceLocator().getImage("full/obj16/ResourceChange");
164   }
165
166   /**
167    * This returns the label text for the adapted class.
168    * <!-- begin-user-doc -->
169    * <!-- end-user-doc -->
170    * @generated
171    */

172   public String JavaDoc getText(Object JavaDoc object)
173   {
174     String JavaDoc label = ((ResourceChange)object).getResourceURI();
175     return label == null || label.length() == 0 ?
176       getString("_UI_ResourceChange_type") :
177       getString("_UI_ResourceChange_type") + " " + label;
178   }
179
180   /**
181    * This handles model notifications by calling {@link #updateChildren} to update any cached
182    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
183    * <!-- begin-user-doc -->
184    * <!-- end-user-doc -->
185    * @generated
186    */

187   public void notifyChanged(Notification notification)
188   {
189     updateChildren(notification);
190
191     switch (notification.getFeatureID(ResourceChange.class))
192     {
193       case ChangePackage.RESOURCE_CHANGE__RESOURCE_URI:
194       case ChangePackage.RESOURCE_CHANGE__RESOURCE:
195       case ChangePackage.RESOURCE_CHANGE__VALUE:
196         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
197         return;
198       case ChangePackage.RESOURCE_CHANGE__LIST_CHANGES:
199         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
200         return;
201     }
202     super.notifyChanged(notification);
203   }
204
205   /**
206    * Return the resource locator for this item provider's resources.
207    * <!-- begin-user-doc -->
208    * <!-- end-user-doc -->
209    * @generated
210    */

211   public ResourceLocator getResourceLocator()
212   {
213     return ChangeEditPlugin.INSTANCE;
214   }
215
216 }
217
Popular Tags