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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*******************************************************************************
* Copyright (c) 2011, 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.tcf.processes.ui.editor.tree;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.tcf.te.core.interfaces.IConnectable;
import org.eclipse.tcf.te.runtime.model.MessageModelNode;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
/**
* Process tree control content provider implementation.
*/
public class ContentProvider extends org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.ContentProvider {
// The target's peer model.
private IPeerNode peerNode;
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.ContentProvider#dispose()
*/
@Override
public void dispose() {
if (peerNode != null) {
IRuntimeModel model = ModelManager.getRuntimeModel(peerNode);
if (model != null && model.getAutoRefreshInterval() > 0) {
// If the model is auto refreshing, then stop it when the editor is disposed.
model.setAutoRefreshInterval(0);
}
}
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.ContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
super.inputChanged(viewer, oldInput, newInput);
peerNode = getPeerNode(newInput);
}
protected IPeerNode getPeerNode(Object input) {
IPeerNode peerNode = input instanceof IPeerNode ? (IPeerNode)input : null;
if (peerNode == null && input instanceof IAdaptable) {
peerNode = (IPeerNode)((IAdaptable)input).getAdapter(IPeerNode.class);
}
return peerNode;
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.ContentProvider#getElements(java.lang.Object)
*/
@Override
public Object[] getElements(Object inputElement) {
if (peerNode != null && peerNode.getConnectState() == IConnectable.STATE_CONNECTED) {
return super.getElements(inputElement);
}
String message = Messages.getStringDelegated(peerNode, "ProcessMonitor_ContentProvider_notConnected"); //$NON-NLS-1$
return new Object[] { new MessageModelNode(message != null ? message : Messages.ContentProvider_notConnected, IStatus.INFO, false) };
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.ContentProvider#isRuntimeModelNodeVisible()
*/
@Override
protected boolean isRuntimeModelNodeVisible() {
return false;
}
}
|