Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse')
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Activator.java64
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFFileService.java21
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFSubSystem.java21
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Messages.java131
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorService.java275
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorServiceManager.java44
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileAdapter.java36
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileResource.java122
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileService.java643
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileSubSystemConfiguration.java116
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessAdapter.java43
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessResource.java313
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessService.java275
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessSubSystemConfiguration.java53
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRSETask.java71
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteFile.java34
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteProcess.java41
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewProcessAdapterFactory.java50
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewRemoteProcessAdapter.java446
-rw-r--r--plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/messages.properties103
20 files changed, 2902 insertions, 0 deletions
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Activator.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Activator.java
new file mode 100644
index 000000000..682b8d4c2
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Activator.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.windriver.tcf.rse.ui";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public ImageDescriptor getImageDescriptorFromPath(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFFileService.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFFileService.java
new file mode 100644
index 000000000..c0a981cb6
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFFileService.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import com.windriver.tcf.api.services.IFileSystem;
+
+public interface ITCFFileService {
+
+ public boolean canRead(IFileSystem.FileAttrs attrs);
+
+ public boolean canWrite(IFileSystem.FileAttrs attrs);
+
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFSubSystem.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFSubSystem.java
new file mode 100644
index 000000000..c842c6f8c
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/ITCFSubSystem.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.rse.core.subsystems.ISubSystem;
+
+/**
+ * Subsystem can implement this interface to indicate that it can share TCF connection with
+ * other subsystems on same host.
+ */
+public interface ITCFSubSystem extends ISubSystem {
+
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Messages.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Messages.java
new file mode 100644
index 000000000..57d898ebf
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/Messages.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "com.windriver.tcf.rse.ui.messages"; //$NON-NLS-1$
+
+ public static String SysMonitor_AllProcesses;
+ public static String SysMonitor_Process;
+
+ // PROCESS PROPERTIES
+ public static String PROCESS_ID_LABEL;
+ public static String PROCESS_PID_LABEL;
+ public static String PROCESS_NAME_LABEL;
+ public static String PROCESS_CWD_LABEL;
+ public static String PROCESS_ROOT_LABEL;
+ public static String PROCESS_UID_LABEL;
+ public static String PROCESS_USERNAME_LABEL;
+ public static String PROCESS_GID_LABEL;
+ public static String PROCESS_GROUPNAME_LABEL;
+ public static String PROCESS_PPID_LABEL;
+ public static String PROCESS_PGRP_LABEL;
+ public static String PROCESS_STATE_LABEL;
+ public static String PROCESS_TRACERPID_LABEL;
+ public static String PROCESS_VMSIZE_LABEL;
+ public static String PROCESS_VMRSS_LABEL;
+ public static String PROCESS_SESSION_LABEL;
+ public static String PROCESS_TTY_LABEL;
+ public static String PROCESS_TGID_LABEL;
+ public static String PROCESS_FLAGS_LABEL;
+ public static String PROCESS_MINFLT_LABEL;
+ public static String PROCESS_CMINFLT_LABEL;
+ public static String PROCESS_MAJFLT_LABEL;
+ public static String PROCESS_CMAJFLT_LABEL;
+ public static String PROCESS_UTIME_LABEL;
+ public static String PROCESS_STIME_LABEL;
+ public static String PROCESS_CUTIME_LABEL;
+ public static String PROCESS_CSTIME_LABEL;
+ public static String PROCESS_PC_UTIME_LABEL;
+ public static String PROCESS_PC_STIME_LABEL;
+ public static String PROCESS_PRIORITY_LABEL;
+ public static String PROCESS_NICE_LABEL;
+ public static String PROCESS_ITREALVALUE_LABEL;
+ public static String PROCESS_STARTTIME_LABEL;
+ public static String PROCESS_RLIMIT_LABEL;
+ public static String PROCESS_CODESTART_LABEL;
+ public static String PROCESS_CODEEND_LABEL;
+ public static String PROCESS_STACKSTART_LABEL;
+ public static String PROCESS_SIGNALS_LABEL;
+ public static String PROCESS_SIGBLOCK_LABEL;
+ public static String PROCESS_SIGIGNORE_LABEL;
+ public static String PROCESS_SIGCATCH_LABEL;
+ public static String PROCESS_WCHAN_LABEL;
+ public static String PROCESS_NSWAP_LABEL;
+ public static String PROCESS_CNSWAP_LABEL;
+ public static String PROCESS_EXITSIGNAL_LABEL;
+ public static String PROCESS_PROCESSOR_LABEL;
+ public static String PROCESS_RTPRIORITY_LABEL;
+ public static String PROCESS_POLICY_LABEL;
+
+ public static String PROCESS_ID_TOOLTIP;
+ public static String PROCESS_PID_TOOLTIP;
+ public static String PROCESS_NAME_TOOLTIP;
+ public static String PROCESS_CWD_TOOLTIP;
+ public static String PROCESS_ROOT_TOOLTIP;
+ public static String PROCESS_UID_TOOLTIP;
+ public static String PROCESS_USERNAME_TOOLTIP;
+ public static String PROCESS_GID_TOOLTIP;
+ public static String PROCESS_GROUPNAME_TOOLTIP;
+ public static String PROCESS_PPID_TOOLTIP;
+ public static String PROCESS_PGRP_TOOLTIP;
+ public static String PROCESS_STATE_TOOLTIP;
+ public static String PROCESS_TRACERPID_TOOLTIP;
+ public static String PROCESS_VMSIZE_TOOLTIP;
+ public static String PROCESS_VMRSS_TOOLTIP;
+ public static String PROCESS_SESSION_TOOLTIP;
+ public static String PROCESS_TTY_TOOLTIP;
+ public static String PROCESS_TGID_TOOLTIP;
+ public static String PROCESS_FLAGS_TOOLTIP;
+ public static String PROCESS_MINFLT_TOOLTIP;
+ public static String PROCESS_CMINFLT_TOOLTIP;
+ public static String PROCESS_MAJFLT_TOOLTIP;
+ public static String PROCESS_CMAJFLT_TOOLTIP;
+ public static String PROCESS_UTIME_TOOLTIP;
+ public static String PROCESS_STIME_TOOLTIP;
+ public static String PROCESS_PC_UTIME_TOOLTIP;
+ public static String PROCESS_PC_STIME_TOOLTIP;
+ public static String PROCESS_CUTIME_TOOLTIP;
+ public static String PROCESS_CSTIME_TOOLTIP;
+ public static String PROCESS_PRIORITY_TOOLTIP;
+ public static String PROCESS_NICE_TOOLTIP;
+ public static String PROCESS_ITREALVALUE_TOOLTIP;
+ public static String PROCESS_STARTTIME_TOOLTIP;
+ public static String PROCESS_RLIMIT_TOOLTIP;
+ public static String PROCESS_CODESTART_TOOLTIP;
+ public static String PROCESS_CODEEND_TOOLTIP;
+ public static String PROCESS_STACKSTART_TOOLTIP;
+ public static String PROCESS_SIGNALS_TOOLTIP;
+ public static String PROCESS_SIGBLOCK_TOOLTIP;
+ public static String PROCESS_SIGIGNORE_TOOLTIP;
+ public static String PROCESS_SIGCATCH_TOOLTIP;
+ public static String PROCESS_WCHAN_TOOLTIP;
+ public static String PROCESS_NSWAP_TOOLTIP;
+ public static String PROCESS_CNSWAP_TOOLTIP;
+ public static String PROCESS_EXITSIGNAL_TOOLTIP;
+ public static String PROCESS_PROCESSOR_TOOLTIP;
+ public static String PROCESS_RTPRIORITY_TOOLTIP;
+ public static String PROCESS_POLICY_TOOLTIP;
+
+ public static String PROCESS_VMSIZE_VALUE;
+ public static String PROCESS_VMRSS_VALUE;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorService.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorService.java
new file mode 100644
index 000000000..ebfa0031d
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorService.java
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.subsystems.AbstractConnectorService;
+import org.eclipse.rse.core.subsystems.CommunicationsEvent;
+
+import com.windriver.tcf.api.core.AbstractPeer;
+import com.windriver.tcf.api.core.ChannelTCP;
+import com.windriver.tcf.api.protocol.IChannel;
+import com.windriver.tcf.api.protocol.IPeer;
+import com.windriver.tcf.api.protocol.Protocol;
+import com.windriver.tcf.api.services.IFileSystem;
+import com.windriver.tcf.api.services.ILocator;
+import com.windriver.tcf.api.services.ISysMonitor;
+
+class TCFConnectorService extends AbstractConnectorService {
+
+ private IChannel channel;
+ private Throwable channel_error;
+ private final List<Runnable> state_change = new ArrayList<Runnable>();
+
+ public TCFConnectorService(IHost host, int port) {
+ super("TCF", "Target Communication Framework", host, port);
+ }
+
+ @Override
+ protected void internalConnect(IProgressMonitor monitor) throws Exception {
+ assert !Protocol.isDispatchThread();
+ final Exception[] res = new Exception[1];
+ monitor.beginTask("Connecting " + getHostName(), 1);
+ synchronized (res) {
+ Protocol.invokeLater(new Runnable() {
+ public void run() {
+ connectTCFChannel(res);
+ }
+ });
+ res.wait();
+ }
+ monitor.done();
+ if (res[0] != null) throw res[0];
+ }
+
+ @Override
+ protected void internalDisconnect(IProgressMonitor monitor) throws Exception {
+ assert !Protocol.isDispatchThread();
+ final Exception[] res = new Exception[1];
+ monitor.beginTask("Disconnecting " + getHostName(), 1);
+ synchronized (res) {
+ Protocol.invokeLater(new Runnable() {
+ public void run() {
+ disconnectTCFChannel(res);
+ }
+ });
+ res.wait();
+ }
+ monitor.done();
+ if (res[0] != null) throw res[0];
+ }
+
+ public void acquireCredentials(boolean refresh) throws InterruptedException {
+ }
+
+ public void clearCredentials() {
+ }
+
+ public void clearPassword(boolean persist, boolean propagate) {
+ }
+
+ public String getUserId() {
+ return null;
+ }
+
+ public boolean hasPassword(boolean persistent) {
+ return false;
+ }
+
+ public boolean inheritsCredentials() {
+ return false;
+ }
+
+ public boolean isConnected() {
+ final boolean res[] = new boolean[1];
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ res[0] = channel != null && channel.getState() == IChannel.STATE_OPEN;
+ }
+ });
+ return res[0];
+ }
+
+ public boolean isSuppressed() {
+ return false;
+ }
+
+ public void removePassword() {
+ }
+
+ public void removeUserId() {
+ }
+
+ public boolean requiresPassword() {
+ return false;
+ }
+
+ public boolean requiresUserId() {
+ return false;
+ }
+
+ public void savePassword() {
+ }
+
+ public void saveUserId() {
+ }
+
+ public void setPassword(String matchingUserId, String password,
+ boolean persist, boolean propagate) {
+ }
+
+ public void setSuppressed(boolean suppress) {
+ }
+
+ public void setUserId(String userId) {
+ }
+
+ public boolean sharesCredentials() {
+ return false;
+ }
+
+ public boolean supportsPassword() {
+ return false;
+ }
+
+ public boolean supportsUserId() {
+ return false;
+ }
+
+ private void connectTCFChannel(final Exception[] res) {
+ if (channel != null) {
+ switch (channel.getState()) {
+ case IChannel.STATE_OPEN:
+ case IChannel.STATE_CLOSED:
+ synchronized (res) {
+ if (channel_error instanceof Exception) res[0] = (Exception)channel_error;
+ else if (channel_error != null) res[0] = new Exception(channel_error);
+ else res[0] = null;
+ res.notify();
+ }
+ return;
+ }
+ }
+ if (channel == null) {
+ final String host = getHostName().toLowerCase();
+ // TODO: final int port = getPort();
+ final int port = TCFConnectorServiceManager.TCF_PORT;
+ IPeer peer = null;
+ String ports = Integer.toString(port);
+ ILocator locator = Protocol.getLocator();
+ for (Iterator<IPeer> i = locator.getPeers().values().iterator(); i.hasNext();) {
+ IPeer p = i.next();
+ Map<String, String> attrs = p.getAttributes();
+ if ("TCP".equals(attrs.get(IPeer.ATTR_TRANSPORT_NAME)) &&
+ host.equalsIgnoreCase(attrs.get(IPeer.ATTR_IP_HOST)) &&
+ ports.equals(attrs.get(IPeer.ATTR_IP_PORT))) {
+ peer = p;
+ break;
+ }
+ }
+ if (peer == null) {
+ Map<String, String> attrs = new HashMap<String, String>();
+ attrs.put(IPeer.ATTR_ID, "RSE:" + host + ":" + port);
+ attrs.put(IPeer.ATTR_NAME, getName());
+ attrs.put(IPeer.ATTR_TRANSPORT_NAME, "TCP");
+ attrs.put(IPeer.ATTR_IP_HOST, host);
+ attrs.put(IPeer.ATTR_IP_PORT, ports);
+ peer = new AbstractPeer(attrs) {
+ public IChannel openChannel() {
+ return new ChannelTCP(this, host, port);
+ }
+ };
+ }
+ channel = peer.openChannel();
+ channel.addChannelListener(new IChannel.IChannelListener() {
+
+ public void onChannelOpened() {
+ onConnected();
+ }
+
+ public void congestionLevel(int level) {
+ }
+
+ public void onChannelClosed(Throwable error) {
+ channel.removeChannelListener(this);
+ onDisconnected(error);
+ }
+
+ });
+ assert channel.getState() == IChannel.STATE_OPENNING;
+ }
+ state_change.add(new Runnable() {
+ public void run() {
+ connectTCFChannel(res);
+ }
+ });
+ }
+
+ private void disconnectTCFChannel(final Exception[] res) {
+ if (channel == null || channel.getState() == IChannel.STATE_CLOSED) {
+ synchronized (res) {
+ res[0] = null;
+ res.notify();
+ }
+ return;
+ }
+ if (channel.getState() == IChannel.STATE_OPEN) channel.close();
+ state_change.add(new Runnable() {
+ public void run() {
+ disconnectTCFChannel(res);
+ }
+ });
+ }
+
+ private void onConnected() {
+ assert channel != null;
+ if (state_change.isEmpty()) return;
+ Runnable[] r = state_change.toArray(new Runnable[state_change.size()]);
+ state_change.clear();
+ for (int i = 0; i < r.length; i++) r[i].run();
+ }
+
+ private void onDisconnected(Throwable error) {
+ assert channel != null;
+ channel_error = error;
+ if (state_change.isEmpty()) {
+ fireCommunicationsEvent(CommunicationsEvent.CONNECTION_ERROR);
+ }
+ else {
+ Runnable[] r = state_change.toArray(new Runnable[state_change.size()]);
+ state_change.clear();
+ for (int i = 0; i < r.length; i++) r[i].run();
+ }
+ channel = null;
+ channel_error = null;
+ }
+
+ public ISysMonitor getSysMonitorService() {
+ if (channel == null || channel.getState() != IChannel.STATE_OPEN) throw new Error("Not connected");
+ ISysMonitor m = channel.getRemoteService(ISysMonitor.class);
+ if (m == null) throw new Error("Remote peer does not support SysMonitor service");
+ return m;
+ }
+
+ public IFileSystem getFileSystemService() {
+ if (channel == null || channel.getState() != IChannel.STATE_OPEN) throw new Error("Not connected");
+ IFileSystem m = channel.getRemoteService(IFileSystem.class);
+ if (m == null) throw new Error("Remote peer does not support FileSystem service");
+ return m;
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorServiceManager.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorServiceManager.java
new file mode 100644
index 000000000..e13fd58d8
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFConnectorServiceManager.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+
+public class TCFConnectorServiceManager extends AbstractConnectorServiceManager {
+
+ public static int TCF_PORT = 1534;
+
+ private static final TCFConnectorServiceManager manager =
+ new TCFConnectorServiceManager();
+
+ @Override
+ public IConnectorService createConnectorService(IHost host) {
+ return new TCFConnectorService(host, TCF_PORT);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class getSubSystemCommonInterface(ISubSystem subsystem) {
+ return ITCFSubSystem.class;
+ }
+
+ @Override
+ public boolean sharesSystem(ISubSystem otherSubSystem) {
+ return otherSubSystem instanceof ITCFSubSystem;
+ }
+
+ public static TCFConnectorServiceManager getInstance() {
+ return manager;
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileAdapter.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileAdapter.java
new file mode 100644
index 000000000..e5164df66
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileAdapter.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.rse.services.files.IHostFile;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext;
+
+public class TCFFileAdapter implements IHostFileToRemoteFileAdapter {
+
+ public IRemoteFile convertToRemoteFile(FileServiceSubSystem ss,
+ IRemoteFileContext ctx, IRemoteFile parent, IHostFile node) {
+ return new TCFRemoteFile(ss, ctx, parent, node);
+ }
+
+ public IRemoteFile[] convertToRemoteFiles(FileServiceSubSystem ss,
+ IRemoteFileContext ctx, IRemoteFile parent, IHostFile[] nodes) {
+ if (nodes == null) return null;
+ IRemoteFile[] res = new IRemoteFile[nodes.length];
+ for (int i = 0; i < res.length; i++) {
+ res[i] = new TCFRemoteFile(ss, ctx, parent, nodes[i]);
+ }
+ return res;
+ }
+
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileResource.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileResource.java
new file mode 100644
index 000000000..39cfa52e6
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileResource.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.rse.core.subsystems.AbstractResource;
+import org.eclipse.rse.services.files.IHostFile;
+
+import com.windriver.tcf.api.services.IFileSystem;
+
+public class TCFFileResource extends AbstractResource implements IHostFile {
+
+ private final ITCFFileService service;
+ private String parent;
+ private String name;
+ private final IFileSystem.FileAttrs attrs;
+ private final boolean root;
+
+ public TCFFileResource(ITCFFileService service, String parent, String name,
+ IFileSystem.FileAttrs attrs, boolean root) {
+ if (name == null) {
+ int i = parent.lastIndexOf('/');
+ if (i > 0) {
+ name = parent.substring(i + 1);
+ parent = parent.substring(0, i);
+ }
+ }
+ this.service = service;
+ this.parent = parent;
+ this.name = name;
+ this.attrs = attrs;
+ this.root = root;
+ }
+
+ private String toLocalPath(String path) {
+ if (path.length() > 1 && path.charAt(1) == ':') {
+ return path.replace('/', '\\');
+ }
+ else {
+ return path.replace('\\', '/');
+ }
+ }
+
+ public boolean canRead() {
+ return attrs != null && service.canRead(attrs);
+ }
+
+ public boolean canWrite() {
+ return attrs != null && service.canWrite(attrs);
+ }
+
+ public boolean exists() {
+ return attrs != null;
+ }
+
+ public synchronized String getAbsolutePath() {
+ if (root) return toLocalPath(name);
+ if (parent.endsWith("/")) return toLocalPath(parent + name);
+ return toLocalPath(parent + '/' + name);
+ }
+
+ public long getModifiedDate() {
+ if (attrs == null) return 0;
+ if ((attrs.flags & IFileSystem.ATTR_ACMODTIME) == 0) return 0;
+ return attrs.mtime;
+ }
+
+ public synchronized String getName() {
+ return toLocalPath(name);
+ }
+
+ public synchronized String getParentPath() {
+ return toLocalPath(parent);
+ }
+
+ public long getSize() {
+ if (attrs == null) return 0;
+ if ((attrs.flags & IFileSystem.ATTR_SIZE) == 0) return 0;
+ return attrs.size;
+ }
+
+ public boolean isArchive() {
+ return false;
+ }
+
+ public boolean isDirectory() {
+ if (attrs == null) return false;
+ return attrs.isDirectory();
+ }
+
+ public boolean isFile() {
+ if (attrs == null) return false;
+ return attrs.isFile();
+ }
+
+ public synchronized boolean isHidden() {
+ return name.startsWith(".");
+ }
+
+ public synchronized boolean isRoot() {
+ return root;
+ }
+
+ public synchronized void renameTo(String path) {
+ path = path.replace('\\', '/');
+ if (path.equals("/")) {
+ parent = name = "/";
+ return;
+ }
+ assert !path.endsWith("/");
+ int i = path.lastIndexOf('/');
+ parent = path.substring(0, i);
+ name = path.substring(i + 1);
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileService.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileService.java
new file mode 100644
index 000000000..6eb030f61
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileService.java
@@ -0,0 +1,643 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.services.clientserver.FileTypeMatcher;
+import org.eclipse.rse.services.clientserver.IMatcher;
+import org.eclipse.rse.services.clientserver.NamePatternMatcher;
+import org.eclipse.rse.services.clientserver.messages.IndicatorException;
+import org.eclipse.rse.services.clientserver.messages.SystemMessage;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.services.files.AbstractFileService;
+import org.eclipse.rse.services.files.IHostFile;
+
+import com.windriver.tcf.api.protocol.IToken;
+import com.windriver.tcf.api.protocol.Protocol;
+import com.windriver.tcf.api.services.IFileSystem;
+import com.windriver.tcf.api.services.IFileSystem.DirEntry;
+import com.windriver.tcf.api.services.IFileSystem.FileAttrs;
+import com.windriver.tcf.api.services.IFileSystem.FileSystemException;
+import com.windriver.tcf.api.services.IFileSystem.IFileHandle;
+import com.windriver.tcf.api.util.TCFFileInputStream;
+import com.windriver.tcf.api.util.TCFFileOutputStream;
+
+public class TCFFileService extends AbstractFileService implements ITCFFileService {
+
+ private final TCFConnectorService connector;
+
+ private UserInfo user_info;
+
+ private static final class UserInfo {
+ final int r_uid;
+ final int e_uid;
+ final int r_gid;
+ final int e_gid;
+ final String home;
+
+ final Throwable error;
+
+ UserInfo(int r_uid, int e_uid, int r_gid, int e_gid, String home) {
+ this.r_uid = r_uid;
+ this.e_uid = e_uid;
+ this.r_gid = r_gid;
+ this.e_gid = e_gid;
+ this.home = home;
+ error = null;
+ }
+
+ UserInfo(Throwable error) {
+ this.error = error;
+ r_uid = -1;
+ e_uid = -1;
+ r_gid = -1;
+ e_gid = -1;
+ home = null;
+ }
+ }
+
+ public TCFFileService(IHost host) {
+ connector = (TCFConnectorService)TCFConnectorServiceManager
+ .getInstance().getConnectorService(host, ITCFSubSystem.class);
+ }
+
+ public String getDescription() {
+ return "The TCF File Service uses the Target Communication Framework to provide service" +
+ "for the Files subsystem. It requires a TCF agent to be running on the remote machine.";
+ }
+
+ public SystemMessage getMessage(String id) {
+ try {
+ return new SystemMessage("TCF", "C", "0001",
+ SystemMessage.ERROR, id, "");
+ }
+ catch (IndicatorException e) {
+ throw new Error(e);
+ }
+ }
+
+ public SystemMessage getMessage(Throwable x) {
+ try {
+ return new SystemMessage("TCF", "C", "0002",
+ SystemMessage.ERROR, x.getClass().getName(), x.getMessage());
+ }
+ catch (IndicatorException e) {
+ throw new Error(e);
+ }
+ }
+
+ public String getName() {
+ return "TCF File Service";
+ }
+
+ public void initService(IProgressMonitor monitor) {
+ }
+
+ public void uninitService(IProgressMonitor monitor) {
+ }
+
+ private String toRemotePath(String parent, String name) throws SystemMessageException {
+ assert !Protocol.isDispatchThread();
+ String s = null;
+ if (parent != null) parent = parent.replace('\\', '/');
+ if (name != null) name = name.replace('\\', '/');
+ if (parent == null || parent.length() == 0) s = name;
+ else if (name == null || name.equals(".")) s = parent;
+ else if (name.equals("/")) s = parent;
+ else if (parent.endsWith("/")) s = parent + name;
+ else s = parent + '/' + name;
+ if (s.startsWith("./") || s.equals(".")) {
+ UserInfo ui = getUserInfo();
+ if (ui.error != null) throw new SystemMessageException(getMessage(ui.error));
+ s = ui.home.replace('\\', '/') + s.substring(1);
+ }
+ while (s.endsWith("/.")) s = s.substring(0, s.length() - 2);
+ return s;
+ }
+
+ public boolean copy(String srcParent,
+ String srcName, String tgtParent, String tgtName, IProgressMonitor monitor)
+ throws SystemMessageException {
+ final String src = toRemotePath(srcParent, srcName);
+ final String tgt = toRemotePath(tgtParent, tgtName);
+ return new TCFRSETask<Boolean>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ fs.copy(src, tgt, false, false, new IFileSystem.DoneCopy() {
+ public void doneCopy(IToken token, FileSystemException error) {
+ if (error != null) error(error);
+ else done(true);
+ }
+ });
+ }
+ }.getS(monitor, "Copy: " + srcName);
+ }
+
+ public boolean copyBatch(String[] srcParents,
+ String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException {
+ for (int i = 0; i < srcParents.length; i++) {
+ if (!copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor)) return false;
+ }
+ return true;
+ }
+
+ public IHostFile createFile(String parent,
+ String name, IProgressMonitor monitor) throws SystemMessageException {
+ try {
+ getOutputStream(parent, name, true, monitor).close();
+ return getFile(parent, name, monitor);
+ }
+ catch (IOException e) {
+ throw new SystemMessageException(getMessage(e));
+ }
+ }
+
+ public IHostFile createFolder(final String parent, final String name, IProgressMonitor monitor) throws SystemMessageException {
+ final String path = toRemotePath(parent, name);
+ return new TCFRSETask<IHostFile>() {
+ public void run() {
+ final IFileSystem fs = connector.getFileSystemService();
+ fs.mkdir(path, null, new IFileSystem.DoneMkDir() {
+ public void doneMkDir(IToken token, FileSystemException error) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ fs.stat(path, new IFileSystem.DoneStat() {
+ public void doneStat(IToken token,
+ FileSystemException error, FileAttrs attrs) {
+ if (error != null) error(error);
+ else done(new TCFFileResource(TCFFileService.this,
+ path, null, attrs, false));
+ }
+ });
+ }
+ });
+ }
+ }.getS(monitor, "Create folder");
+ }
+
+ public boolean delete(String parent,
+ String name, IProgressMonitor monitor) throws SystemMessageException {
+ final String path = toRemotePath(parent, name);
+ return new TCFRSETask<Boolean>() {
+ public void run() {
+ final IFileSystem fs = connector.getFileSystemService();
+ fs.stat(path, new IFileSystem.DoneStat() {
+ public void doneStat(IToken token,
+ FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ IFileSystem.DoneRemove done = new IFileSystem.DoneRemove() {
+ public void doneRemove(IToken token, FileSystemException error) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ done(true);
+ }
+ };
+ if (attrs.isDirectory()) {
+ fs.rmdir(path, done);
+ }
+ else {
+ fs.remove(path, done);
+ }
+ }
+ });
+ }
+ }.getS(monitor, "Delete");
+ }
+
+ public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor)
+ throws SystemMessageException {
+ for (int i = 0; i < remoteParents.length; i++) {
+ delete(remoteParents[i], fileNames[i], monitor);
+ }
+ return true;
+ }
+
+ public boolean download(final String parent,
+ final String name, final File file, final boolean is_binary,
+ final String host_encoding, IProgressMonitor monitor) throws SystemMessageException {
+ monitor.beginTask("Download", 1);
+ try {
+ file.getParentFile().mkdirs();
+ InputStream inp = getInputStream(parent, name, is_binary, new NullProgressMonitor());
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
+ copyStream(inp, out, is_binary, "UTF8", host_encoding);
+ return true;
+ }
+ catch (Throwable x) {
+ if (x instanceof SystemMessageException) throw (SystemMessageException)x;
+ throw new SystemMessageException(getMessage(x));
+ }
+ finally {
+ monitor.done();
+ }
+ }
+
+ public String getEncoding(IProgressMonitor monitor) throws SystemMessageException {
+ return "UTF8";
+ }
+
+ public IHostFile getFile(final String parent,
+ final String name, IProgressMonitor monitor) throws SystemMessageException {
+ final String path = toRemotePath(parent, name);
+ return new TCFRSETask<IHostFile>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ fs.stat(path, new IFileSystem.DoneStat() {
+ public void doneStat(IToken token,
+ FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ if (error.getStatus() == IFileSystem.STATUS_NO_SUCH_FILE) {
+ done(new TCFFileResource(TCFFileService.this, path, null, null, false));
+ return;
+ }
+ error(error);
+ return;
+ }
+ done(new TCFFileResource(TCFFileService.this, path, null, attrs, false));
+ }
+ });
+ }
+ }.getS(monitor, "Stat");
+ }
+
+ protected IHostFile[] internalFetch(final String parent, final String filter, final int fileType, final IProgressMonitor monitor)
+ throws SystemMessageException {
+ final String path = toRemotePath(parent, null);
+ final boolean wantFiles = (fileType==FILE_TYPE_FILES_AND_FOLDERS || (fileType&FILE_TYPE_FILES)!=0);
+ final boolean wantFolders = (fileType==FILE_TYPE_FILES_AND_FOLDERS || (fileType%FILE_TYPE_FOLDERS)!=0);
+ return new TCFRSETask<IHostFile[]>() {
+ private IMatcher matcher = null;
+ public void run() {
+ if (filter == null) {
+ matcher = null;
+ }
+ else if (filter.endsWith(",")) { //$NON-NLS-1$
+ String[] types = filter.split(","); //$NON-NLS-1$
+ matcher = new FileTypeMatcher(types, true);
+ }
+ else {
+ matcher = new NamePatternMatcher(filter, true, true);
+ }
+ final List<TCFFileResource> results = new ArrayList<TCFFileResource>();
+ final IFileSystem fs = connector.getFileSystemService();
+ fs.opendir(path, new IFileSystem.DoneOpen() {
+ public void doneOpen(IToken token, FileSystemException error, final IFileHandle handle) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ fs.readdir(handle, new IFileSystem.DoneReadDir() {
+ public void doneReadDir(IToken token,
+ FileSystemException error, DirEntry[] entries, boolean eof) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ for (DirEntry e : entries) {
+ if (e.attrs == null) {
+ // Attrs are not available if, for example,
+ // the entry is a broken symbolic link
+ }
+ else if (e.attrs.isDirectory()) {
+ //dont filter folder names if getting both folders and files
+ if (wantFolders && (matcher==null || fileType==FILE_TYPE_FILES_AND_FOLDERS || matcher.matches(e.filename))) {
+ results.add(new TCFFileResource(TCFFileService.this,
+ path, e.filename, e.attrs, false));
+ }
+ }
+ else if (e.attrs.isFile()) {
+ if (wantFiles && (matcher == null || matcher.matches(e.filename))) {
+ results.add(new TCFFileResource(TCFFileService.this,
+ path, e.filename, e.attrs, false));
+ }
+ }
+ }
+ if (eof) {
+ fs.close(handle, new IFileSystem.DoneClose() {
+ public void doneClose(IToken token, FileSystemException error) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ done(results.toArray(new TCFFileResource[results.size()]));
+ }
+ });
+ }
+ else {
+ fs.readdir(handle, this);
+ }
+ }
+ });
+ }
+ });
+ }
+ }.getS(monitor, "Get files and folders");
+ }
+
+ public InputStream getInputStream(final String parent, final String name, boolean isBinary, IProgressMonitor monitor)
+ throws SystemMessageException {
+ final String path = toRemotePath(parent, name);
+ final IFileHandle handle = new TCFRSETask<IFileHandle>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ fs.open(path, IFileSystem.O_READ, null, new IFileSystem.DoneOpen() {
+ public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
+ if (error != null) error(error);
+ else done(handle);
+ }
+ });
+ }
+ }.getS(monitor, "Get input stream");
+ return new TCFFileInputStream(handle);
+ }
+
+ public OutputStream getOutputStream(final String parent, final String name, boolean isBinary, IProgressMonitor monitor)
+ throws SystemMessageException {
+ final String path = toRemotePath(parent, name);
+ final IFileHandle handle = new TCFRSETask<IFileHandle>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ int flags = IFileSystem.O_WRITE | IFileSystem.O_CREAT | IFileSystem.O_TRUNC;
+ fs.open(path, flags, null, new IFileSystem.DoneOpen() {
+ public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
+ if (error != null) error(error);
+ else done(handle);
+ }
+ });
+ }
+ }.getS(monitor, "Get output stream");
+ return new TCFFileOutputStream(handle);
+ }
+
+ public IHostFile[] getRoots(IProgressMonitor monitor) throws SystemMessageException {
+ return new TCFRSETask<IHostFile[]>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ fs.roots(new IFileSystem.DoneRoots() {
+ public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ List<TCFFileResource> l = new ArrayList<TCFFileResource>();
+ for (DirEntry e : entries) {
+ if (e.attrs == null) continue;
+ l.add(new TCFFileResource(TCFFileService.this, "", e.filename, e.attrs, true));
+ }
+ done(l.toArray(new IHostFile[l.size()]));
+ }
+ });
+ }
+ }.getS(monitor, "Get roots");
+ }
+
+ public IHostFile getUserHome() {
+ UserInfo ui = getUserInfo();
+ try {
+ return getFile(ui.home, ".", new NullProgressMonitor());
+ }
+ catch (SystemMessageException e) {
+ throw new Error(e);
+ }
+ }
+
+ public boolean isCaseSensitive() {
+ return true;
+ }
+
+ public boolean move(final String srcParent,
+ final String srcName, final String tgtParent, final String tgtName, IProgressMonitor monitor)
+ throws SystemMessageException {
+ final String src_path = toRemotePath(srcParent, srcName);
+ final String tgt_path = toRemotePath(tgtParent, tgtName);
+ return new TCFRSETask<Boolean>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ fs.rename(src_path, tgt_path, new IFileSystem.DoneRename() {
+ public void doneRename(IToken token, FileSystemException error) {
+ if (error != null) error(error);
+ else done(true);
+ }
+ });
+ }
+ }.getS(monitor, "Move");
+ }
+
+ public boolean rename(String remoteParent,
+ String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException {
+ return move(remoteParent, oldName, remoteParent, newName, monitor);
+ }
+
+ public boolean rename(String remoteParent,
+ String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor)
+ throws SystemMessageException {
+ boolean b = move(remoteParent, oldName, remoteParent, newName, monitor);
+ if (b) oldFile.renameTo(toRemotePath(remoteParent, newName));
+ return b;
+ }
+
+ public boolean setLastModified(final String parent,
+ final String name, final long timestamp, IProgressMonitor monitor) throws SystemMessageException {
+ final String path = toRemotePath(parent, name);
+ return new TCFRSETask<Boolean>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ FileAttrs attrs = new FileAttrs(IFileSystem.ATTR_ACMODTIME,
+ 0, 0, 0, 0, timestamp, timestamp, null);
+ fs.setstat(path, attrs, new IFileSystem.DoneSetStat() {
+ public void doneSetStat(IToken token, FileSystemException error) {
+ if (error != null) error(error);
+ else done(true);
+ }
+ });
+ }
+ }.getS(monitor, "Set modification time");
+ }
+
+ public boolean setReadOnly(final String parent,
+ final String name, final boolean readOnly, IProgressMonitor monitor) throws SystemMessageException {
+ final String path = toRemotePath(parent, name);
+ return new TCFRSETask<Boolean>() {
+ public void run() {
+ final IFileSystem fs = connector.getFileSystemService();
+ fs.stat(path, new IFileSystem.DoneStat() {
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ error(error);
+ return;
+ }
+ int p = attrs.permissions;
+ if (readOnly) {
+ p &= ~IFileSystem.S_IWUSR;
+ p &= ~IFileSystem.S_IWGRP;
+ p &= ~IFileSystem.S_IWOTH;
+ }
+ else {
+ p |= IFileSystem.S_IWUSR;
+ p |= IFileSystem.S_IWGRP;
+ p |= IFileSystem.S_IWOTH;
+ }
+ FileAttrs new_attrs = new FileAttrs(IFileSystem.ATTR_PERMISSIONS,
+ 0, 0, 0, p, 0, 0, null);
+ fs.setstat(path, new_attrs, new IFileSystem.DoneSetStat() {
+ public void doneSetStat(IToken token, FileSystemException error) {
+ if (error != null) error(error);
+ else done(true);
+ }
+ });
+ }
+ });
+ }
+ }.getS(monitor, "Set permissions");
+ }
+
+ public boolean upload(InputStream inp,
+ String parent, String name, boolean isBinary,
+ String hostEncoding, IProgressMonitor monitor) throws SystemMessageException {
+ monitor.beginTask("Upload", 1);
+ try {
+ OutputStream out = getOutputStream(parent, name, isBinary, new NullProgressMonitor());
+ copyStream(inp, out, isBinary, hostEncoding, "UTF8");
+ return true;
+ }
+ catch (Throwable x) {
+ if (x instanceof SystemMessageException) throw (SystemMessageException)x;
+ throw new SystemMessageException(getMessage(x));
+ }
+ finally {
+ monitor.done();
+ }
+ }
+
+ public boolean upload(File localFile,
+ String parent, String name, boolean isBinary,
+ String srcEncoding, String hostEncoding, IProgressMonitor monitor)
+ throws SystemMessageException {
+ monitor.beginTask("Upload", 1);
+ try {
+ OutputStream out = getOutputStream(parent, name, isBinary, new NullProgressMonitor());
+ InputStream inp = new BufferedInputStream(new FileInputStream(localFile));
+ copyStream(inp, out, isBinary, hostEncoding, "UTF8");
+ return true;
+ }
+ catch (Throwable x) {
+ if (x instanceof SystemMessageException) throw (SystemMessageException)x;
+ throw new SystemMessageException(getMessage(x));
+ }
+ finally {
+ monitor.done();
+ }
+ }
+
+ private void copyStream(InputStream inp, OutputStream out,
+ boolean is_binary, String inp_encoding, String out_encoding) throws IOException {
+ try {
+ if (!is_binary) {
+ if (inp_encoding.equals("UTF-8")) inp_encoding = "UTF8";
+ if (out_encoding.equals("UTF-8")) out_encoding = "UTF8";
+ }
+ if (is_binary || inp_encoding.equals(out_encoding)) {
+ byte[] buf = new byte[0x1000];
+ for (;;) {
+ int buf_len = inp.read(buf);
+ if (buf_len < 0) break;
+ out.write(buf, 0, buf_len);
+ }
+ }
+ else {
+ Reader reader = new InputStreamReader(inp, inp_encoding);
+ Writer writer = new OutputStreamWriter(out, out_encoding);
+ char[] buf = new char[0x1000];
+ for (;;) {
+ int buf_len = reader.read(buf);
+ if (buf_len < 0) break;
+ writer.write(buf, 0, buf_len);
+ }
+ writer.flush();
+ }
+ }
+ finally {
+ out.close();
+ inp.close();
+ }
+ }
+
+ private synchronized UserInfo getUserInfo() {
+ if (user_info == null || user_info.error != null) {
+ user_info = new TCFRSETask<UserInfo>() {
+ public void run() {
+ IFileSystem fs = connector.getFileSystemService();
+ fs.user(new IFileSystem.DoneUser() {
+ public void doneUser(IToken token, FileSystemException error, int real_uid,
+ int effective_uid, int real_gid, int effective_gid, String home) {
+ if (error != null) done(new UserInfo(error));
+ else done(new UserInfo(real_uid, effective_uid, real_gid, effective_gid, home));
+ }
+ });
+ }
+ }.getE();
+ }
+ return user_info;
+ }
+
+ public boolean canRead(FileAttrs attrs) {
+ if ((attrs.flags & IFileSystem.ATTR_PERMISSIONS) == 0) return false;
+ if ((attrs.flags & IFileSystem.ATTR_UIDGID) == 0) return false;
+ UserInfo ui = getUserInfo();
+ if (ui.error != null) return false;
+ if (ui.e_uid == attrs.uid) {
+ return (attrs.permissions & IFileSystem.S_IRUSR) != 0;
+ }
+ if (ui.e_gid == attrs.gid) {
+ return (attrs.permissions & IFileSystem.S_IRGRP) != 0;
+ }
+ return (attrs.permissions & IFileSystem.S_IROTH) != 0;
+ }
+
+ public boolean canWrite(FileAttrs attrs) {
+ if ((attrs.flags & IFileSystem.ATTR_PERMISSIONS) == 0) return false;
+ if ((attrs.flags & IFileSystem.ATTR_UIDGID) == 0) return false;
+ UserInfo ui = getUserInfo();
+ if (ui.error != null) return false;
+ if (ui.e_uid == attrs.uid) {
+ return (attrs.permissions & IFileSystem.S_IWUSR) != 0;
+ }
+ if (ui.e_gid == attrs.gid) {
+ return (attrs.permissions & IFileSystem.S_IWGRP) != 0;
+ }
+ return (attrs.permissions & IFileSystem.S_IWOTH) != 0;
+ }
+
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileSubSystemConfiguration.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileSubSystemConfiguration.java
new file mode 100644
index 000000000..af6678aef
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFFileSubSystemConfiguration.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.util.Vector;
+
+import org.eclipse.rse.core.filters.ISystemFilter;
+import org.eclipse.rse.core.filters.ISystemFilterPool;
+import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.services.clientserver.SystemSearchString;
+import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.search.IHostSearchResultConfiguration;
+import org.eclipse.rse.services.search.IHostSearchResultSet;
+import org.eclipse.rse.services.search.ISearchService;
+import org.eclipse.rse.subsystems.files.core.ILanguageUtilityFactory;
+import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystemConfiguration;
+import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
+import org.eclipse.rse.ui.SystemBasePlugin;
+
+public class TCFFileSubSystemConfiguration extends FileServiceSubSystemConfiguration {
+
+ private final TCFFileAdapter file_adapter = new TCFFileAdapter();
+
+ @Override
+ public ISubSystem createSubSystemInternal(IHost host) {
+ TCFConnectorService connectorService = (TCFConnectorService)getConnectorService(host);
+ return new FileServiceSubSystem(host, connectorService,
+ getFileService(host), getHostFileAdapter(), createSearchService(host));
+ }
+
+ public IFileService createFileService(IHost host) {
+ return new TCFFileService(host);
+ }
+
+ public IHostSearchResultConfiguration createSearchConfiguration(IHost host,
+ IHostSearchResultSet resultSet, Object searchTarget,
+ SystemSearchString searchString) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ISearchService createSearchService(IHost host) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IHostFileToRemoteFileAdapter getHostFileAdapter() {
+ return file_adapter;
+ }
+
+ public ILanguageUtilityFactory getLanguageUtilityFactory(IRemoteFileSubSystem ss) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean supportsArchiveManagement() {
+ return false;
+ }
+
+ public IConnectorService getConnectorService(IHost host) {
+ return TCFConnectorServiceManager.getInstance()
+ .getConnectorService(host, ITCFSubSystem.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class getServiceImplType() {
+ return TCFFileService.class;
+ }
+
+ public void setConnectorService(IHost host, IConnectorService connectorService) {
+ TCFConnectorServiceManager.getInstance().setConnectorService(host, getServiceImplType(), connectorService);
+ }
+
+ protected ISystemFilterPool createDefaultFilterPool(ISystemFilterPoolManager mgr) {
+ ISystemFilterPool pool = null;
+ try {
+ pool = mgr.createSystemFilterPool(getDefaultFilterPoolName(mgr.getName(), getId()), true);
+
+ Vector<String> filterStrings = new Vector<String>();
+ RemoteFileFilterString myHomeFilterString = new RemoteFileFilterString(this);
+ myHomeFilterString.setPath(".");
+ myHomeFilterString.setFile("*");
+ filterStrings.add(myHomeFilterString.toString());
+ ISystemFilter filter = mgr.createSystemFilter(pool, "Home", filterStrings);
+ filter.setNonChangable(true);
+ filter.setSingleFilterStringOnly(true);
+
+ filterStrings = new Vector<String>();
+ RemoteFileFilterString rootFilesFilterString = new RemoteFileFilterString(this);
+ rootFilesFilterString.setPath("");
+ rootFilesFilterString.setFile("*");
+ filterStrings.add(rootFilesFilterString.toString());
+ filter = mgr.createSystemFilter(pool, "Root", filterStrings);
+ filter.setNonChangable(true);
+ filter.setSingleFilterStringOnly(true);
+ }
+ catch (Exception exc) {
+ SystemBasePlugin.logError("Error creating default filter pool", exc); //$NON-NLS-1$
+ }
+ return pool;
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessAdapter.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessAdapter.java
new file mode 100644
index 000000000..3748cda67
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessAdapter.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.rse.services.clientserver.processes.IHostProcess;
+import org.eclipse.rse.subsystems.processes.core.subsystem.IHostProcessToRemoteProcessAdapter;
+import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess;
+import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessContext;
+
+public class TCFProcessAdapter implements IHostProcessToRemoteProcessAdapter {
+
+ public IRemoteProcess convertToRemoteProcess(IRemoteProcessContext context,
+ IRemoteProcess parent, IHostProcess node) {
+ IHostProcess[] nodes = new IHostProcess[]{ node };
+ IRemoteProcess[] processes = convertToRemoteProcesses(context, parent, nodes);
+ if (processes != null && processes.length > 0) return processes[0];
+ return null;
+ }
+
+ public IRemoteProcess[] convertToRemoteProcesses(
+ IRemoteProcessContext context, IRemoteProcess parent,
+ IHostProcess[] nodes) {
+
+ if (nodes == null)return null;
+ List<IRemoteProcess> list = new ArrayList<IRemoteProcess>(nodes.length);
+ for (int idx = 0; idx < nodes.length; idx++) {
+ TCFProcessResource node = (TCFProcessResource)nodes[idx];
+ list.add(new TCFRemoteProcess(context, node));
+ }
+ return list.toArray(new IRemoteProcess[list.size()]);
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessResource.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessResource.java
new file mode 100644
index 000000000..b46d4e4a5
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessResource.java
@@ -0,0 +1,313 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.math.BigInteger;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.rse.core.subsystems.AbstractResource;
+import org.eclipse.rse.services.clientserver.processes.IHostProcess;
+
+import com.windriver.tcf.api.protocol.IToken;
+import com.windriver.tcf.api.protocol.Protocol;
+import com.windriver.tcf.api.services.ISysMonitor;
+import com.windriver.tcf.api.services.ISysMonitor.SysMonitorContext;
+
+public class TCFProcessResource extends AbstractResource implements IHostProcess {
+
+ private final TCFProcessService rse_service;
+ private final ISysMonitor tcf_service;
+ private final TCFProcessResource prev;
+ private final String id;
+ private Throwable error;
+ private ISysMonitor.SysMonitorContext context;
+
+ private final List<Runnable> children_wait_list = new ArrayList<Runnable>();
+ private boolean children_loading;
+ private boolean children_loaded;
+ private Throwable children_error;
+ private boolean running_wait_list;
+
+ private long gid = -1;
+ private String name;
+ private long ppid = -1;
+ private long pid = -1;
+ private String state;
+ private long tgid = -1;
+ private long tracepid = -1;
+ private long uid;
+ private String username;
+ private long vm_rss_kb;
+ private long vm_size_kb;
+ private String utime_pc;
+ private String stime_pc;
+ private long timestamp;
+
+ private Map<String, Object> properties = new HashMap<String, Object>();
+
+ private static final NumberFormat percent_format;
+
+ static {
+ percent_format = NumberFormat.getPercentInstance();
+ percent_format.setMaximumFractionDigits(3);
+ }
+
+ TCFProcessResource(TCFProcessService rse_service, ISysMonitor service,
+ TCFProcessResource prev, String id) {
+ this.rse_service = rse_service;
+ this.tcf_service = service;
+ this.prev = prev;
+ this.id = id;
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ public String getParentID() {
+ return (String)properties.get(ISysMonitor.PROP_PARENTID);
+ }
+
+ public TCFProcessService getService() {
+ return rse_service;
+ }
+
+ public void invalidate() {
+ assert Protocol.isDispatchThread();
+ error = null;
+ context = null;
+ }
+
+ public boolean validate(final Runnable done) {
+ assert Protocol.isDispatchThread();
+ if (error != null) return true;
+ if (context != null) return true;
+ tcf_service.getContext(id, new ISysMonitor.DoneGetContext() {
+
+ public void doneGetContext(IToken token, Exception error, SysMonitorContext context) {
+ TCFProcessResource.this.error = error;
+ TCFProcessResource.this.context = context;
+ if (error != null) {
+ properties = new HashMap<String, Object>();
+ gid = -1;
+ name = null;
+ ppid = -1;
+ pid = -1;
+ state = null;
+ tgid = -1;
+ tracepid = -1;
+ uid = 0;
+ username = null;
+ vm_rss_kb = 0;
+ vm_size_kb = 0;
+ }
+ else {
+ properties = new HashMap<String, Object>(context.getProperties());
+ gid = context.getUGID();
+ name = context.getFile();
+ if (properties.containsKey(ISysMonitor.PROP_PPID)) {
+ ppid = context.getPPID();
+ }
+ pid = context.getPID();
+ state = context.getState();
+ tgid = context.getTGID();
+ if (properties.containsKey(ISysMonitor.PROP_TRACERPID)) {
+ tracepid = context.getTracerPID();
+ }
+ uid = context.getUID();
+ username = context.getUserName();
+ vm_rss_kb = context.getRSS();
+ long page_bytes = context.getPSize();
+ if (page_bytes <= 0 || vm_rss_kb < 0) {
+ vm_rss_kb = -1;
+ }
+ else {
+ vm_rss_kb = (vm_rss_kb * page_bytes + 1023) / 1024;
+ }
+ vm_size_kb = (context.getVSize() + 1023) / 1024;
+ }
+ timestamp = System.currentTimeMillis();
+ Protocol.invokeLater(done);
+ }
+
+ });
+ return false;
+ }
+
+ public Throwable getError() {
+ assert Protocol.isDispatchThread();
+ return error;
+ }
+
+ public ISysMonitor.SysMonitorContext getContext() {
+ assert Protocol.isDispatchThread();
+ return context;
+ }
+
+ // IHostProcess methods
+
+ public String getAllProperties() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getGid() {
+ return gid;
+ }
+
+ public String getLabel() {
+ return Long.toString(getPid()) + " " + name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getPPid() {
+ return ppid;
+ }
+
+ public long getPid() {
+ return pid;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public long getTgid() {
+ return tgid;
+ }
+
+ public long getTracerPid() {
+ return tracepid;
+ }
+
+ public long getUid() {
+ return uid;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public long getVmRSSInKB() {
+ return vm_rss_kb;
+ }
+
+ public long getVmSizeInKB() {
+ return vm_size_kb;
+ }
+
+ public boolean isRoot() {
+ return true;
+ }
+
+ String getStatusLine() {
+ final String STATUS_DELIMITER = "|"; //$NON-NLS-1$
+ StringBuffer s = new StringBuffer();
+ s.append(getPid()).append(STATUS_DELIMITER);
+ s.append(name).append(STATUS_DELIMITER);
+ s.append(getState()).append(STATUS_DELIMITER);
+ s.append(getTgid()).append(STATUS_DELIMITER);
+ s.append(getPPid()).append(STATUS_DELIMITER);
+ s.append('0').append(STATUS_DELIMITER);
+ s.append(getUid()).append(STATUS_DELIMITER);
+ s.append(getUsername()).append(STATUS_DELIMITER);
+ s.append(getGid()).append(STATUS_DELIMITER);
+ s.append(getVmSizeInKB()).append(STATUS_DELIMITER);
+ s.append(getVmRSSInKB()).append(STATUS_DELIMITER);
+ return s.toString();
+ }
+
+ public Map<String,Object> getProperties() {
+ return properties;
+ }
+
+ private String getTimePC(String name) {
+ if (prev == null) return null;
+ Object x = prev.properties.get(name);
+ Object y = properties.get(name);
+ if (x instanceof Number && y instanceof Number) {
+ BigInteger nx = x instanceof BigInteger ? (BigInteger)x : new BigInteger(x.toString());
+ BigInteger ny = y instanceof BigInteger ? (BigInteger)y : new BigInteger(y.toString());
+ double d = ny.subtract(nx).doubleValue() / (timestamp - prev.timestamp);
+ return percent_format.format(d);
+ }
+ return null;
+ }
+
+ public String getUserTimePC() {
+ if (utime_pc != null) return utime_pc;
+ return utime_pc = getTimePC(ISysMonitor.PROP_UTIME);
+ }
+
+ public String getSysTimePC() {
+ if (stime_pc != null) return stime_pc;
+ return stime_pc = getTimePC(ISysMonitor.PROP_STIME);
+ }
+
+ public boolean getChildrenLoading() {
+ return children_loading;
+ }
+
+ public void setChildrenLoading(boolean b) {
+ children_loading = b;
+ }
+
+ public boolean getChildrenLoaded() {
+ return children_loaded;
+ }
+
+ public void setChildrenLoaded(boolean b) {
+ children_loaded = b;
+ }
+
+ public Throwable getChildrenError() {
+ return children_error;
+ }
+
+ public void setChildrenError(Throwable error) {
+ children_error = error;
+ }
+
+ public void addChildrenWaitList(Runnable run) {
+ assert !running_wait_list;
+ assert children_loading;
+ assert !children_loaded;
+ children_wait_list.add(run);
+ }
+
+ public void runChildrenWaitList() {
+ assert !children_loading;
+ assert children_loaded;
+ try {
+ running_wait_list = true;
+ for (Runnable r : children_wait_list) r.run();
+ children_wait_list.clear();
+ }
+ finally {
+ running_wait_list = false;
+ }
+ }
+
+ public void cancelChildrenLoading() {
+ // TODO: cancelChildrenLoading
+ }
+
+ public String toString() {
+ return "[" + getStatusLine() + "]";
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessService.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessService.java
new file mode 100644
index 000000000..4f3445b9f
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessService.java
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.services.clientserver.messages.IndicatorException;
+import org.eclipse.rse.services.clientserver.messages.SystemMessage;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.services.clientserver.processes.HostProcessFilterImpl;
+import org.eclipse.rse.services.clientserver.processes.IHostProcess;
+import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
+import org.eclipse.rse.services.processes.IProcessService;
+
+import com.windriver.tcf.api.protocol.IToken;
+import com.windriver.tcf.api.services.ISysMonitor;
+
+public class TCFProcessService implements IProcessService {
+
+ private final TCFConnectorService connector;
+ private final TCFProcessResource root;
+ private final Map<String,TCFProcessResource> id2res = new HashMap<String,TCFProcessResource>();
+ private final Map<Long,TCFProcessResource> pid2res = new HashMap<Long,TCFProcessResource>();
+
+ public TCFProcessService(IHost host) {
+ connector = (TCFConnectorService)TCFConnectorServiceManager
+ .getInstance().getConnectorService(host, ITCFSubSystem.class);
+ root = new TCFProcessResource(this, null, null, null);
+ }
+
+ public String getDescription() {
+ return "The TCF Process Service uses the Target Communication Framework to provide service for the Processes subsystem." +
+ " It requires a TCF agent to be running on the remote machine.";
+ }
+
+ public SystemMessage getMessage(String messageID) {
+ try {
+ return new SystemMessage("TCF", "C", "0001",
+ SystemMessage.ERROR, messageID, null);
+ }
+ catch (IndicatorException e) {
+ throw new Error(e);
+ }
+ }
+
+ public String getName() {
+ return "TCF Process Service";
+ }
+
+ public void initService(IProgressMonitor monitor) {
+ }
+
+ public void uninitService(IProgressMonitor monitor) {
+ }
+
+ public IHostProcess getParentProcess(long PID, IProgressMonitor monitor)
+ throws SystemMessageException {
+ return getProcess(getProcess(PID, monitor).getPPid(), monitor);
+ }
+
+ public IHostProcess getProcess(final long PID, IProgressMonitor monitor)
+ throws SystemMessageException {
+ return new TCFRSETask<IHostProcess>() {
+ public void run() {
+ if (!loadProcesses(this, root)) return;
+ if (root.getChildrenError() != null) {
+ error(root.getChildrenError());
+ return;
+ }
+ done(pid2res.get(PID));
+ }
+ }.getS(monitor, "Get process properties");
+ }
+
+ public String[] getSignalTypes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean kill(long PID, String signal, IProgressMonitor monitor)
+ throws SystemMessageException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ private void sort(IHostProcess[] arr) {
+ Comparator<IHostProcess> c = new Comparator<IHostProcess>() {
+ public int compare(IHostProcess o1, IHostProcess o2) {
+ long p1 = o1.getPid();
+ long p2 = o2.getPid();
+ if (p1 < p2) return -1;
+ if (p1 > p2) return 1;
+ return 0;
+ }
+ };
+ Arrays.sort(arr, c);
+ }
+
+ public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException {
+ HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
+ return listAllProcesses(rpfs, monitor);
+ }
+
+ public IHostProcess[] listAllProcesses(final IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException {
+ return listAllProcesses(filter, root, monitor);
+ }
+
+ private boolean eqaulIDs(String x, String y) {
+ if (x == null) return y == null;
+ return x.equals(y);
+ }
+
+ public IHostProcess[] listAllProcesses(final IHostProcessFilter filter, final IHostProcess up, IProgressMonitor monitor) throws SystemMessageException {
+ // TODO: figure out better way to flush the cache
+ final TCFProcessResource parent = new TCFRSETask<TCFProcessResource>() {
+ public void run() {
+ TCFProcessResource parent = (TCFProcessResource)up;
+ if (parent == null) {
+ error(new IOException("Invalid parent"));
+ return;
+ }
+ if (filter.getPpid() != null && filter.getPpid().equals("*") || parent.getChildrenError() != null) {
+ for (Iterator<TCFProcessResource> i = pid2res.values().iterator(); i.hasNext();) {
+ TCFProcessResource r = i.next();
+ if (eqaulIDs(parent.getID(), r.getParentID())) {
+ i.remove();
+ if (r.getChildrenLoaded()) r.cancelChildrenLoading();
+ }
+ }
+ parent.setChildrenLoaded(false);
+ parent.setChildrenError(null);
+ }
+ done(parent);
+ }
+ }.getS(monitor, "Flush processes cache");
+ return new TCFRSETask<IHostProcess[]>() {
+ public void run() {
+ if (!loadProcesses(this, parent)) return;
+ if (parent.getChildrenError() != null) {
+ error(parent.getChildrenError());
+ return;
+ }
+ List<IHostProcess> l = new ArrayList<IHostProcess>();
+ for (TCFProcessResource p : pid2res.values()) {
+ if (eqaulIDs(parent.getID(), p.getParentID())) {
+ Throwable error = p.getError();
+ if (error == null && filter.allows(p.getStatusLine())) l.add(p);
+ }
+ }
+ IHostProcess[] arr = new IHostProcess[l.size()];
+ l.toArray(arr);
+ sort(arr);
+ done(arr);
+ }
+ }.getS(monitor, "List processes");
+ }
+
+ public IHostProcess[] listAllProcesses(String exeNameFilter, String userNameFilter, String stateFilter, IProgressMonitor monitor)
+ throws SystemMessageException {
+ HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
+ rpfs.setName(exeNameFilter);
+ rpfs.setUsername(userNameFilter);
+ rpfs.setSpecificState(stateFilter);
+ return listAllProcesses(rpfs, monitor);
+ }
+
+ public IHostProcess[] listChildProcesses(long parentPID, IProgressMonitor monitor) throws SystemMessageException {
+ HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
+ return listChildProcesses(parentPID, rpfs, monitor);
+ }
+
+ public IHostProcess[] listChildProcesses(long parentPID, IHostProcessFilter filter, IProgressMonitor monitor)
+ throws SystemMessageException {
+ filter.setPpid(Long.toString(parentPID));
+ return listAllProcesses(filter, monitor);
+ }
+
+ public IHostProcess[] listRootProcesses(IProgressMonitor monitor)
+ throws SystemMessageException {
+ IHostProcess[] roots = new IHostProcess[1];
+ roots[0] = getProcess(1, monitor);
+ return roots;
+ }
+
+ private boolean loadProcesses(Runnable run, final TCFProcessResource parent) {
+ if (parent.getChildrenLoading()) {
+ parent.addChildrenWaitList(run);
+ return false;
+ }
+ if (parent.getChildrenLoaded()) {
+ return true;
+ }
+ parent.setChildrenLoading(true);
+ try {
+ final ISysMonitor m = connector.getSysMonitorService();
+ m.getChildren(parent.getID(), new ISysMonitor.DoneGetChildren() {
+ public void doneGetChildren(IToken token, Exception error, String[] ids) {
+ try {
+ if (error != null) {
+ loadProcessesDone(parent, error, null);
+ }
+ else if (ids == null) {
+ loadProcessesDone(parent, null, new TCFProcessResource[0]);
+ }
+ else {
+ final TCFProcessResource[] arr = new TCFProcessResource[ids.length];
+ final Set<IHostProcess> pending = new HashSet<IHostProcess>();
+ for (int i = 0; i < ids.length; i++) {
+ final TCFProcessResource r = new TCFProcessResource(
+ TCFProcessService.this, m, id2res.get(ids[i]), ids[i]);
+ if (!r.validate(new Runnable() {
+ public void run() {
+ pending.remove(r);
+ if (pending.isEmpty()) loadProcessesDone(parent, null, arr);
+ }
+ })) pending.add(r);
+ arr[i] = r;
+ }
+ if (pending.isEmpty()) loadProcessesDone(parent, null, arr);
+ }
+ }
+ catch (Throwable x) {
+ loadProcessesDone(parent, x, null);
+ }
+ }
+ });
+ parent.addChildrenWaitList(run);
+ return false;
+ }
+ catch (Throwable x) {
+ loadProcessesDone(parent, x, null);
+ return true;
+ }
+ }
+
+ private void loadProcessesDone(TCFProcessResource parent, Throwable error, TCFProcessResource[] arr) {
+ assert parent.getChildrenLoading();
+ parent.setChildrenLoading(false);
+ parent.setChildrenLoaded(true);
+ if (arr != null && error == null) {
+ for (TCFProcessResource r : arr) {
+ long pid = r.getPid();
+ if (pid > 0 && parent.getPid() != pid) {
+ pid2res.put(new Long(pid), r);
+ id2res.put(r.getID(), r);
+ }
+ }
+ }
+ for (Iterator<TCFProcessResource> i = id2res.values().iterator(); i.hasNext();) {
+ TCFProcessResource r = i.next();
+ if (pid2res.get(r.getPid()) == null) i.remove();
+ }
+ parent.setChildrenError(error);
+ parent.runChildrenWaitList();
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessSubSystemConfiguration.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessSubSystemConfiguration.java
new file mode 100644
index 000000000..0c7242051
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFProcessSubSystemConfiguration.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.services.processes.IProcessService;
+import org.eclipse.rse.subsystems.processes.core.subsystem.IHostProcessToRemoteProcessAdapter;
+import org.eclipse.rse.subsystems.processes.servicesubsystem.ProcessServiceSubSystem;
+import org.eclipse.rse.subsystems.processes.servicesubsystem.ProcessServiceSubSystemConfiguration;
+
+public class TCFProcessSubSystemConfiguration extends ProcessServiceSubSystemConfiguration {
+
+ private final TCFProcessAdapter process_adapter = new TCFProcessAdapter();
+
+ @SuppressWarnings("unchecked")
+ public Class getServiceImplType() {
+ return TCFProcessService.class;
+ }
+
+ @Override
+ public ISubSystem createSubSystemInternal(IHost host) {
+ TCFConnectorService connectorService = (TCFConnectorService)getConnectorService(host);
+ return new ProcessServiceSubSystem(host, connectorService,
+ getProcessService(host), getHostProcessAdapter());
+ }
+
+ public IProcessService createProcessService(IHost host) {
+ return new TCFProcessService(host);
+ }
+
+ public IHostProcessToRemoteProcessAdapter getHostProcessAdapter() {
+ return process_adapter;
+ }
+
+ public IConnectorService getConnectorService(IHost host) {
+ return TCFConnectorServiceManager.getInstance()
+ .getConnectorService(host, ITCFSubSystem.class);
+ }
+
+ public void setConnectorService(IHost host, IConnectorService connectorService) {
+ TCFConnectorServiceManager.getInstance().setConnectorService(host, getServiceImplType(), connectorService);
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRSETask.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRSETask.java
new file mode 100644
index 000000000..9a37e4b6e
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRSETask.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.ExecutionException;
+
+import com.windriver.tcf.api.util.TCFTask;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.services.clientserver.messages.IndicatorException;
+import org.eclipse.rse.services.clientserver.messages.SystemMessage;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+
+public abstract class TCFRSETask<V> extends TCFTask<V> {
+
+ public V get(IProgressMonitor monitor, String task_name)
+ throws InterruptedException, ExecutionException {
+ monitor.beginTask(task_name, 1);
+ try {
+ return get();
+ }
+ finally {
+ monitor.done();
+ }
+ }
+
+ public V getS(IProgressMonitor monitor, String task_name) throws SystemMessageException {
+ if (monitor != null) monitor.beginTask(task_name, 1);
+ try {
+ return get();
+ }
+ catch (Throwable e) {
+ if (e instanceof SystemMessageException) throw (SystemMessageException)e;
+ try {
+ SystemMessage m = new SystemMessage("TCF", "C", "0001", SystemMessage.ERROR,
+ e.getClass().getName(), e.getMessage());
+ throw new SystemMessageException(m);
+ }
+ catch (IndicatorException e1) {
+ throw new Error(e1);
+ }
+ }
+ finally {
+ if (monitor != null) monitor.done();
+ }
+ }
+
+ public V getI(IProgressMonitor monitor, String task_name) throws InvocationTargetException, InterruptedException {
+ if (monitor != null) monitor.beginTask(task_name, 1);
+ try {
+ return get();
+ }
+ catch (Throwable e) {
+ if (e instanceof InvocationTargetException) throw (InvocationTargetException)e;
+ if (e instanceof InterruptedException) throw (InterruptedException)e;
+ throw new InvocationTargetException(e);
+ }
+ finally {
+ if (monitor != null) monitor.done();
+ }
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteFile.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteFile.java
new file mode 100644
index 000000000..6b396d610
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteFile.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.rse.services.files.IHostFile;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.AbstractRemoteFile;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext;
+
+public class TCFRemoteFile extends AbstractRemoteFile {
+
+ public TCFRemoteFile(FileServiceSubSystem ss, IRemoteFileContext ctx, IRemoteFile parent, IHostFile file) {
+ super(ss, ctx, parent, file);
+ }
+
+ public String getCanonicalPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getClassification() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteProcess.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteProcess.java
new file mode 100644
index 000000000..d44b7200c
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFRemoteProcess.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.util.Map;
+
+import org.eclipse.rse.services.clientserver.processes.IHostProcess;
+import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessContext;
+import org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessImpl;
+
+public class TCFRemoteProcess extends RemoteProcessImpl {
+
+ public TCFRemoteProcess(IRemoteProcessContext context, IHostProcess process) {
+ super(context, process);
+ assert process != null;
+ }
+
+ public Object getObject() {
+ return _underlyingProcess;
+ }
+
+ public Map<String,Object> getProperties() {
+ return ((TCFProcessResource)_underlyingProcess).getProperties();
+ }
+
+ public String getUserTimePC() {
+ return ((TCFProcessResource)_underlyingProcess).getUserTimePC();
+ }
+
+ public String getSysTimePC() {
+ return ((TCFProcessResource)_underlyingProcess).getSysTimePC();
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewProcessAdapterFactory.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewProcessAdapterFactory.java
new file mode 100644
index 000000000..b97047796
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewProcessAdapterFactory.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier;
+import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
+import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
+import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
+import org.eclipse.ui.IActionFilter;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+public class TCFSystemViewProcessAdapterFactory implements IAdapterFactory {
+
+ private final TCFSystemViewRemoteProcessAdapter adapter =
+ new TCFSystemViewRemoteProcessAdapter();
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ assert adaptableObject instanceof TCFRemoteProcess;
+ if (adapterType == IPropertySource.class) {
+ ((ISystemViewElementAdapter)adapter).setPropertySourceInput(adaptableObject);
+ }
+ return adapter;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class[] getAdapterList() {
+ return new Class[] {
+ ISystemViewElementAdapter.class,
+ ISystemDragDropAdapter.class,
+ ISystemRemoteElementAdapter.class,
+ IPropertySource.class,
+ IWorkbenchAdapter.class,
+ IActionFilter.class,
+ IDeferredWorkbenchAdapter.class,
+ IRemoteObjectIdentifier.class,
+ };
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewRemoteProcessAdapter.java b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewRemoteProcessAdapter.java
new file mode 100644
index 000000000..748f262ab
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/TCFSystemViewRemoteProcessAdapter.java
@@ -0,0 +1,446 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 com.windriver.tcf.rse.ui;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.rse.core.model.ISystemMessageObject;
+import org.eclipse.rse.core.model.ISystemResourceSet;
+import org.eclipse.rse.core.model.SystemMessageObject;
+import org.eclipse.rse.core.model.SystemRemoteResourceSet;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.services.clientserver.processes.HostProcessFilterImpl;
+import org.eclipse.rse.services.clientserver.processes.IHostProcess;
+import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
+import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteTypes;
+import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess;
+import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessSubSystem;
+import org.eclipse.rse.ui.ISystemMessages;
+import org.eclipse.rse.ui.RSEUIPlugin;
+import org.eclipse.rse.ui.SystemBasePlugin;
+import org.eclipse.rse.ui.SystemMenuManager;
+import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
+import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
+import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
+import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+
+import com.windriver.tcf.api.services.ISysMonitor;
+
+public class TCFSystemViewRemoteProcessAdapter extends AbstractSystemViewAdapter
+ implements ISystemViewElementAdapter, ISystemRemoteElementAdapter{
+
+ private SystemCopyToClipboardAction copyClipboardAction;
+ private static final Object[] EMPTY_LIST = new Object[0];
+ private static IPropertyDescriptor[] properties = null;
+ //private SystemKillProcessAction killProcessAction;
+
+ private static final String PROP_PC_UTIME = "PCUTime";
+ private static final String PROP_PC_STIME = "PCSTime";
+
+ public boolean canDrag(Object element) {
+ return true;
+ }
+
+ public boolean canDrag(SystemRemoteResourceSet elements) {
+ return true;
+ }
+
+ public Object doDrag(Object element, boolean sameSystemType, IProgressMonitor monitor) {
+ return getText(element);
+ }
+
+ public ISystemResourceSet doDrag(SystemRemoteResourceSet set, IProgressMonitor monitor) {
+ return set;
+ }
+
+ public void addActions(SystemMenuManager menu,
+ IStructuredSelection selection, Shell parent, String menuGroup) {
+ /*
+ if (killProcessAction == null)
+ killProcessAction = new SystemKillProcessAction(shell);
+ menu.add(ISystemContextMenuConstants.GROUP_CHANGE, killProcessAction);
+ */
+
+ if (copyClipboardAction == null) {
+ Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
+ copyClipboardAction = new SystemCopyToClipboardAction(shell, clipboard);
+ }
+ menu.add(menuGroup, copyClipboardAction);
+ }
+
+ public ISubSystem getSubSystem(Object element) {
+ if (element instanceof IRemoteProcess) {
+ IRemoteProcess process = (IRemoteProcess)element;
+ return process.getParentRemoteProcessSubSystem();
+ }
+ return super.getSubSystem(element);
+ }
+
+ public ImageDescriptor getImageDescriptor(Object element) {
+ IRemoteProcess process = (IRemoteProcess)element;
+ TCFProcessResource r = (TCFProcessResource)process.getObject();
+ String state = r.getState();
+ if (r.getParentID() != null) {
+ if (state.indexOf('R') >= 0) {
+ return Activator.getDefault().getImageDescriptorFromPath("icons/thread-r.gif"); //$NON-NLS-1$
+ }
+ return Activator.getDefault().getImageDescriptorFromPath("icons/thread-s.gif"); //$NON-NLS-1$
+ }
+ else {
+ if (state.indexOf('R') >= 0) {
+ return Activator.getDefault().getImageDescriptorFromPath("icons/process-r.gif"); //$NON-NLS-1$
+ }
+ return Activator.getDefault().getImageDescriptorFromPath("icons/process-s.gif"); //$NON-NLS-1$
+ }
+ }
+
+ public String getText(Object element) {
+ String text = ((IRemoteProcess)element).getLabel();
+ return (text == null) ? "" : text; //$NON-NLS-1$
+ }
+
+ public String getAlternateText(Object element) {
+ IRemoteProcess process = (IRemoteProcess)element;
+ String allProperties = process.getAllProperties();
+ return allProperties.replace('|', '\t');
+ }
+
+ public String getAbsoluteName(Object object) {
+ IRemoteProcess process = (IRemoteProcess) object;
+ return "" + process.getPid(); //$NON-NLS-1$
+ }
+
+ public String getType(Object element) {
+ return "Process";
+ }
+
+ public Object getParent(Object element) {
+ IRemoteProcess process = (IRemoteProcess) element;
+ IRemoteProcess parent = process.getParentRemoteProcess();
+ if ((parent != null) && parent.getAbsolutePath().equals(process.getAbsolutePath()))
+ // should never happen but sometimes it does, leading to infinite loop.
+ parent = null;
+ return parent;
+ }
+
+ public boolean hasChildren(IAdaptable element) {
+ return getChildren(element, new NullProgressMonitor()).length > 0;
+ }
+
+ public Object[] getChildren(IAdaptable element, IProgressMonitor monitor) {
+ IRemoteProcess process = (IRemoteProcess)element;
+ IRemoteProcessSubSystem ss = process.getParentRemoteProcessSubSystem();
+ IHostProcessFilter orgRpfs = process.getFilterString();
+ IHostProcessFilter newRpfs = new HostProcessFilterImpl(orgRpfs.toString());
+
+ Object[] children1 = null;
+ Object[] children2 = null;
+ newRpfs.setPpid(Long.toString(process.getPid()));
+
+ try {
+ TCFProcessResource r = (TCFProcessResource)process.getObject();
+ IHostProcess[] nodes = r.getService().listAllProcesses(orgRpfs, r, monitor);
+ TCFProcessAdapter adapter = new TCFProcessAdapter();
+ children1 = adapter.convertToRemoteProcesses(process.getContext(), process, nodes);
+ if (children1 == null) children1 = EMPTY_LIST;
+
+ children2 = ss.listAllProcesses(newRpfs, process.getContext(), monitor);
+ if (children2 == null) children2 = EMPTY_LIST;
+ }
+ catch (Exception exc) {
+ children1 = new SystemMessageObject[1];
+ children1[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED), ISystemMessageObject.MSGTYPE_ERROR, element);
+ children2 = null;
+ SystemBasePlugin.logError("Exception resolving file filter strings", exc); //$NON-NLS-1$
+ }
+ if (children1 == null || children1.length == 0) return children2;
+ if (children2 == null || children2.length == 0) return children1;
+ Object[] children = new Object[children1.length + children2.length];
+ System.arraycopy(children1, 0, children, 0, children1.length);
+ System.arraycopy(children2, 0, children, children1.length, children2.length);
+ return children;
+ }
+
+ protected IPropertyDescriptor[] internalGetPropertyDescriptors() {
+ if (properties != null) return properties;
+ List<IPropertyDescriptor> l = new ArrayList<IPropertyDescriptor>();
+
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_ID, Messages.PROCESS_ID_LABEL, Messages.PROCESS_ID_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_PID, Messages.PROCESS_PID_LABEL, Messages.PROCESS_PID_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_FILE, Messages.PROCESS_NAME_LABEL, Messages.PROCESS_NAME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CWD, Messages.PROCESS_CWD_LABEL, Messages.PROCESS_CWD_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_ROOT, Messages.PROCESS_ROOT_LABEL, Messages.PROCESS_ROOT_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_STATE, Messages.PROCESS_STATE_LABEL, Messages.PROCESS_STATE_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_UID, Messages.PROCESS_UID_LABEL, Messages.PROCESS_UID_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_USERNAME, Messages.PROCESS_USERNAME_LABEL, Messages.PROCESS_USERNAME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_UGID, Messages.PROCESS_GID_LABEL, Messages.PROCESS_GID_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_GROUPNAME, Messages.PROCESS_GROUPNAME_LABEL, Messages.PROCESS_GROUPNAME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_PPID, Messages.PROCESS_PPID_LABEL, Messages.PROCESS_PPID_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_PGRP, Messages.PROCESS_PGRP_LABEL, Messages.PROCESS_PGRP_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_TGID, Messages.PROCESS_TGID_LABEL, Messages.PROCESS_TGID_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_TRACERPID, Messages.PROCESS_TRACERPID_LABEL, Messages.PROCESS_TRACERPID_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_VSIZE, Messages.PROCESS_VMSIZE_LABEL, Messages.PROCESS_VMSIZE_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_RSS, Messages.PROCESS_VMRSS_LABEL, Messages.PROCESS_VMRSS_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_SESSION, Messages.PROCESS_SESSION_LABEL, Messages.PROCESS_SESSION_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_TTY, Messages.PROCESS_TTY_LABEL, Messages.PROCESS_TTY_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_FLAGS, Messages.PROCESS_FLAGS_LABEL, Messages.PROCESS_FLAGS_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_MINFLT, Messages.PROCESS_MINFLT_LABEL, Messages.PROCESS_MINFLT_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CMINFLT, Messages.PROCESS_CMINFLT_LABEL, Messages.PROCESS_CMINFLT_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_MAJFLT, Messages.PROCESS_MAJFLT_LABEL, Messages.PROCESS_MAJFLT_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CMAJFLT, Messages.PROCESS_CMAJFLT_LABEL, Messages.PROCESS_CMAJFLT_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_UTIME, Messages.PROCESS_UTIME_LABEL, Messages.PROCESS_UTIME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_STIME, Messages.PROCESS_STIME_LABEL, Messages.PROCESS_STIME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CUTIME, Messages.PROCESS_CUTIME_LABEL, Messages.PROCESS_CUTIME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CSTIME, Messages.PROCESS_CSTIME_LABEL, Messages.PROCESS_CSTIME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(PROP_PC_UTIME, Messages.PROCESS_PC_UTIME_LABEL, Messages.PROCESS_PC_UTIME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(PROP_PC_STIME, Messages.PROCESS_PC_STIME_LABEL, Messages.PROCESS_PC_STIME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_PRIORITY, Messages.PROCESS_PRIORITY_LABEL, Messages.PROCESS_PRIORITY_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_NICE, Messages.PROCESS_NICE_LABEL, Messages.PROCESS_NICE_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_ITREALVALUE, Messages.PROCESS_ITREALVALUE_LABEL, Messages.PROCESS_ITREALVALUE_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_STARTTIME, Messages.PROCESS_STARTTIME_LABEL, Messages.PROCESS_STARTTIME_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_RLIMIT, Messages.PROCESS_RLIMIT_LABEL, Messages.PROCESS_RLIMIT_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CODESTART, Messages.PROCESS_CODESTART_LABEL, Messages.PROCESS_CODESTART_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CODEEND, Messages.PROCESS_CODEEND_LABEL, Messages.PROCESS_CODEEND_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_STACKSTART, Messages.PROCESS_STACKSTART_LABEL, Messages.PROCESS_STACKSTART_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_SIGNALS, Messages.PROCESS_SIGNALS_LABEL, Messages.PROCESS_SIGNALS_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_SIGBLOCK, Messages.PROCESS_SIGBLOCK_LABEL, Messages.PROCESS_SIGBLOCK_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_SIGIGNORE, Messages.PROCESS_SIGIGNORE_LABEL, Messages.PROCESS_SIGIGNORE_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_SIGCATCH, Messages.PROCESS_SIGCATCH_LABEL, Messages.PROCESS_SIGCATCH_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_WCHAN, Messages.PROCESS_WCHAN_LABEL, Messages.PROCESS_WCHAN_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_NSWAP, Messages.PROCESS_NSWAP_LABEL, Messages.PROCESS_NSWAP_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_CNSWAP, Messages.PROCESS_CNSWAP_LABEL, Messages.PROCESS_CNSWAP_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_EXITSIGNAL, Messages.PROCESS_EXITSIGNAL_LABEL, Messages.PROCESS_EXITSIGNAL_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_PROCESSOR, Messages.PROCESS_PROCESSOR_LABEL, Messages.PROCESS_PROCESSOR_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_RTPRIORITY, Messages.PROCESS_RTPRIORITY_LABEL, Messages.PROCESS_RTPRIORITY_TOOLTIP));
+ l.add(createSimplePropertyDescriptor(ISysMonitor.PROP_POLICY, Messages.PROCESS_POLICY_LABEL, Messages.PROCESS_POLICY_TOOLTIP));
+
+ properties = l.toArray(new IPropertyDescriptor[l.size()]);
+ return properties;
+ }
+
+ /**
+ * Returns the current value for the named property.
+ * @return the current value of the given property
+ */
+ protected Object internalGetPropertyValue(Object key) {
+ return getPropertyValue(key, true);
+ }
+
+ /**
+ * Returns the current value for the named property.
+ *
+ * @param property the name or key of the property as named by its property descriptor
+ * @param formatted indication of whether to return the value in formatted or raw form
+ * @return the current value of the given property
+ */
+ public Object getPropertyValue(Object property, boolean formatted) {
+ String name = (String)property;
+ TCFRemoteProcess process = (TCFRemoteProcess)propertySourceInput;
+ Object p = process.getProperties().get((String)property);
+
+ if (formatted) {
+ if (name.equals(ISysMonitor.PROP_VSIZE)) {
+ return sub(Messages.PROCESS_VMSIZE_VALUE, "&1", Long.toString(process.getVmSizeInKB()));
+ }
+ if (name.equals(ISysMonitor.PROP_RSS)) {
+ return sub(Messages.PROCESS_VMRSS_VALUE, "&1", Long.toString(process.getVmRSSInKB()));
+ }
+ if (name.equals(ISysMonitor.PROP_SIGNALS))return formatBitSet(p);
+ if (name.equals(ISysMonitor.PROP_SIGBLOCK)) return formatBitSet(p);
+ if (name.equals(ISysMonitor.PROP_SIGCATCH)) return formatBitSet(p);
+ if (name.equals(ISysMonitor.PROP_SIGIGNORE)) return formatBitSet(p);
+ if (name.equals(ISysMonitor.PROP_CODESTART)) return formatHex(p);
+ if (name.equals(ISysMonitor.PROP_CODEEND)) return formatHex(p);
+ if (name.equals(ISysMonitor.PROP_STACKSTART)) return formatHex(p);
+ if (name.equals(ISysMonitor.PROP_WCHAN)) return formatHex(p);
+ if (name.equals(ISysMonitor.PROP_FLAGS)) return formatBitSet(p);
+ if (name.equals(ISysMonitor.PROP_UTIME)) return formatTime(p);
+ if (name.equals(ISysMonitor.PROP_STIME)) return formatTime(p);
+ if (name.equals(ISysMonitor.PROP_CUTIME)) return formatTime(p);
+ if (name.equals(ISysMonitor.PROP_CSTIME)) return formatTime(p);
+ if (name.equals(ISysMonitor.PROP_STARTTIME)) return formatTime(p);
+ if (name.equals(ISysMonitor.PROP_ITREALVALUE)) return formatTime(p);
+ if (name.equals(PROP_PC_UTIME)) return process.getUserTimePC();
+ if (name.equals(PROP_PC_STIME)) return process.getSysTimePC();
+ }
+
+ if (p == null) return null;
+ if (formatted) return p.toString();
+ return p;
+ }
+
+ private String formatTime(Object o) {
+ if (o instanceof Number) {
+ BigInteger n = new BigInteger(o.toString());
+ BigInteger s[] = n.divideAndRemainder(BigInteger.valueOf(1000));
+ BigInteger m[] = s[0].divideAndRemainder(BigInteger.valueOf(60));
+ BigInteger h[] = m[0].divideAndRemainder(BigInteger.valueOf(60));
+ StringBuffer buf = new StringBuffer();
+ if (!h[0].equals(BigInteger.ZERO)) {
+ buf.append(h[0]);
+ buf.append("h ");
+ }
+ if (buf.length() > 0 || !h[1].equals(BigInteger.ZERO)) {
+ buf.append(h[1]);
+ buf.append("m ");
+ }
+ buf.append(m[1]);
+ buf.append('.');
+ String ms = s[1].toString();
+ buf.append("000".substring(ms.length()));
+ buf.append(ms);
+ buf.append('s');
+ return buf.toString();
+ }
+ if (o == null) return null;
+ return o.toString();
+ }
+
+ private void formatHex(StringBuffer buf, BigInteger n, int cnt) {
+ BigInteger m[] = n.divideAndRemainder(BigInteger.valueOf(16));
+ if (cnt < 7 || !m[0].equals(BigInteger.ZERO)) {
+ formatHex(buf, m[0], cnt + 1);
+ }
+ int d = m[1].intValue();
+ buf.append((char)(d <= 9 ? '0' + d : 'a' + d - 10));
+ }
+
+ protected String formatHex(Object o) {
+ if (o instanceof Number) {
+ BigInteger n = new BigInteger(o.toString());
+ StringBuffer buf = new StringBuffer();
+ buf.append("0x");
+ formatHex(buf, n, 0);
+ return buf.toString();
+ }
+ if (o == null) return null;
+ return o.toString();
+ }
+
+ protected String formatBitSet(Object o) {
+ if (o instanceof Number) {
+ StringBuffer buf = new StringBuffer();
+ long n = ((Number)o).longValue();
+ for (int i = 0; i < 64; i++) {
+ if ((n & (1l << i)) != 0) {
+ if (buf.length() > 0) buf.append(',');
+ int i0 = i;
+ while (i < 63 && (n & (1l << (i + 1))) != 0) i++;
+ buf.append(i0);
+ if (i0 != i) {
+ buf.append("..");
+ buf.append(i);
+ }
+ }
+ }
+ return buf.toString();
+ }
+ if (o == null) return null;
+ return o.toString();
+ }
+
+ protected String formatState(String state) {
+ return state;
+ }
+
+ /**
+ * Return fully qualified name that uniquely identifies this remote object's remote parent within its subsystem
+ */
+ public String getAbsoluteParentName(Object element) {
+ IRemoteProcess process = (IRemoteProcess) element;
+ IRemoteProcess parent = process.getParentRemoteProcess();
+ if (parent != null) return parent.getAbsolutePath();
+ else return "/proc/0"; //$NON-NLS-1$
+ }
+
+ /**
+ * Given a remote object, returns it remote parent object. Eg, given a process, return the process that
+ * spawned it.
+ * <p>
+ * The shell is required in order to set the cursor to a busy state if a remote trip is required.
+ *
+ * @return an IRemoteProcess object for the parent
+ */
+ public Object getRemoteParent(Object element, IProgressMonitor monitor) throws Exception {
+ return ((IRemoteProcess) element).getParentRemoteProcess();
+ }
+
+ /**
+ * Given a remote object, return the unqualified names of the objects contained in that parent. This is
+ * used for testing for uniqueness on a rename operation, for example. Sometimes, it is not
+ * enough to just enumerate all the objects in the parent for this purpose, because duplicate
+ * names are allowed if the types are different, such as on iSeries. In this case return only
+ * the names which should be used to do name-uniqueness validation on a rename operation.
+ *
+ * @return an array of all file and folder names in the parent of the given IRemoteFile object
+ */
+ public String[] getRemoteParentNamesInUse(Object element, IProgressMonitor monitor) throws Exception {
+ String[] pids = EMPTY_STRING_LIST;
+
+ IRemoteProcess process = (IRemoteProcess) element;
+ String parentName = "" + process.getPPid(); //$NON-NLS-1$
+ if (parentName.equals("-1")) // given a root? //$NON-NLS-1$
+ return pids; // not much we can do. Should never happen: you can't rename a root!
+
+ Object[] children = getChildren(process.getParentRemoteProcess(), monitor);
+ if ((children == null) || (children.length == 0))
+ return pids;
+
+ pids = new String[children.length];
+ for (int idx = 0; idx < pids.length; idx++)
+ pids[idx] = "" + ((IRemoteProcess) children[idx]).getPid(); //$NON-NLS-1$
+
+ return pids;
+ }
+
+ public String getRemoteSubType(Object element) {
+ return null;
+ }
+
+ public String getRemoteType(Object element) {
+ IRemoteProcess process = (IRemoteProcess) element;
+ if (process.isRoot())
+ return ISystemProcessRemoteTypes.TYPE_ROOT;
+ else
+ return ISystemProcessRemoteTypes.TYPE_PROCESS;
+ }
+
+ public String getRemoteTypeCategory(Object element) {
+ return ISystemProcessRemoteTypes.TYPECATEGORY;
+ }
+
+ /**
+ * Return the subsystem factory id that owns this remote object
+ * The value must not be translated, so that property pages registered via xml can subset by it.
+ */
+ public String getSubSystemConfigurationId(Object element) {
+ IRemoteProcess process = (IRemoteProcess) element;
+ return process.getParentRemoteProcessSubSystem().getSubSystemConfiguration().getId();
+ }
+
+ public boolean refreshRemoteObject(Object oldElement, Object newElement) {
+ return false;
+ }
+
+ public boolean supportsUserDefinedActions(Object object) {
+ return false;
+ }
+}
diff --git a/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/messages.properties b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/messages.properties
new file mode 100644
index 000000000..3b48e7409
--- /dev/null
+++ b/plugins/com.windriver.tcf.rse.ui/src/com/windriver/tcf/rse/ui/messages.properties
@@ -0,0 +1,103 @@
+SysMonitor_AllProcesses=All Processes
+SysMonitor_Process=Process
+
+PROCESS_ID_LABEL=Context ID
+PROCESS_PID_LABEL=Process ID
+PROCESS_NAME_LABEL=Executable Name
+PROCESS_CWD_LABEL=CWD
+PROCESS_ROOT_LABEL=FS Root
+PROCESS_UID_LABEL=User ID
+PROCESS_USERNAME_LABEL=Username
+PROCESS_GID_LABEL=Group ID
+PROCESS_GROUPNAME_LABEL=Groupname
+PROCESS_PPID_LABEL=Parent PID
+PROCESS_PGRP_LABEL=Proucess Group
+PROCESS_STATE_LABEL=State
+PROCESS_TRACERPID_LABEL=Tracer PID
+PROCESS_VMSIZE_LABEL=VM Size
+PROCESS_VMRSS_LABEL=VM RSS
+PROCESS_SESSION_LABEL=Session
+PROCESS_TTY_LABEL=TTY
+PROCESS_TGID_LABEL=Task Group ID
+PROCESS_FLAGS_LABEL=Flags
+PROCESS_MINFLT_LABEL=Minor Faults
+PROCESS_CMINFLT_LABEL=Children Minor Faults
+PROCESS_MAJFLT_LABEL=Major Faults
+PROCESS_CMAJFLT_LABEL=Children Major Faults
+PROCESS_UTIME_LABEL=User Time
+PROCESS_STIME_LABEL=System Time
+PROCESS_CUTIME_LABEL=Children User Time
+PROCESS_CSTIME_LABEL=Children System Time
+PROCESS_PC_UTIME_LABEL=% User Time
+PROCESS_PC_STIME_LABEL=% System Time
+PROCESS_PRIORITY_LABEL=Priority
+PROCESS_NICE_LABEL=Nice
+PROCESS_ITREALVALUE_LABEL=Interval Timer
+PROCESS_STARTTIME_LABEL=Start Time
+PROCESS_RLIMIT_LABEL=RSS Limit
+PROCESS_CODESTART_LABEL=Code Start
+PROCESS_CODEEND_LABEL=Code End
+PROCESS_STACKSTART_LABEL=Stack Start
+PROCESS_SIGNALS_LABEL=Pending Signals
+PROCESS_SIGBLOCK_LABEL=Blocked Signals
+PROCESS_SIGIGNORE_LABEL=Ignored Signals
+PROCESS_SIGCATCH_LABEL=Caught Signals
+PROCESS_WCHAN_LABEL=Wait Channel
+PROCESS_NSWAP_LABEL=Swaped Pages
+PROCESS_CNSWAP_LABEL=Children Swapped Pages
+PROCESS_EXITSIGNAL_LABEL=Exit Signal
+PROCESS_PROCESSOR_LABEL=Processor
+PROCESS_RTPRIORITY_LABEL=Real Time Priority
+PROCESS_POLICY_LABEL=Scheduling Policy
+
+PROCESS_ID_TOOLTIP=TCF context ID of the process
+PROCESS_PID_TOOLTIP=The system ID number of the process
+PROCESS_NAME_TOOLTIP=The executable associated with the process
+PROCESS_CWD_TOOLTIP=Current working directory of the process
+PROCESS_ROOT_TOOLTIP=Current file system root of the process
+PROCESS_UID_TOOLTIP=The user ID of the owner of the process
+PROCESS_USERNAME_TOOLTIP=The username of the owner of the process
+PROCESS_GID_TOOLTIP=The group ID of the owner of the process
+PROCESS_GROUPNAME_TOOLTIP=The groupname of the owner of the process
+PROCESS_PPID_TOOLTIP=The process ID of the parent of the process
+PROCESS_PGRP_TOOLTIP=The process group ID
+PROCESS_STATE_TOOLTIP=The state in which the process currently is
+PROCESS_TRACERPID_TOOLTIP=The tracer process ID of the process
+PROCESS_VMSIZE_TOOLTIP=The amount of virtual memory taken up by this process
+PROCESS_VMRSS_TOOLTIP=The amount of virtual memory resident set size of this process (actual RAM taken up by the process)
+PROCESS_SESSION_TOOLTIP=The session ID of the process
+PROCESS_TTY_TOOLTIP=The TTY the process uses
+PROCESS_TGID_TOOLTIP=The task group to which process belongs
+PROCESS_FLAGS_TOOLTIP=The kernel flags word of the process.
+PROCESS_MINFLT_TOOLTIP=The number of minor faults the process has made which have not required loading a memory page from disk.
+PROCESS_CMINFLT_TOOLTIP=The number of minor faults that the process's waited-for children have made.
+PROCESS_MAJFLT_TOOLTIP=The number of major faults the process has made which have required loading a memory page from disk.
+PROCESS_CMAJFLT_TOOLTIP=Children Major Faults
+PROCESS_UTIME_TOOLTIP=User Time
+PROCESS_STIME_TOOLTIP=System Time
+PROCESS_CUTIME_TOOLTIP=Children User Time
+PROCESS_CSTIME_TOOLTIP=Children System Time
+PROCESS_PC_UTIME_TOOLTIP=% User Time
+PROCESS_PC_STIME_TOOLTIP=% System Time
+PROCESS_PRIORITY_TOOLTIP=Priority
+PROCESS_NICE_TOOLTIP=Nice
+PROCESS_ITREALVALUE_TOOLTIP=Interval Timer
+PROCESS_STARTTIME_TOOLTIP=Start Time
+PROCESS_RLIMIT_TOOLTIP=RSS Limit
+PROCESS_CODESTART_TOOLTIP=Code Start
+PROCESS_CODEEND_TOOLTIP=Code End
+PROCESS_STACKSTART_TOOLTIP=Stack Start
+PROCESS_SIGNALS_TOOLTIP=Pending Signals
+PROCESS_SIGBLOCK_TOOLTIP=Blocked Signals
+PROCESS_SIGIGNORE_TOOLTIP=Ignored Signals
+PROCESS_SIGCATCH_TOOLTIP=Caught Signals
+PROCESS_WCHAN_TOOLTIP=Wait Channel
+PROCESS_NSWAP_TOOLTIP=Swaped Pages
+PROCESS_CNSWAP_TOOLTIP=Children Swapped Pages
+PROCESS_EXITSIGNAL_TOOLTIP=Exit Signal
+PROCESS_PROCESSOR_TOOLTIP=Processor
+PROCESS_RTPRIORITY_TOOLTIP=Real Time Priority
+PROCESS_POLICY_TOOLTIP=Scheduling Policy
+
+PROCESS_VMSIZE_VALUE=&1 KB
+PROCESS_VMRSS_VALUE=&1 KB \ No newline at end of file

Back to the top