1 7 package Olj.provider; 8 9 10 import Olj.OljFactory; 11 import Olj.OljPackage; 12 import Olj.VariablesType; 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 VariablesTypeItemProvider 39 extends ItemProviderAdapter 40 implements 41 IEditingDomainItemProvider, 42 IStructuredItemContentProvider, 43 ITreeItemContentProvider, 44 IItemLabelProvider, 45 IItemPropertySource { 46 52 public VariablesTypeItemProvider(AdapterFactory adapterFactory) { 53 super(adapterFactory); 54 } 55 56 62 public List getPropertyDescriptors(Object object) { 63 if (itemPropertyDescriptors == null) { 64 super.getPropertyDescriptors(object); 65 66 addOverridePropertyDescriptor(object); 67 addPrefixPropertyDescriptor(object); 68 addReplaceInConstantsPropertyDescriptor(object); 69 addReplaceInDataPropertyDescriptor(object); 70 addReplaceInJDBCPropertyDescriptor(object); 71 addReplaceInSQLPropertyDescriptor(object); 72 addSuffixPropertyDescriptor(object); 73 } 74 return itemPropertyDescriptors; 75 } 76 77 83 protected void addOverridePropertyDescriptor(Object object) { 84 itemPropertyDescriptors.add 85 (new ItemPropertyDescriptor 86 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 87 getResourceLocator(), 88 getString("_UI_VariablesType_override_feature"), 89 getString("_UI_PropertyDescriptor_description", "_UI_VariablesType_override_feature", "_UI_VariablesType_type"), 90 OljPackage.eINSTANCE.getVariablesType_Override(), 91 true, 92 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 93 } 94 95 101 protected void addPrefixPropertyDescriptor(Object object) { 102 itemPropertyDescriptors.add 103 (new ItemPropertyDescriptor 104 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 105 getResourceLocator(), 106 getString("_UI_VariablesType_prefix_feature"), 107 getString("_UI_PropertyDescriptor_description", "_UI_VariablesType_prefix_feature", "_UI_VariablesType_type"), 108 OljPackage.eINSTANCE.getVariablesType_Prefix(), 109 true, 110 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 111 } 112 113 119 protected void addReplaceInConstantsPropertyDescriptor(Object object) { 120 itemPropertyDescriptors.add 121 (new ItemPropertyDescriptor 122 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 123 getResourceLocator(), 124 getString("_UI_VariablesType_replaceInConstants_feature"), 125 getString("_UI_PropertyDescriptor_description", "_UI_VariablesType_replaceInConstants_feature", "_UI_VariablesType_type"), 126 OljPackage.eINSTANCE.getVariablesType_ReplaceInConstants(), 127 true, 128 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 129 } 130 131 137 protected void addReplaceInDataPropertyDescriptor(Object object) { 138 itemPropertyDescriptors.add 139 (new ItemPropertyDescriptor 140 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 141 getResourceLocator(), 142 getString("_UI_VariablesType_replaceInData_feature"), 143 getString("_UI_PropertyDescriptor_description", "_UI_VariablesType_replaceInData_feature", "_UI_VariablesType_type"), 144 OljPackage.eINSTANCE.getVariablesType_ReplaceInData(), 145 true, 146 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 147 } 148 149 155 protected void addReplaceInJDBCPropertyDescriptor(Object object) { 156 itemPropertyDescriptors.add 157 (new ItemPropertyDescriptor 158 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 159 getResourceLocator(), 160 getString("_UI_VariablesType_replaceInJDBC_feature"), 161 getString("_UI_PropertyDescriptor_description", "_UI_VariablesType_replaceInJDBC_feature", "_UI_VariablesType_type"), 162 OljPackage.eINSTANCE.getVariablesType_ReplaceInJDBC(), 163 true, 164 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 165 } 166 167 173 protected void addReplaceInSQLPropertyDescriptor(Object object) { 174 itemPropertyDescriptors.add 175 (new ItemPropertyDescriptor 176 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 177 getResourceLocator(), 178 getString("_UI_VariablesType_replaceInSQL_feature"), 179 getString("_UI_PropertyDescriptor_description", "_UI_VariablesType_replaceInSQL_feature", "_UI_VariablesType_type"), 180 OljPackage.eINSTANCE.getVariablesType_ReplaceInSQL(), 181 true, 182 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 183 } 184 185 191 protected void addSuffixPropertyDescriptor(Object object) { 192 itemPropertyDescriptors.add 193 (new ItemPropertyDescriptor 194 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 195 getResourceLocator(), 196 getString("_UI_VariablesType_suffix_feature"), 197 getString("_UI_PropertyDescriptor_description", "_UI_VariablesType_suffix_feature", "_UI_VariablesType_type"), 198 OljPackage.eINSTANCE.getVariablesType_Suffix(), 199 true, 200 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 201 } 202 203 211 public Collection getChildrenFeatures(Object object) { 212 if (childrenFeatures == null) { 213 super.getChildrenFeatures(object); 214 childrenFeatures.add(OljPackage.eINSTANCE.getVariablesType_Variable()); 215 } 216 return childrenFeatures; 217 } 218 219 225 public Object getImage(Object object) { 226 return getResourceLocator().getImage("full/obj16/VariablesType"); 227 } 228 229 235 public String getText(Object object) { 236 String label = ((VariablesType)object).getOverride(); 237 return label == null || label.length() == 0 ? 238 getString("_UI_VariablesType_type") : 239 getString("_UI_VariablesType_type") + " " + label; 240 } 241 242 249 public void notifyChanged(Notification notification) { 250 updateChildren(notification); 251 252 switch (notification.getFeatureID(VariablesType.class)) { 253 case OljPackage.VARIABLES_TYPE__OVERRIDE: 254 case OljPackage.VARIABLES_TYPE__PREFIX: 255 case OljPackage.VARIABLES_TYPE__REPLACE_IN_CONSTANTS: 256 case OljPackage.VARIABLES_TYPE__REPLACE_IN_DATA: 257 case OljPackage.VARIABLES_TYPE__REPLACE_IN_JDBC: 258 case OljPackage.VARIABLES_TYPE__REPLACE_IN_SQL: 259 case OljPackage.VARIABLES_TYPE__SUFFIX: 260 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 261 return; 262 case OljPackage.VARIABLES_TYPE__VARIABLE: 263 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 264 return; 265 } 266 super.notifyChanged(notification); 267 } 268 269 276 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { 277 super.collectNewChildDescriptors(newChildDescriptors, object); 278 279 newChildDescriptors.add 280 (createChildParameter 281 (OljPackage.eINSTANCE.getVariablesType_Variable(), 282 OljFactory.eINSTANCE.createVariableType())); 283 } 284 285 291 public ResourceLocator getResourceLocator() { 292 return OljEditPlugin.INSTANCE; 293 } 294 295 } 296 | Popular Tags |