$search
00001 00007 package org.best_of_robotics.model.datatypes.provider; 00008 00009 00010 import java.util.Collection; 00011 import java.util.List; 00012 00013 import org.best_of_robotics.model.datatypes.CustomType; 00014 import org.best_of_robotics.model.datatypes.DatatypesFactory; 00015 import org.best_of_robotics.model.datatypes.DatatypesPackage; 00016 00017 import org.eclipse.emf.common.notify.AdapterFactory; 00018 import org.eclipse.emf.common.notify.Notification; 00019 00020 import org.eclipse.emf.common.util.ResourceLocator; 00021 00022 import org.eclipse.emf.ecore.EStructuralFeature; 00023 00024 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 00025 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 00026 import org.eclipse.emf.edit.provider.IItemLabelProvider; 00027 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; 00028 import org.eclipse.emf.edit.provider.IItemPropertySource; 00029 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 00030 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 00031 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 00032 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 00033 import org.eclipse.emf.edit.provider.ViewerNotification; 00034 00041 public class CustomTypeItemProvider 00042 extends ItemProviderAdapter 00043 implements 00044 IEditingDomainItemProvider, 00045 IStructuredItemContentProvider, 00046 ITreeItemContentProvider, 00047 IItemLabelProvider, 00048 IItemPropertySource { 00055 public CustomTypeItemProvider(AdapterFactory adapterFactory) { 00056 super(adapterFactory); 00057 } 00058 00065 @Override 00066 public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { 00067 if (itemPropertyDescriptors == null) { 00068 super.getPropertyDescriptors(object); 00069 00070 addNamePropertyDescriptor(object); 00071 } 00072 return itemPropertyDescriptors; 00073 } 00074 00081 protected void addNamePropertyDescriptor(Object object) { 00082 itemPropertyDescriptors.add 00083 (createItemPropertyDescriptor 00084 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 00085 getResourceLocator(), 00086 getString("_UI_DataType_name_feature"), 00087 getString("_UI_PropertyDescriptor_description", "_UI_DataType_name_feature", "_UI_DataType_type"), 00088 DatatypesPackage.Literals.DATA_TYPE__NAME, 00089 true, 00090 false, 00091 false, 00092 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 00093 null, 00094 null)); 00095 } 00096 00105 @Override 00106 public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { 00107 if (childrenFeatures == null) { 00108 super.getChildrenFeatures(object); 00109 childrenFeatures.add(DatatypesPackage.Literals.CUSTOM_TYPE__FIELDS); 00110 } 00111 return childrenFeatures; 00112 } 00113 00119 @Override 00120 protected EStructuralFeature getChildFeature(Object object, Object child) { 00121 // Check the type of the specified child object and return the proper feature to use for 00122 // adding (see {@link AddCommand}) it as a child. 00123 00124 return super.getChildFeature(object, child); 00125 } 00126 00133 @Override 00134 public Object getImage(Object object) { 00135 return overlayImage(object, getResourceLocator().getImage("full/obj16/CustomType")); 00136 } 00137 00145 @Override 00146 public String getText(Object object) { 00147 String label = ((CustomType)object).getLabel(); 00148 return label == null || label.length() == 0 ? 00149 getString("_UI_CustomType_type") : 00150 label + " - " + getString("_UI_CustomType_type"); 00151 } 00152 00160 @Override 00161 public void notifyChanged(Notification notification) { 00162 updateChildren(notification); 00163 00164 switch (notification.getFeatureID(CustomType.class)) { 00165 case DatatypesPackage.CUSTOM_TYPE__NAME: 00166 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 00167 return; 00168 case DatatypesPackage.CUSTOM_TYPE__FIELDS: 00169 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 00170 return; 00171 } 00172 super.notifyChanged(notification); 00173 } 00174 00182 @Override 00183 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { 00184 super.collectNewChildDescriptors(newChildDescriptors, object); 00185 00186 newChildDescriptors.add 00187 (createChildParameter 00188 (DatatypesPackage.Literals.CUSTOM_TYPE__FIELDS, 00189 DatatypesFactory.eINSTANCE.createField())); 00190 } 00191 00198 @Override 00199 public ResourceLocator getResourceLocator() { 00200 return DataTypesEditPlugin.INSTANCE; 00201 } 00202 00203 }