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.EClassifier; 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 37 import org.eclipse.emf.edit.provider.ViewerNotification; 38 39 45 public class EClassifierItemProvider 46 extends ENamedElementItemProvider 47 implements 48 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 49 { 50 56 public EClassifierItemProvider(AdapterFactory adapterFactory) 57 { 58 super(adapterFactory); 59 } 60 61 67 public List getPropertyDescriptors(Object object) 68 { 69 if (itemPropertyDescriptors == null) 70 { 71 super.getPropertyDescriptors(object); 72 73 addInstanceClassNamePropertyDescriptor(object); 74 addDefaultValuePropertyDescriptor(object); 75 } 76 return itemPropertyDescriptors; 77 } 78 79 85 protected void addInstanceClassNamePropertyDescriptor(Object object) 86 { 87 itemPropertyDescriptors.add 88 (createItemPropertyDescriptor 89 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 90 getResourceLocator(), 91 getString("_UI_EClassifier_instanceClassName_feature"), 92 getString("_UI_PropertyDescriptor_description", "_UI_EClassifier_instanceClassName_feature", "_UI_EClassifier_type"), 93 EcorePackage.eINSTANCE.getEClassifier_InstanceClassName(), 94 true, 95 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 96 null, 97 null)); 98 } 99 100 106 protected void addDefaultValuePropertyDescriptor(Object object) 107 { 108 itemPropertyDescriptors.add 109 (createItemPropertyDescriptor 110 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 111 getResourceLocator(), 112 getString("_UI_EClassifier_defaultValue_feature"), 113 getString("_UI_PropertyDescriptor_description", "_UI_EClassifier_defaultValue_feature", "_UI_EClassifier_type"), 114 EcorePackage.eINSTANCE.getEClassifier_DefaultValue(), 115 false, 116 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 117 null, 118 null)); 119 } 120 121 127 public String getText(Object object) 128 { 129 String label = ((EClassifier)object).getName(); 130 return label == null || label.length() == 0 ? 131 getString("_UI_EClassifier_type") : 132 getString("_UI_EClassifier_type") + " " + label; 133 } 134 135 142 public void notifyChanged(Notification notification) 143 { 144 updateChildren(notification); 145 146 switch (notification.getFeatureID(EClassifier.class)) 147 { 148 case EcorePackage.ECLASSIFIER__INSTANCE_CLASS_NAME: 149 case EcorePackage.ECLASSIFIER__DEFAULT_VALUE: 150 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 151 return; 152 } 153 super.notifyChanged(notification); 154 } 155 156 163 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 164 { 165 super.collectNewChildDescriptors(newChildDescriptors, object); 166 } 167 168 174 public ResourceLocator getResourceLocator() 175 { 176 return EcoreEditPlugin.INSTANCE; 177 } 178 179 } 180 | Popular Tags |