Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3f073a862628cd8d6de5c3f2a9422d0a1945d77e (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
/*******************************************************************************
 * Copyright (c) 2013 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.tcf.processes.ui.internal.properties;

import org.eclipse.tcf.te.runtime.services.ServiceUtils;
import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate;


/**
 * Process monitor property tester (UI).
 */
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {

	/* (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) {
    	// Get the UI delegate for the context (== receiver)
		IProcessMonitorUIDelegate delegate = ServiceUtils.getUIServiceDelegate(receiver, receiver, IProcessMonitorUIDelegate.class);
		if ("isColumnActive".equals(property) || "isFilterActive".equals(property)) { //$NON-NLS-1$ //$NON-NLS-2$
			// If no delegate is registered for the context, the column or filter are treated as active (== no activation expression)
			if (delegate == null) return true;

			// Column or the filter id is the only argument to be passed in
			String id = args.length > 0 && args[0] instanceof String ? (String)args[0] : null;
			if (id != null) {
				boolean isActive = "isColumnActive".equals(property) ? delegate.isColumnActive(receiver, id) : delegate.isFilterActive(receiver, id); //$NON-NLS-1$
				if (expectedValue instanceof Boolean) {
					return ((Boolean)expectedValue).equals(Boolean.valueOf(isActive));
				}
			}
		}

	    return false;
    }

}

Back to the top