~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CPropertyTester.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2013-10-03 20:30:16 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131003203016-d4ug6l0xgosasumq
Tags: 8.2.1-1
* New upstream release.
* Updated autotools documentation sources.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
7
7
 * 
8
 
 *  Contributors:
 
8
 * Contributors:
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;
22
22
 
23
23
/**
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.
25
25
 */
26
26
public class CPropertyTester extends PropertyTester {
27
 
        
28
27
        @Override
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);
34
 
                else
35
 
                        return false;
 
33
                return false;
36
34
        }
37
35
 
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);
42
40
                        if (res != null) {
43
41
                                celement = CoreModel.getDefault().create(res);
44
42
                        }
45
43
                }
46
 
                return (celement != null && celement instanceof IBinary);
 
44
                return celement != null && celement instanceof IBinary;
47
45
        }
48
46
        
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)
53
51
                        return true;
54
 
                else
55
 
                        return false;
 
52
                return false;
56
53
        }
57
 
        
58
54
}