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