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