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