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