KickJava   Java API By Example, From Geeks To Geeks.

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


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: ENamedElementItemProvider.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.ENamedElement;
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 import org.eclipse.emf.edit.provider.ViewerNotification;
37
38 /**
39  * This is the item provider adapter for a {@link org.eclipse.emf.ecore.ENamedElement} object.
40  * <!-- begin-user-doc -->
41  * <!-- end-user-doc -->
42  * @generated
43  */

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

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

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

83   protected void addNamePropertyDescriptor(Object JavaDoc object)
84   {
85     itemPropertyDescriptors.add
86       (createItemPropertyDescriptor
87         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
88          getResourceLocator(),
89          getString("_UI_ENamedElement_name_feature"),
90          getString("_UI_PropertyDescriptor_description", "_UI_ENamedElement_name_feature", "_UI_ENamedElement_type"),
91          EcorePackage.eINSTANCE.getENamedElement_Name(),
92          true,
93          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
94          null,
95          null));
96   }
97
98   /**
99    * This returns the label text for the adapted class.
100    * <!-- begin-user-doc -->
101    * <!-- end-user-doc -->
102    * @generated
103    */

104   public String JavaDoc getText(Object JavaDoc object)
105   {
106     String JavaDoc label = ((ENamedElement)object).getName();
107     return label == null || label.length() == 0 ?
108       getString("_UI_ENamedElement_type") :
109       getString("_UI_ENamedElement_type") + " " + label;
110   }
111
112   /**
113    * This handles model notifications by calling {@link #updateChildren} to update any cached
114    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
115    * <!-- begin-user-doc -->
116    * <!-- end-user-doc -->
117    * @generated
118    */

119   public void notifyChanged(Notification notification)
120   {
121     updateChildren(notification);
122
123     switch (notification.getFeatureID(ENamedElement.class))
124     {
125       case EcorePackage.ENAMED_ELEMENT__NAME:
126         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
127         return;
128     }
129     super.notifyChanged(notification);
130   }
131
132   /**
133    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
134    * describing all of the children that can be created under this object.
135    * <!-- begin-user-doc -->
136    * <!-- end-user-doc -->
137    * @generated
138    */

139   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
140   {
141     super.collectNewChildDescriptors(newChildDescriptors, object);
142   }
143
144   /**
145    * Return the resource locator for this item provider's resources.
146    * <!-- begin-user-doc -->
147    * <!-- end-user-doc -->
148    * @generated
149    */

150   public ResourceLocator getResourceLocator()
151   {
152     return EcoreEditPlugin.INSTANCE;
153   }
154
155 }
156
Popular Tags