1 7 package Olj.provider; 8 9 10 import Olj.JdbcSourceParametersType; 11 import Olj.OljFactory; 12 import Olj.OljPackage; 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.edit.provider.ComposeableAdapterFactory; 23 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 24 import org.eclipse.emf.edit.provider.IItemLabelProvider; 25 import org.eclipse.emf.edit.provider.IItemPropertySource; 26 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 27 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 28 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 29 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 30 import org.eclipse.emf.edit.provider.ViewerNotification; 31 32 38 public class JdbcSourceParametersTypeItemProvider 39 extends ItemProviderAdapter 40 implements 41 IEditingDomainItemProvider, 42 IStructuredItemContentProvider, 43 ITreeItemContentProvider, 44 IItemLabelProvider, 45 IItemPropertySource { 46 52 public JdbcSourceParametersTypeItemProvider(AdapterFactory adapterFactory) { 53 super(adapterFactory); 54 } 55 56 62 public List getPropertyDescriptors(Object object) { 63 if (itemPropertyDescriptors == null) { 64 super.getPropertyDescriptors(object); 65 66 addDbVendorPropertyDescriptor(object); 67 addDriverNamePropertyDescriptor(object); 68 } 69 return itemPropertyDescriptors; 70 } 71 72 78 protected void addDbVendorPropertyDescriptor(Object object) { 79 itemPropertyDescriptors.add 80 (new ItemPropertyDescriptor 81 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 82 getResourceLocator(), 83 getString("_UI_JdbcSourceParametersType_dbVendor_feature"), 84 getString("_UI_PropertyDescriptor_description", "_UI_JdbcSourceParametersType_dbVendor_feature", "_UI_JdbcSourceParametersType_type"), 85 OljPackage.eINSTANCE.getJdbcSourceParametersType_DbVendor(), 86 true, 87 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 88 } 89 90 96 protected void addDriverNamePropertyDescriptor(Object object) { 97 itemPropertyDescriptors.add 98 (new ItemPropertyDescriptor 99 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 100 getResourceLocator(), 101 getString("_UI_JdbcSourceParametersType_driverName_feature"), 102 getString("_UI_PropertyDescriptor_description", "_UI_JdbcSourceParametersType_driverName_feature", "_UI_JdbcSourceParametersType_type"), 103 OljPackage.eINSTANCE.getJdbcSourceParametersType_DriverName(), 104 true, 105 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 106 } 107 108 116 public Collection getChildrenFeatures(Object object) { 117 if (childrenFeatures == null) { 118 super.getChildrenFeatures(object); 119 childrenFeatures.add(OljPackage.eINSTANCE.getJdbcSourceParametersType_JdbcSourceParameter()); 120 } 121 return childrenFeatures; 122 } 123 124 130 public Object getImage(Object object) { 131 return getResourceLocator().getImage("full/obj16/JdbcSourceParametersType"); 132 } 133 134 140 public String getText(Object object) { 141 String label = ((JdbcSourceParametersType)object).getDriverName(); 142 return label == null || label.length() == 0 ? 143 getString("_UI_JdbcSourceParametersType_type") : 144 getString("_UI_JdbcSourceParametersType_type") + " " + label; 145 } 146 147 154 public void notifyChanged(Notification notification) { 155 updateChildren(notification); 156 157 switch (notification.getFeatureID(JdbcSourceParametersType.class)) { 158 case OljPackage.JDBC_SOURCE_PARAMETERS_TYPE__DB_VENDOR: 159 case OljPackage.JDBC_SOURCE_PARAMETERS_TYPE__DRIVER_NAME: 160 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 161 return; 162 case OljPackage.JDBC_SOURCE_PARAMETERS_TYPE__JDBC_SOURCE_PARAMETER: 163 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 164 return; 165 } 166 super.notifyChanged(notification); 167 } 168 169 176 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { 177 super.collectNewChildDescriptors(newChildDescriptors, object); 178 179 newChildDescriptors.add 180 (createChildParameter 181 (OljPackage.eINSTANCE.getJdbcSourceParametersType_JdbcSourceParameter(), 182 OljFactory.eINSTANCE.createJdbcSourceParameterType())); 183 } 184 185 191 public ResourceLocator getResourceLocator() { 192 return OljEditPlugin.INSTANCE; 193 } 194 195 } 196 | Popular Tags |