1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.fzi.se.quality.provider; |
8 | |
9 | |
10 | import de.fzi.se.quality.QualityPackage; |
11 | import de.fzi.se.quality.QualityRepository; |
12 | |
13 | import de.fzi.se.quality.qualityannotation.QualityAnnotationFactory; |
14 | |
15 | import de.uka.ipd.sdq.identifier.provider.IdentifierItemProvider; |
16 | |
17 | import java.util.Collection; |
18 | import java.util.List; |
19 | |
20 | import org.eclipse.emf.common.notify.AdapterFactory; |
21 | import org.eclipse.emf.common.notify.Notification; |
22 | |
23 | import org.eclipse.emf.common.util.ResourceLocator; |
24 | |
25 | import org.eclipse.emf.ecore.EStructuralFeature; |
26 | |
27 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
28 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
29 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
30 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
31 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
32 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
33 | import org.eclipse.emf.edit.provider.ViewerNotification; |
34 | |
35 | /** |
36 | * This is the item provider adapter for a {@link de.fzi.se.quality.QualityRepository} object. |
37 | * <!-- begin-user-doc --> |
38 | * <!-- end-user-doc --> |
39 | * @generated |
40 | */ |
41 | public class QualityRepositoryItemProvider |
42 | extends IdentifierItemProvider |
43 | implements |
44 | IEditingDomainItemProvider, |
45 | IStructuredItemContentProvider, |
46 | ITreeItemContentProvider, |
47 | IItemLabelProvider, |
48 | IItemPropertySource { |
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 QualityRepositoryItemProvider(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(QualityPackage.Literals.QUALITY_REPOSITORY__QUALITY_STATEMENTS); |
87 | } |
88 | return childrenFeatures; |
89 | } |
90 | |
91 | /** |
92 | * <!-- begin-user-doc --> |
93 | * <!-- end-user-doc --> |
94 | * @generated |
95 | */ |
96 | @Override |
97 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
98 | // Check the type of the specified child object and return the proper feature to use for |
99 | // adding (see {@link AddCommand}) it as a child. |
100 | |
101 | return super.getChildFeature(object, child); |
102 | } |
103 | |
104 | /** |
105 | * This returns QualityRepository.gif. |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | @Override |
111 | public Object getImage(Object object) { |
112 | return overlayImage(object, getResourceLocator().getImage("full/obj16/QualityRepository")); |
113 | } |
114 | |
115 | /** |
116 | * This returns the label text for the adapted class. |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | @Override |
122 | public String getText(Object object) { |
123 | String label = ((QualityRepository)object).getId(); |
124 | return label == null || label.length() == 0 ? |
125 | getString("_UI_QualityRepository_type") : |
126 | getString("_UI_QualityRepository_type") + " " + label; |
127 | } |
128 | |
129 | /** |
130 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
131 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | @Override |
137 | public void notifyChanged(Notification notification) { |
138 | updateChildren(notification); |
139 | |
140 | switch (notification.getFeatureID(QualityRepository.class)) { |
141 | case QualityPackage.QUALITY_REPOSITORY__QUALITY_STATEMENTS: |
142 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
143 | return; |
144 | } |
145 | super.notifyChanged(notification); |
146 | } |
147 | |
148 | /** |
149 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
150 | * that can be created under this object. |
151 | * <!-- begin-user-doc --> |
152 | * <!-- end-user-doc --> |
153 | * @generated |
154 | */ |
155 | @Override |
156 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
157 | super.collectNewChildDescriptors(newChildDescriptors, object); |
158 | |
159 | newChildDescriptors.add |
160 | (createChildParameter |
161 | (QualityPackage.Literals.QUALITY_REPOSITORY__QUALITY_STATEMENTS, |
162 | QualityAnnotationFactory.eINSTANCE.createQualityAnnotation())); |
163 | } |
164 | |
165 | /** |
166 | * Return the resource locator for this item provider's resources. |
167 | * <!-- begin-user-doc --> |
168 | * <!-- end-user-doc --> |
169 | * @generated |
170 | */ |
171 | @Override |
172 | public ResourceLocator getResourceLocator() { |
173 | return QualityEditPlugin.INSTANCE; |
174 | } |
175 | |
176 | } |