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.DatatypesPackage;
00014 import org.best_of_robotics.model.datatypes.VectorType;
00015
00016 import org.eclipse.emf.common.notify.AdapterFactory;
00017 import org.eclipse.emf.common.notify.Notification;
00018
00019 import org.eclipse.emf.common.util.ResourceLocator;
00020
00021 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
00022 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
00023 import org.eclipse.emf.edit.provider.IItemLabelProvider;
00024 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
00025 import org.eclipse.emf.edit.provider.IItemPropertySource;
00026 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
00027 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
00028 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
00029 import org.eclipse.emf.edit.provider.ItemProviderAdapter;
00030 import org.eclipse.emf.edit.provider.ViewerNotification;
00031
00038 public class VectorTypeItemProvider
00039 extends ItemProviderAdapter
00040 implements
00041 IEditingDomainItemProvider,
00042 IStructuredItemContentProvider,
00043 ITreeItemContentProvider,
00044 IItemLabelProvider,
00045 IItemPropertySource {
00052 public VectorTypeItemProvider(AdapterFactory adapterFactory) {
00053 super(adapterFactory);
00054 }
00055
00062 @Override
00063 public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
00064 if (itemPropertyDescriptors == null) {
00065 super.getPropertyDescriptors(object);
00066
00067 addNamePropertyDescriptor(object);
00068 addTemplatePropertyDescriptor(object);
00069 }
00070 return itemPropertyDescriptors;
00071 }
00072
00079 protected void addNamePropertyDescriptor(Object object) {
00080 itemPropertyDescriptors.add
00081 (createItemPropertyDescriptor
00082 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
00083 getResourceLocator(),
00084 getString("_UI_DataType_name_feature"),
00085 getString("_UI_PropertyDescriptor_description", "_UI_DataType_name_feature", "_UI_DataType_type"),
00086 DatatypesPackage.Literals.DATA_TYPE__NAME,
00087 true,
00088 false,
00089 false,
00090 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
00091 null,
00092 null));
00093 }
00094
00101 protected void addTemplatePropertyDescriptor(Object object) {
00102 itemPropertyDescriptors.add
00103 (createItemPropertyDescriptor
00104 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
00105 getResourceLocator(),
00106 getString("_UI_VectorType_template_feature"),
00107 getString("_UI_PropertyDescriptor_description", "_UI_VectorType_template_feature", "_UI_VectorType_type"),
00108 DatatypesPackage.Literals.VECTOR_TYPE__TEMPLATE,
00109 true,
00110 false,
00111 true,
00112 null,
00113 null,
00114 null));
00115 }
00116
00123 @Override
00124 public Object getImage(Object object) {
00125 return overlayImage(object, getResourceLocator().getImage("full/obj16/VectorType"));
00126 }
00127
00135 @Override
00136 public String getText(Object object) {
00137
00138 String label = ((VectorType)object).getLabel();
00139 return label == null || label.length() == 0 ?
00140 getString("_UI_VectorType_type") :
00141 label + " - " + getString("_UI_VectorType_type");
00142 }
00143
00151 @Override
00152 public void notifyChanged(Notification notification) {
00153 updateChildren(notification);
00154
00155 switch (notification.getFeatureID(VectorType.class)) {
00156 case DatatypesPackage.VECTOR_TYPE__NAME:
00157 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
00158 return;
00159 }
00160 super.notifyChanged(notification);
00161 }
00162
00170 @Override
00171 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
00172 super.collectNewChildDescriptors(newChildDescriptors, object);
00173 }
00174
00181 @Override
00182 public ResourceLocator getResourceLocator() {
00183 return DataTypesEditPlugin.INSTANCE;
00184 }
00185
00186 }