KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2xml > provider > XMLMapItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 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: XMLMapItemProvider.java,v 1.4 2005/06/21 16:16:58 khussey Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2xml.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.EObject;
27
//import org.eclipse.emf.ecore.EReference;
28
//import org.eclipse.emf.ecore.EStructuralFeature;
29

30 //import org.eclipse.emf.ecore.util.FeatureMap;
31
//import org.eclipse.emf.ecore.util.FeatureMapUtil;
32

33 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
34 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
35 import org.eclipse.emf.edit.provider.IItemLabelProvider;
36 import org.eclipse.emf.edit.provider.IItemPropertySource;
37 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
38 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
39 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
40 import org.eclipse.emf.edit.provider.ItemProviderAdapter;
41 import org.eclipse.emf.edit.provider.ViewerNotification;
42 //import org.eclipse.emf.mapping.MappingPlugin;
43
import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLFactory;
44 import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
45 import org.eclipse.emf.mapping.ecore2xml.XMLMap;
46 import org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPlugin;
47
48
49 /**
50  * This is the item provider adapter for a {@link org.eclipse.emf.mapping.ecore2xml.XMLMap} object.
51  * <!-- begin-user-doc -->
52  * <!-- end-user-doc -->
53  * @generated
54  */

55 public class XMLMapItemProvider
56   extends ItemProviderAdapter
57   implements
58     IEditingDomainItemProvider,
59     IStructuredItemContentProvider,
60     ITreeItemContentProvider,
61     IItemLabelProvider,
62     IItemPropertySource
63 {
64   /**
65    * This constructs an instance from a factory and a notifier.
66    * <!-- begin-user-doc -->
67    * <!-- end-user-doc -->
68    * @generated
69    */

70   public XMLMapItemProvider(AdapterFactory adapterFactory)
71   {
72     super(adapterFactory);
73   }
74
75   /**
76    * This returns the property descriptors for the adapted class.
77    * <!-- begin-user-doc -->
78    * <!-- end-user-doc -->
79    * @generated
80    */

81   public List JavaDoc getPropertyDescriptors(Object JavaDoc object)
82   {
83     if (itemPropertyDescriptors == null)
84     {
85       super.getPropertyDescriptors(object);
86
87       addIDAttributeNamePropertyDescriptor(object);
88       addNoNamespacePackagePropertyDescriptor(object);
89     }
90     return itemPropertyDescriptors;
91   }
92
93   /**
94    * This adds a property descriptor for the ID Attribute Name feature.
95    * <!-- begin-user-doc -->
96    * <!-- end-user-doc -->
97    * @generated
98    */

99   protected void addIDAttributeNamePropertyDescriptor(Object JavaDoc object)
100   {
101     itemPropertyDescriptors.add
102       (createItemPropertyDescriptor
103         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
104          getResourceLocator(),
105          getString("_UI_XMLMap_iDAttributeName_feature"), //$NON-NLS-1$
106
getString("_UI_PropertyDescriptor_description", "_UI_XMLMap_iDAttributeName_feature", "_UI_XMLMap_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
107
Ecore2XMLPackage.eINSTANCE.getXMLMap_IDAttributeName(),
108          true,
109          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
110          null,
111          null));
112   }
113
114   /**
115    * This adds a property descriptor for the No Namespace Package feature.
116    * <!-- begin-user-doc -->
117    * <!-- end-user-doc -->
118    * @generated
119    */

120   protected void addNoNamespacePackagePropertyDescriptor(Object JavaDoc object)
121   {
122     itemPropertyDescriptors.add
123       (createItemPropertyDescriptor
124         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
125          getResourceLocator(),
126          getString("_UI_XMLMap_noNamespacePackage_feature"), //$NON-NLS-1$
127
getString("_UI_PropertyDescriptor_description", "_UI_XMLMap_noNamespacePackage_feature", "_UI_XMLMap_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
128
Ecore2XMLPackage.eINSTANCE.getXMLMap_NoNamespacePackage(),
129          true,
130          null,
131          null,
132          null));
133   }
134
135   /**
136    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
137    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
138    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
139    * <!-- begin-user-doc -->
140    * <!-- end-user-doc -->
141    * @generated
142    */

143   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
144   {
145     if (childrenFeatures == null)
146     {
147       super.getChildrenFeatures(object);
148       childrenFeatures.add(Ecore2XMLPackage.eINSTANCE.getXMLMap_EcoreToXMLInfo());
149     }
150     return childrenFeatures;
151   }
152
153   /**
154    * This returns XMLMap.gif.
155    * <!-- begin-user-doc -->
156    * <!-- end-user-doc -->
157    * @generated
158    */

159   public Object JavaDoc getImage(Object JavaDoc object)
160   {
161     return getResourceLocator().getImage("full/obj16/XMLMap"); //$NON-NLS-1$
162
}
163
164   /**
165    * This returns the label text for the adapted class.
166    * <!-- begin-user-doc -->
167    * <!-- end-user-doc -->
168    * @generated
169    */

170   public String JavaDoc getText(Object JavaDoc object)
171   {
172     String JavaDoc label = ((XMLMap)object).getIDAttributeName();
173     return label == null || label.length() == 0 ?
174       getString("_UI_XMLMap_type") : //$NON-NLS-1$
175
getString("_UI_XMLMap_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
176
}
177
178   /**
179    * This handles model notifications by calling {@link #updateChildren} to update any cached
180    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
181    * <!-- begin-user-doc -->
182    * <!-- end-user-doc -->
183    * @generated
184    */

185   public void notifyChanged(Notification notification)
186   {
187     updateChildren(notification);
188
189     switch (notification.getFeatureID(XMLMap.class))
190     {
191       case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME:
192         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
193         return;
194       case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO:
195         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
196         return;
197     }
198     super.notifyChanged(notification);
199   }
200
201   /**
202    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
203    * describing all of the children that can be created under this object.
204    * <!-- begin-user-doc -->
205    * <!-- end-user-doc -->
206    * @generated
207    */

208   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
209   {
210     super.collectNewChildDescriptors(newChildDescriptors, object);
211
212     newChildDescriptors.add
213       (createChildParameter
214         (Ecore2XMLPackage.eINSTANCE.getXMLMap_EcoreToXMLInfo(),
215          Ecore2XMLFactory.eINSTANCE.create(Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry())));
216   }
217
218   /**
219    * Return the resource locator for this item provider's resources.
220    * <!-- begin-user-doc -->
221    * <!-- end-user-doc -->
222    * @generated
223    */

224   public ResourceLocator getResourceLocator()
225   {
226     return Ecore2XMLUIPlugin.INSTANCE;
227   }
228
229 }
230
Popular Tags