Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 079f75bb8b6195aa8e56c5f34c57087f11073952 (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
55
56
57
58
/*******************************************************************************
 * Copyright (c) 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.te.launch.ui.internal;

import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.tcf.te.launch.ui.internal.handler.DeleteHandler;
import org.eclipse.tcf.te.launch.ui.internal.handler.RefreshHandler;
import org.eclipse.tcf.te.launch.ui.model.LaunchNode;

/**
 * The property tester for a launch tree node.
 */
public class LaunchNodePropertyTester extends PropertyTester {
	private final DeleteHandler deleteHandler = new DeleteHandler();
	private final RefreshHandler refreshHandler = new RefreshHandler();

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
	 */
	@Override
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
		if (receiver instanceof LaunchNode) {
			LaunchNode node = (LaunchNode)receiver;
			if (property.equals("isLaunchConfigType")) { //$NON-NLS-1$
				if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) {
					boolean isValue = expectedValue == null || expectedValue.equals(node.getLaunchConfigurationType().getIdentifier());
					return isValue;
				}
			}
			else if (property.equals("isLaunchConfig")) { //$NON-NLS-1$
				return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType());
			}
			else if (property.equals("canDelete")) { //$NON-NLS-1$
				return deleteHandler.canDelete(receiver);
			}
			else if (property.equals("canRefresh")) { //$NON-NLS-1$
				return refreshHandler.canRefresh(receiver);
			}
			else if (property.equals("hasLaunchMode")) { //$NON-NLS-1$
				if (expectedValue != null && LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType())) {
					return node.getLaunchConfigurationType().supportsMode(expectedValue.toString());
				}
			}
			else if (property.equals("isValidLaunchConfig")) { //$NON-NLS-1$
				return true;
			}
		}
		return false;
	}
}

Back to the top