1 7 package Olj.provider; 8 9 10 import Olj.ConstantColumnType; 11 import Olj.OljPackage; 12 13 import java.util.Collection ; 14 import java.util.List ; 15 16 import org.eclipse.emf.common.notify.AdapterFactory; 17 import org.eclipse.emf.common.notify.Notification; 18 19 import org.eclipse.emf.common.util.ResourceLocator; 20 21 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 22 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 23 import org.eclipse.emf.edit.provider.IItemLabelProvider; 24 import org.eclipse.emf.edit.provider.IItemPropertySource; 25 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 26 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 27 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 28 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 29 import org.eclipse.emf.edit.provider.ViewerNotification; 30 31 37 public class ConstantColumnTypeItemProvider 38 extends ItemProviderAdapter 39 implements 40 IEditingDomainItemProvider, 41 IStructuredItemContentProvider, 42 ITreeItemContentProvider, 43 IItemLabelProvider, 44 IItemPropertySource { 45 51 public ConstantColumnTypeItemProvider(AdapterFactory adapterFactory) { 52 super(adapterFactory); 53 } 54 55 61 public List getPropertyDescriptors(Object object) { 62 if (itemPropertyDescriptors == null) { 63 super.getPropertyDescriptors(object); 64 65 addConstantValuePropertyDescriptor(object); 66 addTargetColumnNamePropertyDescriptor(object); 67 addTargetTableIDPropertyDescriptor(object); 68 addTargetTableNamePropertyDescriptor(object); 69 addValueModePropertyDescriptor(object); 70 } 71 return itemPropertyDescriptors; 72 } 73 74 80 protected void addConstantValuePropertyDescriptor(Object object) { 81 itemPropertyDescriptors.add 82 (new ItemPropertyDescriptor 83 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 84 getResourceLocator(), 85 getString("_UI_ConstantColumnType_constantValue_feature"), 86 getString("_UI_PropertyDescriptor_description", "_UI_ConstantColumnType_constantValue_feature", "_UI_ConstantColumnType_type"), 87 OljPackage.eINSTANCE.getConstantColumnType_ConstantValue(), 88 true, 89 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 90 } 91 92 98 protected void addTargetColumnNamePropertyDescriptor(Object object) { 99 itemPropertyDescriptors.add 100 (new ItemPropertyDescriptor 101 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 102 getResourceLocator(), 103 getString("_UI_ConstantColumnType_targetColumnName_feature"), 104 getString("_UI_PropertyDescriptor_description", "_UI_ConstantColumnType_targetColumnName_feature", "_UI_ConstantColumnType_type"), 105 OljPackage.eINSTANCE.getConstantColumnType_TargetColumnName(), 106 true, 107 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 108 } 109 110 116 protected void addTargetTableIDPropertyDescriptor(Object object) { 117 itemPropertyDescriptors.add 118 (new ItemPropertyDescriptor 119 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 120 getResourceLocator(), 121 getString("_UI_ConstantColumnType_targetTableID_feature"), 122 getString("_UI_PropertyDescriptor_description", "_UI_ConstantColumnType_targetTableID_feature", "_UI_ConstantColumnType_type"), 123 OljPackage.eINSTANCE.getConstantColumnType_TargetTableID(), 124 true, 125 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 126 } 127 128 134 protected void addTargetTableNamePropertyDescriptor(Object object) { 135 itemPropertyDescriptors.add 136 (new ItemPropertyDescriptor 137 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 138 getResourceLocator(), 139 getString("_UI_ConstantColumnType_targetTableName_feature"), 140 getString("_UI_PropertyDescriptor_description", "_UI_ConstantColumnType_targetTableName_feature", "_UI_ConstantColumnType_type"), 141 OljPackage.eINSTANCE.getConstantColumnType_TargetTableName(), 142 true, 143 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 144 } 145 146 152 protected void addValueModePropertyDescriptor(Object object) { 153 itemPropertyDescriptors.add 154 (new ItemPropertyDescriptor 155 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 156 getResourceLocator(), 157 getString("_UI_ConstantColumnType_valueMode_feature"), 158 getString("_UI_PropertyDescriptor_description", "_UI_ConstantColumnType_valueMode_feature", "_UI_ConstantColumnType_type"), 159 OljPackage.eINSTANCE.getConstantColumnType_ValueMode(), 160 true, 161 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 162 } 163 164 170 public Object getImage(Object object) { 171 return getResourceLocator().getImage("full/obj16/ConstantColumnType"); 172 } 173 174 180 public String getText(Object object) { 181 String label = ((ConstantColumnType)object).getTargetColumnName(); 182 return label == null || label.length() == 0 ? 183 getString("_UI_ConstantColumnType_type") : 184 getString("_UI_ConstantColumnType_type") + " " + label; 185 } 186 187 194 public void notifyChanged(Notification notification) { 195 updateChildren(notification); 196 197 switch (notification.getFeatureID(ConstantColumnType.class)) { 198 case OljPackage.CONSTANT_COLUMN_TYPE__CONSTANT_VALUE: 199 case OljPackage.CONSTANT_COLUMN_TYPE__TARGET_COLUMN_NAME: 200 case OljPackage.CONSTANT_COLUMN_TYPE__TARGET_TABLE_ID: 201 case OljPackage.CONSTANT_COLUMN_TYPE__TARGET_TABLE_NAME: 202 case OljPackage.CONSTANT_COLUMN_TYPE__VALUE_MODE: 203 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 204 return; 205 } 206 super.notifyChanged(notification); 207 } 208 209 216 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { 217 super.collectNewChildDescriptors(newChildDescriptors, object); 218 } 219 220 226 public ResourceLocator getResourceLocator() { 227 return OljEditPlugin.INSTANCE; 228 } 229 230 } 231 | Popular Tags |