Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools')
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/LinuxToolsPlugin.java85
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.java33
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.properties21
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages_pt.properties21
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFProvider.java140
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFWrapper.java100
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetProvider.java194
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetWrapper.java237
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadProcessor.java280
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadTool.java208
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadView.java336
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewContentProvider.java61
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewLabelProvider.java54
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/DialogOptions.java109
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.java49
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.properties38
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages_pt.properties38
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/ViewActionOptions.java60
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapProcessor.java139
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapTool.java184
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapVViewLabelProvider.java59
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapView.java290
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapViewContentProvider.java60
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.java40
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.properties27
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages_pt.properties27
26 files changed, 2890 insertions, 0 deletions
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/LinuxToolsPlugin.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/LinuxToolsPlugin.java
new file mode 100644
index 0000000000..551a2f5f97
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/LinuxToolsPlugin.java
@@ -0,0 +1,85 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools;
+
+import org.eclipse.tml.common.utilities.BasePlugin;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class LinuxToolsPlugin extends BasePlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.tml.linuxtools"; //$NON-NLS-1$
+
+ // Common icons
+ public static final String ICON_RUN = "run.gif"; //$NON-NLS-1$
+ public static final String ICON_PAUSE = "pause.gif"; //$NON-NLS-1$
+ public static final String ICON_OPTIONS = "options.gif"; //$NON-NLS-1$
+ public static final String ICON_REFRESH = "refresh.gif"; //$NON-NLS-1$
+ public static final String ICON_DISCONNECT = "disconnect.gif"; //$NON-NLS-1$
+ public static final String ICON_CONNECT = "connect.gif"; //$NON-NLS-1$
+
+ // The shared instance
+ private static LinuxToolsPlugin plugin;
+
+ private static final String[] allIcons = {ICON_RUN,
+ ICON_PAUSE,
+ ICON_OPTIONS,
+ ICON_REFRESH,
+ ICON_DISCONNECT,
+ ICON_CONNECT};
+
+ /**
+ * Returns the shared instance
+ * @return the shared instance
+ */
+ public static LinuxToolsPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * The constructor
+ */
+ public LinuxToolsPlugin() {
+ }
+
+ /*
+ * (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);
+ }
+
+ @Override
+ protected void initializeImageRegistry() {
+ String path = getIconPath();
+ for (String s: allIcons) {
+ putImageInRegistry(s, path + s);
+ }
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.java
new file mode 100644
index 0000000000..230ef50afa
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.java
@@ -0,0 +1,33 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Otávio Ferranti
+ *
+ */
+public class Messages extends NLS {
+
+ private static String BUNDLE_NAME = "org.eclipse.tml.linuxtools.messages"; //$NON-NLS-1$
+ public static String TML_Plugin_Name;
+ public static String TML_Error;
+ public static String TML_Resource_Not_Available;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.properties b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.properties
new file mode 100644
index 0000000000..7bbec42950
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages.properties
@@ -0,0 +1,21 @@
+################################################################################
+# Copyright (c) 2008 Motorola Inc.
+# 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
+#
+# Initial Contributors:
+# Otávio Ferranti (Motorola)
+#
+# Contributors:
+# {Name} (company) - description of contribution.
+################################################################################
+
+# NLS_MESSAGEFORMAT_VAR
+# NLS_ENCODING=UTF-8
+
+TML_Plugin_Name=Linux Tools Plugin (Incubation)
+TML_Error=A unexpected exception was found
+TML_Resource_Not_Available=Resource not available
+
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages_pt.properties b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages_pt.properties
new file mode 100644
index 0000000000..04197c9627
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/Messages_pt.properties
@@ -0,0 +1,21 @@
+################################################################################
+# Copyright (c) 2008 Motorola Inc.
+# 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
+#
+# Initial Contributors:
+# Otávio Ferranti (Motorola)
+#
+# Contributors:
+# {Name} (company) - description of contribution.
+################################################################################
+
+# NLS_MESSAGEFORMAT_VAR
+# NLS_ENCODING=UTF-8
+
+TML_Plugin_Name=Plugin de Ferramentas Linux (Incubation)
+TML_Error=Uma exceção inesperada ocorreu
+TML_Resource_Not_Available=Recurso não disponível
+
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFProvider.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFProvider.java
new file mode 100644
index 0000000000..e98ba8b7ef
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFProvider.java
@@ -0,0 +1,140 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.network.tcf;
+
+import java.io.IOException;
+
+import org.eclipse.tml.common.utilities.logger.ILogger;
+
+import org.eclipse.tml.linuxtools.LinuxToolsPlugin;
+import org.eclipse.tml.linuxtools.network.IConnectionProvider;
+import org.eclipse.tml.linuxtools.network.IConstants.CommandCode;
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+import org.eclipse.tml.linuxtools.tools.AbstractNotifier;
+
+public class TCFProvider extends AbstractNotifier implements
+ IConnectionProvider {
+
+ private TCFWrapper connectionWrapper = null;
+ private ILogger logger = null;
+
+ private Thread connectThread = null;
+ private Thread sendCommandThread = null;
+
+ /**
+ * The constructor.
+ */
+ public TCFProvider() {
+ connectionWrapper = new TCFWrapper();
+ logger = LinuxToolsPlugin.getLogger();
+ }
+
+ /**
+ * This method will be executed in a separated thread and will produce
+ * an event to be sent to the registered listeners.
+ */
+ public void connect(String host, int port) throws IOException {
+ final String hostAux = host;
+ final int portAux = port;
+ final TCFWrapper connectionWrapperAux = connectionWrapper;
+
+ /*TODO: Enhance this. It would be great if all these executed-in-other threads
+ were located under a synchronized block */
+
+ connectThread = new Thread() {
+ public void run() {
+ try {
+ connectionWrapperAux.connect(hostAux, portAux);
+ TCFProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_CONNECT_FINISHED,
+ OperationCode.SUCCESS);
+ } catch (IOException ie) {
+ TCFProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_CONNECT_ERROR,
+ OperationCode.UNEXPECTED_RESULT);
+ }
+
+ }
+ };
+ connectThread.start();
+ }
+
+ public void disconnect() throws IOException {
+ if (null != connectThread &&
+ connectThread.isAlive()) {
+ connectThread.interrupt();
+ }
+
+ if (null != sendCommandThread &&
+ sendCommandThread.isAlive()) {
+ sendCommandThread.interrupt();
+ }
+ connectionWrapper.disconnect();
+ notifyListeners(
+ EventCode.EVT_PROVIDER_DISCONNECT_FINISHED, OperationCode.SUCCESS);
+ }
+
+ public StringBuffer getLastResponde() {
+ return connectionWrapper.getLastResponde();
+ }
+
+ public void login(String user, String password) throws IOException {
+
+ }
+
+ /**
+ * This method will be executed in a separated thread and will produce
+ * an event to be sent to the registered listeners.
+ */
+ public void sendCommand(CommandCode cmd, String cmdStr) throws IOException {
+
+ if (CommandCode.FETCH_FILE != cmd) {
+ return;
+ }
+
+ final TCFWrapper connectionWrapperAux = connectionWrapper;
+
+ final String path = cmdStr.substring(0, cmdStr.lastIndexOf("/"));
+ final String fileName = cmdStr.substring(cmdStr.lastIndexOf("/"));
+
+ sendCommandThread = new Thread() {
+ public void run() {
+ try {
+
+ if (null != connectionWrapperAux.fetchFile(path, fileName)) {
+ StringBuffer result = connectionWrapperAux.getLastResponde();
+ TCFProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_SENDCOMMAND_FINISHED, result);
+ } else {
+ logger.info("##### NULL ######");
+ }
+ } catch (IOException ie) {
+ TCFProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_SENDCOMMAND_ERROR, null);
+ }
+
+ }
+ };
+ sendCommandThread.start();
+ }
+
+ public void sendData(String out) {
+ connectionWrapper.sendData(out);
+ }
+
+ public void setResponseLength(int maxLength) {
+ connectionWrapper.setResponseLength(maxLength);
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFWrapper.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFWrapper.java
new file mode 100644
index 0000000000..f5a125c975
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/tcf/TCFWrapper.java
@@ -0,0 +1,100 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.network.tcf;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.rse.core.IRSECoreRegistry;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
+
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+
+public class TCFWrapper {
+
+ private StringBuffer lastResponse = null;
+ private IHost rseHost = null;
+
+ public void connect(String host, int port) throws IOException {
+ ISystemRegistry rseSystemRegistry = RSECorePlugin.getTheSystemRegistry();
+ IRSECoreRegistry rseCoreRegistry = RSECorePlugin.getTheCoreRegistry();
+ IRSESystemType tcfSystemType = rseCoreRegistry.getSystemTypeById("org.eclipse.tm.tcf.rse.systemType");
+ try {
+ rseHost = rseSystemRegistry.createHost(tcfSystemType, host, host, host);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void disconnect() throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public StringBuffer getLastResponde() {
+ return lastResponse;
+ }
+
+ public OperationCode login(String user, String password) throws IOException {
+ // TODO Auto-generated method stub
+ return OperationCode.SUCCESS;
+ }
+
+ public String fetchFile(String path, String fileName) throws IOException {
+ IRemoteFileSubSystem remoteFileSubSystem =
+ RemoteFileUtility.getFileSubSystem(rseHost);
+ InputStream inputStream = null;
+
+ try {
+ remoteFileSubSystem.connect(new NullProgressMonitor(), false);
+ inputStream = remoteFileSubSystem.getInputStream(path, fileName,
+ false, new NullProgressMonitor());
+ } catch (SystemMessageException sme) {
+ // TODO Auto-generated catch block
+ sme.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ lastResponse = new StringBuffer();
+
+ byte[] b = new byte[16];
+ char[] c = new char[16];
+ while (inputStream.read(b) >= 0) {
+ for (int i = 0; i < b.length; i++) {
+ c[i] = (char) b[i];
+ }
+ lastResponse.append(c);
+ }
+ return "OK";
+ }
+
+ public void sendData(String out) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setResponseLength(int maxLength) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetProvider.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetProvider.java
new file mode 100644
index 0000000000..9d100c3cf2
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetProvider.java
@@ -0,0 +1,194 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.network.telnet;
+
+import java.io.IOException;
+
+import org.eclipse.tml.common.utilities.logger.ILogger;
+
+import org.eclipse.tml.linuxtools.LinuxToolsPlugin;
+import org.eclipse.tml.linuxtools.network.IConnectionProvider;
+import org.eclipse.tml.linuxtools.network.IConstants.CommandCode;
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+import org.eclipse.tml.linuxtools.tools.AbstractNotifier;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class TelnetProvider extends AbstractNotifier implements IConnectionProvider {
+
+ final private String CMD_FETCH_PREFIX = "cat "; //$NON-NLS-1$
+
+ private TelnetWrapper connectionWrapper = null;
+ private ILogger logger = null;
+
+ private Thread connectThread = null;
+ private Thread loginThread = null;
+ private Thread sendCommandThread = null;
+
+ /**
+ * The constructor.
+ */
+ public TelnetProvider() {
+ connectionWrapper = new TelnetWrapper();
+ logger = LinuxToolsPlugin.getLogger();
+ }
+
+ /**
+ * This method will be executed in a separated thread and will produce
+ * an event to be sent to the registered listeners.
+ */
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxmemorymapviewer.network.IConnectionProvider#connect(java.lang.String, int)
+ */
+ public void connect(String host, int port) throws IOException {
+ final String hostAux = host;
+ final int portAux = port;
+ final TelnetWrapper connectionWrapperAux = connectionWrapper;
+
+ /*TODO: Enhance this. It would be great if all these executed-in-other threads
+ were located under a synchronized block */
+
+ connectThread = new Thread() {
+ public void run() {
+ try {
+ OperationCode opCode;
+ opCode = connectionWrapperAux.connect(hostAux, portAux);
+ TelnetProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_CONNECT_FINISHED, opCode);
+ } catch (IOException ie) {
+ TelnetProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_CONNECT_ERROR,
+ OperationCode.UNEXPECTED_RESULT);
+ }
+
+ }
+ };
+ connectThread.start();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxmemorymapviewer.network.IConnectionProvider#disconnect()
+ */
+ public void disconnect() throws IOException {
+ if (null != connectThread &&
+ connectThread.isAlive()) {
+ connectThread.interrupt();
+ }
+ if (null != loginThread &&
+ loginThread.isAlive()) {
+ loginThread.interrupt();
+ }
+ if (null != sendCommandThread &&
+ sendCommandThread.isAlive()) {
+ sendCommandThread.interrupt();
+ }
+ connectionWrapper.disconnect();
+ notifyListeners(
+ EventCode.EVT_PROVIDER_DISCONNECT_FINISHED, OperationCode.SUCCESS);
+ }
+
+ /**
+ * This method will be executed in a separated thread and will produce
+ * an event to be sent to the registered listeners.
+ */
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxmemorymapviewer.network.IConnectionProvider#login(java.lang.String, java.lang.String)
+ */
+ public void login(String user, String password) throws IOException {
+ final String userAux = user;
+ final String passwordAux = password;
+ final TelnetWrapper connectionWrapperAux = connectionWrapper;
+
+ /*TODO: Enhance this. It would be great if all these executed-in-other threads
+ were located under a synchronized block */
+ loginThread = new Thread() {
+ public void run() {
+ try {
+ OperationCode opCode;
+ opCode = connectionWrapperAux.login(userAux, passwordAux);
+ TelnetProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_LOGIN_FINISHED, opCode);
+ } catch (IOException ie) {
+ TelnetProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_LOGIN_ERROR,
+ OperationCode.UNEXPECTED_RESULT);
+ }
+ }
+ };
+ loginThread.start();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxmemorymapviewer.network.IConnectionProvider#getLastResponde()
+ */
+ public StringBuffer getLastResponde() {
+ return connectionWrapper.getLastResponde();
+ }
+
+ /**
+ * This method will be executed in a separated thread and will produce
+ * an event to be sent to the registered listeners.
+ */
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxmemorymapviewer.network.IConnectionProvider#sendCommand(java.lang.String)
+ */
+ public void sendCommand(CommandCode cmd, String cmdStr) throws IOException {
+
+ if (CommandCode.FETCH_FILE != cmd) {
+ return;
+ }
+
+ final String commandAux = CMD_FETCH_PREFIX + cmdStr + "\n"; //$NON-NLS-1$
+
+ final TelnetWrapper connectionWrapperAux = connectionWrapper;
+
+ /*TODO: Enhance this. It would be great if all these executed-in-other threads
+ were located under a synchronized block */
+ sendCommandThread = new Thread() {
+ public void run() {
+ try {
+ connectionWrapperAux.setResponseLength(2048);
+ if (null != connectionWrapperAux.sendCommand(commandAux)) {
+ StringBuffer result = connectionWrapperAux.getLastResponde();
+ TelnetProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_SENDCOMMAND_FINISHED, result);
+ } else {
+ logger.info("##### NULL ######");
+ }
+ } catch (IOException ie) {
+ TelnetProvider.this.notifyListeners(
+ EventCode.EVT_PROVIDER_SENDCOMMAND_ERROR, null);
+ }
+
+ }
+ };
+ sendCommandThread.start();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxmemorymapviewer.network.IConnectionProvider#sendData(java.lang.String)
+ */
+ public void sendData(String out) {
+ connectionWrapper.sendData(out);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxmemorymapviewer.network.IConnectionProvider#setResponseLength(int)
+ */
+ public void setResponseLength(int maxLength) {
+ connectionWrapper.setResponseLength(maxLength);
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetWrapper.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetWrapper.java
new file mode 100644
index 0000000000..0818f29553
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/network/telnet/TelnetWrapper.java
@@ -0,0 +1,237 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * Otávio Ferranti - Eldorado Research Institute - Bug 255255 [tml][proctools] Add extension points
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.network.telnet;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.Thread;
+import java.util.HashMap;
+
+import org.apache.commons.net.telnet.EchoOptionHandler;
+import org.apache.commons.net.telnet.InvalidTelnetOptionException;
+import org.apache.commons.net.telnet.SuppressGAOptionHandler;
+import org.apache.commons.net.telnet.TelnetClient;
+import org.apache.commons.net.telnet.TerminalTypeOptionHandler;
+
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class TelnetWrapper {
+
+ final public String PROMPT = "[###]:"; //$NON-NLS-1$
+ final private String[] LOGIN_TOKENS = {"login:", //$NON-NLS-1$
+ "Login:"}; //$NON-NLS-1$
+ final private String[] PASSWORD_TOKENS = {"password:", //$NON-NLS-1$
+ "Password:"}; //$NON-NLS-1$
+ final private String[] LOGIN_FAILED_TOKENS = {"Login incorrect", //$NON-NLS-1$
+ "Access denied"}; //$NON-NLS-1$
+ final private String CHANGE_PROMPT = "export PS1='[\\043\\043\\043]:'\n"; //$NON-NLS-1$
+
+ // private ILogger logger = null;
+ private TelnetClient client = null;
+ private InputStream inStream = null;
+ private PrintStream outStream = null;
+ private StringBuffer lastResponse = null;
+ private int maxResponseDataLength = 1024;
+
+ private int MAX_LENGTH_PASSWORD_TOKENS = 32;
+ private int MAX_LENGTH_LOGIN_FAILED = 32;
+ private int MAX_LENGTH_LOGIN_INITSCREEN = 2048;
+ private int MAX_LENGTH_CHANGE_PROMPT = 128;
+
+ /**
+ * Constructor
+ */
+ public TelnetWrapper() {
+ if (null == this.client) {
+ this.client = new TelnetClient();
+ try {
+ this.client.addOptionHandler(new TerminalTypeOptionHandler(
+ "VT100", false, false, true, false)); //$NON-NLS-1$
+ this.client.addOptionHandler(new SuppressGAOptionHandler(
+ true, true, true, true));
+ this.client.addOptionHandler(new EchoOptionHandler(
+ false, false, false, false));
+ } catch (InvalidTelnetOptionException itoe) { }
+ // logger = LinuxToolsPlugin.getLogger();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IConnectionWrapper#connect(java.lang.String, int)
+ */
+ public OperationCode connect(String host, int port) throws IOException {
+ OperationCode retVal;
+
+ this.client.connect(host, port);
+
+ inStream = client.getInputStream();
+ outStream = new PrintStream (client.getOutputStream());
+
+ // sendData(user+"\n");
+ if(null == readUntilTokens(LOGIN_TOKENS)) {
+ retVal = OperationCode.SUCCESS;
+ } else {
+ retVal = OperationCode.LOGIN_REQUIRED;
+ }
+ return retVal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IConnectionWrapper#disconnect()
+ */
+ public void disconnect() throws IOException {
+ if (null != client) {
+ client.disconnect();
+ // System.out.println("Connection closed ...");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IConnectionWrapper#login(java.lang.String, java.lang.String)
+ */
+ public OperationCode login(String user, String password) throws IOException {
+ OperationCode retVal = OperationCode.UNEXPECTED_RESULT;
+
+ sendData(user+"\n"); //$NON-NLS-1$
+ setResponseLength(MAX_LENGTH_PASSWORD_TOKENS);
+ if (null != readUntilTokens(PASSWORD_TOKENS)) {
+ sendData(password+"\n"); //$NON-NLS-1$
+
+ setResponseLength(MAX_LENGTH_LOGIN_FAILED);
+ if (null != readUntilTokens(LOGIN_FAILED_TOKENS)) {
+ if(null != readUntilTokens(LOGIN_TOKENS)) {
+ retVal = OperationCode.LOGIN_FAILED;
+ } else {
+ retVal = OperationCode.UNEXPECTED_RESULT;
+ }
+ return retVal;
+ } else {
+ setResponseLength(MAX_LENGTH_LOGIN_INITSCREEN);
+ int toBeSkipped = inStream.available();
+ inStream.skip(toBeSkipped);
+ }
+ }
+ try {
+ Thread.sleep (2000);
+ } catch (InterruptedException ite) {
+
+ }
+ setResponseLength(MAX_LENGTH_CHANGE_PROMPT);
+ sendData(CHANGE_PROMPT);
+ if (null != readUntilTokens(PROMPT)) {
+ retVal = OperationCode.SUCCESS;
+ }
+ return retVal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IConnectionWrapper#getLastResponde()
+ */
+ public StringBuffer getLastResponde() {
+ return lastResponse;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IConnectionWrapper#sendCommand(java.lang.String)
+ */
+ public String sendCommand(String command) throws IOException {
+ sendData (command);
+ return readUntilTokens (PROMPT);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IConnectionWrapper#sendData(java.lang.String)
+ */
+ public void sendData(String out) {
+ if (null != outStream) {
+ outStream.print(out);
+ outStream.flush();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IConnectionWrapper#setResponseLength(int)
+ */
+ public void setResponseLength(int maxLength) {
+ maxResponseDataLength = maxLength;
+ }
+
+ /**
+ * @param token
+ * @return
+ * @throws IOException
+ */
+ private String readUntilTokens(String token)throws IOException {
+ return readUntilTokens(new String[] {token});
+ }
+
+ /**
+ * @param tokenArray
+ * @return
+ * @throws IOException
+ */
+ private String readUntilTokens(final String []tokenArray) throws IOException {
+ String matchedString = null;
+ boolean tokenFound = false;
+ StringBuffer readData = new StringBuffer();
+
+ HashMap<String,Integer> hashMap = new HashMap<String,Integer>();
+
+ for (int i = 0; i < tokenArray.length; i++) {
+ hashMap.put(tokenArray[i], new Integer(0));
+ }
+
+ for (int i = 0; i < this.maxResponseDataLength; i++) {
+
+ int aux = inStream.read();
+
+ char ch = 0;
+ if (aux == 0 || aux == 1) {
+ continue;
+ } else {
+ ch = (char) aux;
+ }
+ readData.append(ch);
+
+ // if (ch != 1 && ch != 0)
+ // logger.info(ch);
+
+ for (int j = 0; j < tokenArray.length; j++) {
+ String token = tokenArray[j];
+ Integer rank = hashMap.get(token);
+ if (ch == token.charAt(rank)) {
+ rank ++;
+ if (rank >= token.length()) {
+ // MATCHED
+ readData.setLength(readData.length() - token.length());
+ matchedString = token;
+ tokenFound = true;
+ }
+ } else {
+ rank = 0;
+ }
+ hashMap.put(token, rank);
+ }
+ if (tokenFound) {
+ break;
+ }
+ }
+ this.lastResponse = readData;
+ return matchedString;
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadProcessor.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadProcessor.java
new file mode 100644
index 0000000000..a61aa62116
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadProcessor.java
@@ -0,0 +1,280 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Scanner;
+import java.util.regex.MatchResult;
+
+import org.eclipse.tml.common.utilities.logger.ILogger;
+
+import org.eclipse.tml.linuxtools.LinuxToolsPlugin;
+import org.eclipse.tml.linuxtools.network.IConstants.CommandCode;
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConnectionProvider;
+import org.eclipse.tml.linuxtools.tools.AbstractNotifier;
+import org.eclipse.tml.linuxtools.tools.IListener;
+import org.eclipse.tml.linuxtools.tools.INotifier;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class CpuLoadProcessor extends AbstractNotifier implements IListener {
+
+ final private String CMD_FETCH_STAT = "/proc/stat"; //$NON-NLS-1$
+ final private String PARSE_PATTERN_1 = "cpu(\\d*)(.*)"; //$NON-NLS-1$;
+ final private String PARSE_PATTERN_2 = "\\s+(\\d+)"; //$NON-NLS-1$;
+ final private String DATA_FORMAT = "%1$02.1f %%"; //$NON-NLS-1$;
+
+ final private String MSG_EXECUTING_COMMAND =
+ Messages.CpuLoadProcessor_Msg_Executing_the_command;
+
+ final private String MSG_GOT_RESULT =
+ Messages.CpuLoadProcessor_Msg_Got_The_Result;
+
+ final private int MAX_COLUMNS = 100;
+
+ private int[][] previousData = null;
+ private long[] previousTotal = null;
+ private IConnectionProvider connectionProvider = null;
+
+ private ILogger logger = null;
+
+ /**
+ * The constructor;
+ * @param connectionProvider
+ */
+ public CpuLoadProcessor(IConnectionProvider connectionProvider) {
+ setConnectionProvider(connectionProvider);
+ logger = LinuxToolsPlugin.getLogger();
+ }
+
+ /**
+ * Requests data.
+ * @throws IOException
+ */
+ public void gatherData() throws IOException {
+ this.connectionProvider.sendCommand(CommandCode.FETCH_FILE, this.CMD_FETCH_STAT);
+ logger.debug(MSG_EXECUTING_COMMAND + "\n" + this.CMD_FETCH_STAT); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IListener#notify(org.eclipse.tml.linuxtools.network.INotifier, org.eclipse.tml.linuxtools.network.IConstants.EventCode, java.lang.Object)
+ */
+ public void notify(INotifier notifier,
+ EventCode event,
+ Object result) {
+ if (notifier == this.connectionProvider &&
+ event == EventCode.EVT_PROVIDER_SENDCOMMAND_FINISHED) {
+ Object[][] parsedResult = parseStat((StringBuffer) result);
+ this.notifyListeners(EventCode.EVT_PROCESSOR_GATHERDATA_FINISHED,
+ parsedResult);
+ }
+ }
+
+ /**
+ * Set the connection provider.
+ * @param connectionProvider
+ */
+ public void setConnectionProvider (IConnectionProvider connectionProvider) {
+ if (null != this.connectionProvider) {
+ this.connectionProvider.removeListener(this);
+ }
+ this.connectionProvider = connectionProvider;
+ if (null != this.connectionProvider) {
+ this.connectionProvider.addListener(this);
+ }
+ }
+
+ /**
+ * @param currentDataStr
+ * @return
+ */
+ private Object[][] calculateTimes(String[][] currentDataStr) {
+ String[][] resultStr = null;
+
+ if (null == currentDataStr) {
+ currentDataStr = new String[][] {{"0"}};
+ }
+ if (null == previousData) {
+ previousData = new int[][] {{0}};
+ previousTotal = new long[] {1};
+ }
+ if (previousData.length != currentDataStr.length ||
+ previousData[0].length != currentDataStr[0].length) {
+ previousData = String2int(currentDataStr);
+ previousTotal = new long[previousData.length];
+
+ for (int j = 0; j < previousData.length; j++) {
+ long total = 0;
+ for (int i = 0; i < previousData[0].length; i++) {
+ total += previousData[j][i];
+ }
+ previousTotal[j] = total;
+ }
+ }
+ final int[][] currentDataInt = String2int(currentDataStr);
+ float[][] resultFloat = new float[currentDataStr.length][currentDataStr[0].length];
+
+ for (int j = 0; j < currentDataInt.length; j++) {
+ long total = 0;
+ for (int i = 0; i < currentDataInt[0].length; i++) {
+ total += currentDataInt[j][i];
+ }
+ float deltaTotal = total - previousTotal[j];
+ previousTotal[j] = total;
+ for (int i = 0; i < currentDataInt[0].length; i++) {
+ float deltaData = currentDataInt[j][i] - previousData[j][i];
+ if (0 == deltaTotal) {
+ resultFloat[j][i] = 0;
+ } else {
+ resultFloat[j][i] = 100* deltaData / deltaTotal;
+ }
+ }
+ }
+ previousData = currentDataInt;
+ resultStr = float2StringFormated(resultFloat, DATA_FORMAT);
+ return resultStr;
+ }
+
+ /**
+ * @param target
+ * @param Source
+ */
+ private void copyData(Object[][] target, Object[][] Source) {
+ for (int j = 0; j < target.length; j++) {
+ for (int i = 1; i < target[0].length; i++) {
+ target[j][i] = Source[j][i-1];
+ }
+ }
+ }
+
+ /**
+ * @param input
+ * @return
+ */
+ private String[][] float2StringFormated (float[][] input, String format) {
+ String[][] output = null;
+ if (null != input) {
+ output = new String[input.length][input[0].length];
+ for (int j = 0; j < output.length; j++) {
+ for (int i = 0; i < output[0].length; i++) {
+ output[j][i] = String.format(format, new Float(input[j][i]));
+ }
+ }
+ }
+ return output;
+ }
+
+ /**
+ * @param data
+ * @return
+ */
+ private Object[][] parseStat(StringBuffer data) {
+ logger.debug(MSG_GOT_RESULT + "\n" + data.toString());
+
+ int requiredColumns = 0;
+
+ Scanner s1 = new Scanner(data.toString());
+ ArrayList<String[]> list = new ArrayList<String[]>();
+
+ while (s1.hasNextLine()) {
+ String[] entry = new String[MAX_COLUMNS];;
+
+ Scanner s2 = new Scanner(s1.nextLine());
+ s2.findInLine(PARSE_PATTERN_1);
+
+ try {
+
+ MatchResult result = s2.match();
+ entry[0] = result.group(1).trim();
+
+ String aux = result.group(2);
+
+ Scanner s3 = new Scanner(aux);
+ entry[1] = s3.findInLine(PARSE_PATTERN_2).trim();
+
+ s3.match();
+ int i = 2;
+
+ while (s3.hasNext() && i < MAX_COLUMNS) {
+ entry[i] = s3.next().trim();
+
+ if (i > requiredColumns) {
+ requiredColumns = i;
+ }
+ i++;
+ }
+ s3.close();
+ if (null != entry) {
+ list.add(entry);
+ }
+ } catch (IllegalStateException ise) {
+ }
+ s2.close();
+ }
+ s1.close();
+
+ String[][] dataAux = new String[list.size()][requiredColumns + 1];
+ for (int j = 0; j < dataAux.length; j++) {
+ for (int i = 0; i < dataAux[0].length; i++) {
+ dataAux[j][i] = list.get(j)[i];
+ }
+ }
+ String[][] dataStrippedAux = stripFirstColumn(dataAux);
+ Object[][] result = calculateTimes(dataStrippedAux);
+ copyData(dataAux, result);
+ return dataAux;
+ }
+
+ /**
+ * @param input
+ * @return
+ */
+ private int[][] String2int (String[][] input) {
+ int[][] output = null;
+ if (null != input) {
+ output = new int[input.length][input[0].length];
+ for (int j = 0; j < output.length; j++) {
+ for (int i = 0; i < output[0].length; i++) {
+ try {
+ output[j][i] = new Integer(input[j][i]).intValue();
+ }
+ catch (NumberFormatException nfe) {
+ output[j][i] = -1;
+ }
+ }
+ }
+ }
+ return output;
+ }
+
+ /**
+ * @param input
+ * @return
+ */
+ private String[][] stripFirstColumn (String[][] input) {
+ String output[][] = null;
+ if (null != input) {
+ output = new String[input.length][input[0].length-1];
+ for (int j = 0; j < output.length; j++) {
+ for (int i = 0; i < output[0].length; i++) {
+ output[j][i] = input[j][i+1];
+ }
+ }
+ }
+ return output;
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadTool.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadTool.java
new file mode 100644
index 0000000000..923bc31ea7
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadTool.java
@@ -0,0 +1,208 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * Otávio Ferranti - Eldorado Research Institute - Bug 255255 [tml][proctools] Add extension points
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.tml.linuxtools.network.IConnectionProvider;
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+import org.eclipse.tml.linuxtools.tools.AbstractNotifier;
+import org.eclipse.tml.linuxtools.tools.IListener;
+import org.eclipse.tml.linuxtools.tools.INotifier;
+import org.eclipse.tml.linuxtools.tools.ITool;
+import org.eclipse.tml.linuxtools.utilities.Extensions;
+import org.eclipse.tml.linuxtools.utilities.ProtocolDescriptor;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class CpuLoadTool extends AbstractNotifier implements IListener, ITool {
+
+ public enum ToolStateEnum {RUNNING, STOPPED, STOP_SCHEDULED};
+
+ private IConnectionProvider connectionProvider = null;
+ private CpuLoadProcessor processor = null;
+ private int delay = 1000;
+
+ private ToolStateEnum toolState = ToolStateEnum.STOPPED;
+
+ private String[] requiredCapabilities = {"GET_FILE"}; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#createConnection(java.lang.String, int, java.lang.String)
+ */
+ public void connect (String host,
+ int port,
+ ProtocolDescriptor protocol) {
+
+ Class<IConnectionProvider> connectionProviderClass =
+ protocol.getConnectionProviderClass();
+
+ try {
+ Object aux = connectionProviderClass.newInstance();
+ connectionProvider = (IConnectionProvider) aux;
+ } catch (InstantiationException ie) {
+ } catch (IllegalAccessException iae) {
+ } catch (ClassCastException cce) {
+ }
+
+ connectionProvider.addListener(this);
+ try {
+ connectionProvider.connect(host, port);
+ } catch (IOException ie) { }
+ processor = new CpuLoadProcessor(connectionProvider);
+
+ processor.addListener(this);
+ toolState = ToolStateEnum.STOPPED;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#closeConnection()
+ */
+ public void disconnect() {
+ if (null != connectionProvider) {
+ try {
+ connectionProvider.disconnect();
+ } catch (IOException ie) {
+ }
+ connectionProvider = null;
+ toolState = ToolStateEnum.STOPPED;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#login(java.lang.String, java.lang.String)
+ */
+ public void login (String user, String password) {
+ try {
+ connectionProvider.login(user, password);
+ } catch (IOException ie) {
+ //TODO: Nothing ?
+ }
+ }
+
+ public List<ProtocolDescriptor> getProtocolsDescriptors() {
+ List <ProtocolDescriptor> pdList = Extensions.findProcotols(requiredCapabilities);
+ return pdList;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.IListener#notify(org.eclipse.tml.linuxtools.tools.INotifier, org.eclipse.tml.linuxtools.network.IConstants.EventCode, java.lang.Object)
+ */
+ public void notify(INotifier notifier, EventCode event, Object result) {
+ try {
+ if (notifier == connectionProvider) {
+ switch (event) {
+ case EVT_PROVIDER_CONNECT_FINISHED:
+ if (OperationCode.SUCCESS == result) {
+ start();
+ }
+ this.notifyListeners(
+ EventCode.EVT_TOOL_CONNECT_FINISHED,
+ result);
+ break;
+ case EVT_PROVIDER_CONNECT_ERROR:
+
+ break;
+ case EVT_PROVIDER_LOGIN_FINISHED:
+ if (OperationCode.SUCCESS == result) {
+ start();
+ }
+ this.notifyListeners(
+ EventCode.EVT_TOOL_LOGIN_FINISHED,
+ result);
+ break;
+ case EVT_PROVIDER_SENDCOMMAND_FINISHED:
+ break;
+ case EVT_PROVIDER_SENDCOMMAND_ERROR:
+ break;
+ case EVT_PROVIDER_SENDDATA_FINISHED:
+ break;
+ case EVT_PROVIDER_SENDDATA_ERROR:
+ break;
+ case EVT_PROVIDER_DISCONNECT_FINISHED:
+ this.notifyListeners(
+ EventCode.EVT_TOOL_DISCONNECT_FINISHED,
+ result);
+ break;
+ }
+ }
+ if (notifier == processor) {
+ switch (event) {
+ case EVT_PROCESSOR_GATHERDATA_FINISHED:
+ if (ToolStateEnum.RUNNING == toolState) {
+ try {
+ notifyListeners(EventCode.EVT_TOOL_REFRESH_VIEW,
+ result);
+ Thread.sleep(delay);
+ processor.gatherData();
+ } catch (InterruptedException ie) {
+ }
+ } else if (ToolStateEnum.STOP_SCHEDULED == toolState) {
+ toolState = ToolStateEnum.STOPPED;
+ }
+ break;
+ case EVT_PROCESSOR_GATHERDATA_ERROR:
+ break;
+ }
+ }
+ } catch (IOException ie) {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#getRefreshDelay()
+ */
+ public int getRefreshDelay() {
+ return this.delay;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#setRefreshDelay(int)
+ */
+ public void setRefreshDelay(int delay) {
+ this.delay = delay;
+ }
+
+ /**
+ *
+ */
+ public void start() {
+ try {
+ if (null != processor) {
+ if (ToolStateEnum.STOPPED == toolState) {
+ toolState = ToolStateEnum.RUNNING;
+ processor.gatherData();
+ } else if (ToolStateEnum.STOP_SCHEDULED == toolState) {
+ toolState = ToolStateEnum.RUNNING;
+ }
+ }
+ } catch (IOException ie) {
+ //TODO: Nothing ?
+ }
+ }
+
+ /**
+ *
+ */
+ public void stop () {
+ toolState = ToolStateEnum.STOP_SCHEDULED;
+ }
+
+ public void refresh() {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadView.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadView.java
new file mode 100644
index 0000000000..bb64d5525c
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadView.java
@@ -0,0 +1,336 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.SWT;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.ViewPart;
+
+import org.eclipse.tml.linuxtools.LinuxToolsPlugin;
+
+import org.eclipse.tml.linuxtools.tools.IListener;
+import org.eclipse.tml.linuxtools.tools.INotifier;
+import org.eclipse.tml.linuxtools.tools.ITool;
+
+import org.eclipse.tml.linuxtools.ui.IToolViewPart;
+import org.eclipse.tml.linuxtools.ui.DialogLogin;
+import org.eclipse.tml.linuxtools.ui.ViewActionConnect;
+import org.eclipse.tml.linuxtools.ui.ViewActionDisconnect;
+import org.eclipse.tml.linuxtools.ui.ViewActionPause;
+import org.eclipse.tml.linuxtools.ui.ViewActionRun;
+
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class CpuLoadView extends ViewPart implements IToolViewPart, IListener {
+
+ private class CpuSorter extends ViewerSorter {
+
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ int result = 0;
+ try {
+ int a = new Integer(((String[]) e1)[0]).intValue();
+ int b = new Integer(((String[]) e2)[0]).intValue();
+ if (a > b) {
+ result = 1;
+ } else if (a < b) {
+ result = -1;
+ };
+ }
+ catch (NumberFormatException nfe) {
+ //TODO: Nothing ?
+ }
+ return result;
+ }
+ }
+ final private String COL_LABEL_CPU = Messages.CpuLoadView_Col_Label_Cpu;
+ final private String COL_LABEL_USER_MODE = Messages.CpuLoadView_Col_Label_User_Mode;
+ final private String COL_LABEL_NICE = Messages.CpuLoadView_Col_Label_Nice;
+ final private String COL_LABEL_SYSTEM = Messages.CpuLoadView_Col_Label_System;
+ final private String COL_LABEL_IDLE = Messages.CpuLoadView_Col_Label_Idle;
+ final private String COL_LABEL_WAIT = Messages.CpuLoadView_Col_Label_Wait;
+ final private String COL_LABEL_HIRQ = Messages.CpuLoadView_Col_label_HIrq;
+
+ final private String COL_LABEL_SIRQ = Messages.CpuLoadView_Col_Label_SIrq;
+
+ private ITool tool = null;
+ private TableViewer viewer;
+
+ private Action runAction;
+ private Action pauseAction;
+ private Action optionsAction;
+ private Action disconnectAction;
+ private Action connectAction;
+
+ private boolean receivedData = false;
+
+ private IPartListener partActivationListener = new IPartListener() {
+ public void partActivated(IWorkbenchPart part) {
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ }
+
+ public void partClosed(IWorkbenchPart part) {
+ if (CpuLoadView.this.getSite().getPart() == part) {
+ ITool tool = CpuLoadView.this.getTool();
+ if (null != tool) {
+ tool.disconnect();
+ }
+ }
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+ }
+ };
+
+ /**
+ * The constructor.
+ */
+ public CpuLoadView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+
+ viewer = new TableViewer(parent, SWT.FULL_SELECTION |
+ SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new CpuLoadViewContentProvider());
+ viewer.setLabelProvider(new CpuLoadViewLabelProvider());
+ viewer.setSorter(new CpuSorter());
+
+ Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_CPU);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_USER_MODE);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_NICE);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_SYSTEM);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_IDLE);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_WAIT);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_HIRQ);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_SIRQ);
+
+ refresh();
+ resize();
+
+ makeActions();
+ // hookDoubleClickAction();
+ addToToolBar();
+
+ getViewSite()
+ .getWorkbenchWindow()
+ .getPartService()
+ .addPartListener(partActivationListener);
+
+ setConnectEnabled(true);
+ setRunPauseEnabled(false, false);
+ }
+
+ private void addToToolBar() {
+ IActionBars actionBars = getViewSite().getActionBars();
+ IToolBarManager toolBarMmanager = actionBars.getToolBarManager();
+ toolBarMmanager.add(runAction);
+ toolBarMmanager.add(pauseAction);
+ toolBarMmanager.add(optionsAction);
+ toolBarMmanager.add(disconnectAction);
+ toolBarMmanager.add(connectAction);
+ }
+
+ private void makeActions() {
+
+ runAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionRun();
+ delegate.init(CpuLoadView.this);
+ delegate.run(this);
+ setRunPauseEnabled(false, true);
+ }
+ };
+ runAction.setToolTipText(Messages.CpuLoadView_Action_Run);
+ runAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_RUN));
+
+ pauseAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionPause();
+ delegate.init(CpuLoadView.this);
+ delegate.run(this);
+ setRunPauseEnabled(true, false);
+ }
+ };
+ pauseAction.setToolTipText(Messages.CpuLoadView_Action_Pause);
+ pauseAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_PAUSE));
+
+ optionsAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionOptions();
+ delegate.init(CpuLoadView.this);
+ delegate.run(this);
+ }
+ };
+ optionsAction.setToolTipText(Messages.CpuLoadView_Action_Options);
+ optionsAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_OPTIONS));
+
+ disconnectAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionDisconnect();
+ delegate.init(CpuLoadView.this);
+ delegate.run(this);
+ }
+ };
+ disconnectAction.setToolTipText(Messages.CpuLoadView_Action_Disconnect);
+ disconnectAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_DISCONNECT));
+
+ connectAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionConnect();
+ delegate.init(CpuLoadView.this);
+ delegate.run(this);
+ }
+ };
+ connectAction.setToolTipText(Messages.CpuLoadView_Action_Connect);
+ connectAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_CONNECT));
+ }
+
+ private void setConnectEnabled(boolean bool) {
+ connectAction.setEnabled(bool);
+ disconnectAction.setEnabled(!bool);
+ }
+
+ private void setRunPauseEnabled(boolean runBool, boolean pauseBool) {
+ runAction.setEnabled(runBool);
+ pauseAction.setEnabled(pauseBool);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.ui.IToolView#getTool()
+ */
+ public ITool getTool() {
+ if(null == tool) {
+ tool = new CpuLoadTool();
+ tool.addListener(this);
+ }
+ return tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IListener#notify(org.eclipse.tml.linuxtools.network.INotifier, org.eclipse.tml.linuxtools.network.IConstants.EventCode, java.lang.Object)
+ */
+ public void notify(INotifier notifier, EventCode event, Object result) {
+ if (notifier == this.tool) {
+ final Object finalResult = result;
+ final EventCode finalEvent = event;
+ final ViewPart finalView = this;
+ final ITool finalTool = this.tool;
+
+ this.getViewSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ switch(finalEvent) {
+ case EVT_TOOL_REFRESH_VIEW:
+ viewer.setInput(finalResult);
+ refresh();
+ if (!receivedData) {
+ resize();
+ receivedData = true;
+ }
+ break;
+ case EVT_TOOL_CONNECT_FINISHED:
+ case EVT_TOOL_LOGIN_FINISHED:
+ switch ((OperationCode)finalResult) {
+ case SUCCESS:
+ setConnectEnabled(false);
+ setRunPauseEnabled(false, true);
+ break;
+ case LOGIN_REQUIRED: {
+ final DialogLogin dialog = new DialogLogin(
+ finalView.getViewSite().getShell(),
+ finalTool, false);
+ dialog.open();
+ }
+ break;
+ case LOGIN_FAILED: {
+ final DialogLogin dialog = new DialogLogin(
+ finalView.getViewSite().getShell(),
+ finalTool, true);
+ dialog.open();
+ }
+ break;
+ }
+ break;
+ case EVT_TOOL_DISCONNECT_FINISHED:
+ setConnectEnabled(true);
+ setRunPauseEnabled(false, false);
+ break;
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ *
+ */
+ public void refresh() {
+ viewer.refresh();
+ }
+
+ /**
+ *
+ */
+ public void resize() {
+ Table table = viewer.getTable();
+ for (int i = 0, n = table.getColumnCount(); i < n; i++) {
+ table.getColumn(i).pack();
+ }
+ }
+
+ /**
+ * @param data
+ */
+ public void setData (Object data) {
+ viewer.setInput(data);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+} \ No newline at end of file
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewContentProvider.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewContentProvider.java
new file mode 100644
index 0000000000..968b005d39
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewContentProvider.java
@@ -0,0 +1,61 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/*
+ * The content provider class is responsible for
+ * providing objects to the view. It can wrap
+ * existing objects in adapters or simply return
+ * objects as-is. These objects may be sensitive
+ * to the current input of the view, or ignore
+ * it and always show the same content
+ * (like Task List, for example).
+ */
+
+/**
+ * @author Otávio Ferranti
+ */
+public class CpuLoadViewContentProvider implements IStructuredContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object parent) {
+ if (parent instanceof String[][]) {
+ return (String[][]) parent;
+ } else {
+ String[][] aux = new String[1][];
+ aux[0] = new String[] {"", "", //$NON-NLS-1$ //$NON-NLS-2$
+ "", "", //$NON-NLS-1$ //$NON-NLS-2$
+ "", "", //$NON-NLS-1$ //$NON-NLS-2$
+ "", ""}; //$NON-NLS-1$ //$NON-NLS-2$
+ return aux;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewLabelProvider.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewLabelProvider.java
new file mode 100644
index 0000000000..9ad1c21ebf
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/CpuLoadViewLabelProvider.java
@@ -0,0 +1,54 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class CpuLoadViewLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object obj, int index) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object obj, int index) {
+ if (obj instanceof String[]) {
+ return getText(((Object[]) obj)[index]);
+ } else {
+ return new String(""); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object obj) {
+ return PlatformUI.getWorkbench().
+ getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
+ }
+}
+
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/DialogOptions.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/DialogOptions.java
new file mode 100644
index 0000000000..187ba65a9a
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/DialogOptions.java
@@ -0,0 +1,109 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import org.eclipse.tml.linuxtools.tools.ITool;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class DialogOptions extends TitleAreaDialog {
+
+ final private String WINDOW_TITLE = Messages.OptionsDialog_Window_Title;
+ final private String WINDOW_MESSAGE = Messages.OptionsDialog_Window_Message;
+ final private String LABEL_REFRESH = Messages.OptionsDialog_Label_Refresh_Rate;
+ final private String LABEL_TIMEUNIT = "ms"; //$NON-NLS-1$
+
+ private Spinner spinner;
+
+ private ITool tool = null;
+
+ /**
+ * The constructor.
+ * @param parent
+ */
+ public DialogOptions(Shell parent, ITool tool) {
+ super(parent);
+ this.tool = tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ setTitle(WINDOW_TITLE);
+ setMessage(WINDOW_MESSAGE);
+
+ Composite dialogArea = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(3, false);
+
+ gridLayout.marginLeft = 7;
+ gridLayout.marginRight = 7;
+
+ dialogArea.setLayout(gridLayout);
+ dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
+ dialogArea.setFont(parent.getFont());
+
+ Label refreshLabel = new Label(dialogArea, SWT.NULL);
+ refreshLabel.setText(LABEL_REFRESH);
+
+ spinner = new Spinner(dialogArea, SWT.BORDER);
+
+ Label timeUnit = new Label(dialogArea, SWT.NULL);
+ timeUnit.setText(LABEL_TIMEUNIT);
+
+ spinner.setMinimum(0);
+ spinner.setMaximum(50000);
+ spinner.setSelection(tool.getRefreshDelay());
+ spinner.setIncrement(100);
+ spinner.setPageIncrement(500);
+ spinner.pack();
+
+ return dialogArea;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
+ */
+ protected Point getInitialSize() {
+ return super.getInitialSize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ tool.setRefreshDelay(spinner.getSelection());
+ super.okPressed();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+ */
+ protected void cancelPressed() {
+ super.cancelPressed();
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.java
new file mode 100644
index 0000000000..c5a3830093
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.java
@@ -0,0 +1,49 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
+ "org.eclipse.tml.linuxtools.tools.cpuload.messages"; //$NON-NLS-1$
+ public static String CpuLoadProcessor_Msg_Executing_the_command;
+ public static String CpuLoadProcessor_Msg_Got_The_Result;
+ public static String CpuLoadView_Action_Connect;
+ public static String CpuLoadView_Action_Disconnect;
+ public static String CpuLoadView_Action_Options;
+ public static String CpuLoadView_Action_Pause;
+ public static String CpuLoadView_Action_Run;
+ public static String CpuLoadView_Col_Label_Cpu;
+ public static String CpuLoadView_Col_label_HIrq;
+ public static String CpuLoadView_Col_Label_Idle;
+ public static String CpuLoadView_Col_Label_Nice;
+ public static String CpuLoadView_Col_Label_SIrq;
+ public static String CpuLoadView_Col_Label_System;
+ public static String CpuLoadView_Col_Label_User_Mode;
+ public static String CpuLoadView_Col_Label_Wait;
+ public static String OptionsDialog_Label_Refresh_Rate;
+ public static String OptionsDialog_Window_Message;
+ public static String OptionsDialog_Window_Title;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.properties b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.properties
new file mode 100644
index 0000000000..4c8f82103a
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages.properties
@@ -0,0 +1,38 @@
+################################################################################
+# Copyright (c) 2008 Motorola Inc.
+# 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
+#
+# Initial Contributors:
+# Otávio Ferranti (Motorola)
+#
+# Contributors:
+# {Name} (company) - description of contribution.
+################################################################################
+
+# NLS_MESSAGEFORMAT_VAR
+# NLS_ENCODING=UTF-8
+
+CpuLoadView_Col_Label_Cpu=Cpu
+CpuLoadView_Col_Label_User_Mode=User
+CpuLoadView_Col_Label_Nice=Nice
+CpuLoadView_Col_Label_System=System
+CpuLoadView_Col_Label_Idle=Idle
+CpuLoadView_Col_Label_Wait=Wait
+CpuLoadView_Col_label_HIrq=HW Irq
+CpuLoadView_Col_Label_SIrq=SW Irq
+
+CpuLoadView_Action_Run=Run
+CpuLoadView_Action_Pause=Pause
+CpuLoadView_Action_Options=Options
+CpuLoadView_Action_Disconnect=Disconnect
+CpuLoadView_Action_Connect=Connect
+
+CpuLoadProcessor_Msg_Executing_the_command=Executing the command:
+CpuLoadProcessor_Msg_Got_The_Result=Got the result:
+
+OptionsDialog_Window_Title=Options
+OptionsDialog_Window_Message=Some options may take effect only after reconnection
+OptionsDialog_Label_Refresh_Rate=Refresh delay:
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages_pt.properties b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages_pt.properties
new file mode 100644
index 0000000000..f052c1b389
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/Messages_pt.properties
@@ -0,0 +1,38 @@
+################################################################################
+# Copyright (c) 2008 Motorola Inc.
+# 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
+#
+# Initial Contributors:
+# Otávio Ferranti (Motorola)
+#
+# Contributors:
+# {Name} (company) - description of contribution.
+################################################################################
+
+# NLS_MESSAGEFORMAT_VAR
+# NLS_ENCODING=UTF-8
+
+CpuLoadView_Col_Label_Cpu=Cpu
+CpuLoadView_Col_Label_User_Mode=Usuário
+CpuLoadView_Col_Label_Nice=Nice
+CpuLoadView_Col_Label_System=Sistema
+CpuLoadView_Col_Label_Idle=Ocioso
+CpuLoadView_Col_Label_Wait=Espera
+CpuLoadView_Col_label_HIrq=Int HW
+CpuLoadView_Col_Label_SIrq=Int SW
+
+CpuLoadView_Action_Run=Executar
+CpuLoadView_Action_Pause=Pausar
+CpuLoadView_Action_Options=Opções
+CpuLoadView_Action_Disconnect=Desconectar
+CpuLoadView_Action_Connect=Conectar
+
+CpuLoadProcessor_Msg_Executing_the_command=Executando o comando:
+CpuLoadProcessor_Msg_Got_The_Result=Resultado obtido:
+
+OptionsDialog_Window_Title=Opções
+OptionsDialog_Window_Message=Algumas opções só terão efeito após reconectar
+OptionsDialog_Label_Refresh_Rate=Intervalo de atualização:
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/ViewActionOptions.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/ViewActionOptions.java
new file mode 100644
index 0000000000..8392868816
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/cpuload/ViewActionOptions.java
@@ -0,0 +1,60 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.cpuload;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.tml.linuxtools.ui.IToolViewPart;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class ViewActionOptions implements IViewActionDelegate {
+
+ private IViewPart targetPart;
+
+ /**
+ * The constructor.
+ */
+ public ViewActionOptions() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ this.targetPart = view;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ final DialogOptions dialog = new DialogOptions(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ ((IToolViewPart) this.targetPart).getTool());
+ dialog.open();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapProcessor.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapProcessor.java
new file mode 100644
index 0000000000..adacf507b8
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapProcessor.java
@@ -0,0 +1,139 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.memorymap;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Scanner;
+import java.util.regex.MatchResult;
+
+import org.eclipse.tml.common.utilities.logger.ILogger;
+
+import org.eclipse.tml.linuxtools.LinuxToolsPlugin;
+import org.eclipse.tml.linuxtools.network.IConstants.CommandCode;
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConnectionProvider;
+import org.eclipse.tml.linuxtools.tools.AbstractNotifier;
+import org.eclipse.tml.linuxtools.tools.IListener;
+import org.eclipse.tml.linuxtools.tools.INotifier;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class MemoryMapProcessor extends AbstractNotifier implements IListener {
+
+ final private String CMD_FETCH_IOMEM = "/proc/iomem"; //$NON-NLS-1$
+ final private String PARSE_PATTERN = "\\s*(\\w{8})-(\\w{8})\\s*:\\s*(.*)"; //$NON-NLS-1$
+
+ final private String MSG_EXECUTING_COMMAND =
+ Messages.MemoryMapProcessor_Msg_Executing_The_Command;
+
+ final private String MSG_GOT_RESULT =
+ Messages.MemoryMapProcessor_Msg_Got_The_Result;
+
+ final private int MAX_COLUMNS = 4;
+ private IConnectionProvider connectionProvider = null;
+
+ private ILogger logger = null;
+
+ /**
+ * The constructor;
+ * @param connectionProvider
+ */
+ public MemoryMapProcessor(IConnectionProvider connectionProvider) {
+ setConnectionProvider(connectionProvider);
+ logger = LinuxToolsPlugin.getLogger();
+ }
+
+ /**
+ * @throws IOException
+ */
+ public void gatherData() throws IOException {
+ connectionProvider.setResponseLength(8192);
+ connectionProvider.sendCommand(CommandCode.FETCH_FILE, this.CMD_FETCH_IOMEM);
+ logger.debug(MSG_EXECUTING_COMMAND + "\n" + this.CMD_FETCH_IOMEM); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IListener#notify(org.eclipse.tml.linuxtools.network.INotifier, org.eclipse.tml.linuxtools.network.IConstants.EventCode, java.lang.Object)
+ */
+ public void notify(INotifier notifier,
+ EventCode event,
+ Object result) {
+ if (notifier == this.connectionProvider &&
+ event == EventCode.EVT_PROVIDER_SENDCOMMAND_FINISHED) {
+ this.connectionProvider.setResponseLength(1024);
+ Object[][] parsedResult = parseIomem((StringBuffer) result);
+ this.notifyListeners(EventCode.EVT_PROCESSOR_GATHERDATA_FINISHED,
+ parsedResult);
+ }
+ }
+
+ /**
+ * @param connectionProvider
+ */
+ public void setConnectionProvider (IConnectionProvider connectionProvider) {
+ if (null != this.connectionProvider) {
+ this.connectionProvider.removeListener(this);
+ }
+ this.connectionProvider = connectionProvider;
+ if (null != this.connectionProvider) {
+ this.connectionProvider.addListener(this);
+ }
+ }
+
+ /**
+ * @param data
+ * @return
+ */
+ private Object[][] parseIomem(StringBuffer data) {
+ logger.debug(MSG_GOT_RESULT + "\n" + data.toString());
+
+ Scanner s1 = new Scanner(data.toString());
+
+ ArrayList<String[]> list = new ArrayList<String[]>();
+
+ int j = 0;
+
+ while (s1.hasNextLine()) {
+ Scanner s2 = new Scanner(s1.nextLine());
+ s2.findInLine(PARSE_PATTERN);
+
+ String[] entry = null;
+ try {
+ MatchResult result = s2.match();
+ entry = new String[MAX_COLUMNS];
+ for (int i = 1; i <= result.groupCount() && i <= MAX_COLUMNS - 1; i++) {
+ entry[i-1] = result.group(i);
+ }
+ entry[MAX_COLUMNS - 1] = new Integer(j).toString();
+ j++;
+ } catch (IllegalStateException ise) {
+ //TODO: Nothing ?
+ }
+
+ s2.close();
+ if (null != entry) {
+ list.add(entry);
+ }
+ }
+ s1.close();
+
+ String[][] retVal = new String[list.size()][MAX_COLUMNS];
+ for (int i = 0; i < retVal.length; i++) {
+ retVal[i] = list.get(i);
+ }
+ return retVal;
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapTool.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapTool.java
new file mode 100644
index 0000000000..048fe4568f
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapTool.java
@@ -0,0 +1,184 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * Otávio Ferranti - Eldorado Research Institute - Bug 255255 [tml][proctools] Add extension points
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.memorymap;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.tml.linuxtools.network.IConnectionProvider;
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+import org.eclipse.tml.linuxtools.tools.AbstractNotifier;
+import org.eclipse.tml.linuxtools.tools.IListener;
+import org.eclipse.tml.linuxtools.tools.INotifier;
+import org.eclipse.tml.linuxtools.tools.ITool;
+import org.eclipse.tml.linuxtools.utilities.Extensions;
+import org.eclipse.tml.linuxtools.utilities.ProtocolDescriptor;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class MemoryMapTool extends AbstractNotifier implements IListener, ITool {
+
+ private IConnectionProvider connectionProvider = null;
+ private MemoryMapProcessor processor = null;
+
+ private String[] requiredCapabilities = {"GET_FILE"}; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.memorymap.iTool#createInstance(java.lang.String, int, java.lang.String)
+ */
+ public void connect (String host,
+ int port,
+ ProtocolDescriptor protocol) {
+
+ Class<IConnectionProvider> connectionProviderClass =
+ protocol.getConnectionProviderClass();
+
+ try {
+ Object aux = connectionProviderClass.newInstance();
+ connectionProvider = (IConnectionProvider) aux;
+ } catch (InstantiationException ie) {
+ } catch (IllegalAccessException iae) {
+ } catch (ClassCastException cce) {
+ }
+
+ connectionProvider.addListener(this);
+ try {
+ connectionProvider.connect(host, port);
+ } catch (IOException ie) { }
+ processor = new MemoryMapProcessor(connectionProvider);
+
+ processor.addListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#closeConnection()
+ */
+ public void disconnect() {
+ if (null != connectionProvider) {
+ try {
+ connectionProvider.disconnect();
+ } catch (IOException ie) {
+ }
+ connectionProvider = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.memorymap.iTool#login(java.lang.String, java.lang.String)
+ */
+ public void login (String user, String password) {
+ try {
+ connectionProvider.login(user, password);
+ } catch (IOException ie) {
+ //TODO: Nothing ?
+ }
+ }
+
+ public List<ProtocolDescriptor> getProtocolsDescriptors() {
+ List <ProtocolDescriptor> pdList = Extensions.findProcotols(requiredCapabilities);
+ return pdList;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.IListener#notify(org.eclipse.tml.linuxtools.tools.INotifier, org.eclipse.tml.linuxtools.network.IConstants.EventCode, java.lang.Object)
+ */
+ public void notify(INotifier notifier, EventCode event, Object result) {
+ try {
+ if (notifier == connectionProvider) {
+ switch (event) {
+ case EVT_PROVIDER_CONNECT_FINISHED:
+ if (OperationCode.SUCCESS == result) {
+ processor.gatherData();
+ }
+ this.notifyListeners(
+ EventCode.EVT_TOOL_CONNECT_FINISHED,
+ result);
+ break;
+ case EVT_PROVIDER_CONNECT_ERROR:
+ break;
+ case EVT_PROVIDER_LOGIN_FINISHED:
+ if (OperationCode.SUCCESS == result) {
+ processor.gatherData();
+ }
+ this.notifyListeners(
+ EventCode.EVT_TOOL_LOGIN_FINISHED,
+ result);
+ break;
+ case EVT_PROVIDER_SENDCOMMAND_FINISHED:
+ break;
+ case EVT_PROVIDER_SENDCOMMAND_ERROR:
+ break;
+ case EVT_PROVIDER_SENDDATA_FINISHED:
+ break;
+ case EVT_PROVIDER_SENDDATA_ERROR:
+ break;
+ case EVT_PROVIDER_DISCONNECT_FINISHED:
+ this.notifyListeners(
+ EventCode.EVT_TOOL_DISCONNECT_FINISHED,
+ result);
+ break;
+ }
+ }
+ if (notifier == processor) {
+ switch (event) {
+ case EVT_PROCESSOR_GATHERDATA_FINISHED:
+ notifyListeners(EventCode.EVT_TOOL_REFRESH_VIEW,
+ result);
+ break;
+ case EVT_PROCESSOR_GATHERDATA_ERROR:
+ break;
+ }
+ }
+ } catch (IOException ie) {
+ }
+ }
+
+ /**
+ *
+ */
+ public void refresh() {
+ try {
+ if (null != processor) {
+ processor.gatherData();
+ }
+ } catch (IOException ie) {
+ //TODO: Nothing ?
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#getRefreshDelay()
+ */
+ public int getRefreshDelay() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.tools.ITool#setRefreshDelay(int)
+ */
+ public void setRefreshDelay(int delay) {
+ // TODO Auto-generated method stub
+ }
+
+ public void start() {
+ // TODO Auto-generated method stub
+ }
+
+ public void stop() {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapVViewLabelProvider.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapVViewLabelProvider.java
new file mode 100644
index 0000000000..0a6f34bcde
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapVViewLabelProvider.java
@@ -0,0 +1,59 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.memorymap;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class MemoryMapVViewLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object obj, int index) {
+ //TODO: Enhance this.
+ if (index == 2) {
+ return getImage(((Object[]) obj)[index]);
+ } else {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object obj, int index) {
+ if (obj instanceof String[]) {
+ return getText(((Object[]) obj)[index]);
+ } else {
+ return new String(""); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object obj) {
+ return PlatformUI.getWorkbench().
+ getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
+ }
+}
+
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapView.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapView.java
new file mode 100644
index 0000000000..9a095f7d1c
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapView.java
@@ -0,0 +1,290 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.memorymap;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.action.*;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.SWT;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.ViewPart;
+
+import org.eclipse.tml.linuxtools.LinuxToolsPlugin;
+import org.eclipse.tml.linuxtools.tools.IListener;
+import org.eclipse.tml.linuxtools.tools.INotifier;
+import org.eclipse.tml.linuxtools.tools.ITool;
+import org.eclipse.tml.linuxtools.ui.IToolViewPart;
+import org.eclipse.tml.linuxtools.ui.DialogLogin;
+import org.eclipse.tml.linuxtools.ui.ViewActionDisconnect;
+import org.eclipse.tml.linuxtools.ui.ViewActionConnect;
+import org.eclipse.tml.linuxtools.ui.ViewActionRefresh;
+import org.eclipse.tml.linuxtools.network.IConstants.EventCode;
+import org.eclipse.tml.linuxtools.network.IConstants.OperationCode;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class MemoryMapView extends ViewPart implements IToolViewPart, IListener {
+
+ private class AddressSorter extends ViewerSorter {
+
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ int result = 0;
+ try {
+ int a = new Integer(((String[]) e1)[MAX_COLUMNS - 1]).intValue();
+ int b = new Integer(((String[]) e2)[MAX_COLUMNS - 1]).intValue();
+ if (a > b) {
+ result = 1;
+ } else if (a < b) {
+ result = -1;
+ };
+ }
+ catch (NumberFormatException nfe) {
+ //TODO: Nothing ?
+ }
+ return result;
+ }
+ }
+ final private String COL_LABEL_ADDRESS_START = Messages.MemoryMapView_Col_Label_Address_Start;
+ final private String COL_LABEL_ADDRESS_END = Messages.MemoryMapView_Col_Label_Address_End;
+ final private String COL_LABEL_REGION = Messages.MemoryMapView_Col_label_Region;
+
+ final private int MAX_COLUMNS = 4;
+
+ private ITool tool = null;
+ private TableViewer viewer;
+
+ private Action refreshAction;
+ private Action disconnectAction;
+ private Action connectAction;
+
+ private IPartListener partActivationListener = new IPartListener() {
+ public void partActivated(IWorkbenchPart part) {
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ }
+
+ public void partClosed(IWorkbenchPart part) {
+ if (MemoryMapView.this.getSite().getPart() == part) {
+ ITool tool = MemoryMapView.this.getTool();
+ if (null != tool) {
+ tool.disconnect();
+ }
+ }
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+ }
+ };
+
+ /**
+ * The constructor.
+ */
+ public MemoryMapView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl(Composite parent) {
+
+ viewer = new TableViewer(parent, SWT.FULL_SELECTION |
+ SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new MemoryMapViewContentProvider());
+ viewer.setLabelProvider(new MemoryMapVViewLabelProvider());
+ viewer.setSorter(new AddressSorter());
+
+ Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_ADDRESS_START);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_ADDRESS_END);
+ new TableColumn(table, SWT.LEFT).setText(COL_LABEL_REGION);
+
+ refresh();
+ resize();
+
+ makeActions();
+ // hookDoubleClickAction();
+ addToToolBar();
+
+ getViewSite()
+ .getWorkbenchWindow()
+ .getPartService()
+ .addPartListener(partActivationListener);
+
+ setConnectEnabled(true);
+ refreshAction.setEnabled(false);
+ }
+
+ private void addToToolBar() {
+ IActionBars actionBars = getViewSite().getActionBars();
+ IToolBarManager toolBarMmanager = actionBars.getToolBarManager();
+ toolBarMmanager.add(refreshAction);
+ toolBarMmanager.add(disconnectAction);
+ toolBarMmanager.add(connectAction);
+ }
+
+ private void makeActions() {
+
+ refreshAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionRefresh();
+ delegate.init(MemoryMapView.this);
+ delegate.run(this);
+ this.setEnabled(false);
+ }
+ };
+ refreshAction.setToolTipText(Messages.MemoryMapView_Action_Refresh);
+ refreshAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_REFRESH));
+
+ disconnectAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionDisconnect();
+ delegate.init(MemoryMapView.this);
+ delegate.run(this);
+ }
+ };
+ disconnectAction.setToolTipText(Messages.MemoryMapView_Action_Disconnect);
+ disconnectAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_DISCONNECT));
+
+ connectAction = new Action() {
+ public void run() {
+ IViewActionDelegate delegate = new ViewActionConnect();
+ delegate.init(MemoryMapView.this);
+ delegate.run(this);
+ }
+ };
+ connectAction.setToolTipText(Messages.MemoryMapView_Action_Connect);
+ connectAction.setImageDescriptor(
+ LinuxToolsPlugin.getDefault().getImageDescriptor(LinuxToolsPlugin.ICON_CONNECT));
+
+ }
+
+ private void setConnectEnabled(boolean bool) {
+ connectAction.setEnabled(bool);
+ disconnectAction.setEnabled(!bool);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.ui.IToolView#getTool()
+ */
+ public ITool getTool() {
+ if(null == tool) {
+ tool = new MemoryMapTool();
+ tool.addListener(this);
+ }
+ return tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tml.linuxtools.network.IListener#notify(org.eclipse.tml.linuxtools.network.INotifier, org.eclipse.tml.linuxtools.network.IConstants.EventCode, java.lang.Object)
+ */
+ public void notify(INotifier notifier, EventCode event, Object result) {
+ if (notifier == tool) {
+ final Object finalResult = result;
+ final EventCode finalEvent = event;
+ final ViewPart finalView = this;
+ final ITool finalTool = this.tool;
+
+ this.getViewSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ switch(finalEvent) {
+ case EVT_TOOL_REFRESH_VIEW:
+ viewer.setInput(finalResult);
+ refreshAction.setEnabled(true);
+ refresh();
+ resize();
+ break;
+ case EVT_TOOL_CONNECT_FINISHED:
+ case EVT_TOOL_LOGIN_FINISHED:
+ switch ((OperationCode)finalResult) {
+ case SUCCESS:
+ setConnectEnabled(false);
+ refreshAction.setEnabled(true);
+ break;
+ case LOGIN_REQUIRED: {
+ final DialogLogin dialog = new DialogLogin(
+ finalView.getViewSite().getShell(),
+ finalTool, false);
+ dialog.open();
+ }
+ break;
+ case LOGIN_FAILED: {
+ final DialogLogin dialog = new DialogLogin(
+ finalView.getViewSite().getShell(),
+ finalTool, true);
+ dialog.open();
+ }
+ break;
+ }
+ break;
+ case EVT_TOOL_DISCONNECT_FINISHED:
+ setConnectEnabled(true);
+ refreshAction.setEnabled(false);
+ break;
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ *
+ */
+ public void refresh() {
+ viewer.refresh();
+ }
+
+ /**
+ *
+ */
+ public void resize() {
+ Table table = viewer.getTable();
+ for (int i = 0, n = table.getColumnCount(); i < n; i++) {
+ table.getColumn(i).pack();
+ }
+ }
+
+ /**
+ * @param data
+ */
+ public void setData (Object data) {
+ viewer.setInput(data);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+} \ No newline at end of file
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapViewContentProvider.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapViewContentProvider.java
new file mode 100644
index 0000000000..e24f886359
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/MemoryMapViewContentProvider.java
@@ -0,0 +1,60 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.memorymap;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/*
+ * The content provider class is responsible for
+ * providing objects to the view. It can wrap
+ * existing objects in adapters or simply return
+ * objects as-is. These objects may be sensitive
+ * to the current input of the view, or ignore
+ * it and always show the same content
+ * (like Task List, for example).
+ */
+
+/**
+ * @author Otávio Ferranti
+ */
+public class MemoryMapViewContentProvider implements IStructuredContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object parent) {
+ if (parent instanceof String[][]) {
+ return (String[][]) parent;
+ } else {
+ String[][] aux = new String[1][];
+ aux[0] = new String[] {"", //$NON-NLS-1$
+ "", //$NON-NLS-1$
+ ""}; //$NON-NLS-1$
+ return aux;
+ }
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.java
new file mode 100644
index 0000000000..41ee2b3956
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.java
@@ -0,0 +1,40 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. 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
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.tools.memorymap;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
+ "org.eclipse.tml.linuxtools.tools.memorymap.messages"; //$NON-NLS-1$
+
+ public static String MemoryMapProcessor_Msg_Executing_The_Command;
+ public static String MemoryMapProcessor_Msg_Got_The_Result;
+ public static String MemoryMapView_Action_Refresh;
+ public static String MemoryMapView_Action_Disconnect;
+ public static String MemoryMapView_Action_Connect;
+ public static String MemoryMapView_Col_Label_Address_End;
+ public static String MemoryMapView_Col_Label_Address_Start;
+ public static String MemoryMapView_Col_label_Region;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.properties b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.properties
new file mode 100644
index 0000000000..26498c4b9b
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages.properties
@@ -0,0 +1,27 @@
+################################################################################
+# Copyright (c) 2008 Motorola Inc.
+# 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
+#
+# Initial Contributors:
+# Otávio Ferranti (Motorola)
+#
+# Contributors:
+# {Name} (company) - description of contribution.
+################################################################################
+
+# NLS_MESSAGEFORMAT_VAR
+# NLS_ENCODING=UTF-8
+
+MemoryMapView_Col_Label_Address_Start=Start
+MemoryMapView_Col_Label_Address_End=End
+MemoryMapView_Col_label_Region=Region name
+
+MemoryMapView_Action_Refresh=Refresh
+MemoryMapView_Action_Disconnect=Disconnect
+MemoryMapView_Action_Connect=Connect
+
+MemoryMapProcessor_Msg_Executing_The_Command=Executing the command:
+MemoryMapProcessor_Msg_Got_The_Result=Got the result:
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages_pt.properties b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages_pt.properties
new file mode 100644
index 0000000000..5e5213a877
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools/src/org/eclipse/sequoyah/linuxtools/tools/memorymap/Messages_pt.properties
@@ -0,0 +1,27 @@
+################################################################################
+# Copyright (c) 2008 Motorola Inc.
+# 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
+#
+# Initial Contributors:
+# Otávio Ferranti (Motorola)
+#
+# Contributors:
+# {Name} (company) - description of contribution.
+################################################################################
+
+# NLS_MESSAGEFORMAT_VAR
+# NLS_ENCODING=UTF-8
+
+MemoryMapView_Col_Label_Address_Start=Início
+MemoryMapView_Col_Label_Address_End=Fim
+MemoryMapView_Col_label_Region=Nome do intervalo
+
+MemoryMapView_Action_Refresh=Atualizar
+MemoryMapView_Action_Disconnect=Desconectar
+MemoryMapView_Action_Connect=Conectar
+
+MemoryMapProcessor_Msg_Executing_The_Command=Executando o comando:
+MemoryMapProcessor_Msg_Got_The_Result=Resultado obtido:

Back to the top