1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.usagemodel.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.ComposeableAdapterFactory; |
17 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
18 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
19 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
20 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
21 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
22 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
23 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
24 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
25 | import org.eclipse.emf.edit.provider.ViewerNotification; |
26 | |
27 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
28 | import de.uka.ipd.sdq.pcm.usagemodel.BranchTransition; |
29 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelFactory; |
30 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.usagemodel.BranchTransition} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class BranchTransitionItemProvider |
39 | extends ItemProviderAdapter |
40 | implements |
41 | IEditingDomainItemProvider, |
42 | IStructuredItemContentProvider, |
43 | ITreeItemContentProvider, |
44 | IItemLabelProvider, |
45 | IItemPropertySource { |
46 | /** |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @generated |
50 | */ |
51 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
52 | |
53 | /** |
54 | * This constructs an instance from a factory and a notifier. |
55 | * <!-- begin-user-doc --> |
56 | * <!-- end-user-doc --> |
57 | * @generated |
58 | */ |
59 | public BranchTransitionItemProvider(AdapterFactory adapterFactory) { |
60 | super(adapterFactory); |
61 | } |
62 | |
63 | /** |
64 | * This returns the property descriptors for the adapted class. |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @generated |
68 | */ |
69 | @Override |
70 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
71 | if (itemPropertyDescriptors == null) { |
72 | super.getPropertyDescriptors(object); |
73 | |
74 | addBranchProbabilityPropertyDescriptor(object); |
75 | } |
76 | return itemPropertyDescriptors; |
77 | } |
78 | |
79 | /** |
80 | * This adds a property descriptor for the Branch Probability feature. |
81 | * <!-- begin-user-doc --> |
82 | * <!-- end-user-doc --> |
83 | * @generated |
84 | */ |
85 | protected void addBranchProbabilityPropertyDescriptor(Object object) { |
86 | itemPropertyDescriptors.add |
87 | (createItemPropertyDescriptor |
88 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
89 | getResourceLocator(), |
90 | getString("_UI_BranchTransition_branchProbability_feature"), |
91 | getString("_UI_PropertyDescriptor_description", "_UI_BranchTransition_branchProbability_feature", "_UI_BranchTransition_type"), |
92 | UsagemodelPackage.Literals.BRANCH_TRANSITION__BRANCH_PROBABILITY, |
93 | true, |
94 | false, |
95 | false, |
96 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
97 | null, |
98 | null)); |
99 | } |
100 | |
101 | /** |
102 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
103 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
104 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @generated |
108 | */ |
109 | @Override |
110 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
111 | if (childrenFeatures == null) { |
112 | super.getChildrenFeatures(object); |
113 | childrenFeatures.add(UsagemodelPackage.Literals.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION); |
114 | } |
115 | return childrenFeatures; |
116 | } |
117 | |
118 | /** |
119 | * <!-- begin-user-doc --> |
120 | * <!-- end-user-doc --> |
121 | * @generated |
122 | */ |
123 | @Override |
124 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
125 | // Check the type of the specified child object and return the proper feature to use for |
126 | // adding (see {@link AddCommand}) it as a child. |
127 | |
128 | return super.getChildFeature(object, child); |
129 | } |
130 | |
131 | /** |
132 | * This returns BranchTransition.gif. |
133 | * <!-- begin-user-doc --> |
134 | * <!-- end-user-doc --> |
135 | * @generated |
136 | */ |
137 | @Override |
138 | public Object getImage(Object object) { |
139 | return overlayImage(object, getResourceLocator().getImage("full/obj16/BranchTransition")); |
140 | } |
141 | |
142 | /** |
143 | * This returns the label text for the adapted class. |
144 | * <!-- begin-user-doc --> |
145 | * <!-- end-user-doc --> |
146 | * @generated |
147 | */ |
148 | @Override |
149 | public String getText(Object object) { |
150 | BranchTransition branchTransition = (BranchTransition)object; |
151 | return getString("_UI_BranchTransition_type") + " " + branchTransition.getBranchProbability(); |
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(BranchTransition.class)) { |
166 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_PROBABILITY: |
167 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
168 | return; |
169 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION: |
170 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
171 | return; |
172 | } |
173 | super.notifyChanged(notification); |
174 | } |
175 | |
176 | /** |
177 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
178 | * that can be created under this object. |
179 | * <!-- begin-user-doc --> |
180 | * <!-- end-user-doc --> |
181 | * @generated |
182 | */ |
183 | @Override |
184 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
185 | super.collectNewChildDescriptors(newChildDescriptors, object); |
186 | |
187 | newChildDescriptors.add |
188 | (createChildParameter |
189 | (UsagemodelPackage.Literals.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION, |
190 | UsagemodelFactory.eINSTANCE.createScenarioBehaviour())); |
191 | } |
192 | |
193 | /** |
194 | * Return the resource locator for this item provider's resources. |
195 | * <!-- begin-user-doc --> |
196 | * <!-- end-user-doc --> |
197 | * @generated |
198 | */ |
199 | @Override |
200 | public ResourceLocator getResourceLocator() { |
201 | return PalladioComponentModelEditPlugin.INSTANCE; |
202 | } |
203 | |
204 | } |