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.Ecore2XMLPackage; 44 import org.eclipse.emf.mapping.ecore2xml.XMLInfo; 45 import org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPlugin; 46 47 53 public class XMLInfoItemProvider 54 extends ItemProviderAdapter 55 implements 56 IEditingDomainItemProvider, 57 IStructuredItemContentProvider, 58 ITreeItemContentProvider, 59 IItemLabelProvider, 60 IItemPropertySource 61 { 62 68 public XMLInfoItemProvider(AdapterFactory adapterFactory) 69 { 70 super(adapterFactory); 71 } 72 73 79 public List getPropertyDescriptors(Object 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 98 protected void addNamePropertyDescriptor(Object object) 99 { 100 itemPropertyDescriptors.add 101 (createItemPropertyDescriptor 102 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 103 getResourceLocator(), 104 getString("_UI_XMLInfo_name_feature"), getString("_UI_PropertyDescriptor_description", "_UI_XMLInfo_name_feature", "_UI_XMLInfo_type"), Ecore2XMLPackage.eINSTANCE.getXMLInfo_Name(), 107 true, 108 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 109 null, 110 null)); 111 } 112 113 119 protected void addTargetNamespacePropertyDescriptor(Object object) 120 { 121 itemPropertyDescriptors.add 122 (createItemPropertyDescriptor 123 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 124 getResourceLocator(), 125 getString("_UI_XMLInfo_targetNamespace_feature"), getString("_UI_PropertyDescriptor_description", "_UI_XMLInfo_targetNamespace_feature", "_UI_XMLInfo_type"), Ecore2XMLPackage.eINSTANCE.getXMLInfo_TargetNamespace(), 128 true, 129 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 130 null, 131 null)); 132 } 133 134 140 protected void addXMLRepresentationPropertyDescriptor(Object object) 141 { 142 itemPropertyDescriptors.add 143 (createItemPropertyDescriptor 144 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 145 getResourceLocator(), 146 getString("_UI_XMLInfo_xMLRepresentation_feature"), getString("_UI_PropertyDescriptor_description", "_UI_XMLInfo_xMLRepresentation_feature", "_UI_XMLInfo_type"), Ecore2XMLPackage.eINSTANCE.getXMLInfo_XMLRepresentation(), 149 true, 150 ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, 151 null, 152 null)); 153 } 154 155 161 public Object getImage(Object object) 162 { 163 return getResourceLocator().getImage("full/obj16/XMLInfo"); } 165 166 172 public String getText(Object object) 173 { 174 String label = ((XMLInfo)object).getName(); 175 return label == null || label.length() == 0 ? 176 getString("_UI_XMLInfo_type") : getString("_UI_XMLInfo_type") + " " + label; } 179 180 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 209 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 210 { 211 super.collectNewChildDescriptors(newChildDescriptors, object); 212 } 213 214 220 public ResourceLocator getResourceLocator() 221 { 222 return Ecore2XMLUIPlugin.INSTANCE; 223 } 224 225 } 226 | Popular Tags |