2 * Copyright (c) 2015 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
;
18 import org
.eclipse
.emf
.compare
.ComparePackage
;
19 import org
.eclipse
.emf
.compare
.DifferenceKind
;
20 import org
.eclipse
.emf
.compare
.ResourceLocationChange
;
21 import org
.eclipse
.emf
.edit
.provider
.ComposeableAdapterFactory
;
22 import org
.eclipse
.emf
.edit
.provider
.IEditingDomainItemProvider
;
23 import org
.eclipse
.emf
.edit
.provider
.IItemColorProvider
;
24 import org
.eclipse
.emf
.edit
.provider
.IItemFontProvider
;
25 import org
.eclipse
.emf
.edit
.provider
.IItemLabelProvider
;
26 import org
.eclipse
.emf
.edit
.provider
.IItemPropertyDescriptor
;
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
.ViewerNotification
;
34 * This is the item provider adapter for a {@link org.eclipse.emf.compare.ResourceLocationChange} object.
35 * <!-- begin-user-doc -->
36 * <!-- end-user-doc -->
40 @SuppressWarnings("all")
41 public class ResourceLocationChangeItemProvider
extends DiffItemProvider
implements IEditingDomainItemProvider
, IStructuredItemContentProvider
, ITreeItemContentProvider
, IItemLabelProvider
, IItemPropertySource
, IItemColorProvider
, IItemFontProvider
{
43 * <!-- begin-user-doc -->
44 * <!-- end-user-doc -->
47 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$
50 * This constructs an instance from a factory and a notifier.
51 * <!-- begin-user-doc -->
52 * <!-- end-user-doc -->
55 public ResourceLocationChangeItemProvider(AdapterFactory adapterFactory
) {
56 super(adapterFactory
);
60 * This returns the property descriptors for the adapted class.
61 * <!-- begin-user-doc -->
62 * <!-- end-user-doc -->
66 public List
<IItemPropertyDescriptor
> getPropertyDescriptors(Object object
) {
67 if (itemPropertyDescriptors
== null) {
68 super.getPropertyDescriptors(object
);
70 addBaseLocationPropertyDescriptor(object
);
71 addChangedLocationPropertyDescriptor(object
);
73 return itemPropertyDescriptors
;
77 * This adds a property descriptor for the Base Location feature.
78 * <!-- begin-user-doc -->
79 * <!-- end-user-doc -->
82 protected void addBaseLocationPropertyDescriptor(Object object
) {
83 itemPropertyDescriptors
84 .add(createItemPropertyDescriptor(
85 ((ComposeableAdapterFactory
)adapterFactory
).getRootAdapterFactory(),
87 getString("_UI_ResourceLocationChange_baseLocation_feature"), //$NON-NLS-1$
89 "_UI_PropertyDescriptor_description", "_UI_ResourceLocationChange_baseLocation_feature", "_UI_ResourceLocationChange_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
90 ComparePackage
.Literals
.RESOURCE_LOCATION_CHANGE__BASE_LOCATION
, true, false, false,
91 ItemPropertyDescriptor
.GENERIC_VALUE_IMAGE
, null, null));
95 * This adds a property descriptor for the Changed Location feature.
96 * <!-- begin-user-doc -->
97 * <!-- end-user-doc -->
100 protected void addChangedLocationPropertyDescriptor(Object object
) {
101 itemPropertyDescriptors
102 .add(createItemPropertyDescriptor(
103 ((ComposeableAdapterFactory
)adapterFactory
).getRootAdapterFactory(),
104 getResourceLocator(),
105 getString("_UI_ResourceLocationChange_changedLocation_feature"), //$NON-NLS-1$
107 "_UI_PropertyDescriptor_description", "_UI_ResourceLocationChange_changedLocation_feature", "_UI_ResourceLocationChange_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
108 ComparePackage
.Literals
.RESOURCE_LOCATION_CHANGE__CHANGED_LOCATION
, true, false,
109 false, ItemPropertyDescriptor
.GENERIC_VALUE_IMAGE
, null, null));
113 * This returns ResourceLocationChange.gif.
114 * <!-- begin-user-doc -->
115 * <!-- end-user-doc -->
119 public Object
getImage(Object object
) {
120 return overlayImage(object
, getResourceLocator().getImage("full/obj16/ResourceLocationChange")); //$NON-NLS-1$
124 * This returns the label text for the adapted class.
125 * <!-- begin-user-doc -->
126 * <!-- end-user-doc -->
130 public String
getText(Object object
) {
131 DifferenceKind labelValue
= ((ResourceLocationChange
)object
).getKind();
132 String label
= labelValue
== null ?
null : labelValue
.toString();
133 return label
== null || label
.length() == 0 ?
getString("_UI_ResourceLocationChange_type") : //$NON-NLS-1$
134 getString("_UI_ResourceLocationChange_type") + " " + label
; //$NON-NLS-1$ //$NON-NLS-2$
138 * This handles model notifications by calling {@link #updateChildren} to update any cached
139 * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
140 * <!-- begin-user-doc -->
141 * <!-- end-user-doc -->
145 public void notifyChanged(Notification notification
) {
146 updateChildren(notification
);
148 switch (notification
.getFeatureID(ResourceLocationChange
.class)) {
149 case ComparePackage
.RESOURCE_LOCATION_CHANGE__BASE_LOCATION
:
150 case ComparePackage
.RESOURCE_LOCATION_CHANGE__CHANGED_LOCATION
:
151 fireNotifyChanged(new ViewerNotification(notification
, notification
.getNotifier(), false,
155 super.notifyChanged(notification
);
159 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
160 * that can be created under this object.
161 * <!-- begin-user-doc -->
162 * <!-- end-user-doc -->
166 protected void collectNewChildDescriptors(Collection
<Object
> newChildDescriptors
, Object object
) {
167 super.collectNewChildDescriptors(newChildDescriptors
, object
);