blob: 776990519fc2f5a27e9a7ad6560404c77c607df0 (
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
|
/*******************************************************************************
* Copyright (c) 2011, 2014 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.ui.views.expressions;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate;
import org.eclipse.tcf.te.ui.views.editor.Editor;
import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
import org.eclipse.ui.IEditorInput;
/**
* Property tester implementation.
*/
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) {
if ("hasApplicableEditorBindings".equals(property)) { //$NON-NLS-1$
IUIService service = ServiceManager.getInstance().getService(receiver, IUIService.class);
IEditorHandlerDelegate delegate = service != null ? service.getDelegate(receiver, IEditorHandlerDelegate.class) : null;
IEditorInput input = (delegate != null) ? delegate.getEditorInput(receiver) : null;
return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(
input != null ? Boolean.valueOf(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input).length > 0) : Boolean.FALSE);
}
if ("isDirty".equals(property) && receiver instanceof Editor && expectedValue instanceof Boolean) { //$NON-NLS-1$
Editor editor = (Editor) receiver;
return ((Boolean)expectedValue).booleanValue() == editor.isDirty();
}
return false;
}
}
|