Skip to content

Package: ContainerItemProvider

ContainerItemProvider

nameinstructionbranchcomplexitylinemethod
ContainerItemProvider(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%
collectNewChildDescriptors(Collection, Object)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getChildFeature(Object, Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getChildrenFeatures(Object)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getPropertyDescriptors(Object)
M: 10 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getText(Object)
M: 26 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
notifyChanged(Notification)
M: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (c) 2011-2013 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: */
14: package org.eclipse.emf.ecp.view.spi.model.provider;
15:
16: import java.util.Collection;
17: import java.util.List;
18:
19: import org.eclipse.emf.common.notify.AdapterFactory;
20: import org.eclipse.emf.common.notify.Notification;
21: import org.eclipse.emf.ecore.EStructuralFeature;
22: import org.eclipse.emf.ecp.view.spi.model.VContainer;
23: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
24: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
25: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
26: import org.eclipse.emf.edit.provider.ViewerNotification;
27:
28: /**
29: * This is the item provider adapter for a {@link org.eclipse.emf.ecp.view.spi.model.VContainer} object.
30: * <!-- begin-user-doc -->
31: *
32: * @since 1.2
33: * <!-- end-user-doc -->
34: * @generated
35: */
36: public class ContainerItemProvider extends ElementItemProvider {
37:         /**
38:          * This constructs an instance from a factory and a notifier.
39:          * <!-- begin-user-doc -->
40:          * <!-- end-user-doc -->
41:          *
42:          * @generated
43:          */
44:         public ContainerItemProvider(AdapterFactory adapterFactory) {
45:                 super(adapterFactory);
46:         }
47:
48:         /**
49:          * This returns the property descriptors for the adapted class.
50:          * <!-- begin-user-doc -->
51:          * <!-- end-user-doc -->
52:          *
53:          * @generated
54:          */
55:         @Override
56:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
57:•                if (itemPropertyDescriptors == null) {
58:                         super.getPropertyDescriptors(object);
59:
60:                 }
61:                 return itemPropertyDescriptors;
62:         }
63:
64:         /**
65:          * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
66:          * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
67:          * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
68:          * <!-- begin-user-doc -->
69:          * <!-- end-user-doc -->
70:          *
71:          * @generated
72:          */
73:         @Override
74:         public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
75:•                if (childrenFeatures == null) {
76:                         super.getChildrenFeatures(object);
77:                         childrenFeatures.add(VViewPackage.Literals.CONTAINER__CHILDREN);
78:                 }
79:                 return childrenFeatures;
80:         }
81:
82:         /**
83:          * <!-- begin-user-doc -->
84:          * <!-- end-user-doc -->
85:          *
86:          * @generated
87:          */
88:         @Override
89:         protected EStructuralFeature getChildFeature(Object object, Object child) {
90:                 // Check the type of the specified child object and return the proper feature to use for
91:                 // adding (see {@link AddCommand}) it as a child.
92:
93:                 return super.getChildFeature(object, child);
94:         }
95:
96:         /**
97:          * This returns the label text for the adapted class.
98:          * <!-- begin-user-doc -->
99:          * <!-- end-user-doc -->
100:          *
101:          * @generated
102:          */
103:         @Override
104:         public String getText(Object object) {
105:                 final String label = ((VContainer) object).getName();
106:•                return label == null || label.length() == 0 ? getString("_UI_Container_type") : //$NON-NLS-1$
107:                         getString("_UI_Container_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
108:         }
109:
110:         /**
111:          * This handles model notifications by calling {@link #updateChildren} to update any cached
112:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
113:          * <!-- begin-user-doc -->
114:          * <!-- end-user-doc -->
115:          *
116:          * @generated
117:          */
118:         @Override
119:         public void notifyChanged(Notification notification) {
120:                 updateChildren(notification);
121:
122:•                switch (notification.getFeatureID(VContainer.class)) {
123:                 case VViewPackage.CONTAINER__CHILDREN:
124:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
125:                         return;
126:                 }
127:                 super.notifyChanged(notification);
128:         }
129:
130:         /**
131:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
132:          * that can be created under this object.
133:          * <!-- begin-user-doc -->
134:          * <!-- end-user-doc -->
135:          *
136:          * @generated
137:          */
138:         @Override
139:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
140:                 super.collectNewChildDescriptors(newChildDescriptors, object);
141:
142:                 newChildDescriptors.add(createChildParameter(VViewPackage.Literals.CONTAINER__CHILDREN,
143:                         VViewFactory.eINSTANCE.createControl()));
144:         }
145:
146: }