KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-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: EAttributeItemProvider.java,v 1.7 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.EAttribute;
27 import org.eclipse.emf.ecore.EcorePackage;
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
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.EAttribute} object.
41  * <!-- begin-user-doc -->
42  * <!-- end-user-doc -->
43  * @generated
44  */

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

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

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

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

106   protected void addEAttributeTypePropertyDescriptor(Object JavaDoc object)
107   {
108     itemPropertyDescriptors.add
109       (createItemPropertyDescriptor
110         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
111          getResourceLocator(),
112          getString("_UI_EAttribute_eAttributeType_feature"),
113          getString("_UI_PropertyDescriptor_description", "_UI_EAttribute_eAttributeType_feature", "_UI_EAttribute_type"),
114          EcorePackage.eINSTANCE.getEAttribute_EAttributeType(),
115          false,
116          null,
117          null,
118          null));
119   }
120
121   /**
122    * This returns EAttribute.gif.
123    * <!-- begin-user-doc -->
124    * <!-- end-user-doc -->
125    * @generated NOT
126    */

127   public Object JavaDoc getImage(Object JavaDoc object)
128   {
129     return getComposedImage(object, getResourceLocator().getImage("full/obj16/EAttribute"));
130   }
131
132   /**
133    * This returns the label text for the adapted class.
134    * <!-- begin-user-doc -->
135    * <!-- end-user-doc -->
136    * @generated NOT
137    */

138   public String JavaDoc getText(Object JavaDoc object)
139   {
140     EAttribute eAttribute = (EAttribute)object;
141     StringBuffer JavaDoc result = new StringBuffer JavaDoc();
142     result.append(eAttribute.getName());
143     if (eAttribute.getEType() != null)
144     {
145       result.append(" : ");
146       result.append(eAttribute.getEType().getName());
147     }
148     return result.toString();
149   }
150
151   /**
152    * This handles model notifications by calling {@link #updateChildren} to update any cached
153    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
154    * <!-- begin-user-doc -->
155    * <!-- end-user-doc -->
156    * @generated
157    */

158   public void notifyChanged(Notification notification)
159   {
160     updateChildren(notification);
161
162     switch (notification.getFeatureID(EAttribute.class))
163     {
164       case EcorePackage.EATTRIBUTE__ID:
165       case EcorePackage.EATTRIBUTE__EATTRIBUTE_TYPE:
166         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
167         return;
168     }
169     super.notifyChanged(notification);
170   }
171
172   /**
173    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
174    * describing all of the children that can be created under this object.
175    * <!-- begin-user-doc -->
176    * <!-- end-user-doc -->
177    * @generated
178    */

179   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
180   {
181     super.collectNewChildDescriptors(newChildDescriptors, object);
182   }
183
184   /**
185    * Return the resource locator for this item provider's resources.
186    * <!-- begin-user-doc -->
187    * <!-- end-user-doc -->
188    * @generated
189    */

190   public ResourceLocator getResourceLocator()
191   {
192     return EcoreEditPlugin.INSTANCE;
193   }
194
195 }
196
Popular Tags