Skip to content

Package: LabelItemProvider

LabelItemProvider

nameinstructionbranchcomplexitylinemethod
LabelItemProvider(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%
addDomainModelReferencePropertyDescriptor(Object)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
addStylePropertyDescriptor(Object)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
collectNewChildDescriptors(Collection, Object)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getImage(Object)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPropertyDescriptors(Object)
M: 0 C: 16
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getText(Object)
M: 0 C: 34
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 5
100%
M: 0 C: 1
100%
notifyChanged(Notification)
M: 0 C: 22
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%

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.label.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.ecp.view.spi.label.model.VLabel;
22: import org.eclipse.emf.ecp.view.spi.label.model.VLabelPackage;
23: import org.eclipse.emf.ecp.view.spi.model.VElement;
24: import org.eclipse.emf.ecp.view.spi.model.VElementUtil;
25: import org.eclipse.emf.ecp.view.spi.model.provider.ContainedElementItemProvider;
26: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
27: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
28: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
29: import org.eclipse.emf.edit.provider.ViewerNotification;
30:
31: /**
32: * This is the item provider adapter for a {@link org.eclipse.emf.ecp.view.spi.label.model.VLabel} object.
33: * <!-- begin-user-doc -->
34: * <!-- end-user-doc -->
35: *
36: * @generated
37: */
38: public class LabelItemProvider
39:         extends ContainedElementItemProvider {
40:         /**
41:          * This constructs an instance from a factory and a notifier.
42:          * <!-- begin-user-doc -->
43:          * <!-- end-user-doc -->
44:          *
45:          * @generated
46:          */
47:         public LabelItemProvider(AdapterFactory adapterFactory) {
48:                 super(adapterFactory);
49:         }
50:
51:         /**
52:          * This returns the property descriptors for the adapted class.
53:          * <!-- begin-user-doc -->
54:          * <!-- end-user-doc -->
55:          *
56:          * @generated
57:          */
58:         @Override
59:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
60:•                if (itemPropertyDescriptors == null) {
61:                         super.getPropertyDescriptors(object);
62:
63:                         addStylePropertyDescriptor(object);
64:                         addDomainModelReferencePropertyDescriptor(object);
65:                 }
66:                 return itemPropertyDescriptors;
67:         }
68:
69:         /**
70:          * This adds a property descriptor for the Style feature.
71:          * <!-- begin-user-doc -->
72:          * <!-- end-user-doc -->
73:          *
74:          * @generated
75:          */
76:         protected void addStylePropertyDescriptor(Object object) {
77:                 itemPropertyDescriptors
78:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
79:                                 getResourceLocator(),
80:                                 getString("_UI_Label_style_feature"), //$NON-NLS-1$
81:                                 getString("_UI_PropertyDescriptor_description", "_UI_Label_style_feature", "_UI_Label_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
82:                                 VLabelPackage.Literals.LABEL__STYLE,
83:                                 true,
84:                                 false,
85:                                 false,
86:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
87:                                 null,
88:                                 null));
89:         }
90:
91:         /**
92:          * This adds a property descriptor for the Domain Model Reference feature.
93:          * <!-- begin-user-doc -->
94:          *
95:          * @since 1.4
96:          * <!-- end-user-doc -->
97:          * @generated
98:          */
99:         protected void addDomainModelReferencePropertyDescriptor(Object object) {
100:                 itemPropertyDescriptors
101:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
102:                                 getResourceLocator(),
103:                                 getString("_UI_Label_domainModelReference_feature"), //$NON-NLS-1$
104:                                 getString("_UI_PropertyDescriptor_description", "_UI_Label_domainModelReference_feature", //$NON-NLS-1$ //$NON-NLS-2$
105:                                         "_UI_Label_type"), //$NON-NLS-1$
106:                                 VLabelPackage.Literals.LABEL__DOMAIN_MODEL_REFERENCE,
107:                                 true,
108:                                 false,
109:                                 false,
110:                                 null,
111:                                 null,
112:                                 null));
113:         }
114:
115:         /**
116:          * This returns Label.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/Label")); //$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 NOT
133:          */
134:         @Override
135:         public String getText(Object object) {
136:                 String label = ((VLabel) object).getName();
137:•                if (label == null) {
138:                         label = VElementUtil.getCleanName(VElement.class.cast(object));
139:                 }
140:•                return label == null || label.length() == 0 ? getString("_UI_Label_type") : //$NON-NLS-1$
141:                         getString("_UI_Label_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
142:         }
143:
144:         /**
145:          * This handles model notifications by calling {@link #updateChildren} to update any cached
146:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
147:          * <!-- begin-user-doc -->
148:          * <!-- end-user-doc -->
149:          *
150:          * @generated
151:          */
152:         @Override
153:         public void notifyChanged(Notification notification) {
154:                 updateChildren(notification);
155:
156:•                switch (notification.getFeatureID(VLabel.class)) {
157:                 case VLabelPackage.LABEL__STYLE:
158:                 case VLabelPackage.LABEL__DOMAIN_MODEL_REFERENCE:
159:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
160:                         return;
161:                 }
162:                 super.notifyChanged(notification);
163:         }
164:
165:         /**
166:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
167:          * that can be created under this object.
168:          * <!-- begin-user-doc -->
169:          * <!-- end-user-doc -->
170:          *
171:          * @generated
172:          */
173:         @Override
174:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
175:                 super.collectNewChildDescriptors(newChildDescriptors, object);
176:         }
177:
178: }