blob: 053b040bb609d1f9563438c86f5998d7b8ddae1c (
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
59
|
/*******************************************************************************
* 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.terminals.internal;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
/**
* Terminals property tester implementation.
*/
@SuppressWarnings("restriction")
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 ("hasApplicableLauncherDelegates".equals(property)) { //$NON-NLS-1$
ISelection selection = receiver instanceof ISelection ? (ISelection)receiver : new StructuredSelection(receiver);
return expectedValue.equals(Boolean.valueOf(LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection).length > 0));
}
if ("hasDisconnectButton".equals(property) && receiver instanceof CTabItem) { //$NON-NLS-1$
CTabItem tabItem = (CTabItem)receiver;
if (!tabItem.isDisposed()) {
Boolean hasDisconnectButton = (Boolean) tabItem.getData(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON);
return expectedValue.equals(hasDisconnectButton);
}
return false;
}
if ("canDisconnect".equals(property) && receiver instanceof CTabItem) { //$NON-NLS-1$
CTabItem tabItem = (CTabItem)receiver;
if (!tabItem.isDisposed() && tabItem.getData() instanceof ITerminalViewControl) {
ITerminalViewControl terminal = (ITerminalViewControl)tabItem.getData();
TerminalState state = terminal.getState();
return expectedValue.equals(Boolean.valueOf(state != TerminalState.CLOSED));
}
return false;
}
return false;
}
}
|