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