1 17 package org.eclipse.emf.mapping.ecore2xml.provider; 18 19 20 import java.util.Collection ; 21 import java.util.List ; 22 import java.util.Map ; 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 31 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.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 55 public class ENamedElementToXMLInfoMapEntryItemProvider 56 extends ItemProviderAdapter 57 implements 58 IEditingDomainItemProvider, 59 IStructuredItemContentProvider, 60 ITreeItemContentProvider, 61 IItemLabelProvider, 62 IItemPropertySource 63 { 64 70 public ENamedElementToXMLInfoMapEntryItemProvider(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 addKeyPropertyDescriptor(object); 88 } 89 return itemPropertyDescriptors; 90 } 91 92 98 protected void addKeyPropertyDescriptor(Object object) 99 { 100 itemPropertyDescriptors.add 101 (createItemPropertyDescriptor 102 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 103 getResourceLocator(), 104 getString("_UI_ENamedElementToXMLInfoMapEntry_key_feature"), getString("_UI_PropertyDescriptor_description", "_UI_ENamedElementToXMLInfoMapEntry_key_feature", "_UI_ENamedElementToXMLInfoMapEntry_type"), Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry_Key(), 107 true, 108 null, 109 null, 110 null)); 111 } 112 113 121 public Collection getChildrenFeatures(Object 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 137 public Object getImage(Object object) 138 { 139 return getResourceLocator().getImage("full/obj16/ENamedElementToXMLInfoMapEntry"); } 141 142 148 public String getText(Object object) 149 { 150 Map.Entry eNamedElementToXMLInfoMapEntry = (Map.Entry )object; 151 Object key = eNamedElementToXMLInfoMapEntry.getKey(); 152 Object value = eNamedElementToXMLInfoMapEntry.getValue(); 153 return "" + (key instanceof ENamedElement ? ((ENamedElement)key).getName() : String.valueOf(key)) + " -> " + (value instanceof XMLInfo ? ((XMLInfo)value).getName() : String.valueOf(value)); } 155 156 163 public void notifyChanged(Notification notification) 164 { 165 updateChildren(notification); 166 167 switch (notification.getFeatureID(Map.Entry .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 186 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object 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 202 public ResourceLocator getResourceLocator() 203 { 204 return Ecore2XMLUIPlugin.INSTANCE; 205 } 206 207 } 208 | Popular Tags |