Skip to content

Package: CustomReflectiveItemProvider

CustomReflectiveItemProvider

nameinstructionbranchcomplexitylinemethod
CustomReflectiveItemProvider(AdapterFactory)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getPropertyDescriptors(Object)
M: 0 C: 64
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 12
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: * Alexandra Buzila - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.model.common.edit.provider;
15:
16: import java.util.List;
17:
18: import org.eclipse.emf.common.notify.AdapterFactory;
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecore.EReference;
21: import org.eclipse.emf.ecore.EStructuralFeature;
22: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
23: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
24: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
25: import org.eclipse.emf.edit.provider.ReflectiveItemProvider;
26:
27: /**
28: * @author Alexandra Buzila
29: *
30: */
31: public class CustomReflectiveItemProvider extends ReflectiveItemProvider
32:
33: {
34:         /**
35:          * A custom reflective item provider.
36:          *
37:          * @param adapterFactory the parent {@link AdapterFactory}
38:          */
39:         public CustomReflectiveItemProvider(AdapterFactory adapterFactory) {
40:                 super(adapterFactory);
41:         }
42:
43:         @Override
44:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
45:                 super.getPropertyDescriptors(object);
46:
47:•                for (final EStructuralFeature eFeature : ((EObject) object).eClass().getEAllStructuralFeatures()) {
48:•                        if (eFeature instanceof EReference && ((EReference) eFeature).isContainment()) {
49:                                 itemPropertyDescriptors.add(
50:                                         new ItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
51:                                                 getFeatureText(eFeature),
52:                                                 getResourceLocator().getString("_UI_Property_description", //$NON-NLS-1$
53:                                                         new Object[] { getFeatureText(eFeature), eFeature.getEType().getName() }),
54:                                                 eFeature,
55:                                                 eFeature.isChangeable(),
56:                                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE));
57:                         }
58:                 }
59:                 return itemPropertyDescriptors;
60:         }
61: }