KickJava   Java API By Example, From Geeks To Geeks.

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


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

45 public class EClassifierItemProvider
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 EClassifierItemProvider(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       addInstanceClassNamePropertyDescriptor(object);
74       addDefaultValuePropertyDescriptor(object);
75     }
76     return itemPropertyDescriptors;
77   }
78
79   /**
80    * This adds a property descriptor for the Instance Class Name feature.
81    * <!-- begin-user-doc -->
82    * <!-- end-user-doc -->
83    * @generated
84    */

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

106   protected void addDefaultValuePropertyDescriptor(Object JavaDoc object)
107   {
108     itemPropertyDescriptors.add
109       (createItemPropertyDescriptor
110         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
111          getResourceLocator(),
112          getString("_UI_EClassifier_defaultValue_feature"),
113          getString("_UI_PropertyDescriptor_description", "_UI_EClassifier_defaultValue_feature", "_UI_EClassifier_type"),
114          EcorePackage.eINSTANCE.getEClassifier_DefaultValue(),
115          false,
116          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
117          null,
118          null));
119   }
120
121   /**
122    * This returns the label text for the adapted class.
123    * <!-- begin-user-doc -->
124    * <!-- end-user-doc -->
125    * @generated
126    */

127   public String JavaDoc getText(Object JavaDoc object)
128   {
129     String JavaDoc label = ((EClassifier)object).getName();
130     return label == null || label.length() == 0 ?
131       getString("_UI_EClassifier_type") :
132       getString("_UI_EClassifier_type") + " " + label;
133   }
134
135   /**
136    * This handles model notifications by calling {@link #updateChildren} to update any cached
137    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
138    * <!-- begin-user-doc -->
139    * <!-- end-user-doc -->
140    * @generated
141    */

142   public void notifyChanged(Notification notification)
143   {
144     updateChildren(notification);
145
146     switch (notification.getFeatureID(EClassifier.class))
147     {
148       case EcorePackage.ECLASSIFIER__INSTANCE_CLASS_NAME:
149       case EcorePackage.ECLASSIFIER__DEFAULT_VALUE:
150         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
151         return;
152     }
153     super.notifyChanged(notification);
154   }
155
156   /**
157    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
158    * describing all of the children that can be created under this object.
159    * <!-- begin-user-doc -->
160    * <!-- end-user-doc -->
161    * @generated
162    */

163   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
164   {
165     super.collectNewChildDescriptors(newChildDescriptors, object);
166   }
167
168   /**
169    * Return the resource locator for this item provider's resources.
170    * <!-- begin-user-doc -->
171    * <!-- end-user-doc -->
172    * @generated
173    */

174   public ResourceLocator getResourceLocator()
175   {
176     return EcoreEditPlugin.INSTANCE;
177   }
178
179 }
180
Popular Tags