KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > genmodel > provider > GenEnumItemProvider


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: GenEnumItemProvider.java,v 1.9 2005/06/08 06:17:51 nickb Exp $
16  */

17 package org.eclipse.emf.codegen.ecore.genmodel.provider;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.eclipse.emf.codegen.ecore.genmodel.GenEnum;
24 import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
25 import org.eclipse.emf.common.notify.AdapterFactory;
26 import org.eclipse.emf.common.notify.Notification;
27 import org.eclipse.emf.common.util.ResourceLocator;
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
35 import org.eclipse.emf.edit.provider.ViewerNotification;
36
37 // import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
38

39
40 /**
41  * This is the item provider adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenEnum} object.
42  * <!-- begin-user-doc -->
43  * <!-- end-user-doc -->
44  * @generated
45  */

46 public class GenEnumItemProvider
47   extends GenDataTypeItemProvider
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 GenEnumItemProvider(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       addEcoreEnumPropertyDescriptor(object);
75     }
76     return itemPropertyDescriptors;
77   }
78
79   /**
80    * This adds a property descriptor for the Ecore Enum feature.
81    * <!-- begin-user-doc -->
82    * <!-- end-user-doc -->
83    * @generated
84    */

85   protected void addEcoreEnumPropertyDescriptor(Object JavaDoc object)
86   {
87     itemPropertyDescriptors.add
88       (createItemPropertyDescriptor
89         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
90          getResourceLocator(),
91          getString("_UI_GenEnum_ecoreEnum_feature"),
92          getString("_UI_GenEnum_ecoreEnum_description"),
93          GenModelPackage.eINSTANCE.getGenEnum_EcoreEnum(),
94          false,
95          null,
96          getString("_UI_EcorePropertyCategory"),
97          null));
98   }
99
100   /**
101    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
102    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
103    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
104    * <!-- begin-user-doc -->
105    * <!-- end-user-doc -->
106    * @generated
107    */

108   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
109   {
110     if (childrenFeatures == null)
111     {
112       super.getChildrenFeatures(object);
113       childrenFeatures.add(GenModelPackage.eINSTANCE.getGenEnum_GenEnumLiterals());
114     }
115     return childrenFeatures;
116   }
117
118   /**
119    */

120   public Object JavaDoc getImage(Object JavaDoc object)
121   {
122     return new UnderlayedImage(getResourceLocator().getImage("full/obj16/EEnum"));
123   }
124
125   /**
126    * This returns the label text for the adapted class.
127    */

128   public String JavaDoc getText(Object JavaDoc object)
129   {
130     GenEnum genEnum = (GenEnum)object;
131     return genEnum.getEcoreEnum().getName();
132   }
133
134   /**
135    * This handles model notifications by calling {@link #updateChildren} to update any cached
136    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
137    * <!-- begin-user-doc -->
138    * <!-- end-user-doc -->
139    * @generated
140    */

141   public void notifyChanged(Notification notification)
142   {
143     updateChildren(notification);
144
145     switch (notification.getFeatureID(GenEnum.class))
146     {
147       case GenModelPackage.GEN_ENUM__ECORE_ENUM:
148         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
149         return;
150       case GenModelPackage.GEN_ENUM__GEN_ENUM_LITERALS:
151         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
152         return;
153     }
154     super.notifyChanged(notification);
155   }
156
157   /**
158    * Return the resource locator for this item provider's resources.
159    * <!-- begin-user-doc -->
160    * <!-- end-user-doc -->
161    * @generated
162    */

163   public ResourceLocator getResourceLocator()
164   {
165     return GenModelEditPlugin.INSTANCE;
166   }
167
168 }
169
Popular Tags