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.ChangeKind; 27 import org.eclipse.emf.ecore.change.ChangePackage; 28 import org.eclipse.emf.ecore.change.ListChange; 29 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 30 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 31 import org.eclipse.emf.edit.provider.IItemLabelProvider; 32 import org.eclipse.emf.edit.provider.IItemPropertySource; 33 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 34 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 35 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 36 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 37 38 import org.eclipse.emf.edit.provider.ViewerNotification; 39 40 46 public class ListChangeItemProvider 47 extends ItemProviderAdapter 48 implements 49 IEditingDomainItemProvider, 50 IStructuredItemContentProvider, 51 ITreeItemContentProvider, 52 IItemLabelProvider, 53 IItemPropertySource 54 { 55 61 public ListChangeItemProvider(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 addKindPropertyDescriptor(object); 79 addIndexPropertyDescriptor(object); 80 addMoveToIndexPropertyDescriptor(object); 81 addValuesPropertyDescriptor(object); 82 } 83 return itemPropertyDescriptors; 84 } 85 86 92 protected void addKindPropertyDescriptor(Object object) 93 { 94 itemPropertyDescriptors.add 95 (createItemPropertyDescriptor 96 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 97 getResourceLocator(), 98 getString("_UI_ListChange_kind_feature"), 99 getString("_UI_PropertyDescriptor_description", "_UI_ListChange_kind_feature", "_UI_ListChange_type"), 100 ChangePackage.eINSTANCE.getListChange_Kind(), 101 true, 102 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 103 null, 104 null)); 105 } 106 107 113 protected void addIndexPropertyDescriptor(Object object) 114 { 115 itemPropertyDescriptors.add 116 (createItemPropertyDescriptor 117 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 118 getResourceLocator(), 119 getString("_UI_ListChange_index_feature"), 120 getString("_UI_PropertyDescriptor_description", "_UI_ListChange_index_feature", "_UI_ListChange_type"), 121 ChangePackage.eINSTANCE.getListChange_Index(), 122 true, 123 ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, 124 null, 125 null)); 126 } 127 128 134 protected void addMoveToIndexPropertyDescriptor(Object object) 135 { 136 itemPropertyDescriptors.add 137 (createItemPropertyDescriptor 138 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 139 getResourceLocator(), 140 getString("_UI_ListChange_moveToIndex_feature"), 141 getString("_UI_PropertyDescriptor_description", "_UI_ListChange_moveToIndex_feature", "_UI_ListChange_type"), 142 ChangePackage.eINSTANCE.getListChange_MoveToIndex(), 143 true, 144 ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, 145 null, 146 null)); 147 } 148 149 155 protected void addValuesPropertyDescriptor(Object object) 156 { 157 itemPropertyDescriptors.add 158 (createItemPropertyDescriptor 159 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 160 getResourceLocator(), 161 getString("_UI_ListChange_values_feature"), 162 getString("_UI_PropertyDescriptor_description", "_UI_ListChange_values_feature", "_UI_ListChange_type"), 163 ChangePackage.eINSTANCE.getListChange_Values(), 164 true, 165 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 166 null, 167 null)); 168 } 169 170 178 public Collection getChildrenFeatures(Object object) 179 { 180 if (childrenFeatures == null) 181 { 182 super.getChildrenFeatures(object); 183 childrenFeatures.add(ChangePackage.eINSTANCE.getListChange_FeatureMapEntryValues()); 184 } 185 return childrenFeatures; 186 } 187 188 194 public Object getImage(Object object) 195 { 196 return getResourceLocator().getImage("full/obj16/ListChange"); 197 } 198 199 205 public String getText(Object object) 206 { 207 ChangeKind labelValue = ((ListChange)object).getKind(); 208 String label = labelValue == null ? null : labelValue.toString(); 209 return label == null || label.length() == 0 ? 210 getString("_UI_ListChange_type") : 211 getString("_UI_ListChange_type") + " " + label; 212 } 213 214 221 public void notifyChanged(Notification notification) 222 { 223 updateChildren(notification); 224 225 switch (notification.getFeatureID(ListChange.class)) 226 { 227 case ChangePackage.LIST_CHANGE__KIND: 228 case ChangePackage.LIST_CHANGE__INDEX: 229 case ChangePackage.LIST_CHANGE__MOVE_TO_INDEX: 230 case ChangePackage.LIST_CHANGE__VALUES: 231 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 232 return; 233 case ChangePackage.LIST_CHANGE__FEATURE_MAP_ENTRY_VALUES: 234 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 235 return; 236 } 237 super.notifyChanged(notification); 238 } 239 240 246 public ResourceLocator getResourceLocator() 247 { 248 return ChangeEditPlugin.INSTANCE; 249 } 250 251 } 252 | Popular Tags |