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