2 * Copyright (c) 2012 Obeo.
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
9 * Obeo - initial API and implementation
11 package org
.eclipse
.emf
.compare
.provider
;
13 import java
.util
.Collection
;
14 import java
.util
.List
;
16 import org
.eclipse
.emf
.common
.notify
.AdapterFactory
;
17 import org
.eclipse
.emf
.common
.notify
.Notification
;
19 import org
.eclipse
.emf
.compare
.ComparePackage
;
20 import org
.eclipse
.emf
.compare
.DifferenceKind
;
21 import org
.eclipse
.emf
.compare
.FeatureMapChange
;
23 import org
.eclipse
.emf
.edit
.provider
.ComposeableAdapterFactory
;
24 import org
.eclipse
.emf
.edit
.provider
.IEditingDomainItemProvider
;
25 import org
.eclipse
.emf
.edit
.provider
.IItemColorProvider
;
26 import org
.eclipse
.emf
.edit
.provider
.IItemFontProvider
;
27 import org
.eclipse
.emf
.edit
.provider
.IItemLabelProvider
;
28 import org
.eclipse
.emf
.edit
.provider
.IItemPropertyDescriptor
;
29 import org
.eclipse
.emf
.edit
.provider
.IItemPropertySource
;
30 import org
.eclipse
.emf
.edit
.provider
.IStructuredItemContentProvider
;
31 import org
.eclipse
.emf
.edit
.provider
.ITreeItemContentProvider
;
32 import org
.eclipse
.emf
.edit
.provider
.ItemPropertyDescriptor
;
33 import org
.eclipse
.emf
.edit
.provider
.ViewerNotification
;
36 * This is the item provider adapter for a {@link org.eclipse.emf.compare.FeatureMapChange} object.
37 * <!-- begin-user-doc -->
38 * <!-- end-user-doc -->
42 @SuppressWarnings("all")
43 public class FeatureMapChangeItemProvider
extends DiffItemProvider
implements IEditingDomainItemProvider
, IStructuredItemContentProvider
, ITreeItemContentProvider
, IItemLabelProvider
, IItemPropertySource
, IItemColorProvider
, IItemFontProvider
{
45 * <!-- begin-user-doc -->
46 * <!-- end-user-doc -->
49 public static final String copyright
= "Copyright (c) 2012 Obeo.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\n\r\nContributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$
52 * This constructs an instance from a factory and a notifier.
53 * <!-- begin-user-doc -->
54 * <!-- end-user-doc -->
57 public FeatureMapChangeItemProvider(AdapterFactory adapterFactory
) {
58 super(adapterFactory
);
62 * This returns the property descriptors for the adapted class.
63 * <!-- begin-user-doc -->
64 * <!-- end-user-doc -->
68 public List
<IItemPropertyDescriptor
> getPropertyDescriptors(Object object
) {
69 if (itemPropertyDescriptors
== null) {
70 super.getPropertyDescriptors(object
);
72 addAttributePropertyDescriptor(object
);
73 addValuePropertyDescriptor(object
);
75 return itemPropertyDescriptors
;
79 * This adds a property descriptor for the Attribute feature.
80 * <!-- begin-user-doc -->
81 * <!-- end-user-doc -->
84 protected void addAttributePropertyDescriptor(Object object
) {
85 itemPropertyDescriptors
86 .add(createItemPropertyDescriptor(
87 ((ComposeableAdapterFactory
)adapterFactory
).getRootAdapterFactory(),
89 getString("_UI_FeatureMapChange_attribute_feature"), //$NON-NLS-1$
91 "_UI_PropertyDescriptor_description", "_UI_FeatureMapChange_attribute_feature", "_UI_FeatureMapChange_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
92 ComparePackage
.Literals
.FEATURE_MAP_CHANGE__ATTRIBUTE
, true, false, true, null, null,
97 * This adds a property descriptor for the Value feature.
98 * <!-- begin-user-doc -->
99 * <!-- end-user-doc -->
102 protected void addValuePropertyDescriptor(Object object
) {
103 itemPropertyDescriptors
104 .add(createItemPropertyDescriptor(
105 ((ComposeableAdapterFactory
)adapterFactory
).getRootAdapterFactory(),
106 getResourceLocator(),
107 getString("_UI_FeatureMapChange_value_feature"), //$NON-NLS-1$
109 "_UI_PropertyDescriptor_description", "_UI_FeatureMapChange_value_feature", "_UI_FeatureMapChange_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
110 ComparePackage
.Literals
.FEATURE_MAP_CHANGE__VALUE
, true, false, false,
111 ItemPropertyDescriptor
.GENERIC_VALUE_IMAGE
, null, null));
115 * This returns FeatureMapChange.gif.
116 * <!-- begin-user-doc -->
117 * <!-- end-user-doc -->
121 public Object
getImage(Object object
) {
122 return overlayImage(object
, getResourceLocator().getImage("full/obj16/FeatureMapChange")); //$NON-NLS-1$
126 * This returns the label text for the adapted class.
127 * <!-- begin-user-doc -->
128 * <!-- end-user-doc -->
132 public String
getText(Object object
) {
133 DifferenceKind labelValue
= ((FeatureMapChange
)object
).getKind();
134 String label
= labelValue
== null ?
null : labelValue
.toString();
135 return label
== null || label
.length() == 0 ?
getString("_UI_FeatureMapChange_type") : //$NON-NLS-1$
136 getString("_UI_FeatureMapChange_type") + " " + label
; //$NON-NLS-1$ //$NON-NLS-2$
140 * This handles model notifications by calling {@link #updateChildren} to update any cached
141 * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
142 * <!-- begin-user-doc -->
143 * <!-- end-user-doc -->
147 public void notifyChanged(Notification notification
) {
148 updateChildren(notification
);
150 switch (notification
.getFeatureID(FeatureMapChange
.class)) {
151 case ComparePackage
.FEATURE_MAP_CHANGE__VALUE
:
152 fireNotifyChanged(new ViewerNotification(notification
, notification
.getNotifier(), false,
156 super.notifyChanged(notification
);
160 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
161 * that can be created under this object.
162 * <!-- begin-user-doc -->
163 * <!-- end-user-doc -->
167 protected void collectNewChildDescriptors(Collection
<Object
> newChildDescriptors
, Object object
) {
168 super.collectNewChildDescriptors(newChildDescriptors
, object
);