blob: fe6708ab313b891126c77b9efba0460740f8c437 (
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
|
/*******************************************************************************
* Copyright (c) 2011 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.ui.filter;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
/**
* Filter implementation filtering unreachable peers.
*/
public class UnreachablePeersFilter extends ViewerFilter {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
// Filter only elements of simulator IPeerModel
if (element instanceof IPeerModel) {
final IPeerModel peerModel = (IPeerModel)element;
// Determine the current action of the peer model
final int[] state = new int[1];
if (Protocol.isDispatchThread()) {
state[0] = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE);
} else {
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
state[0] = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE);
}
});
}
return state[0] != IPeerModelProperties.STATE_NOT_REACHABLE && state[0] != IPeerModelProperties.STATE_ERROR;
}
return true;
}
}
|