1
1
/*******************************************************************************
2
* Copyright (c) 2000, 2009 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
2
* Copyright (c) 2000, 2009 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
9
* IBM Corporation - initial implementation
10
10
* Ken Ryall (Nokia) - Modified to launch on a project context.
11
11
*******************************************************************************/
21
21
import org.eclipse.core.runtime.IAdaptable;
24
* A property tester that determines if a file is an executable.
24
* A property tester that determines if a file is an executable or a C/C++ project.
26
26
public class CPropertyTester extends PropertyTester {
29
28
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
30
29
if ("isExecutable".equals(property)) //$NON-NLS-1$
31
30
return isExecutable(receiver);
32
else if ("isCProject".equals(property)) //$NON-NLS-1$
31
if ("isCProject".equals(property)) //$NON-NLS-1$
33
32
return isCProject(receiver);
38
36
private boolean isExecutable(Object receiver) {
39
37
ICElement celement = null;
40
38
if (receiver instanceof IAdaptable) {
41
IResource res = (IResource) ((IAdaptable)receiver).getAdapter(IResource.class);
39
IResource res = (IResource) ((IAdaptable) receiver).getAdapter(IResource.class);
43
41
celement = CoreModel.getDefault().create(res);
46
return (celement != null && celement instanceof IBinary);
44
return celement != null && celement instanceof IBinary;
49
47
private boolean isCProject(Object receiver) {
50
48
if (receiver instanceof IProject)
51
return CoreModel.hasCNature((IProject)receiver);
52
else if (receiver instanceof ICProject)
49
return CoreModel.hasCNature((IProject) receiver);
50
if (receiver instanceof ICProject)