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.common.util.ResourceLocator; |
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.ViewerNotification; |
25 | |
26 | import de.uka.ipd.sdq.featuremodel.NamedElement; |
27 | import de.uka.ipd.sdq.featuremodel.featuremodelPackage; |
28 | import de.uka.ipd.sdq.identifier.provider.IdentifierItemProvider; |
29 | |
30 | /** |
31 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.featuremodel.NamedElement} object. |
32 | * <!-- begin-user-doc --> |
33 | * <!-- end-user-doc --> |
34 | * @generated |
35 | */ |
36 | public class NamedElementItemProvider |
37 | extends IdentifierItemProvider |
38 | implements |
39 | IEditingDomainItemProvider, |
40 | IStructuredItemContentProvider, |
41 | ITreeItemContentProvider, |
42 | IItemLabelProvider, |
43 | IItemPropertySource { |
44 | /** |
45 | * This constructs an instance from a factory and a notifier. |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @generated |
49 | */ |
50 | public NamedElementItemProvider(AdapterFactory adapterFactory) { |
51 | super(adapterFactory); |
52 | } |
53 | |
54 | /** |
55 | * This returns the property descriptors for the adapted class. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @generated |
59 | */ |
60 | @Override |
61 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
62 | if (itemPropertyDescriptors == null) { |
63 | super.getPropertyDescriptors(object); |
64 | |
65 | addNamePropertyDescriptor(object); |
66 | } |
67 | return itemPropertyDescriptors; |
68 | } |
69 | |
70 | /** |
71 | * This adds a property descriptor for the Name feature. |
72 | * <!-- begin-user-doc --> |
73 | * <!-- end-user-doc --> |
74 | * @generated |
75 | */ |
76 | protected void addNamePropertyDescriptor(Object object) { |
77 | itemPropertyDescriptors.add |
78 | (createItemPropertyDescriptor |
79 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
80 | getResourceLocator(), |
81 | getString("_UI_NamedElement_name_feature"), |
82 | getString("_UI_PropertyDescriptor_description", "_UI_NamedElement_name_feature", "_UI_NamedElement_type"), |
83 | featuremodelPackage.Literals.NAMED_ELEMENT__NAME, |
84 | true, |
85 | false, |
86 | false, |
87 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
88 | null, |
89 | null)); |
90 | } |
91 | |
92 | /** |
93 | * This returns the label text for the adapted class. |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | @Override |
99 | public String getText(Object object) { |
100 | String label = ((NamedElement)object).getName(); |
101 | return label == null || label.length() == 0 ? |
102 | getString("_UI_NamedElement_type") : |
103 | getString("_UI_NamedElement_type") + " " + label; |
104 | } |
105 | |
106 | /** |
107 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
108 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
109 | * <!-- begin-user-doc --> |
110 | * <!-- end-user-doc --> |
111 | * @generated |
112 | */ |
113 | @Override |
114 | public void notifyChanged(Notification notification) { |
115 | updateChildren(notification); |
116 | |
117 | switch (notification.getFeatureID(NamedElement.class)) { |
118 | case featuremodelPackage.NAMED_ELEMENT__NAME: |
119 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
120 | return; |
121 | } |
122 | super.notifyChanged(notification); |
123 | } |
124 | |
125 | /** |
126 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
127 | * that can be created under this object. |
128 | * <!-- begin-user-doc --> |
129 | * <!-- end-user-doc --> |
130 | * @generated |
131 | */ |
132 | @Override |
133 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
134 | super.collectNewChildDescriptors(newChildDescriptors, object); |
135 | } |
136 | |
137 | /** |
138 | * Return the resource locator for this item provider's resources. |
139 | * <!-- begin-user-doc --> |
140 | * <!-- end-user-doc --> |
141 | * @generated |
142 | */ |
143 | @Override |
144 | public ResourceLocator getResourceLocator() { |
145 | return FeaturemodelEditPlugin.INSTANCE; |
146 | } |
147 | |
148 | } |