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.common.util.ResourceLocator; |
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.ItemProviderAdapter; |
24 | import org.eclipse.emf.edit.provider.ViewerNotification; |
25 | |
26 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
27 | import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisationType; |
28 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
29 | import de.uka.ipd.sdq.pcm.repository.RequiredCharacterisation; |
30 | |
31 | /** |
32 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.repository.RequiredCharacterisation} object. |
33 | * <!-- begin-user-doc --> |
34 | * <!-- end-user-doc --> |
35 | * @generated |
36 | */ |
37 | public class RequiredCharacterisationItemProvider |
38 | extends ItemProviderAdapter |
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 RequiredCharacterisationItemProvider(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 | addTypePropertyDescriptor(object); |
74 | addParameterPropertyDescriptor(object); |
75 | } |
76 | return itemPropertyDescriptors; |
77 | } |
78 | |
79 | /** |
80 | * This adds a property descriptor for the Type feature. |
81 | * <!-- begin-user-doc --> |
82 | * <!-- end-user-doc --> |
83 | * @generated |
84 | */ |
85 | protected void addTypePropertyDescriptor(Object object) { |
86 | itemPropertyDescriptors.add |
87 | (createItemPropertyDescriptor |
88 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
89 | getResourceLocator(), |
90 | getString("_UI_RequiredCharacterisation_type_feature"), |
91 | getString("_UI_PropertyDescriptor_description", "_UI_RequiredCharacterisation_type_feature", "_UI_RequiredCharacterisation_type"), |
92 | RepositoryPackage.Literals.REQUIRED_CHARACTERISATION__TYPE, |
93 | true, |
94 | false, |
95 | false, |
96 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
97 | null, |
98 | null)); |
99 | } |
100 | |
101 | /** |
102 | * This adds a property descriptor for the Parameter feature. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | protected void addParameterPropertyDescriptor(Object object) { |
108 | itemPropertyDescriptors.add |
109 | (createItemPropertyDescriptor |
110 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
111 | getResourceLocator(), |
112 | getString("_UI_RequiredCharacterisation_parameter_feature"), |
113 | getString("_UI_PropertyDescriptor_description", "_UI_RequiredCharacterisation_parameter_feature", "_UI_RequiredCharacterisation_type"), |
114 | RepositoryPackage.Literals.REQUIRED_CHARACTERISATION__PARAMETER, |
115 | true, |
116 | false, |
117 | true, |
118 | null, |
119 | null, |
120 | null)); |
121 | } |
122 | |
123 | /** |
124 | * This returns RequiredCharacterisation.gif. |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | @Override |
130 | public Object getImage(Object object) { |
131 | return overlayImage(object, getResourceLocator().getImage("full/obj16/RequiredCharacterisation")); |
132 | } |
133 | |
134 | /** |
135 | * This returns the label text for the adapted class. |
136 | * <!-- begin-user-doc --> |
137 | * <!-- end-user-doc --> |
138 | * @generated |
139 | */ |
140 | @Override |
141 | public String getText(Object object) { |
142 | VariableCharacterisationType labelValue = ((RequiredCharacterisation)object).getType(); |
143 | String label = labelValue == null ? null : labelValue.toString(); |
144 | return label == null || label.length() == 0 ? |
145 | getString("_UI_RequiredCharacterisation_type") : |
146 | getString("_UI_RequiredCharacterisation_type") + " " + label; |
147 | } |
148 | |
149 | /** |
150 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
151 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
152 | * <!-- begin-user-doc --> |
153 | * <!-- end-user-doc --> |
154 | * @generated |
155 | */ |
156 | @Override |
157 | public void notifyChanged(Notification notification) { |
158 | updateChildren(notification); |
159 | |
160 | switch (notification.getFeatureID(RequiredCharacterisation.class)) { |
161 | case RepositoryPackage.REQUIRED_CHARACTERISATION__TYPE: |
162 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
163 | return; |
164 | } |
165 | super.notifyChanged(notification); |
166 | } |
167 | |
168 | /** |
169 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
170 | * that can be created under this object. |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @generated |
174 | */ |
175 | @Override |
176 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
177 | super.collectNewChildDescriptors(newChildDescriptors, object); |
178 | } |
179 | |
180 | /** |
181 | * Return the resource locator for this item provider's resources. |
182 | * <!-- begin-user-doc --> |
183 | * <!-- end-user-doc --> |
184 | * @generated |
185 | */ |
186 | @Override |
187 | public ResourceLocator getResourceLocator() { |
188 | return PalladioComponentModelEditPlugin.INSTANCE; |
189 | } |
190 | |
191 | } |