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.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.core.CoreFactory; |
24 | import de.uka.ipd.sdq.pcm.usagemodel.Loop; |
25 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelFactory; |
26 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
27 | |
28 | /** |
29 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.usagemodel.Loop} object. |
30 | * <!-- begin-user-doc --> |
31 | * <!-- end-user-doc --> |
32 | * @generated |
33 | */ |
34 | public class LoopItemProvider |
35 | extends AbstractUserActionItemProvider |
36 | implements |
37 | IEditingDomainItemProvider, |
38 | IStructuredItemContentProvider, |
39 | ITreeItemContentProvider, |
40 | IItemLabelProvider, |
41 | IItemPropertySource { |
42 | /** |
43 | * <!-- begin-user-doc --> |
44 | * <!-- end-user-doc --> |
45 | * @generated |
46 | */ |
47 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
48 | |
49 | /** |
50 | * This constructs an instance from a factory and a notifier. |
51 | * <!-- begin-user-doc --> |
52 | * <!-- end-user-doc --> |
53 | * @generated |
54 | */ |
55 | public LoopItemProvider(AdapterFactory adapterFactory) { |
56 | super(adapterFactory); |
57 | } |
58 | |
59 | /** |
60 | * This returns the property descriptors for the adapted class. |
61 | * <!-- begin-user-doc --> |
62 | * <!-- end-user-doc --> |
63 | * @generated |
64 | */ |
65 | @Override |
66 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
67 | if (itemPropertyDescriptors == null) { |
68 | super.getPropertyDescriptors(object); |
69 | |
70 | } |
71 | return itemPropertyDescriptors; |
72 | } |
73 | |
74 | /** |
75 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
76 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
77 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
78 | * <!-- begin-user-doc --> |
79 | * <!-- end-user-doc --> |
80 | * @generated |
81 | */ |
82 | @Override |
83 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
84 | if (childrenFeatures == null) { |
85 | super.getChildrenFeatures(object); |
86 | childrenFeatures.add(UsagemodelPackage.Literals.LOOP__LOOP_ITERATION_LOOP); |
87 | childrenFeatures.add(UsagemodelPackage.Literals.LOOP__BODY_BEHAVIOUR_LOOP); |
88 | } |
89 | return childrenFeatures; |
90 | } |
91 | |
92 | /** |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @generated |
96 | */ |
97 | @Override |
98 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
99 | // Check the type of the specified child object and return the proper feature to use for |
100 | // adding (see {@link AddCommand}) it as a child. |
101 | |
102 | return super.getChildFeature(object, child); |
103 | } |
104 | |
105 | /** |
106 | * This returns Loop.gif. |
107 | * <!-- begin-user-doc --> |
108 | * <!-- end-user-doc --> |
109 | * @generated |
110 | */ |
111 | @Override |
112 | public Object getImage(Object object) { |
113 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Loop")); |
114 | } |
115 | |
116 | /** |
117 | * This returns the label text for the adapted class. |
118 | * <!-- begin-user-doc --> |
119 | * <!-- end-user-doc --> |
120 | * @generated |
121 | */ |
122 | @Override |
123 | public String getText(Object object) { |
124 | String label = ((Loop)object).getId(); |
125 | return label == null || label.length() == 0 ? |
126 | getString("_UI_Loop_type") : |
127 | getString("_UI_Loop_type") + " " + label; |
128 | } |
129 | |
130 | /** |
131 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
132 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
133 | * <!-- begin-user-doc --> |
134 | * <!-- end-user-doc --> |
135 | * @generated |
136 | */ |
137 | @Override |
138 | public void notifyChanged(Notification notification) { |
139 | updateChildren(notification); |
140 | |
141 | switch (notification.getFeatureID(Loop.class)) { |
142 | case UsagemodelPackage.LOOP__LOOP_ITERATION_LOOP: |
143 | case UsagemodelPackage.LOOP__BODY_BEHAVIOUR_LOOP: |
144 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
145 | return; |
146 | } |
147 | super.notifyChanged(notification); |
148 | } |
149 | |
150 | /** |
151 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
152 | * that can be created under this object. |
153 | * <!-- begin-user-doc --> |
154 | * <!-- end-user-doc --> |
155 | * @generated |
156 | */ |
157 | @Override |
158 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
159 | super.collectNewChildDescriptors(newChildDescriptors, object); |
160 | |
161 | newChildDescriptors.add |
162 | (createChildParameter |
163 | (UsagemodelPackage.Literals.LOOP__LOOP_ITERATION_LOOP, |
164 | CoreFactory.eINSTANCE.createPCMRandomVariable())); |
165 | |
166 | newChildDescriptors.add |
167 | (createChildParameter |
168 | (UsagemodelPackage.Literals.LOOP__BODY_BEHAVIOUR_LOOP, |
169 | UsagemodelFactory.eINSTANCE.createScenarioBehaviour())); |
170 | } |
171 | |
172 | } |