KickJava   Java API By Example, From Geeks To Geeks.

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


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: ListChangeItemProvider.java,v 1.8 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.ChangeKind;
27 import org.eclipse.emf.ecore.change.ChangePackage;
28 import org.eclipse.emf.ecore.change.ListChange;
29 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
30 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
31 import org.eclipse.emf.edit.provider.IItemLabelProvider;
32 import org.eclipse.emf.edit.provider.IItemPropertySource;
33 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
34 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
35 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
36 import org.eclipse.emf.edit.provider.ItemProviderAdapter;
37
38 import org.eclipse.emf.edit.provider.ViewerNotification;
39
40 /**
41  * This is the item provider adapter for a {@link org.eclipse.emf.ecore.change.ListChange} object.
42  * <!-- begin-user-doc -->
43  * <!-- end-user-doc -->
44  * @generated
45  */

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

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

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

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

113   protected void addIndexPropertyDescriptor(Object JavaDoc object)
114   {
115     itemPropertyDescriptors.add
116       (createItemPropertyDescriptor
117         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
118          getResourceLocator(),
119          getString("_UI_ListChange_index_feature"),
120          getString("_UI_PropertyDescriptor_description", "_UI_ListChange_index_feature", "_UI_ListChange_type"),
121          ChangePackage.eINSTANCE.getListChange_Index(),
122          true,
123          ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
124          null,
125          null));
126   }
127
128   /**
129    * This adds a property descriptor for the Move To Index feature.
130    * <!-- begin-user-doc -->
131    * <!-- end-user-doc -->
132    * @generated
133    */

134   protected void addMoveToIndexPropertyDescriptor(Object JavaDoc object)
135   {
136     itemPropertyDescriptors.add
137       (createItemPropertyDescriptor
138         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
139          getResourceLocator(),
140          getString("_UI_ListChange_moveToIndex_feature"),
141          getString("_UI_PropertyDescriptor_description", "_UI_ListChange_moveToIndex_feature", "_UI_ListChange_type"),
142          ChangePackage.eINSTANCE.getListChange_MoveToIndex(),
143          true,
144          ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
145          null,
146          null));
147   }
148
149   /**
150    * This adds a property descriptor for the Values feature.
151    * <!-- begin-user-doc -->
152    * <!-- end-user-doc -->
153    * @generated
154    */

155   protected void addValuesPropertyDescriptor(Object JavaDoc object)
156   {
157     itemPropertyDescriptors.add
158       (createItemPropertyDescriptor
159         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
160          getResourceLocator(),
161          getString("_UI_ListChange_values_feature"),
162          getString("_UI_PropertyDescriptor_description", "_UI_ListChange_values_feature", "_UI_ListChange_type"),
163          ChangePackage.eINSTANCE.getListChange_Values(),
164          true,
165          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
166          null,
167          null));
168   }
169
170   /**
171    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
172    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
173    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
174    * <!-- begin-user-doc -->
175    * <!-- end-user-doc -->
176    * @generated
177    */

178   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
179   {
180     if (childrenFeatures == null)
181     {
182       super.getChildrenFeatures(object);
183       childrenFeatures.add(ChangePackage.eINSTANCE.getListChange_FeatureMapEntryValues());
184     }
185     return childrenFeatures;
186   }
187
188   /**
189    * This returns ListChange.gif.
190    * <!-- begin-user-doc -->
191    * <!-- end-user-doc -->
192    * @generated
193    */

194   public Object JavaDoc getImage(Object JavaDoc object)
195   {
196     return getResourceLocator().getImage("full/obj16/ListChange");
197   }
198
199   /**
200    * This returns the label text for the adapted class.
201    * <!-- begin-user-doc -->
202    * <!-- end-user-doc -->
203    * @generated
204    */

205   public String JavaDoc getText(Object JavaDoc object)
206   {
207     ChangeKind labelValue = ((ListChange)object).getKind();
208     String JavaDoc label = labelValue == null ? null : labelValue.toString();
209     return label == null || label.length() == 0 ?
210       getString("_UI_ListChange_type") :
211       getString("_UI_ListChange_type") + " " + label;
212   }
213
214   /**
215    * This handles model notifications by calling {@link #updateChildren} to update any cached
216    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
217    * <!-- begin-user-doc -->
218    * <!-- end-user-doc -->
219    * @generated
220    */

221   public void notifyChanged(Notification notification)
222   {
223     updateChildren(notification);
224
225     switch (notification.getFeatureID(ListChange.class))
226     {
227       case ChangePackage.LIST_CHANGE__KIND:
228       case ChangePackage.LIST_CHANGE__INDEX:
229       case ChangePackage.LIST_CHANGE__MOVE_TO_INDEX:
230       case ChangePackage.LIST_CHANGE__VALUES:
231         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
232         return;
233       case ChangePackage.LIST_CHANGE__FEATURE_MAP_ENTRY_VALUES:
234         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
235         return;
236     }
237     super.notifyChanged(notification);
238   }
239
240   /**
241    * Return the resource locator for this item provider's resources.
242    * <!-- begin-user-doc -->
243    * <!-- end-user-doc -->
244    * @generated
245    */

246   public ResourceLocator getResourceLocator()
247   {
248     return ChangeEditPlugin.INSTANCE;
249   }
250
251 }
252
Popular Tags