1 17 package org.eclipse.emf.mapping.ecore2xml.provider; 18 19 20 import java.util.Collection ; 21 import java.util.List ; 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 30 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.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 55 public class XMLMapItemProvider 56 extends ItemProviderAdapter 57 implements 58 IEditingDomainItemProvider, 59 IStructuredItemContentProvider, 60 ITreeItemContentProvider, 61 IItemLabelProvider, 62 IItemPropertySource 63 { 64 70 public XMLMapItemProvider(AdapterFactory adapterFactory) 71 { 72 super(adapterFactory); 73 } 74 75 81 public List getPropertyDescriptors(Object 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 99 protected void addIDAttributeNamePropertyDescriptor(Object object) 100 { 101 itemPropertyDescriptors.add 102 (createItemPropertyDescriptor 103 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 104 getResourceLocator(), 105 getString("_UI_XMLMap_iDAttributeName_feature"), getString("_UI_PropertyDescriptor_description", "_UI_XMLMap_iDAttributeName_feature", "_UI_XMLMap_type"), Ecore2XMLPackage.eINSTANCE.getXMLMap_IDAttributeName(), 108 true, 109 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 110 null, 111 null)); 112 } 113 114 120 protected void addNoNamespacePackagePropertyDescriptor(Object object) 121 { 122 itemPropertyDescriptors.add 123 (createItemPropertyDescriptor 124 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 125 getResourceLocator(), 126 getString("_UI_XMLMap_noNamespacePackage_feature"), getString("_UI_PropertyDescriptor_description", "_UI_XMLMap_noNamespacePackage_feature", "_UI_XMLMap_type"), Ecore2XMLPackage.eINSTANCE.getXMLMap_NoNamespacePackage(), 129 true, 130 null, 131 null, 132 null)); 133 } 134 135 143 public Collection getChildrenFeatures(Object 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 159 public Object getImage(Object object) 160 { 161 return getResourceLocator().getImage("full/obj16/XMLMap"); } 163 164 170 public String getText(Object object) 171 { 172 String label = ((XMLMap)object).getIDAttributeName(); 173 return label == null || label.length() == 0 ? 174 getString("_UI_XMLMap_type") : getString("_UI_XMLMap_type") + " " + label; } 177 178 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 208 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object 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 224 public ResourceLocator getResourceLocator() 225 { 226 return Ecore2XMLUIPlugin.INSTANCE; 227 } 228 229 } 230 | Popular Tags |