|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package cenrep.provider; |
|
18 |
|
19 |
|
20 import java.util.Collection; |
|
21 import java.util.List; |
|
22 |
|
23 import org.eclipse.emf.common.notify.AdapterFactory; |
|
24 import org.eclipse.emf.common.notify.Notification; |
|
25 import org.eclipse.emf.common.util.ResourceLocator; |
|
26 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
|
27 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
|
28 import org.eclipse.emf.edit.provider.IItemLabelProvider; |
|
29 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
|
30 import org.eclipse.emf.edit.provider.IItemPropertySource; |
|
31 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
|
32 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
|
33 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
|
34 import org.eclipse.emf.edit.provider.ViewerNotification; |
|
35 |
|
36 import cenrep.CenrepFactory; |
|
37 import cenrep.CenrepPackage; |
|
38 import cenrep.Value; |
|
39 |
|
40 /** |
|
41 * This is the item provider adapter for a {@link cenrep.Value} object. |
|
42 * <!-- begin-user-doc --> |
|
43 * <!-- end-user-doc --> |
|
44 * @generated |
|
45 */ |
|
46 public class ValueItemProvider |
|
47 extends ContentItemProvider |
|
48 implements |
|
49 IEditingDomainItemProvider, |
|
50 IStructuredItemContentProvider, |
|
51 ITreeItemContentProvider, |
|
52 IItemLabelProvider, |
|
53 IItemPropertySource{ |
|
54 |
|
55 public final static Value ZERO_VALUE = CenrepFactory.eINSTANCE.createValue(); |
|
56 |
|
57 |
|
58 |
|
59 /** |
|
60 * This constructs an instance from a factory and a notifier. |
|
61 * <!-- begin-user-doc --> |
|
62 * <!-- end-user-doc --> |
|
63 * @generated |
|
64 */ |
|
65 public ValueItemProvider(AdapterFactory adapterFactory) { |
|
66 super(adapterFactory); |
|
67 } |
|
68 |
|
69 /** |
|
70 * This returns the property descriptors for the adapted class. |
|
71 * <!-- begin-user-doc --> |
|
72 * <!-- end-user-doc --> |
|
73 * @generated NOT |
|
74 */ |
|
75 public List getPropertyDescriptors(Object object) { |
|
76 if(object.equals(ZERO_VALUE))return null; |
|
77 if (itemPropertyDescriptors == null) { |
|
78 super.getPropertyDescriptors(object); |
|
79 addValPropertyDescriptor(object); |
|
80 addIdPropertyDescriptor(object); |
|
81 } |
|
82 return itemPropertyDescriptors; |
|
83 } |
|
84 |
|
85 /** |
|
86 * This adds a property descriptor for the Val feature. |
|
87 * <!-- begin-user-doc --> |
|
88 * <!-- end-user-doc --> |
|
89 * @generated |
|
90 */ |
|
91 protected void addValPropertyDescriptor(Object object) { |
|
92 itemPropertyDescriptors.add |
|
93 (createItemPropertyDescriptor |
|
94 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
|
95 getResourceLocator(), |
|
96 getString("_UI_Value_val_feature"), |
|
97 getString("_UI_PropertyDescriptor_description", "_UI_Value_val_feature", "_UI_Value_type"), |
|
98 CenrepPackage.Literals.VALUE__VAL, |
|
99 true, |
|
100 false, |
|
101 false, |
|
102 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
|
103 null, |
|
104 null)); |
|
105 } |
|
106 |
|
107 /** |
|
108 * This adds a property descriptor for the Id feature. |
|
109 * <!-- begin-user-doc --> |
|
110 * <!-- end-user-doc --> |
|
111 * @generated |
|
112 */ |
|
113 protected void addIdPropertyDescriptor(Object object) { |
|
114 itemPropertyDescriptors.add |
|
115 (createItemPropertyDescriptor |
|
116 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
|
117 getResourceLocator(), |
|
118 getString("_UI_Value_id_feature"), |
|
119 getString("_UI_PropertyDescriptor_description", "_UI_Value_id_feature", "_UI_Value_type"), |
|
120 CenrepPackage.Literals.VALUE__ID, |
|
121 true, |
|
122 false, |
|
123 false, |
|
124 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
|
125 null, |
|
126 null)); |
|
127 } |
|
128 |
|
129 /** |
|
130 * This returns Value.gif. |
|
131 * <!-- begin-user-doc --> |
|
132 * <!-- end-user-doc --> |
|
133 * @generated |
|
134 */ |
|
135 @Override |
|
136 public Object getImage(Object object) { |
|
137 return overlayImage(object, getResourceLocator().getImage("full/obj16/Value")); |
|
138 } |
|
139 |
|
140 /** |
|
141 * This returns the label text for the adapted class. |
|
142 * <!-- begin-user-doc --> |
|
143 * <!-- end-user-doc --> |
|
144 * @generated |
|
145 */ |
|
146 @Override |
|
147 public String getText(Object object) { |
|
148 String label = ((Value)object).getId(); |
|
149 return label == null || label.length() == 0 ? |
|
150 getString("_UI_Value_type") : |
|
151 getString("_UI_Value_type") + " " + label; |
|
152 } |
|
153 |
|
154 /** |
|
155 * This handles model notifications by calling {@link #updateChildren} to update any cached |
|
156 * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
|
157 * <!-- begin-user-doc --> |
|
158 * <!-- end-user-doc --> |
|
159 * @generated |
|
160 */ |
|
161 @Override |
|
162 public void notifyChanged(Notification notification) { |
|
163 updateChildren(notification); |
|
164 |
|
165 switch (notification.getFeatureID(Value.class)) { |
|
166 case CenrepPackage.VALUE__VAL: |
|
167 case CenrepPackage.VALUE__ID: |
|
168 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
|
169 return; |
|
170 } |
|
171 super.notifyChanged(notification); |
|
172 } |
|
173 |
|
174 /** |
|
175 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
|
176 * that can be created under this object. |
|
177 * <!-- begin-user-doc --> |
|
178 * <!-- end-user-doc --> |
|
179 * @generated |
|
180 */ |
|
181 @Override |
|
182 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
|
183 super.collectNewChildDescriptors(newChildDescriptors, object); |
|
184 } |
|
185 |
|
186 /** |
|
187 * Return the resource locator for this item provider's resources. |
|
188 * <!-- begin-user-doc --> |
|
189 * <!-- end-user-doc --> |
|
190 * @generated |
|
191 */ |
|
192 @Override |
|
193 public ResourceLocator getResourceLocator() { |
|
194 return CRPluginModelEditPlugin.INSTANCE; |
|
195 } |
|
196 |
|
197 } |