KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > provider > EAnnotationItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2005 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: EAnnotationItemProvider.java,v 1.10 2005/06/08 06:15:46 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.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.EAnnotation;
27 import org.eclipse.emf.ecore.EStructuralFeature;
28 import org.eclipse.emf.ecore.EcoreFactory;
29 import org.eclipse.emf.ecore.EcorePackage;
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.ItemPropertyDescriptor;
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.EAnnotation} object.
42  * <!-- begin-user-doc -->
43  * <!-- end-user-doc -->
44  * @generated
45  */

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

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

68   public List JavaDoc getPropertyDescriptors(Object JavaDoc object)
69   {
70     if (itemPropertyDescriptors == null)
71     {
72       super.getPropertyDescriptors(object);
73
74       addSourcePropertyDescriptor(object);
75       addReferencesPropertyDescriptor(object);
76     }
77     return itemPropertyDescriptors;
78   }
79
80   /**
81    * This adds a property descriptor for the Source feature.
82    * <!-- begin-user-doc -->
83    * <!-- end-user-doc -->
84    * @generated
85    */

86   protected void addSourcePropertyDescriptor(Object JavaDoc object)
87   {
88     itemPropertyDescriptors.add
89       (createItemPropertyDescriptor
90         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
91          getResourceLocator(),
92          getString("_UI_EAnnotation_source_feature"),
93          getString("_UI_PropertyDescriptor_description", "_UI_EAnnotation_source_feature", "_UI_EAnnotation_type"),
94          EcorePackage.eINSTANCE.getEAnnotation_Source(),
95          true,
96          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
97          null,
98          null));
99   }
100
101   /**
102    * This adds a property descriptor for the References feature.
103    * <!-- begin-user-doc -->
104    * <!-- end-user-doc -->
105    * @generated
106    */

107   protected void addReferencesPropertyDescriptor(Object JavaDoc object)
108   {
109     itemPropertyDescriptors.add
110       (createItemPropertyDescriptor
111         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
112          getResourceLocator(),
113          getString("_UI_EAnnotation_references_feature"),
114          getString("_UI_PropertyDescriptor_description", "_UI_EAnnotation_references_feature", "_UI_EAnnotation_type"),
115          EcorePackage.eINSTANCE.getEAnnotation_References(),
116          true,
117          null,
118          null,
119          null));
120   }
121
122   /**
123    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
124    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
125    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
126    * <!-- begin-user-doc -->
127    * <!-- end-user-doc -->
128    * @generated
129    */

130   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
131   {
132     if (childrenFeatures == null)
133     {
134       super.getChildrenFeatures(object);
135       childrenFeatures.add(EcorePackage.eINSTANCE.getEAnnotation_Details());
136       childrenFeatures.add(EcorePackage.eINSTANCE.getEAnnotation_Contents());
137     }
138     return childrenFeatures;
139   }
140
141   /**
142    * <!-- begin-user-doc -->
143    * <!-- end-user-doc -->
144    * @generated
145    */

146   protected EStructuralFeature getChildFeature(Object JavaDoc object, Object JavaDoc child)
147   {
148     // Check the type of the specified child object and return the proper feature to use for
149
// adding (see {@link AddCommand}) it as a child.
150

151     return super.getChildFeature(object, child);
152   }
153
154   /**
155    * This returns EAnnotation.gif.
156    * <!-- begin-user-doc -->
157    * <!-- end-user-doc -->
158    * @generated
159    */

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

171   public String JavaDoc getText(Object JavaDoc object)
172   {
173     EAnnotation eAnnotation = (EAnnotation)object;
174     StringBuffer JavaDoc result = new StringBuffer JavaDoc();
175     if (eAnnotation.getSource() != null)
176     {
177       int index = eAnnotation.getSource().lastIndexOf("/");
178       if (index == -1)
179       {
180         result.append(eAnnotation.getSource());
181       }
182       else
183       {
184         result.append(eAnnotation.getSource().substring(index + 1));
185       }
186     }
187     return result.toString();
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(EAnnotation.class))
202     {
203       case EcorePackage.EANNOTATION__SOURCE:
204         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
205         return;
206       case EcorePackage.EANNOTATION__DETAILS:
207       case EcorePackage.EANNOTATION__CONTENTS:
208         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
209         return;
210     }
211     super.notifyChanged(notification);
212   }
213
214   /**
215    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
216    * describing all of the children that can be created under this object.
217    * <!-- begin-user-doc -->
218    * <!-- end-user-doc -->
219    * @generated NOT
220    */

221   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
222   {
223     // super.collectNewChildDescriptors(newChildDescriptors, object);
224

225     newChildDescriptors.add
226     (createChildParameter
227       (EcorePackage.eINSTANCE.getEAnnotation_Details(),
228        EcoreFactory.eINSTANCE.create(EcorePackage.eINSTANCE.getEStringToStringMapEntry())));
229   }
230
231   /**
232    * Return the resource locator for this item provider's resources.
233    * <!-- begin-user-doc -->
234    * <!-- end-user-doc -->
235    * @generated
236    */

237   public ResourceLocator getResourceLocator()
238   {
239     return EcoreEditPlugin.INSTANCE;
240   }
241
242 }
243
Popular Tags