Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 284ead5a2b3ca0aba78c52d73a40a0caf48e80b6 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*******************************************************************************
 * 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.tcf.processes.ui.internal.tabbed;

import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.ISysMonitor;
import org.eclipse.tcf.te.runtime.services.ServiceUtils;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

/**
 * The property section to display the context IDs of a process.
 */
public class ContextIDSection extends BaseTitledSection {
	// The selected process node
	/* default */ IProcessContextNode node;
	// The system monitor context for the selected process node.
	/* default */ ISysMonitor.SysMonitorContext context;
	// The text field to display the id of the process context.
	private Text idText;
	// The text field to display the parent id of the process context.
	private Text parentIdText;
	// The text field to display the process group id.
	private Text pgrpText;
	// The text field to display the process id.
	private CLabel pidLabel;
	private Text pidText;
	// The text field to display the parent process id.
	private CLabel ppidLabel;
	private Text ppidText;
	// The text field to display the process TTY group ID.
	private Text tgidText;
	// The text field to display the tracer process's id.
	private Text tracerPidText;
	// The text field to display the user id of the process.
	private Text uidText;
	// The text field to display the user group id of the process.
	private Text ugidText;

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
	 */
	@Override
	public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
		super.createControls(parent, aTabbedPropertySheetPage);
		idText = createTextField(null, Messages.ContextIDSection_ID);
		parentIdText = createTextField(idText, Messages.ContextIDSection_ParentID);
		pgrpText = createTextField(parentIdText, Messages.ContextIDSection_GroupID);


		pidText = createText(pgrpText);
		pidLabel = createLabel(pidText, Messages.ContextIDSection_PID);

		ppidText = createText(pidText);
		ppidLabel = createLabel(ppidText, Messages.ContextIDSection_PPID);

		tgidText = createTextField(ppidText, Messages.ContextIDSection_TTY_GRPID);
		tracerPidText = createTextField(tgidText, Messages.ContextIDSection_TracerPID);
		uidText = createTextField(tracerPidText, Messages.ContextIDSection_UserID);
		ugidText = createTextField(uidText, Messages.ContextIDSection_UserGRPID);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection#updateInput(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider)
	 */
	@Override
	protected void updateInput(IPeerNodeProvider input) {
		Assert.isTrue(input instanceof IProcessContextNode);
		final IProcessContextNode node = (IProcessContextNode) input;
		this.node = node;

		Runnable runnable = new Runnable() {
			@Override
			public void run() {
				context = node.getSysMonitorContext();
			}
		};

		Assert.isTrue(!Protocol.isDispatchThread());
		Protocol.invokeAndWait(runnable);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
	 */
	@Override
	public void refresh() {
		IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class);
		IProcessMonitorUIDelegate delegate = ServiceUtils.getUIServiceDelegate(peerNode, peerNode, IProcessMonitorUIDelegate.class);

		String label = delegate != null ? delegate.getMessage("ContextIDSection_PID") : null; //$NON-NLS-1$
		if (label != null) SWTControlUtil.setText(pidLabel, label);
		label = delegate != null ? delegate.getMessage("ContextIDSection_PPID") : null; //$NON-NLS-1$
		if (label != null) SWTControlUtil.setText(ppidLabel, label);

		this.idText.setText(context == null ? "" : (context.getID() != null ? context.getID() : "")); //$NON-NLS-1$ //$NON-NLS-2$
		this.parentIdText.setText(context == null ? "" : (context.getParentID() != null ? context.getParentID() : "")); //$NON-NLS-1$ //$NON-NLS-2$
		this.pgrpText.setText(context == null ? "" : (context.getPGRP() >= 0 ? "" + context.getPGRP() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

		String value = context != null && context.getPID() >= 0 ? Long.toString(context.getPID()) : ""; //$NON-NLS-1$
		String value2 = delegate != null ? delegate.getText(node, "PID", value) : null; //$NON-NLS-1$
		SWTControlUtil.setText(pidText, value2 != null ? value2 : value);

		value = context != null && context.getPPID() >= 0 ? Long.toString(context.getPPID()) : ""; //$NON-NLS-1$
		value2 = delegate != null ? delegate.getText(node, "PPID", value) : null; //$NON-NLS-1$
		SWTControlUtil.setText(ppidText, value2 != null ? value2 : value);

		this.tgidText.setText(context == null ? "" : (context.getTGID() >= 0 ? "" + context.getTGID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		this.tracerPidText.setText(context == null ? "" : (context.getTracerPID() >= 0 ? "" + context.getTracerPID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		this.uidText.setText(context == null ? "" : (context.getUID() >= 0 ? "" + context.getUID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		this.ugidText.setText(context == null ? "" : (context.getUGID() >= 0 ? "" + context.getUGID() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		super.refresh();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText()
	 */
	@Override
	protected String getText() {
		return Messages.ContextIDSection_ContextIDs;
	}

}

Back to the top