blob: d6170355de0c397aac3e5de426531eb2e7214690 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*******************************************************************************
* Copyright (c) 2008, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.internal.debug.ui.launch;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.tcf.debug.ui.ITCFLaunchContext;
import org.eclipse.tcf.internal.debug.ui.Activator;
public class TCFPropertyTester extends PropertyTester {
public boolean test(Object receiver, String property, Object[] args, Object expected_value) {
if (property.equals("areUpdatePoliciesSupported")) return testUpdatePoliciesSupported(receiver);
if (property.equals("isExecutable")) return testIsExecutable(receiver, expected_value);
return false;
}
private boolean testUpdatePoliciesSupported(Object receiver) {
return receiver instanceof IDebugView;
}
private boolean testIsExecutable(Object receiver, Object expected_value) {
Object value = null;
try {
if (receiver instanceof IAdaptable) {
IAdaptable selection = (IAdaptable)receiver;
ITCFLaunchContext context = TCFLaunchContext.getLaunchContext(selection);
if (context != null) {
IProject project = context.getProject(selection);
IPath path = context.getPath(selection);
if (project != null && path != null) {
value = context.isBinary(project, path);
}
}
}
}
catch (Throwable x) {
Activator.log(x);
}
if (expected_value != null) return expected_value.equals(value);
return (value instanceof Boolean) && ((Boolean)value).booleanValue();
}
}
|