KickJava   Java API By Example, From Geeks To Geeks.

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


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: ENamedElementToXMLInfoMapEntryItemProvider.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 import java.util.Map JavaDoc;
23
24 import org.eclipse.emf.common.notify.AdapterFactory;
25 import org.eclipse.emf.common.notify.Notification;
26 import org.eclipse.emf.common.util.ResourceLocator;
27 //import org.eclipse.emf.ecore.EObject;
28
//import org.eclipse.emf.ecore.EReference;
29
//import org.eclipse.emf.ecore.EStructuralFeature;
30

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

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

55 public class ENamedElementToXMLInfoMapEntryItemProvider
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 ENamedElementToXMLInfoMapEntryItemProvider(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       addKeyPropertyDescriptor(object);
88     }
89     return itemPropertyDescriptors;
90   }
91
92   /**
93    * This adds a property descriptor for the Key feature.
94    * <!-- begin-user-doc -->
95    * <!-- end-user-doc -->
96    * @generated
97    */

98   protected void addKeyPropertyDescriptor(Object JavaDoc object)
99   {
100     itemPropertyDescriptors.add
101       (createItemPropertyDescriptor
102         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
103          getResourceLocator(),
104          getString("_UI_ENamedElementToXMLInfoMapEntry_key_feature"), //$NON-NLS-1$
105
getString("_UI_PropertyDescriptor_description", "_UI_ENamedElementToXMLInfoMapEntry_key_feature", "_UI_ENamedElementToXMLInfoMapEntry_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
106
Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry_Key(),
107          true,
108          null,
109          null,
110          null));
111   }
112
113   /**
114    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
115    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
116    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
117    * <!-- begin-user-doc -->
118    * <!-- end-user-doc -->
119    * @generated
120    */

121   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
122   {
123     if (childrenFeatures == null)
124     {
125       super.getChildrenFeatures(object);
126       childrenFeatures.add(Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry_Value());
127     }
128     return childrenFeatures;
129   }
130
131   /**
132    * This returns ENamedElementToXMLInfoMapEntry.gif.
133    * <!-- begin-user-doc -->
134    * <!-- end-user-doc -->
135    * @generated
136    */

137   public Object JavaDoc getImage(Object JavaDoc object)
138   {
139     return getResourceLocator().getImage("full/obj16/ENamedElementToXMLInfoMapEntry"); //$NON-NLS-1$
140
}
141
142   /**
143    * This returns the label text for the adapted class.
144    * <!-- begin-user-doc -->
145    * <!-- end-user-doc -->
146    * @generated NOT
147    */

148   public String JavaDoc getText(Object JavaDoc object)
149   {
150     Map.Entry JavaDoc eNamedElementToXMLInfoMapEntry = (Map.Entry JavaDoc)object;
151     Object JavaDoc key = eNamedElementToXMLInfoMapEntry.getKey();
152     Object JavaDoc value = eNamedElementToXMLInfoMapEntry.getValue();
153     return "" + (key instanceof ENamedElement ? ((ENamedElement)key).getName() : String.valueOf(key)) + " -> " + (value instanceof XMLInfo ? ((XMLInfo)value).getName() : String.valueOf(value)); //$NON-NLS-1$ //$NON-NLS-2$
154
}
155
156   /**
157    * This handles model notifications by calling {@link #updateChildren} to update any cached
158    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
159    * <!-- begin-user-doc -->
160    * <!-- end-user-doc -->
161    * @generated
162    */

163   public void notifyChanged(Notification notification)
164   {
165     updateChildren(notification);
166
167     switch (notification.getFeatureID(Map.Entry JavaDoc.class))
168     {
169       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY:
170         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
171         return;
172       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE:
173         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
174         return;
175     }
176     super.notifyChanged(notification);
177   }
178
179   /**
180    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
181    * describing all of the children that can be created under this object.
182    * <!-- begin-user-doc -->
183    * <!-- end-user-doc -->
184    * @generated
185    */

186   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
187   {
188     super.collectNewChildDescriptors(newChildDescriptors, object);
189
190     newChildDescriptors.add
191       (createChildParameter
192         (Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry_Value(),
193          Ecore2XMLFactory.eINSTANCE.createXMLInfo()));
194   }
195
196   /**
197    * Return the resource locator for this item provider's resources.
198    * <!-- begin-user-doc -->
199    * <!-- end-user-doc -->
200    * @generated
201    */

202   public ResourceLocator getResourceLocator()
203   {
204     return Ecore2XMLUIPlugin.INSTANCE;
205   }
206
207 }
208
Popular Tags