1 17 package org.eclipse.emf.ecore.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.ENamedElement; 27 import org.eclipse.emf.ecore.EcorePackage; 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 36 import org.eclipse.emf.edit.provider.ViewerNotification; 37 38 44 public class ENamedElementItemProvider 45 extends EModelElementItemProvider 46 implements 47 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 48 { 49 55 public ENamedElementItemProvider(AdapterFactory adapterFactory) 56 { 57 super(adapterFactory); 58 } 59 60 66 public List getPropertyDescriptors(Object object) 67 { 68 if (itemPropertyDescriptors == null) 69 { 70 super.getPropertyDescriptors(object); 71 72 addNamePropertyDescriptor(object); 73 } 74 return itemPropertyDescriptors; 75 } 76 77 83 protected void addNamePropertyDescriptor(Object object) 84 { 85 itemPropertyDescriptors.add 86 (createItemPropertyDescriptor 87 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 88 getResourceLocator(), 89 getString("_UI_ENamedElement_name_feature"), 90 getString("_UI_PropertyDescriptor_description", "_UI_ENamedElement_name_feature", "_UI_ENamedElement_type"), 91 EcorePackage.eINSTANCE.getENamedElement_Name(), 92 true, 93 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 94 null, 95 null)); 96 } 97 98 104 public String getText(Object object) 105 { 106 String label = ((ENamedElement)object).getName(); 107 return label == null || label.length() == 0 ? 108 getString("_UI_ENamedElement_type") : 109 getString("_UI_ENamedElement_type") + " " + label; 110 } 111 112 119 public void notifyChanged(Notification notification) 120 { 121 updateChildren(notification); 122 123 switch (notification.getFeatureID(ENamedElement.class)) 124 { 125 case EcorePackage.ENAMED_ELEMENT__NAME: 126 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 127 return; 128 } 129 super.notifyChanged(notification); 130 } 131 132 139 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 140 { 141 super.collectNewChildDescriptors(newChildDescriptors, object); 142 } 143 144 150 public ResourceLocator getResourceLocator() 151 { 152 return EcoreEditPlugin.INSTANCE; 153 } 154 155 } 156 | Popular Tags |