cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 1 | /*************************************************************************************************** |
| 2 | * Copyright (c) 2005, 2006 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | * Oracle Corporation - revision |
| 11 | **************************************************************************************************/ |
| 12 | package org.eclipse.jst.jsf.facesconfig.edit.provider; |
| 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 | import org.eclipse.emf.common.util.ResourceLocator; |
| 20 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 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; |
cbateman | 26b5883 | 2007-10-02 17:57:10 +0000 | [diff] [blame] | 26 | import org.eclipse.emf.edit.provider.ITableItemLabelProvider; |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 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; |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 31 | import org.eclipse.jst.jsf.facesconfig.FacesConfigPlugin; |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 32 | import org.eclipse.jst.jsf.facesconfig.emf.ConverterType; |
gkessler | 97f5fcd | 2010-03-17 23:28:55 +0000 | [diff] [blame] | 33 | import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 34 | import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; |
| 35 | import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; |
| 36 | |
| 37 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 38 | * This is the item provider adapter for a {@link org.eclipse.jst.jsf.facesconfig.emf.ConverterType} object. |
cbateman | 26b5883 | 2007-10-02 17:57:10 +0000 | [diff] [blame] | 39 | * <!-- begin-user-doc --> |
| 40 | * @extends ITableItemLabelProvider |
| 41 | * <!-- end-user-doc --> |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 42 | * @generated |
| 43 | */ |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 44 | @SuppressWarnings("nls") |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 45 | public class ConverterTypeItemProvider extends ItemProviderAdapter implements |
cbateman | 26b5883 | 2007-10-02 17:57:10 +0000 | [diff] [blame] | 46 | IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource, ITableItemLabelProvider { |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 47 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 48 | * <!-- begin-user-doc --> <!-- end-user-doc --> |
| 49 | * @generated |
| 50 | */ |
gkessler | cfc5308 | 2008-11-18 22:25:04 +0000 | [diff] [blame] | 51 | public static final String copyright = "Copyright (c) 2005, 2006 IBM Corporation and others"; //$NON-NLS-1$ |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 54 | * This constructs an instance from a factory and a notifier. |
cbateman | 26b5883 | 2007-10-02 17:57:10 +0000 | [diff] [blame] | 55 | * <!-- begin-user-doc --> |
| 56 | * @param adapterFactory |
| 57 | * <!-- end-user-doc --> |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 58 | * @generated |
| 59 | */ |
| 60 | public ConverterTypeItemProvider(AdapterFactory adapterFactory) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 61 | super(adapterFactory); |
| 62 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * This returns the property descriptors for the adapted class. <!-- |
| 66 | * begin-user-doc --> <!-- end-user-doc --> |
| 67 | * |
| 68 | * @generated |
| 69 | */ |
| 70 | public List getPropertyDescriptors(Object object) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 71 | if (itemPropertyDescriptors == null) { |
| 72 | super.getPropertyDescriptors(object); |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 73 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 74 | addIdPropertyDescriptor(object); |
| 75 | } |
| 76 | return itemPropertyDescriptors; |
| 77 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 78 | |
| 79 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 80 | * This adds a property descriptor for the Id feature. |
cbateman | 26b5883 | 2007-10-02 17:57:10 +0000 | [diff] [blame] | 81 | * <!-- begin-user-doc --> |
cbateman | 26b5883 | 2007-10-02 17:57:10 +0000 | [diff] [blame] | 82 | * @param object |
| 83 | * <!-- end-user-doc --> |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 84 | * @generated |
| 85 | */ |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 86 | protected void addIdPropertyDescriptor(Object object) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 87 | itemPropertyDescriptors.add |
| 88 | (createItemPropertyDescriptor |
| 89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 90 | getResourceLocator(), |
| 91 | getString("_UI_ConverterType_id_feature"), |
| 92 | getString("_UI_PropertyDescriptor_description", "_UI_ConverterType_id_feature", "_UI_ConverterType_type"), |
| 93 | FacesConfigPackage.Literals.CONVERTER_TYPE__ID, |
| 94 | true, |
| 95 | false, |
| 96 | false, |
| 97 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
| 98 | null, |
| 99 | null)); |
| 100 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 101 | |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 102 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 103 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 104 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 105 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 106 | * <!-- begin-user-doc --> <!-- end-user-doc --> |
| 107 | * @generated |
| 108 | */ |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 109 | public Collection getChildrenFeatures(Object object) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 110 | if (childrenFeatures == null) { |
| 111 | super.getChildrenFeatures(object); |
| 112 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__DESCRIPTION); |
| 113 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__DISPLAY_NAME); |
| 114 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__ICON); |
| 115 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_ID); |
| 116 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_FOR_CLASS); |
| 117 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_CLASS); |
| 118 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__ATTRIBUTE); |
| 119 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__PROPERTY); |
| 120 | childrenFeatures.add(FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_EXTENSION); |
| 121 | } |
| 122 | return childrenFeatures; |
| 123 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 124 | |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 125 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 126 | * <!-- begin-user-doc --> <!-- end-user-doc --> |
| 127 | * @generated |
| 128 | */ |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 129 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 130 | // Check the type of the specified child object and return the proper feature to use for |
| 131 | // adding (see {@link AddCommand}) it as a child. |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 132 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 133 | return super.getChildFeature(object, child); |
| 134 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * This returns ConverterType.gif. <!-- begin-user-doc --> <!-- end-user-doc |
| 138 | * --> |
| 139 | * |
| 140 | * @generated |
| 141 | */ |
| 142 | public Object getImage(Object object) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 143 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ConverterType")); |
| 144 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 145 | |
gkessler | 97f5fcd | 2010-03-17 23:28:55 +0000 | [diff] [blame] | 146 | /** |
| 147 | * This returns the label text for the adapted class. <!-- begin-user-doc |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 148 | * --> <!-- end-user-doc --> |
gkessler | 97f5fcd | 2010-03-17 23:28:55 +0000 | [diff] [blame] | 149 | * |
| 150 | * @generated NOT |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 151 | */ |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 152 | public String getText(Object object) { |
gkessler | 97f5fcd | 2010-03-17 23:28:55 +0000 | [diff] [blame] | 153 | String label = null; |
| 154 | |
| 155 | if (((ConverterType) object).getDisplayName() != null |
| 156 | && ((ConverterType) object).getDisplayName().size() > 0) { |
| 157 | label = ((DisplayNameType) ((ConverterType) object) |
| 158 | .getDisplayName().get(0)).getTextContent(); |
| 159 | } |
| 160 | |
| 161 | if (label == null && ((ConverterType) object).getConverterId() != null) { |
| 162 | label = ((ConverterType) object).getConverterId().getTextContent(); |
| 163 | } |
| 164 | |
| 165 | if (label == null || label.length() == 0) { |
| 166 | if (((ConverterType) object).getConverterClass() != null) |
| 167 | label = ((ConverterType) object).getConverterClass() |
| 168 | .getTextContent(); |
| 169 | } |
| 170 | if (label == null || label.length() ==0) { |
| 171 | label = ((ConverterType) object).getId(); |
| 172 | } |
| 173 | |
| 174 | return label == null || label.length() == 0 ? getString("_UI_ConverterType_type") |
| 175 | : label; |
| 176 | // : getString("_UI_ConverterType_type") + " " + label; |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 177 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 178 | |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 179 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 180 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 181 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 182 | * <!-- begin-user-doc --> <!-- |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 183 | * end-user-doc --> |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 184 | * @generated |
| 185 | */ |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 186 | public void notifyChanged(Notification notification) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 187 | updateChildren(notification); |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 188 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 189 | switch (notification.getFeatureID(ConverterType.class)) { |
| 190 | case FacesConfigPackage.CONVERTER_TYPE__ID: |
| 191 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 192 | return; |
| 193 | case FacesConfigPackage.CONVERTER_TYPE__DESCRIPTION: |
| 194 | case FacesConfigPackage.CONVERTER_TYPE__DISPLAY_NAME: |
| 195 | case FacesConfigPackage.CONVERTER_TYPE__ICON: |
| 196 | case FacesConfigPackage.CONVERTER_TYPE__CONVERTER_ID: |
| 197 | case FacesConfigPackage.CONVERTER_TYPE__CONVERTER_FOR_CLASS: |
| 198 | case FacesConfigPackage.CONVERTER_TYPE__CONVERTER_CLASS: |
| 199 | case FacesConfigPackage.CONVERTER_TYPE__ATTRIBUTE: |
| 200 | case FacesConfigPackage.CONVERTER_TYPE__PROPERTY: |
| 201 | case FacesConfigPackage.CONVERTER_TYPE__CONVERTER_EXTENSION: |
| 202 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 203 | return; |
| 204 | } |
| 205 | super.notifyChanged(notification); |
| 206 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 207 | |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 208 | /** |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 209 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 210 | * that can be created under this object. |
| 211 | * <!-- begin-user-doc |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 212 | * --> <!-- end-user-doc --> |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 213 | * @generated |
| 214 | */ |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 215 | protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 216 | super.collectNewChildDescriptors(newChildDescriptors, object); |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 217 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 218 | newChildDescriptors.add |
| 219 | (createChildParameter |
| 220 | (FacesConfigPackage.Literals.CONVERTER_TYPE__DESCRIPTION, |
| 221 | FacesConfigFactory.eINSTANCE.createDescriptionType())); |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 222 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 223 | newChildDescriptors.add |
| 224 | (createChildParameter |
| 225 | (FacesConfigPackage.Literals.CONVERTER_TYPE__DISPLAY_NAME, |
| 226 | FacesConfigFactory.eINSTANCE.createDisplayNameType())); |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 227 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 228 | newChildDescriptors.add |
| 229 | (createChildParameter |
| 230 | (FacesConfigPackage.Literals.CONVERTER_TYPE__ICON, |
| 231 | FacesConfigFactory.eINSTANCE.createIconType())); |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 232 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 233 | newChildDescriptors.add |
| 234 | (createChildParameter |
| 235 | (FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_ID, |
| 236 | FacesConfigFactory.eINSTANCE.createConverterIdType())); |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 237 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 238 | newChildDescriptors.add |
| 239 | (createChildParameter |
| 240 | (FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_FOR_CLASS, |
| 241 | FacesConfigFactory.eINSTANCE.createConverterForClassType())); |
cbateman | 39c1542 | 2006-12-21 02:36:52 +0000 | [diff] [blame] | 242 | |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 243 | newChildDescriptors.add |
| 244 | (createChildParameter |
| 245 | (FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_CLASS, |
| 246 | FacesConfigFactory.eINSTANCE.createConverterClassType())); |
| 247 | |
| 248 | newChildDescriptors.add |
| 249 | (createChildParameter |
| 250 | (FacesConfigPackage.Literals.CONVERTER_TYPE__ATTRIBUTE, |
| 251 | FacesConfigFactory.eINSTANCE.createAttributeType())); |
| 252 | |
| 253 | newChildDescriptors.add |
| 254 | (createChildParameter |
| 255 | (FacesConfigPackage.Literals.CONVERTER_TYPE__PROPERTY, |
| 256 | FacesConfigFactory.eINSTANCE.createPropertyType())); |
| 257 | |
| 258 | newChildDescriptors.add |
| 259 | (createChildParameter |
| 260 | (FacesConfigPackage.Literals.CONVERTER_TYPE__CONVERTER_EXTENSION, |
| 261 | FacesConfigFactory.eINSTANCE.createConverterExtensionType())); |
| 262 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 263 | |
| 264 | /** |
| 265 | * Return the resource locator for this item provider's resources. <!-- |
| 266 | * begin-user-doc --> <!-- end-user-doc --> |
| 267 | * |
| 268 | * @generated |
| 269 | */ |
| 270 | public ResourceLocator getResourceLocator() { |
gkessler | 4027278 | 2010-03-17 00:22:30 +0000 | [diff] [blame] | 271 | return FacesConfigPlugin.INSTANCE; |
| 272 | } |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 273 | |
| 274 | /* (non-Javadoc) |
| 275 | * @see org.eclipse.emf.edit.provider.ITableItemLabelProvider#getColumnImage(java.lang.Object, int) |
| 276 | */ |
| 277 | public Object getColumnImage(Object object, int columnIndex) { |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 278 | if(columnIndex ==0) |
| 279 | return getImage(object); |
| 280 | return null; |
| 281 | } |
| 282 | |
| 283 | /* (non-Javadoc) |
| 284 | * @see org.eclipse.emf.edit.provider.ITableItemLabelProvider#getColumnText(java.lang.Object, int) |
| 285 | */ |
| 286 | public String getColumnText(Object object, int columnIndex) { |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 287 | switch (columnIndex) { |
gkessler | 97f5fcd | 2010-03-17 23:28:55 +0000 | [diff] [blame] | 288 | |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 289 | case 0: |
| 290 | return getText(object); |
| 291 | case 1: |
gkessler | 97f5fcd | 2010-03-17 23:28:55 +0000 | [diff] [blame] | 292 | return getString("_UI_ConverterType_type"); //$NON-NLS-1$ |
cbateman | 6d3359f | 2006-11-28 20:23:25 +0000 | [diff] [blame] | 293 | } |
| 294 | return null; |
| 295 | } |
| 296 | |
| 297 | } |