1 7 package Olj.provider; 8 9 10 import Olj.OljFactory; 11 import Olj.OljPackage; 12 import Olj.SqlType; 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.ecore.EStructuralFeature; 23 24 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 25 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 26 import org.eclipse.emf.edit.provider.IItemLabelProvider; 27 import org.eclipse.emf.edit.provider.IItemPropertySource; 28 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 29 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 30 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 31 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 32 import org.eclipse.emf.edit.provider.ViewerNotification; 33 34 40 public class SqlTypeItemProvider 41 extends ItemProviderAdapter 42 implements 43 IEditingDomainItemProvider, 44 IStructuredItemContentProvider, 45 ITreeItemContentProvider, 46 IItemLabelProvider, 47 IItemPropertySource { 48 54 public SqlTypeItemProvider(AdapterFactory adapterFactory) { 55 super(adapterFactory); 56 } 57 58 64 public List getPropertyDescriptors(Object object) { 65 if (itemPropertyDescriptors == null) { 66 super.getPropertyDescriptors(object); 67 68 addCommitPropertyDescriptor(object); 69 addLogModePropertyDescriptor(object); 70 addNamePropertyDescriptor(object); 71 addOnErrorContinuePropertyDescriptor(object); 72 addReturnCodePropertyDescriptor(object); 73 } 74 return itemPropertyDescriptors; 75 } 76 77 83 protected void addCommitPropertyDescriptor(Object object) { 84 itemPropertyDescriptors.add 85 (new ItemPropertyDescriptor 86 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 87 getResourceLocator(), 88 getString("_UI_SqlType_commit_feature"), 89 getString("_UI_PropertyDescriptor_description", "_UI_SqlType_commit_feature", "_UI_SqlType_type"), 90 OljPackage.eINSTANCE.getSqlType_Commit(), 91 true, 92 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 93 } 94 95 101 protected void addLogModePropertyDescriptor(Object object) { 102 itemPropertyDescriptors.add 103 (new ItemPropertyDescriptor 104 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 105 getResourceLocator(), 106 getString("_UI_SqlType_logMode_feature"), 107 getString("_UI_PropertyDescriptor_description", "_UI_SqlType_logMode_feature", "_UI_SqlType_type"), 108 OljPackage.eINSTANCE.getSqlType_LogMode(), 109 true, 110 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 111 } 112 113 119 protected void addNamePropertyDescriptor(Object object) { 120 itemPropertyDescriptors.add 121 (new ItemPropertyDescriptor 122 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 123 getResourceLocator(), 124 getString("_UI_SqlType_name_feature"), 125 getString("_UI_PropertyDescriptor_description", "_UI_SqlType_name_feature", "_UI_SqlType_type"), 126 OljPackage.eINSTANCE.getSqlType_Name(), 127 true, 128 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 129 } 130 131 137 protected void addOnErrorContinuePropertyDescriptor(Object object) { 138 itemPropertyDescriptors.add 139 (new ItemPropertyDescriptor 140 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 141 getResourceLocator(), 142 getString("_UI_SqlType_onErrorContinue_feature"), 143 getString("_UI_PropertyDescriptor_description", "_UI_SqlType_onErrorContinue_feature", "_UI_SqlType_type"), 144 OljPackage.eINSTANCE.getSqlType_OnErrorContinue(), 145 true, 146 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 147 } 148 149 155 protected void addReturnCodePropertyDescriptor(Object object) { 156 itemPropertyDescriptors.add 157 (new ItemPropertyDescriptor 158 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 159 getResourceLocator(), 160 getString("_UI_SqlType_returnCode_feature"), 161 getString("_UI_PropertyDescriptor_description", "_UI_SqlType_returnCode_feature", "_UI_SqlType_type"), 162 OljPackage.eINSTANCE.getSqlType_ReturnCode(), 163 true, 164 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 165 } 166 167 175 public Collection getChildrenFeatures(Object object) { 176 if (childrenFeatures == null) { 177 super.getChildrenFeatures(object); 178 childrenFeatures.add(OljPackage.eINSTANCE.getSqlType_JdbcTargetParameters()); 179 childrenFeatures.add(OljPackage.eINSTANCE.getSqlType_Include()); 180 childrenFeatures.add(OljPackage.eINSTANCE.getSqlType_SqlStmt()); 181 } 182 return childrenFeatures; 183 } 184 185 190 protected EStructuralFeature getChildFeature(Object object, Object child) { 191 194 return super.getChildFeature(object, child); 195 } 196 197 203 public Object getImage(Object object) { 204 return getResourceLocator().getImage("full/obj16/SqlType"); 205 } 206 207 213 public String getText(Object object) { 214 String label = ((SqlType)object).getName(); 215 return label == null || label.length() == 0 ? 216 getString("_UI_SqlType_type") : 217 getString("_UI_SqlType_type") + " " + label; 218 } 219 220 227 public void notifyChanged(Notification notification) { 228 updateChildren(notification); 229 230 switch (notification.getFeatureID(SqlType.class)) { 231 case OljPackage.SQL_TYPE__COMMIT: 232 case OljPackage.SQL_TYPE__LOG_MODE: 233 case OljPackage.SQL_TYPE__NAME: 234 case OljPackage.SQL_TYPE__ON_ERROR_CONTINUE: 235 case OljPackage.SQL_TYPE__RETURN_CODE: 236 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 237 return; 238 case OljPackage.SQL_TYPE__JDBC_TARGET_PARAMETERS: 239 case OljPackage.SQL_TYPE__INCLUDE: 240 case OljPackage.SQL_TYPE__SQL_STMT: 241 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 242 return; 243 } 244 super.notifyChanged(notification); 245 } 246 247 254 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { 255 super.collectNewChildDescriptors(newChildDescriptors, object); 256 257 newChildDescriptors.add 258 (createChildParameter 259 (OljPackage.eINSTANCE.getSqlType_JdbcTargetParameters(), 260 OljFactory.eINSTANCE.createJdbcTargetParametersType())); 261 262 newChildDescriptors.add 263 (createChildParameter 264 (OljPackage.eINSTANCE.getSqlType_Include(), 265 OljFactory.eINSTANCE.createIncludeType())); 266 267 newChildDescriptors.add 268 (createChildParameter 269 (OljPackage.eINSTANCE.getSqlType_SqlStmt(), 270 OljFactory.eINSTANCE.createSqlStmtType())); 271 } 272 273 279 public ResourceLocator getResourceLocator() { 280 return OljEditPlugin.INSTANCE; 281 } 282 283 } 284 | Popular Tags |