Skip to content

Package: ProjectEMFStoreDirtyDecorator

ProjectEMFStoreDirtyDecorator

nameinstructionbranchcomplexitylinemethod
ProjectEMFStoreDirtyDecorator()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 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: 43 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 13 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.emfstore.internal.ui.decorator;
16:
17: import org.eclipse.emf.ecp.core.ECPProject;
18: import org.eclipse.emf.ecp.core.ECPProvider;
19: import org.eclipse.emf.ecp.core.util.ECPUtil;
20: import org.eclipse.emf.ecp.emfstore.core.internal.EMFStoreProvider;
21: import org.eclipse.emf.ecp.emfstore.internal.ui.e3.Activator;
22: import org.eclipse.emf.ecp.spi.core.InternalProject;
23: import org.eclipse.emf.emfstore.client.ESLocalProject;
24: import org.eclipse.jface.viewers.IDecoration;
25: import org.eclipse.jface.viewers.ILabelProviderListener;
26: import org.eclipse.jface.viewers.ILightweightLabelDecorator;
27:
28: /**
29: * Dirty Decorator for Projects.
30: *
31: * @author Tobias Verhoeven
32: */
33: public class ProjectEMFStoreDirtyDecorator implements ILightweightLabelDecorator {
34:
35:         private final String dirtyPath = EMFStoreDirtyDecorator.dirtyPath;
36:
37:         /**
38:          * Instantiates a new EMFStoreDirtyDecorator.
39:          */
40:         public ProjectEMFStoreDirtyDecorator() {
41:                 super();
42:         }
43:
44:         /** {@inheritDoc} */
45:         @Override
46:         public void decorate(Object element, IDecoration decoration) {
47:
48:•                if (!(element instanceof ECPProject)) {
49:                         return;
50:                 }
51:                 final ECPProvider ecpProvider = ECPUtil.getECPProviderRegistry().getProvider(EMFStoreProvider.NAME);
52:                 final EMFStoreProvider provider = (EMFStoreProvider) ECPUtil.getResolvedElement(ecpProvider);
53:                 final InternalProject project = (InternalProject) element;
54:•                if (!project.getProvider().equals(provider)) {
55:                         return;
56:                 }
57:                 final ESLocalProject projectSpace = provider.getProjectSpace(project);
58:
59:•                if (projectSpace == null) {
60:                         return;
61:                 }
62:
63:•                if (project.isOpen() && projectSpace.isShared() && projectSpace.hasUncommitedChanges()) {
64:                         decoration.addOverlay(Activator.getImageDescriptor(dirtyPath), IDecoration.BOTTOM_LEFT);
65:                 }
66:
67:         }
68:
69:         /** {@inheritDoc} */
70:         @Override
71:         public void addListener(ILabelProviderListener listener) {
72:         }
73:
74:         /** {@inheritDoc} */
75:         @Override
76:         public void dispose() {
77:
78:         }
79:
80:         /** {@inheritDoc} */
81:         @Override
82:         public boolean isLabelProperty(Object element, String property) {
83:                 return false;
84:         }
85:
86:         /** {@inheritDoc} */
87:         @Override
88:         public void removeListener(ILabelProviderListener listener) {
89:         }
90: }