Skip to content

Package: ValidationFailedDecorator

ValidationFailedDecorator

nameinstructionbranchcomplexitylinemethod
ValidationFailedDecorator()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
addListener(ILabelProviderListener)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
decorate(Object, IDecoration)
M: 75 C: 0
0%
M: 22 C: 0
0%
M: 13 C: 0
0%
M: 22 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isLabelProperty(Object, String)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
removeListener(ILabelProviderListener)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2012 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: *******************************************************************************/
15: package org.eclipse.emf.ecp.validation.connector;
16:
17: import org.eclipse.emf.common.util.Diagnostic;
18: import org.eclipse.emf.ecore.EObject;
19: import org.eclipse.emf.ecp.core.ECPProject;
20: import org.eclipse.emf.ecp.core.util.ECPUtil;
21: import org.eclipse.jface.viewers.IDecoration;
22: import org.eclipse.jface.viewers.ILabelProviderListener;
23: import org.eclipse.jface.viewers.ILightweightLabelDecorator;
24:
25: /**
26: * This class decorates the navigator if the validation of a project fails.
27: *
28: * @author Eugen Neufeld
29: * @author emueller
30: */
31: public class ValidationFailedDecorator implements ILightweightLabelDecorator {
32:
33:         /**
34:          * {@inheritDoc}
35:          */
36:         @Override
37:         public void decorate(final Object element, IDecoration decoration) {
38:•                if (!(element instanceof EObject) && !(element instanceof ECPProject)) {
39:                         return;
40:                 }
41:
42:                 Integer severity = null;
43:
44:•                if (element instanceof EObject) {
45:
46:                         final ECPProject project = ECPUtil.getECPProjectManager().getProject(element);
47:
48:•                        if (project != null && project.isOpen()) {
49:                                 severity = Activator.getDefault().getValidationService(project).getDiagnostic(element).getSeverity();
50:                         }
51:•                } else if (element instanceof ECPProject && ((ECPProject) element).isOpen()) {
52:•                        if (ECPUtil.getECPProjectManager().getProject(((ECPProject) element).getName()) == null) {
53:                                 return;
54:                         }
55:                         severity = Activator.getDefault().getValidationService((ECPProject) element).getRootDiagnostic()
56:                                 .getSeverity();
57:                 }
58:
59:•                if (severity == null) {
60:                         return;
61:                 }
62:
63:•                switch (severity.intValue()) {
64:                 case Diagnostic.ERROR:
65:                         decoration.addOverlay(Activator.getImageDescriptor("icons/error_decorate.png"), IDecoration.BOTTOM_RIGHT); //$NON-NLS-1$
66:                         break;
67:                 case Diagnostic.WARNING:
68:                         decoration.addOverlay(Activator.getImageDescriptor("icons/warning_decorate.png"), IDecoration.BOTTOM_RIGHT); //$NON-NLS-1$
69:                         break;
70:                 case Diagnostic.OK:
71:                         decoration.addOverlay(null);
72:                         break;
73:                 default:
74:                         break;
75:                 }
76:
77:         }
78:
79:         /** {@inheritDoc} */
80:         @Override
81:         public void addListener(ILabelProviderListener listener) {
82:
83:         }
84:
85:         /** {@inheritDoc} */
86:         @Override
87:         public void dispose() {
88:
89:         }
90:
91:         /** {@inheritDoc} */
92:         @Override
93:         public boolean isLabelProperty(Object element, String property) {
94:                 return false;
95:         }
96:
97:         /** {@inheritDoc} */
98:         @Override
99:         public void removeListener(ILabelProviderListener listener) {
100:         }
101:
102: }