Package: IsInBuildPathPropertyTester

IsInBuildPathPropertyTester

nameinstructionbranchcomplexitylinemethod
IsInBuildPathPropertyTester()
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%
test(Object, String, Object[], Object)
M: 95 C: 0
0%
M: 24 C: 0
0%
M: 13 C: 0
0%
M: 23 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.core
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.core.propertytester;
23:
24: import org.eclipse.core.expressions.PropertyTester;
25: import org.eclipse.core.resources.IFolder;
26: import org.eclipse.core.resources.IProject;
27: import org.overture.ide.core.resources.IVdmProject;
28: import org.overture.ide.core.resources.ModelBuildPath;
29: /**
30: * Property: IsInBuildPath
31: * If expectedValue is true it will return TRUE if the receiver is in the path. If the
32: * expectedValue is false it will return TRUE if the receiver is not in the path.
33: * @author kela
34: *
35: */
36: public class IsInBuildPathPropertyTester extends PropertyTester
37: {
38:         final static String PROPERTY = "IsInBuildPath";
39:
40:         public boolean test(Object receiver, String property, Object[] args,
41:                         Object expectedValue)
42:         {
43:                 IVdmProject project = null;
44:                 boolean checkIfInSourcePath = true;
45:•                if (expectedValue instanceof Boolean)
46:                 {
47:                         checkIfInSourcePath = (Boolean) expectedValue;
48:                 }
49:•                if (receiver instanceof IProject)
50:                 {
51:                         project = (IVdmProject) ((IProject) receiver).getAdapter(IVdmProject.class);
52:
53:•                } else if (receiver instanceof IVdmProject)
54:                 {
55:                         project = (IVdmProject) receiver;
56:                 }
57:
58:•                if (project != null && property.equalsIgnoreCase(PROPERTY))
59:                 {
60:                         ModelBuildPath path = project.getModelBuildPath();
61:
62:•                        if (checkIfInSourcePath)
63:                         {
64:                                 return path.contains((IProject) project.getAdapter(IProject.class));
65:                         } else
66:                         {
67:•                                return !path.contains((IProject) project.getAdapter(IProject.class));
68:                         }
69:
70:•                } else if (receiver instanceof IFolder)
71:                 {
72:                         IFolder file = (IFolder) receiver;
73:
74:                         project = (IVdmProject) file.getProject().getAdapter(IVdmProject.class);
75:
76:•                        if (project != null)
77:                         {
78:                                 ModelBuildPath path = project.getModelBuildPath();
79:•                                if (property.equalsIgnoreCase(PROPERTY))
80:                                 {
81:•                                        if (checkIfInSourcePath)
82:                                         {
83:                                                 return path.getModelSrcPaths().contains(file);
84:                                         } else
85:                                         {
86:•                                                return !path.getModelSrcPaths().contains(file);
87:                                         }
88:                                 }
89:                         }
90:                 }
91:                 return false;
92:         }
93:
94: }