1 17 package org.eclipse.emf.ecore.change.provider; 18 19 20 import java.util.List ; 21 22 import org.eclipse.emf.common.notify.AdapterFactory; 23 import org.eclipse.emf.common.notify.Notification; 24 25 import org.eclipse.emf.common.util.ResourceLocator; 26 27 import org.eclipse.emf.ecore.change.ChangePackage; 28 import org.eclipse.emf.ecore.change.FeatureMapEntry; 29 30 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 31 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 32 import org.eclipse.emf.edit.provider.IItemLabelProvider; 33 import org.eclipse.emf.edit.provider.IItemPropertySource; 34 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 35 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 36 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 37 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 38 import org.eclipse.emf.edit.provider.ViewerNotification; 39 40 46 public class FeatureMapEntryItemProvider 47 extends ItemProviderAdapter 48 implements 49 IEditingDomainItemProvider, 50 IStructuredItemContentProvider, 51 ITreeItemContentProvider, 52 IItemLabelProvider, 53 IItemPropertySource 54 { 55 61 public FeatureMapEntryItemProvider(AdapterFactory adapterFactory) 62 { 63 super(adapterFactory); 64 } 65 66 72 public List getPropertyDescriptors(Object object) 73 { 74 if (itemPropertyDescriptors == null) 75 { 76 super.getPropertyDescriptors(object); 77 78 addFeatureNamePropertyDescriptor(object); 79 addDataValuePropertyDescriptor(object); 80 addValuePropertyDescriptor(object); 81 addFeaturePropertyDescriptor(object); 82 addReferenceValuePropertyDescriptor(object); 83 } 84 return itemPropertyDescriptors; 85 } 86 87 93 protected void addFeatureNamePropertyDescriptor(Object object) 94 { 95 itemPropertyDescriptors.add 96 (createItemPropertyDescriptor 97 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 98 getResourceLocator(), 99 getString("_UI_FeatureMapEntry_featureName_feature"), 100 getString("_UI_PropertyDescriptor_description", "_UI_FeatureMapEntry_featureName_feature", "_UI_FeatureMapEntry_type"), 101 ChangePackage.eINSTANCE.getFeatureMapEntry_FeatureName(), 102 true, 103 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 104 null, 105 null)); 106 } 107 108 114 protected void addDataValuePropertyDescriptor(Object object) 115 { 116 itemPropertyDescriptors.add 117 (createItemPropertyDescriptor 118 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 119 getResourceLocator(), 120 getString("_UI_FeatureMapEntry_dataValue_feature"), 121 getString("_UI_PropertyDescriptor_description", "_UI_FeatureMapEntry_dataValue_feature", "_UI_FeatureMapEntry_type"), 122 ChangePackage.eINSTANCE.getFeatureMapEntry_DataValue(), 123 true, 124 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 125 null, 126 null)); 127 } 128 129 135 protected void addValuePropertyDescriptor(Object object) 136 { 137 itemPropertyDescriptors.add 138 (createItemPropertyDescriptor 139 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 140 getResourceLocator(), 141 getString("_UI_FeatureMapEntry_value_feature"), 142 getString("_UI_PropertyDescriptor_description", "_UI_FeatureMapEntry_value_feature", "_UI_FeatureMapEntry_type"), 143 ChangePackage.eINSTANCE.getFeatureMapEntry_Value(), 144 false, 145 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 146 null, 147 null)); 148 } 149 150 156 protected void addFeaturePropertyDescriptor(Object object) 157 { 158 itemPropertyDescriptors.add 159 (createItemPropertyDescriptor 160 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 161 getResourceLocator(), 162 getString("_UI_FeatureMapEntry_feature_feature"), 163 getString("_UI_PropertyDescriptor_description", "_UI_FeatureMapEntry_feature_feature", "_UI_FeatureMapEntry_type"), 164 ChangePackage.eINSTANCE.getFeatureMapEntry_Feature(), 165 true, 166 null, 167 null, 168 null)); 169 } 170 171 177 protected void addReferenceValuePropertyDescriptor(Object object) 178 { 179 itemPropertyDescriptors.add 180 (createItemPropertyDescriptor 181 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 182 getResourceLocator(), 183 getString("_UI_FeatureMapEntry_referenceValue_feature"), 184 getString("_UI_PropertyDescriptor_description", "_UI_FeatureMapEntry_referenceValue_feature", "_UI_FeatureMapEntry_type"), 185 ChangePackage.eINSTANCE.getFeatureMapEntry_ReferenceValue(), 186 true, 187 null, 188 null, 189 null)); 190 } 191 192 198 public Object getImage(Object object) 199 { 200 return getResourceLocator().getImage("full/obj16/FeatureMapEntry"); 201 } 202 203 209 public String getText(Object object) 210 { 211 String label = ((FeatureMapEntry)object).getFeatureName(); 212 return label == null || label.length() == 0 ? 213 getString("_UI_FeatureMapEntry_type") : 214 getString("_UI_FeatureMapEntry_type") + " " + label; 215 } 216 217 224 public void notifyChanged(Notification notification) 225 { 226 updateChildren(notification); 227 228 switch (notification.getFeatureID(FeatureMapEntry.class)) 229 { 230 case ChangePackage.FEATURE_MAP_ENTRY__FEATURE_NAME: 231 case ChangePackage.FEATURE_MAP_ENTRY__DATA_VALUE: 232 case ChangePackage.FEATURE_MAP_ENTRY__VALUE: 233 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 234 return; 235 } 236 super.notifyChanged(notification); 237 } 238 239 245 public ResourceLocator getResourceLocator() 246 { 247 return ChangeEditPlugin.INSTANCE; 248 } 249 250 } 251 | Popular Tags |