KickJava   Java API By Example, From Geeks To Geeks.

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


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: EEnumLiteralItemProvider.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.EEnumLiteral;
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.EEnumLiteral} object.
41  * <!-- begin-user-doc -->
42  * <!-- end-user-doc -->
43  * @generated
44  */

45 public class EEnumLiteralItemProvider
46   extends ENamedElementItemProvider
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 EEnumLiteralItemProvider(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       addValuePropertyDescriptor(object);
74       addInstancePropertyDescriptor(object);
75     }
76     return itemPropertyDescriptors;
77   }
78
79   /**
80    * This adds a property descriptor for the Value feature.
81    * <!-- begin-user-doc -->
82    * <!-- end-user-doc -->
83    * @generated
84    */

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

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

127   public Object JavaDoc getImage(Object JavaDoc object)
128   {
129     return getResourceLocator().getImage("full/obj16/EEnumLiteral");
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     EEnumLiteral eEnumLiteral = (EEnumLiteral)object;
141     StringBuffer JavaDoc result = new StringBuffer JavaDoc();
142     result.append(eEnumLiteral.getName());
143     result.append(" = ");
144     result.append(eEnumLiteral.getValue());
145     return result.toString();
146   }
147
148   /**
149    * This handles model notifications by calling {@link #updateChildren} to update any cached
150    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
151    * <!-- begin-user-doc -->
152    * <!-- end-user-doc -->
153    * @generated
154    */

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

176   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
177   {
178     super.collectNewChildDescriptors(newChildDescriptors, object);
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 EcoreEditPlugin.INSTANCE;
190   }
191
192 }
193
Popular Tags