KickJava   Java API By Example, From Geeks To Geeks.

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


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: ChangeDescriptionItemProvider.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.EStructuralFeature;
27
28 import org.eclipse.emf.ecore.change.ChangeDescription;
29 import org.eclipse.emf.ecore.change.ChangePackage;
30 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
31 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
32 import org.eclipse.emf.edit.provider.IItemLabelProvider;
33 import org.eclipse.emf.edit.provider.IItemPropertySource;
34 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
35 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
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.ChangeDescription} object.
42  * <!-- begin-user-doc -->
43  * <!-- end-user-doc -->
44  * @generated
45  */

46 public class ChangeDescriptionItemProvider
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 ChangeDescriptionItemProvider(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       addObjectsToDetachPropertyDescriptor(object);
79     }
80     return itemPropertyDescriptors;
81   }
82
83   /**
84    * This adds a property descriptor for the Objects To Detach feature.
85    * <!-- begin-user-doc -->
86    * <!-- end-user-doc -->
87    * @generated
88    */

89   protected void addObjectsToDetachPropertyDescriptor(Object JavaDoc object)
90   {
91     itemPropertyDescriptors.add
92       (createItemPropertyDescriptor
93         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
94          getResourceLocator(),
95          getString("_UI_ChangeDescription_objectsToDetach_feature"),
96          getString("_UI_PropertyDescriptor_description", "_UI_ChangeDescription_objectsToDetach_feature", "_UI_ChangeDescription_type"),
97          ChangePackage.eINSTANCE.getChangeDescription_ObjectsToDetach(),
98          true,
99          null,
100          null,
101          null));
102   }
103
104   /**
105    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
106    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
107    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
108    * <!-- begin-user-doc -->
109    * <!-- end-user-doc -->
110    * @generated
111    */

112   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
113   {
114     if (childrenFeatures == null)
115     {
116       super.getChildrenFeatures(object);
117       childrenFeatures.add(ChangePackage.eINSTANCE.getChangeDescription_ObjectChanges());
118       childrenFeatures.add(ChangePackage.eINSTANCE.getChangeDescription_ObjectsToAttach());
119       childrenFeatures.add(ChangePackage.eINSTANCE.getChangeDescription_ResourceChanges());
120     }
121     return childrenFeatures;
122   }
123
124   /**
125    * <!-- begin-user-doc -->
126    * <!-- end-user-doc -->
127    * @generated
128    */

129   protected EStructuralFeature getChildFeature(Object JavaDoc object, Object JavaDoc child)
130   {
131     // Check the type of the specified child object and return the proper feature to use for
132
// adding (see {@link AddCommand}) it as a child.
133

134     return super.getChildFeature(object, child);
135   }
136
137   /**
138    * This returns ChangeDescription.gif.
139    * <!-- begin-user-doc -->
140    * <!-- end-user-doc -->
141    * @generated
142    */

143   public Object JavaDoc getImage(Object JavaDoc object)
144   {
145     return getResourceLocator().getImage("full/obj16/ChangeDescription");
146   }
147
148   /**
149    * This returns the label text for the adapted class.
150    * <!-- begin-user-doc -->
151    * <!-- end-user-doc -->
152    * @generated
153    */

154   public String JavaDoc getText(Object JavaDoc object)
155   {
156     return getString("_UI_ChangeDescription_type");
157   }
158
159   /**
160    * This handles model notifications by calling {@link #updateChildren} to update any cached
161    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
162    * <!-- begin-user-doc -->
163    * <!-- end-user-doc -->
164    * @generated
165    */

166   public void notifyChanged(Notification notification)
167   {
168     updateChildren(notification);
169
170     switch (notification.getFeatureID(ChangeDescription.class))
171     {
172       case ChangePackage.CHANGE_DESCRIPTION__OBJECT_CHANGES:
173       case ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_ATTACH:
174       case ChangePackage.CHANGE_DESCRIPTION__RESOURCE_CHANGES:
175         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
176         return;
177     }
178     super.notifyChanged(notification);
179   }
180
181   /**
182    * Return the resource locator for this item provider's resources.
183    * <!-- begin-user-doc -->
184    * <!-- end-user-doc -->
185    * @generated
186    */

187   public ResourceLocator getResourceLocator()
188   {
189     return ChangeEditPlugin.INSTANCE;
190   }
191
192 }
193
Popular Tags