Go to the documentation of this file.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.DatatypesFactory;
00014 import org.best_of_robotics.model.datatypes.DatatypesPackage;
00015 import org.best_of_robotics.model.datatypes.TypesLibrary;
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 TypesLibraryItemProvider
00042 extends ItemProviderAdapter
00043 implements
00044 IEditingDomainItemProvider,
00045 IStructuredItemContentProvider,
00046 ITreeItemContentProvider,
00047 IItemLabelProvider,
00048 IItemPropertySource {
00055 public TypesLibraryItemProvider(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 addIncludesPropertyDescriptor(object);
00072 }
00073 return itemPropertyDescriptors;
00074 }
00075
00082 protected void addNamePropertyDescriptor(Object object) {
00083 itemPropertyDescriptors.add
00084 (createItemPropertyDescriptor
00085 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
00086 getResourceLocator(),
00087 getString("_UI_TypesLibrary_name_feature"),
00088 getString("_UI_PropertyDescriptor_description", "_UI_TypesLibrary_name_feature", "_UI_TypesLibrary_type"),
00089 DatatypesPackage.Literals.TYPES_LIBRARY__NAME,
00090 true,
00091 false,
00092 false,
00093 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
00094 null,
00095 null));
00096 }
00097
00104 protected void addIncludesPropertyDescriptor(Object object) {
00105 itemPropertyDescriptors.add
00106 (createItemPropertyDescriptor
00107 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
00108 getResourceLocator(),
00109 getString("_UI_TypesLibrary_includes_feature"),
00110 getString("_UI_PropertyDescriptor_description", "_UI_TypesLibrary_includes_feature", "_UI_TypesLibrary_type"),
00111 DatatypesPackage.Literals.TYPES_LIBRARY__INCLUDES,
00112 true,
00113 false,
00114 true,
00115 null,
00116 null,
00117 null));
00118 }
00119
00128 @Override
00129 public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
00130 if (childrenFeatures == null) {
00131 super.getChildrenFeatures(object);
00132 childrenFeatures.add(DatatypesPackage.Literals.TYPES_LIBRARY__TYPES);
00133 }
00134 return childrenFeatures;
00135 }
00136
00142 @Override
00143 protected EStructuralFeature getChildFeature(Object object, Object child) {
00144
00145
00146
00147 return super.getChildFeature(object, child);
00148 }
00149
00156 @Override
00157 public Object getImage(Object object) {
00158 return overlayImage(object, getResourceLocator().getImage("full/obj16/TypesLibrary"));
00159 }
00160
00168 @Override
00169 public String getText(Object object) {
00170 String label = ((TypesLibrary)object).getName();
00171 return label == null || label.length() == 0 ?
00172 getString("_UI_TypesLibrary_type") :
00173 label + " - " + getString("_UI_TypesLibrary_type");
00174 }
00175
00183 @Override
00184 public void notifyChanged(Notification notification) {
00185 updateChildren(notification);
00186
00187 switch (notification.getFeatureID(TypesLibrary.class)) {
00188 case DatatypesPackage.TYPES_LIBRARY__NAME:
00189 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
00190 return;
00191 case DatatypesPackage.TYPES_LIBRARY__TYPES:
00192 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
00193 return;
00194 }
00195 super.notifyChanged(notification);
00196 }
00197
00205 @Override
00206 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
00207 super.collectNewChildDescriptors(newChildDescriptors, object);
00208
00209 newChildDescriptors.add
00210 (createChildParameter
00211 (DatatypesPackage.Literals.TYPES_LIBRARY__TYPES,
00212 DatatypesFactory.eINSTANCE.createSimpleType()));
00213
00214 newChildDescriptors.add
00215 (createChildParameter
00216 (DatatypesPackage.Literals.TYPES_LIBRARY__TYPES,
00217 DatatypesFactory.eINSTANCE.createRosIDLReference()));
00218
00219 newChildDescriptors.add
00220 (createChildParameter
00221 (DatatypesPackage.Literals.TYPES_LIBRARY__TYPES,
00222 DatatypesFactory.eINSTANCE.createVectorType()));
00223
00224 newChildDescriptors.add
00225 (createChildParameter
00226 (DatatypesPackage.Literals.TYPES_LIBRARY__TYPES,
00227 DatatypesFactory.eINSTANCE.createCustomType()));
00228 }
00229
00236 @Override
00237 public ResourceLocator getResourceLocator() {
00238 return DataTypesEditPlugin.INSTANCE;
00239 }
00240
00241 }