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.IEditingDomainItemProvider; |
16 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
17 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
18 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
19 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
20 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
21 | import org.eclipse.emf.edit.provider.ViewerNotification; |
22 | |
23 | import de.uka.ipd.sdq.pcm.repository.BasicComponent; |
24 | import de.uka.ipd.sdq.pcm.repository.RepositoryFactory; |
25 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
26 | import de.uka.ipd.sdq.pcm.seff.InternalAction; |
27 | import de.uka.ipd.sdq.pcm.seff.SeffFactory; |
28 | |
29 | /** |
30 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.repository.BasicComponent} object. |
31 | * <!-- begin-user-doc --> |
32 | * <!-- end-user-doc --> |
33 | * @generated |
34 | */ |
35 | public class BasicComponentItemProvider |
36 | extends ImplementationComponentTypeItemProvider |
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 BasicComponentItemProvider(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 | } |
72 | return itemPropertyDescriptors; |
73 | } |
74 | |
75 | /** |
76 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
77 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
78 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | @Override |
84 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
85 | if (childrenFeatures == null) { |
86 | super.getChildrenFeatures(object); |
87 | childrenFeatures.add(RepositoryPackage.Literals.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT); |
88 | childrenFeatures.add(RepositoryPackage.Literals.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT); |
89 | } |
90 | return childrenFeatures; |
91 | } |
92 | |
93 | /** |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | @Override |
99 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
100 | // Check the type of the specified child object and return the proper feature to use for |
101 | // adding (see {@link AddCommand}) it as a child. |
102 | |
103 | return super.getChildFeature(object, child); |
104 | } |
105 | |
106 | /** |
107 | * This returns BasicComponent.gif. |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | @Override |
113 | public Object getImage(Object object) { |
114 | return overlayImage(object, getResourceLocator().getImage("full/obj16/BasicComponent")); |
115 | } |
116 | |
117 | /** |
118 | * This returns the label text for the adapted class. |
119 | * <!-- begin-user-doc --> |
120 | * FB: Adapted method to produce a more informative label for display in non-PCM editors. |
121 | * In PCM editors, display is not controlled by this method but through a more general |
122 | * mechanism (I'n not sure where it's actually controlled, maybe the |
123 | * de.uka.ipd.sdq.pcmbench.tabs.PropertyLabelProvider.getText() method?) |
124 | * <!-- end-user-doc --> |
125 | * @generated not |
126 | */ |
127 | @Override |
128 | public String getText(Object object) { |
129 | return ((BasicComponent)object).getEntityName() |
130 | + " [ID: " + ((BasicComponent)object).getId() + "]" |
131 | + " <" + getString("_UI_BasicComponent_type") + ">"; |
132 | } |
133 | |
134 | /** |
135 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
136 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
137 | * <!-- begin-user-doc --> |
138 | * <!-- end-user-doc --> |
139 | * @generated |
140 | */ |
141 | @Override |
142 | public void notifyChanged(Notification notification) { |
143 | updateChildren(notification); |
144 | |
145 | switch (notification.getFeatureID(BasicComponent.class)) { |
146 | case RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT: |
147 | case RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT: |
148 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
149 | return; |
150 | } |
151 | super.notifyChanged(notification); |
152 | } |
153 | |
154 | /** |
155 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
156 | * that can be created under this object. |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @generated |
160 | */ |
161 | @Override |
162 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
163 | super.collectNewChildDescriptors(newChildDescriptors, object); |
164 | |
165 | newChildDescriptors.add |
166 | (createChildParameter |
167 | (RepositoryPackage.Literals.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT, |
168 | SeffFactory.eINSTANCE.createResourceDemandingSEFF())); |
169 | |
170 | newChildDescriptors.add |
171 | (createChildParameter |
172 | (RepositoryPackage.Literals.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT, |
173 | RepositoryFactory.eINSTANCE.createPassiveResource())); |
174 | } |
175 | |
176 | } |