1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourcetype.provider; |
7 | |
8 | |
9 | import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProvider; |
10 | import java.util.Collection; |
11 | import java.util.List; |
12 | |
13 | import org.eclipse.emf.common.notify.AdapterFactory; |
14 | import org.eclipse.emf.common.notify.Notification; |
15 | import org.eclipse.emf.common.util.ResourceLocator; |
16 | import org.eclipse.emf.ecore.EStructuralFeature; |
17 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
18 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
19 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
20 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
21 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
22 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
23 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
24 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
25 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
26 | import org.eclipse.emf.edit.provider.ViewerNotification; |
27 | |
28 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
29 | import de.uka.ipd.sdq.pcm.repository.RepositoryFactory; |
30 | import de.uka.ipd.sdq.pcm.resourcetype.ResourceSignature; |
31 | import de.uka.ipd.sdq.pcm.resourcetype.ResourcetypePackage; |
32 | |
33 | /** |
34 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.resourcetype.ResourceSignature} object. |
35 | * <!-- begin-user-doc --> |
36 | * <!-- end-user-doc --> |
37 | * @generated |
38 | */ |
39 | public class ResourceSignatureItemProvider |
40 | extends EntityItemProvider |
41 | implements |
42 | IEditingDomainItemProvider, |
43 | IStructuredItemContentProvider, |
44 | ITreeItemContentProvider, |
45 | IItemLabelProvider, |
46 | IItemPropertySource { |
47 | /** |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @generated |
51 | */ |
52 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
53 | |
54 | /** |
55 | * This constructs an instance from a factory and a notifier. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @generated |
59 | */ |
60 | public ResourceSignatureItemProvider(AdapterFactory adapterFactory) { |
61 | super(adapterFactory); |
62 | } |
63 | |
64 | /** |
65 | * This returns the property descriptors for the adapted class. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @generated |
69 | */ |
70 | @Override |
71 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
72 | if (itemPropertyDescriptors == null) { |
73 | super.getPropertyDescriptors(object); |
74 | |
75 | addResourceServiceIdPropertyDescriptor(object); |
76 | } |
77 | return itemPropertyDescriptors; |
78 | } |
79 | |
80 | /** |
81 | * This adds a property descriptor for the Resource Service Id feature. |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | protected void addResourceServiceIdPropertyDescriptor(Object object) { |
87 | itemPropertyDescriptors.add |
88 | (createItemPropertyDescriptor |
89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
90 | getResourceLocator(), |
91 | getString("_UI_ResourceSignature_resourceServiceId_feature"), |
92 | getString("_UI_PropertyDescriptor_description", "_UI_ResourceSignature_resourceServiceId_feature", "_UI_ResourceSignature_type"), |
93 | ResourcetypePackage.Literals.RESOURCE_SIGNATURE__RESOURCE_SERVICE_ID, |
94 | true, |
95 | false, |
96 | false, |
97 | ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, |
98 | null, |
99 | null)); |
100 | } |
101 | |
102 | /** |
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 --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | @Override |
111 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
112 | if (childrenFeatures == null) { |
113 | super.getChildrenFeatures(object); |
114 | childrenFeatures.add(ResourcetypePackage.Literals.RESOURCE_SIGNATURE__PARAMETER_RESOURCE_SIGNATURE); |
115 | } |
116 | return childrenFeatures; |
117 | } |
118 | |
119 | /** |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @generated |
123 | */ |
124 | @Override |
125 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
126 | // Check the type of the specified child object and return the proper feature to use for |
127 | // adding (see {@link AddCommand}) it as a child. |
128 | |
129 | return super.getChildFeature(object, child); |
130 | } |
131 | |
132 | /** |
133 | * This returns ResourceSignature.gif. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public Object getImage(Object object) { |
140 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ResourceSignature")); |
141 | } |
142 | |
143 | /** |
144 | * This returns the label text for the adapted class. |
145 | * <!-- begin-user-doc --> |
146 | * <!-- end-user-doc --> |
147 | * @generated |
148 | */ |
149 | @Override |
150 | public String getText(Object object) { |
151 | String label = ((ResourceSignature)object).getId(); |
152 | return label == null || label.length() == 0 ? |
153 | getString("_UI_ResourceSignature_type") : |
154 | getString("_UI_ResourceSignature_type") + " " + label; |
155 | } |
156 | |
157 | /** |
158 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
159 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
160 | * <!-- begin-user-doc --> |
161 | * <!-- end-user-doc --> |
162 | * @generated |
163 | */ |
164 | @Override |
165 | public void notifyChanged(Notification notification) { |
166 | updateChildren(notification); |
167 | |
168 | switch (notification.getFeatureID(ResourceSignature.class)) { |
169 | case ResourcetypePackage.RESOURCE_SIGNATURE__RESOURCE_SERVICE_ID: |
170 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
171 | return; |
172 | case ResourcetypePackage.RESOURCE_SIGNATURE__PARAMETER_RESOURCE_SIGNATURE: |
173 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
174 | return; |
175 | } |
176 | super.notifyChanged(notification); |
177 | } |
178 | |
179 | /** |
180 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
181 | * that can be created under this object. |
182 | * <!-- begin-user-doc --> |
183 | * <!-- end-user-doc --> |
184 | * @generated |
185 | */ |
186 | @Override |
187 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
188 | super.collectNewChildDescriptors(newChildDescriptors, object); |
189 | |
190 | newChildDescriptors.add |
191 | (createChildParameter |
192 | (ResourcetypePackage.Literals.RESOURCE_SIGNATURE__PARAMETER_RESOURCE_SIGNATURE, |
193 | RepositoryFactory.eINSTANCE.createParameter())); |
194 | } |
195 | |
196 | /** |
197 | * Return the resource locator for this item provider's resources. |
198 | * <!-- begin-user-doc --> |
199 | * <!-- end-user-doc --> |
200 | * @generated |
201 | */ |
202 | @Override |
203 | public ResourceLocator getResourceLocator() { |
204 | return PalladioComponentModelEditPlugin.INSTANCE; |
205 | } |
206 | |
207 | } |