1 7 package Olj.provider; 8 9 10 import Olj.OljFactory; 11 import Olj.OljPackage; 12 import Olj.TransformationType; 13 14 import java.util.Collection ; 15 import java.util.List ; 16 17 import org.eclipse.emf.common.notify.AdapterFactory; 18 import org.eclipse.emf.common.notify.Notification; 19 20 import org.eclipse.emf.common.util.ResourceLocator; 21 22 import org.eclipse.emf.ecore.EStructuralFeature; 23 24 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 25 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 26 import org.eclipse.emf.edit.provider.IItemLabelProvider; 27 import org.eclipse.emf.edit.provider.IItemPropertySource; 28 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 29 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 30 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 31 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 32 import org.eclipse.emf.edit.provider.ViewerNotification; 33 34 40 public class TransformationTypeItemProvider 41 extends ItemProviderAdapter 42 implements 43 IEditingDomainItemProvider, 44 IStructuredItemContentProvider, 45 ITreeItemContentProvider, 46 IItemLabelProvider, 47 IItemPropertySource { 48 54 public TransformationTypeItemProvider(AdapterFactory adapterFactory) { 55 super(adapterFactory); 56 } 57 58 64 public List getPropertyDescriptors(Object object) { 65 if (itemPropertyDescriptors == null) { 66 super.getPropertyDescriptors(object); 67 68 addNamePropertyDescriptor(object); 69 addTransformatorClassNamePropertyDescriptor(object); 70 addTransformatorConfigPropertyDescriptor(object); 71 } 72 return itemPropertyDescriptors; 73 } 74 75 81 protected void addNamePropertyDescriptor(Object object) { 82 itemPropertyDescriptors.add 83 (new ItemPropertyDescriptor 84 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 85 getResourceLocator(), 86 getString("_UI_TransformationType_name_feature"), 87 getString("_UI_PropertyDescriptor_description", "_UI_TransformationType_name_feature", "_UI_TransformationType_type"), 88 OljPackage.eINSTANCE.getTransformationType_Name(), 89 true, 90 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 91 } 92 93 99 protected void addTransformatorClassNamePropertyDescriptor(Object object) { 100 itemPropertyDescriptors.add 101 (new ItemPropertyDescriptor 102 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 103 getResourceLocator(), 104 getString("_UI_TransformationType_transformatorClassName_feature"), 105 getString("_UI_PropertyDescriptor_description", "_UI_TransformationType_transformatorClassName_feature", "_UI_TransformationType_type"), 106 OljPackage.eINSTANCE.getTransformationType_TransformatorClassName(), 107 true, 108 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 109 } 110 111 117 protected void addTransformatorConfigPropertyDescriptor(Object object) { 118 itemPropertyDescriptors.add 119 (new ItemPropertyDescriptor 120 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 121 getResourceLocator(), 122 getString("_UI_TransformationType_transformatorConfig_feature"), 123 getString("_UI_PropertyDescriptor_description", "_UI_TransformationType_transformatorConfig_feature", "_UI_TransformationType_type"), 124 OljPackage.eINSTANCE.getTransformationType_TransformatorConfig(), 125 true, 126 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 127 } 128 129 137 public Collection getChildrenFeatures(Object object) { 138 if (childrenFeatures == null) { 139 super.getChildrenFeatures(object); 140 childrenFeatures.add(OljPackage.eINSTANCE.getTransformationType_SourceColumns()); 141 childrenFeatures.add(OljPackage.eINSTANCE.getTransformationType_TargetColumns()); 142 childrenFeatures.add(OljPackage.eINSTANCE.getTransformationType_JavaScript()); 143 } 144 return childrenFeatures; 145 } 146 147 152 protected EStructuralFeature getChildFeature(Object object, Object child) { 153 156 return super.getChildFeature(object, child); 157 } 158 159 165 public Object getImage(Object object) { 166 return getResourceLocator().getImage("full/obj16/TransformationType"); 167 } 168 169 175 public String getText(Object object) { 176 String label = ((TransformationType)object).getName(); 177 return label == null || label.length() == 0 ? 178 getString("_UI_TransformationType_type") : 179 getString("_UI_TransformationType_type") + " " + label; 180 } 181 182 189 public void notifyChanged(Notification notification) { 190 updateChildren(notification); 191 192 switch (notification.getFeatureID(TransformationType.class)) { 193 case OljPackage.TRANSFORMATION_TYPE__NAME: 194 case OljPackage.TRANSFORMATION_TYPE__TRANSFORMATOR_CLASS_NAME: 195 case OljPackage.TRANSFORMATION_TYPE__TRANSFORMATOR_CONFIG: 196 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 197 return; 198 case OljPackage.TRANSFORMATION_TYPE__SOURCE_COLUMNS: 199 case OljPackage.TRANSFORMATION_TYPE__TARGET_COLUMNS: 200 case OljPackage.TRANSFORMATION_TYPE__JAVA_SCRIPT: 201 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 202 return; 203 } 204 super.notifyChanged(notification); 205 } 206 207 214 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { 215 super.collectNewChildDescriptors(newChildDescriptors, object); 216 217 newChildDescriptors.add 218 (createChildParameter 219 (OljPackage.eINSTANCE.getTransformationType_SourceColumns(), 220 OljFactory.eINSTANCE.createSourceColumnsType())); 221 222 newChildDescriptors.add 223 (createChildParameter 224 (OljPackage.eINSTANCE.getTransformationType_TargetColumns(), 225 OljFactory.eINSTANCE.createTargetColumnsType())); 226 227 newChildDescriptors.add 228 (createChildParameter 229 (OljPackage.eINSTANCE.getTransformationType_JavaScript(), 230 OljFactory.eINSTANCE.createJavaScriptType())); 231 } 232 233 239 public ResourceLocator getResourceLocator() { 240 return OljEditPlugin.INSTANCE; 241 } 242 243 } 244 | Popular Tags |