KickJava   Java API By Example, From Geeks To Geeks.

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


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: XMLInfoItemProvider.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.Ecore2XMLPackage;
44 import org.eclipse.emf.mapping.ecore2xml.XMLInfo;
45 import org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPlugin;
46
47 /**
48  * This is the item provider adapter for a {@link org.eclipse.emf.mapping.ecore2xml.XMLInfo} object.
49  * <!-- begin-user-doc -->
50  * <!-- end-user-doc -->
51  * @generated
52  */

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

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

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

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

119   protected void addTargetNamespacePropertyDescriptor(Object JavaDoc object)
120   {
121     itemPropertyDescriptors.add
122       (createItemPropertyDescriptor
123         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
124          getResourceLocator(),
125          getString("_UI_XMLInfo_targetNamespace_feature"), //$NON-NLS-1$
126
getString("_UI_PropertyDescriptor_description", "_UI_XMLInfo_targetNamespace_feature", "_UI_XMLInfo_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
127
Ecore2XMLPackage.eINSTANCE.getXMLInfo_TargetNamespace(),
128          true,
129          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
130          null,
131          null));
132   }
133
134   /**
135    * This adds a property descriptor for the XML Representation feature.
136    * <!-- begin-user-doc -->
137    * <!-- end-user-doc -->
138    * @generated
139    */

140   protected void addXMLRepresentationPropertyDescriptor(Object JavaDoc object)
141   {
142     itemPropertyDescriptors.add
143       (createItemPropertyDescriptor
144         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
145          getResourceLocator(),
146          getString("_UI_XMLInfo_xMLRepresentation_feature"), //$NON-NLS-1$
147
getString("_UI_PropertyDescriptor_description", "_UI_XMLInfo_xMLRepresentation_feature", "_UI_XMLInfo_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
148
Ecore2XMLPackage.eINSTANCE.getXMLInfo_XMLRepresentation(),
149          true,
150          ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
151          null,
152          null));
153   }
154
155   /**
156    * This returns XMLInfo.gif.
157    * <!-- begin-user-doc -->
158    * <!-- end-user-doc -->
159    * @generated
160    */

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

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

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

209   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
210   {
211     super.collectNewChildDescriptors(newChildDescriptors, object);
212   }
213
214   /**
215    * Return the resource locator for this item provider's resources.
216    * <!-- begin-user-doc -->
217    * <!-- end-user-doc -->
218    * @generated
219    */

220   public ResourceLocator getResourceLocator()
221   {
222     return Ecore2XMLUIPlugin.INSTANCE;
223   }
224
225 }
226
Popular Tags