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.EStructuralFeature; 27 28 import org.eclipse.emf.ecore.change.ChangeDescription; 29 import org.eclipse.emf.ecore.change.ChangePackage; 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.ItemProviderAdapter; 37 38 import org.eclipse.emf.edit.provider.ViewerNotification; 39 40 46 public class ChangeDescriptionItemProvider 47 extends ItemProviderAdapter 48 implements 49 IEditingDomainItemProvider, 50 IStructuredItemContentProvider, 51 ITreeItemContentProvider, 52 IItemLabelProvider, 53 IItemPropertySource 54 { 55 61 public ChangeDescriptionItemProvider(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 addObjectsToDetachPropertyDescriptor(object); 79 } 80 return itemPropertyDescriptors; 81 } 82 83 89 protected void addObjectsToDetachPropertyDescriptor(Object object) 90 { 91 itemPropertyDescriptors.add 92 (createItemPropertyDescriptor 93 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 94 getResourceLocator(), 95 getString("_UI_ChangeDescription_objectsToDetach_feature"), 96 getString("_UI_PropertyDescriptor_description", "_UI_ChangeDescription_objectsToDetach_feature", "_UI_ChangeDescription_type"), 97 ChangePackage.eINSTANCE.getChangeDescription_ObjectsToDetach(), 98 true, 99 null, 100 null, 101 null)); 102 } 103 104 112 public Collection getChildrenFeatures(Object object) 113 { 114 if (childrenFeatures == null) 115 { 116 super.getChildrenFeatures(object); 117 childrenFeatures.add(ChangePackage.eINSTANCE.getChangeDescription_ObjectChanges()); 118 childrenFeatures.add(ChangePackage.eINSTANCE.getChangeDescription_ObjectsToAttach()); 119 childrenFeatures.add(ChangePackage.eINSTANCE.getChangeDescription_ResourceChanges()); 120 } 121 return childrenFeatures; 122 } 123 124 129 protected EStructuralFeature getChildFeature(Object object, Object child) 130 { 131 134 return super.getChildFeature(object, child); 135 } 136 137 143 public Object getImage(Object object) 144 { 145 return getResourceLocator().getImage("full/obj16/ChangeDescription"); 146 } 147 148 154 public String getText(Object object) 155 { 156 return getString("_UI_ChangeDescription_type"); 157 } 158 159 166 public void notifyChanged(Notification notification) 167 { 168 updateChildren(notification); 169 170 switch (notification.getFeatureID(ChangeDescription.class)) 171 { 172 case ChangePackage.CHANGE_DESCRIPTION__OBJECT_CHANGES: 173 case ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_ATTACH: 174 case ChangePackage.CHANGE_DESCRIPTION__RESOURCE_CHANGES: 175 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 176 return; 177 } 178 super.notifyChanged(notification); 179 } 180 181 187 public ResourceLocator getResourceLocator() 188 { 189 return ChangeEditPlugin.INSTANCE; 190 } 191 192 } 193 | Popular Tags |