1 17 package org.eclipse.emf.ecore.sdo.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 import org.eclipse.emf.common.util.ResourceLocator; 25 import org.eclipse.emf.ecore.sdo.EProperty; 26 import org.eclipse.emf.ecore.sdo.SDOPackage; 27 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 28 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 29 import org.eclipse.emf.edit.provider.IItemLabelProvider; 30 import org.eclipse.emf.edit.provider.IItemPropertySource; 31 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 32 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 33 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 34 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 35 36 37 import org.eclipse.emf.edit.provider.ViewerNotification; 38 39 45 public class EPropertyItemProvider 46 extends ItemProviderAdapter 47 implements 48 IEditingDomainItemProvider, 49 IStructuredItemContentProvider, 50 ITreeItemContentProvider, 51 IItemLabelProvider, 52 IItemPropertySource 53 { 54 60 public EPropertyItemProvider(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 addNamePropertyDescriptor(object); 78 addManyPropertyDescriptor(object); 79 addContainmentPropertyDescriptor(object); 80 addDefaultPropertyDescriptor(object); 81 addTypePropertyDescriptor(object); 82 addContainingTypePropertyDescriptor(object); 83 addEStructuralFeaturePropertyDescriptor(object); 84 } 85 return itemPropertyDescriptors; 86 } 87 88 94 protected void addNamePropertyDescriptor(Object object) 95 { 96 itemPropertyDescriptors.add 97 (createItemPropertyDescriptor 98 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 99 getResourceLocator(), 100 getString("_UI_Property_name_feature"), 101 getString("_UI_PropertyDescriptor_description", "_UI_Property_name_feature", "_UI_Property_type"), 102 SDOPackage.eINSTANCE.getProperty_Name(), 103 true, 104 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 105 null, 106 null)); 107 } 108 109 115 protected void addManyPropertyDescriptor(Object object) 116 { 117 itemPropertyDescriptors.add 118 (createItemPropertyDescriptor 119 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 120 getResourceLocator(), 121 getString("_UI_Property_many_feature"), 122 getString("_UI_PropertyDescriptor_description", "_UI_Property_many_feature", "_UI_Property_type"), 123 SDOPackage.eINSTANCE.getProperty_Many(), 124 false, 125 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 126 null, 127 null)); 128 } 129 130 136 protected void addContainmentPropertyDescriptor(Object object) 137 { 138 itemPropertyDescriptors.add 139 (createItemPropertyDescriptor 140 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 141 getResourceLocator(), 142 getString("_UI_Property_containment_feature"), 143 getString("_UI_PropertyDescriptor_description", "_UI_Property_containment_feature", "_UI_Property_type"), 144 SDOPackage.eINSTANCE.getProperty_Containment(), 145 false, 146 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 147 null, 148 null)); 149 } 150 151 157 protected void addDefaultPropertyDescriptor(Object object) 158 { 159 itemPropertyDescriptors.add 160 (createItemPropertyDescriptor 161 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 162 getResourceLocator(), 163 getString("_UI_Property_default_feature"), 164 getString("_UI_PropertyDescriptor_description", "_UI_Property_default_feature", "_UI_Property_type"), 165 SDOPackage.eINSTANCE.getProperty_Default(), 166 false, 167 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 168 null, 169 null)); 170 } 171 172 178 protected void addTypePropertyDescriptor(Object object) 179 { 180 itemPropertyDescriptors.add 181 (createItemPropertyDescriptor 182 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 183 getResourceLocator(), 184 getString("_UI_Property_type_feature"), 185 getString("_UI_PropertyDescriptor_description", "_UI_Property_type_feature", "_UI_Property_type"), 186 SDOPackage.eINSTANCE.getProperty_Type(), 187 false, 188 null, 189 null, 190 null)); 191 } 192 193 199 protected void addContainingTypePropertyDescriptor(Object object) 200 { 201 itemPropertyDescriptors.add 202 (createItemPropertyDescriptor 203 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 204 getResourceLocator(), 205 getString("_UI_Property_containingType_feature"), 206 getString("_UI_PropertyDescriptor_description", "_UI_Property_containingType_feature", "_UI_Property_type"), 207 SDOPackage.eINSTANCE.getProperty_ContainingType(), 208 false, 209 null, 210 null, 211 null)); 212 } 213 214 220 protected void addEStructuralFeaturePropertyDescriptor(Object object) 221 { 222 itemPropertyDescriptors.add 223 (createItemPropertyDescriptor 224 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 225 getResourceLocator(), 226 getString("_UI_EProperty_eStructuralFeature_feature"), 227 getString("_UI_PropertyDescriptor_description", "_UI_EProperty_eStructuralFeature_feature", "_UI_EProperty_type"), 228 SDOPackage.eINSTANCE.getEProperty_EStructuralFeature(), 229 true, 230 null, 231 null, 232 null)); 233 } 234 235 241 public Object getImage(Object object) 242 { 243 return getResourceLocator().getImage("full/obj16/EProperty"); 244 } 245 246 252 public String getText(Object object) 253 { 254 String label = ((EProperty)object).getName(); 255 return label == null || label.length() == 0 ? 256 getString("_UI_EProperty_type") : 257 getString("_UI_EProperty_type") + " " + label; 258 } 259 260 267 public void notifyChanged(Notification notification) 268 { 269 updateChildren(notification); 270 271 switch (notification.getFeatureID(EProperty.class)) 272 { 273 case SDOPackage.EPROPERTY__NAME: 274 case SDOPackage.EPROPERTY__MANY: 275 case SDOPackage.EPROPERTY__CONTAINMENT: 276 case SDOPackage.EPROPERTY__DEFAULT: 277 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 278 return; 279 } 280 super.notifyChanged(notification); 281 } 282 283 289 public ResourceLocator getResourceLocator() 290 { 291 return SDOEditPlugin.INSTANCE; 292 } 293 294 } 295 | Popular Tags |