1 7 package org.eclipse.emf.ecore.change.provider; 8 9 10 import java.util.Collection ; 11 import java.util.List ; 12 13 import org.eclipse.emf.common.notify.AdapterFactory; 14 import org.eclipse.emf.common.notify.Notification; 15 import org.eclipse.emf.common.util.ResourceLocator; 16 import org.eclipse.emf.ecore.change.ChangePackage; 17 import org.eclipse.emf.ecore.change.ResourceChange; 18 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 19 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 20 import org.eclipse.emf.edit.provider.IItemLabelProvider; 21 import org.eclipse.emf.edit.provider.IItemPropertySource; 22 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 23 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 24 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 25 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 26 27 import org.eclipse.emf.edit.provider.ViewerNotification; 28 29 35 public class ResourceChangeItemProvider 36 extends ItemProviderAdapter 37 implements 38 IEditingDomainItemProvider, 39 IStructuredItemContentProvider, 40 ITreeItemContentProvider, 41 IItemLabelProvider, 42 IItemPropertySource 43 { 44 50 public ResourceChangeItemProvider(AdapterFactory adapterFactory) 51 { 52 super(adapterFactory); 53 } 54 55 61 public List getPropertyDescriptors(Object object) 62 { 63 if (itemPropertyDescriptors == null) 64 { 65 super.getPropertyDescriptors(object); 66 67 addResourceURIPropertyDescriptor(object); 68 addResourcePropertyDescriptor(object); 69 addValuePropertyDescriptor(object); 70 } 71 return itemPropertyDescriptors; 72 } 73 74 80 protected void addResourceURIPropertyDescriptor(Object object) 81 { 82 itemPropertyDescriptors.add 83 (createItemPropertyDescriptor 84 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 85 getResourceLocator(), 86 getString("_UI_ResourceChange_resourceURI_feature"), 87 getString("_UI_PropertyDescriptor_description", "_UI_ResourceChange_resourceURI_feature", "_UI_ResourceChange_type"), 88 ChangePackage.eINSTANCE.getResourceChange_ResourceURI(), 89 true, 90 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 91 null, 92 null)); 93 } 94 95 101 protected void addResourcePropertyDescriptor(Object object) 102 { 103 itemPropertyDescriptors.add 104 (createItemPropertyDescriptor 105 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 106 getResourceLocator(), 107 getString("_UI_ResourceChange_resource_feature"), 108 getString("_UI_PropertyDescriptor_description", "_UI_ResourceChange_resource_feature", "_UI_ResourceChange_type"), 109 ChangePackage.eINSTANCE.getResourceChange_Resource(), 110 true, 111 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 112 null, 113 null)); 114 } 115 116 122 protected void addValuePropertyDescriptor(Object object) 123 { 124 itemPropertyDescriptors.add 125 (createItemPropertyDescriptor 126 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 127 getResourceLocator(), 128 getString("_UI_ResourceChange_value_feature"), 129 getString("_UI_PropertyDescriptor_description", "_UI_ResourceChange_value_feature", "_UI_ResourceChange_type"), 130 ChangePackage.eINSTANCE.getResourceChange_Value(), 131 true, 132 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 133 null, 134 null)); 135 } 136 137 145 public Collection getChildrenFeatures(Object object) 146 { 147 if (childrenFeatures == null) 148 { 149 super.getChildrenFeatures(object); 150 childrenFeatures.add(ChangePackage.eINSTANCE.getResourceChange_ListChanges()); 151 } 152 return childrenFeatures; 153 } 154 155 161 public Object getImage(Object object) 162 { 163 return getResourceLocator().getImage("full/obj16/ResourceChange"); 164 } 165 166 172 public String getText(Object object) 173 { 174 String label = ((ResourceChange)object).getResourceURI(); 175 return label == null || label.length() == 0 ? 176 getString("_UI_ResourceChange_type") : 177 getString("_UI_ResourceChange_type") + " " + label; 178 } 179 180 187 public void notifyChanged(Notification notification) 188 { 189 updateChildren(notification); 190 191 switch (notification.getFeatureID(ResourceChange.class)) 192 { 193 case ChangePackage.RESOURCE_CHANGE__RESOURCE_URI: 194 case ChangePackage.RESOURCE_CHANGE__RESOURCE: 195 case ChangePackage.RESOURCE_CHANGE__VALUE: 196 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 197 return; 198 case ChangePackage.RESOURCE_CHANGE__LIST_CHANGES: 199 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 200 return; 201 } 202 super.notifyChanged(notification); 203 } 204 205 211 public ResourceLocator getResourceLocator() 212 { 213 return ChangeEditPlugin.INSTANCE; 214 } 215 216 } 217 | Popular Tags |