Skip to content

Package: InnerObjectItemProvider$1

InnerObjectItemProvider$1

nameinstructionbranchcomplexitylinemethod
getChoiceOfValues(Object)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
{...}
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: * Lucas Koehler - extension for EnumComboViewerRenderer_PTest
14: */
15: package org.eclipse.emf.ecp.view.core.swt.test.model.provider;
16:
17: import java.util.Collection;
18: import java.util.List;
19: import java.util.Set;
20: import java.util.stream.Collectors;
21:
22: import org.eclipse.emf.common.notify.AdapterFactory;
23: import org.eclipse.emf.common.notify.Notification;
24: import org.eclipse.emf.common.util.Enumerator;
25: import org.eclipse.emf.common.util.ResourceLocator;
26: import org.eclipse.emf.ecore.EEnumLiteral;
27: import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
28: import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
29: import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
30: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
31: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
32: import org.eclipse.emf.edit.provider.IItemLabelProvider;
33: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
34: import org.eclipse.emf.edit.provider.IItemPropertySource;
35: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
36: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
37: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
38: import org.eclipse.emf.edit.provider.ItemProviderAdapter;
39: import org.eclipse.emf.edit.provider.ViewerNotification;
40:
41: /**
42: * This is the item provider adapter for a {@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject} object.
43: * <!-- begin-user-doc -->
44: * <!-- end-user-doc -->
45: *
46: * @generated
47: */
48: public class InnerObjectItemProvider
49:         extends ItemProviderAdapter
50:         implements
51:         IEditingDomainItemProvider,
52:         IStructuredItemContentProvider,
53:         ITreeItemContentProvider,
54:         IItemLabelProvider,
55:         IItemPropertySource {
56:         /**
57:          * This constructs an instance from a factory and a notifier.
58:          * <!-- begin-user-doc -->
59:          * <!-- end-user-doc -->
60:          *
61:          * @generated
62:          */
63:         public InnerObjectItemProvider(AdapterFactory adapterFactory) {
64:                 super(adapterFactory);
65:         }
66:
67:         /**
68:          * This returns the property descriptors for the adapted class.
69:          * <!-- begin-user-doc -->
70:          * <!-- end-user-doc -->
71:          *
72:          * @generated
73:          */
74:         @Override
75:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
76:                 if (itemPropertyDescriptors == null) {
77:                         super.getPropertyDescriptors(object);
78:
79:                         addMyEnumPropertyDescriptor(object);
80:                 }
81:                 return itemPropertyDescriptors;
82:         }
83:
84:         /**
85:          * This adds a property descriptor for the My Enum feature.
86:          * <!-- begin-user-doc -->
87:          * <!-- end-user-doc -->
88:          *
89:          * @generated NOT
90:          */
91:         protected void addMyEnumPropertyDescriptor(Object object) {
92:                 itemPropertyDescriptors
93:                         .add(new ItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
94:                                 getResourceLocator(),
95:                                 getString("_UI_InnerObject_myEnum_feature"), //$NON-NLS-1$
96:                                 getString("_UI_PropertyDescriptor_description", "_UI_InnerObject_myEnum_feature", //$NON-NLS-1$//$NON-NLS-2$
97:                                         "_UI_InnerObject_type"), //$NON-NLS-1$
98:                                 TestPackage.Literals.INNER_OBJECT__MY_ENUM,
99:                                 true,
100:                                 false,
101:                                 false,
102:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
103:                                 null,
104:                                 null) {
105:                                 @Override
106:                                 public Collection<?> getChoiceOfValues(Object object) {
107:                                         final Set<Enumerator> set = TestPackage.Literals.TEST_ENUM.getELiterals().stream()
108:                                                 .map(EEnumLiteral::getInstance).collect(Collectors.toSet());
109:                                         set.remove(TestEnum.D);
110:                                         return set;
111:                                 }
112:                         });
113:         }
114:
115:         /**
116:          * This returns InnerObject.gif.
117:          * <!-- begin-user-doc -->
118:          * <!-- end-user-doc -->
119:          *
120:          * @generated
121:          */
122:         @Override
123:         public Object getImage(Object object) {
124:                 return overlayImage(object, getResourceLocator().getImage("full/obj16/InnerObject")); //$NON-NLS-1$
125:         }
126:
127:         /**
128:          * This returns the label text for the adapted class.
129:          * <!-- begin-user-doc -->
130:          * <!-- end-user-doc -->
131:          *
132:          * @generated
133:          */
134:         @Override
135:         public String getText(Object object) {
136:                 final TestEnum labelValue = ((InnerObject) object).getMyEnum();
137:                 final String label = labelValue == null ? null : labelValue.toString();
138:                 return label == null || label.length() == 0 ? getString("_UI_InnerObject_type") : //$NON-NLS-1$
139:                         getString("_UI_InnerObject_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
140:         }
141:
142:         /**
143:          * This handles model notifications by calling {@link #updateChildren} to update any cached
144:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
145:          * <!-- begin-user-doc -->
146:          * <!-- end-user-doc -->
147:          *
148:          * @generated
149:          */
150:         @Override
151:         public void notifyChanged(Notification notification) {
152:                 updateChildren(notification);
153:
154:                 switch (notification.getFeatureID(InnerObject.class)) {
155:                 case TestPackage.INNER_OBJECT__MY_ENUM:
156:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
157:                         return;
158:                 }
159:                 super.notifyChanged(notification);
160:         }
161:
162:         /**
163:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
164:          * that can be created under this object.
165:          * <!-- begin-user-doc -->
166:          * <!-- end-user-doc -->
167:          *
168:          * @generated
169:          */
170:         @Override
171:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
172:                 super.collectNewChildDescriptors(newChildDescriptors, object);
173:         }
174:
175:         /**
176:          * Return the resource locator for this item provider's resources.
177:          * <!-- begin-user-doc -->
178:          * <!-- end-user-doc -->
179:          *
180:          * @generated
181:          */
182:         @Override
183:         public ResourceLocator getResourceLocator() {
184:                 return TestEditPlugin.INSTANCE;
185:         }
186:
187: }