1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourcetype.provider; |
7 | |
8 | |
9 | import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProvider; |
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.ecore.EStructuralFeature; |
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.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.resourcetype.ResourceInterface; |
28 | import de.uka.ipd.sdq.pcm.resourcetype.ResourcetypeFactory; |
29 | import de.uka.ipd.sdq.pcm.resourcetype.ResourcetypePackage; |
30 | |
31 | /** |
32 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.resourcetype.ResourceInterface} object. |
33 | * <!-- begin-user-doc --> |
34 | * <!-- end-user-doc --> |
35 | * @generated |
36 | */ |
37 | public class ResourceInterfaceItemProvider |
38 | extends EntityItemProvider |
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 ResourceInterfaceItemProvider(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 | } |
74 | return itemPropertyDescriptors; |
75 | } |
76 | |
77 | /** |
78 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
79 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
80 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
81 | * <!-- begin-user-doc --> |
82 | * <!-- end-user-doc --> |
83 | * @generated |
84 | */ |
85 | @Override |
86 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
87 | if (childrenFeatures == null) { |
88 | super.getChildrenFeatures(object); |
89 | childrenFeatures.add(ResourcetypePackage.Literals.RESOURCE_INTERFACE__RESOURCE_SIGNATURES_RESOURCE_INTERFACE); |
90 | } |
91 | return childrenFeatures; |
92 | } |
93 | |
94 | /** |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @generated |
98 | */ |
99 | @Override |
100 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
101 | // Check the type of the specified child object and return the proper feature to use for |
102 | // adding (see {@link AddCommand}) it as a child. |
103 | |
104 | return super.getChildFeature(object, child); |
105 | } |
106 | |
107 | /** |
108 | * This returns ResourceInterface.gif. |
109 | * <!-- begin-user-doc --> |
110 | * <!-- end-user-doc --> |
111 | * @generated |
112 | */ |
113 | @Override |
114 | public Object getImage(Object object) { |
115 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ResourceInterface")); |
116 | } |
117 | |
118 | /** |
119 | * This returns the label text for the adapted class. |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @generated |
123 | */ |
124 | @Override |
125 | public String getText(Object object) { |
126 | String label = ((ResourceInterface)object).getId(); |
127 | return label == null || label.length() == 0 ? |
128 | getString("_UI_ResourceInterface_type") : |
129 | getString("_UI_ResourceInterface_type") + " " + label; |
130 | } |
131 | |
132 | /** |
133 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
134 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
135 | * <!-- begin-user-doc --> |
136 | * <!-- end-user-doc --> |
137 | * @generated |
138 | */ |
139 | @Override |
140 | public void notifyChanged(Notification notification) { |
141 | updateChildren(notification); |
142 | |
143 | switch (notification.getFeatureID(ResourceInterface.class)) { |
144 | case ResourcetypePackage.RESOURCE_INTERFACE__RESOURCE_SIGNATURES_RESOURCE_INTERFACE: |
145 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
146 | return; |
147 | } |
148 | super.notifyChanged(notification); |
149 | } |
150 | |
151 | /** |
152 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
153 | * that can be created under this object. |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | @Override |
159 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
160 | super.collectNewChildDescriptors(newChildDescriptors, object); |
161 | |
162 | newChildDescriptors.add |
163 | (createChildParameter |
164 | (ResourcetypePackage.Literals.RESOURCE_INTERFACE__RESOURCE_SIGNATURES_RESOURCE_INTERFACE, |
165 | ResourcetypeFactory.eINSTANCE.createResourceSignature())); |
166 | } |
167 | |
168 | /** |
169 | * Return the resource locator for this item provider's resources. |
170 | * <!-- begin-user-doc --> |
171 | * <!-- end-user-doc --> |
172 | * @generated |
173 | */ |
174 | @Override |
175 | public ResourceLocator getResourceLocator() { |
176 | return PalladioComponentModelEditPlugin.INSTANCE; |
177 | } |
178 | |
179 | } |