1 17 package org.eclipse.emf.ecore.change.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 import org.eclipse.emf.ecore.change.ChangePackage; 27 import org.eclipse.emf.ecore.change.FeatureChange; 28 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 29 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 30 import org.eclipse.emf.edit.provider.IItemLabelProvider; 31 import org.eclipse.emf.edit.provider.IItemPropertySource; 32 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 33 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 34 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 35 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 36 37 import org.eclipse.emf.edit.provider.ViewerNotification; 38 39 45 public class FeatureChangeItemProvider 46 extends ItemProviderAdapter 47 implements 48 IEditingDomainItemProvider, 49 IStructuredItemContentProvider, 50 ITreeItemContentProvider, 51 IItemLabelProvider, 52 IItemPropertySource 53 { 54 60 public FeatureChangeItemProvider(AdapterFactory adapterFactory) 61 { 62 super(adapterFactory); 63 } 64 65 71 public List getPropertyDescriptors(Object object) 72 { 73 if (itemPropertyDescriptors == null) 74 { 75 super.getPropertyDescriptors(object); 76 77 addSetPropertyDescriptor(object); 78 addValuePropertyDescriptor(object); 79 addFeaturePropertyDescriptor(object); 80 } 81 return itemPropertyDescriptors; 82 } 83 84 90 protected void addSetPropertyDescriptor(Object object) 91 { 92 itemPropertyDescriptors.add 93 (createItemPropertyDescriptor 94 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 95 getResourceLocator(), 96 getString("_UI_FeatureChange_set_feature"), 97 getString("_UI_PropertyDescriptor_description", "_UI_FeatureChange_set_feature", "_UI_FeatureChange_type"), 98 ChangePackage.eINSTANCE.getFeatureChange_Set(), 99 true, 100 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 101 null, 102 null)); 103 } 104 105 111 protected void addValuePropertyDescriptor(Object object) 112 { 113 itemPropertyDescriptors.add 114 (createItemPropertyDescriptor 115 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 116 getResourceLocator(), 117 getString("_UI_FeatureChange_value_feature"), 118 getString("_UI_PropertyDescriptor_description", "_UI_FeatureChange_value_feature", "_UI_FeatureChange_type"), 119 ChangePackage.eINSTANCE.getFeatureChange_Value(), 120 true, 121 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 122 null, 123 null)); 124 } 125 126 132 protected void addFeaturePropertyDescriptor(Object object) 133 { 134 itemPropertyDescriptors.add 135 (createItemPropertyDescriptor 136 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 137 getResourceLocator(), 138 getString("_UI_FeatureChange_feature_feature"), 139 getString("_UI_PropertyDescriptor_description", "_UI_FeatureChange_feature_feature", "_UI_FeatureChange_type"), 140 ChangePackage.eINSTANCE.getFeatureChange_Feature(), 141 true, 142 null, 143 null, 144 null)); 145 } 146 147 155 public Collection getChildrenFeatures(Object object) 156 { 157 if (childrenFeatures == null) 158 { 159 super.getChildrenFeatures(object); 160 childrenFeatures.add(ChangePackage.eINSTANCE.getFeatureChange_ListChanges()); 161 } 162 return childrenFeatures; 163 } 164 165 171 public Object getImage(Object object) 172 { 173 return getResourceLocator().getImage("full/obj16/FeatureChange"); 174 } 175 176 182 public String getText(Object object) 183 { 184 String label = ((FeatureChange)object).getFeatureName(); 185 return label == null || label.length() == 0 ? 186 getString("_UI_FeatureChange_type") : 187 getString("_UI_FeatureChange_type") + " " + label; 188 } 189 190 197 public void notifyChanged(Notification notification) 198 { 199 updateChildren(notification); 200 201 switch (notification.getFeatureID(FeatureChange.class)) 202 { 203 case ChangePackage.FEATURE_CHANGE__SET: 204 case ChangePackage.FEATURE_CHANGE__VALUE: 205 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 206 return; 207 case ChangePackage.FEATURE_CHANGE__LIST_CHANGES: 208 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 209 return; 210 } 211 super.notifyChanged(notification); 212 } 213 214 220 public ResourceLocator getResourceLocator() 221 { 222 return ChangeEditPlugin.INSTANCE; 223 } 224 225 } 226 | Popular Tags |