Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-12-18 04:00:56 -0500
committerUwe Stieber2011-12-18 04:00:56 -0500
commit1bee2b5b8aa49b326e80d04884d7d188ea156998 (patch)
tree6ff37756a08bb70e0636c2ce8d703856eebe3016 /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views
parent5b5dcf236034b834b3772f3b3bc9145a54c8d2b4 (diff)
downloadorg.eclipse.tcf-1bee2b5b8aa49b326e80d04884d7d188ea156998.tar.gz
org.eclipse.tcf-1bee2b5b8aa49b326e80d04884d7d188ea156998.tar.xz
org.eclipse.tcf-1bee2b5b8aa49b326e80d04884d7d188ea156998.zip
Target Explorer: Add communication monitor console
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/icons/eview16/monitor_console.gifbin0 -> 992 bytes
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/activator/UIPlugin.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/help/IContextHelpIds.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/internal/ImageConsts.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Console.java63
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Factory.java103
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/events/EventListener.java61
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.properties6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/console/Console.java4
12 files changed, 275 insertions, 7 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/META-INF/MANIFEST.MF
index e18a49c70..13645f47c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.tcf.te.ui;bundle-version="1.0.0",
org.eclipse.tcf.te.ui.swt;bundle-version="1.0.0",
org.eclipse.tcf.te.tcf.core.scripting;bundle-version="1.0.0",
+ org.eclipse.tcf.te.tcf.log.core;bundle-version="1.0.0",
org.eclipse.tcf.te.tcf.ui;bundle-version="1.0.0",
org.eclipse.tcf.te.tcf.ui.console;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/icons/eview16/monitor_console.gif b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/icons/eview16/monitor_console.gif
new file mode 100644
index 000000000..1fc2e86b7
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/icons/eview16/monitor_console.gif
Binary files differ
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml
index 15276aa92..d929e39c9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml
@@ -55,6 +55,16 @@
</consolePageParticipant>
</extension>
+ <extension point="org.eclipse.ui.console.consolePageParticipants">
+ <consolePageParticipant
+ class="org.eclipse.tcf.te.tcf.ui.console.PageParticipant"
+ id="org.eclipse.tcf.te.tcf.ui.console.PageParticipant">
+ <enablement>
+ <instanceof value="org.eclipse.tcf.te.tcf.ui.views.monitor.console.Console"/>
+ </enablement>
+ </consolePageParticipant>
+ </extension>
+
<!-- Script Pad menu contributions -->
<extension point="org.eclipse.ui.viewActions">
<viewContribution
@@ -178,4 +188,15 @@
</eventListener>
</extension>
+<!-- Monitor console event listener contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.eventListeners">
+ <eventListener
+ class="org.eclipse.tcf.te.tcf.ui.views.monitor.events.EventListener"
+ forcePluginActivation="true">
+ <eventType
+ class="org.eclipse.tcf.te.tcf.log.core.events.MonitorEvent">
+ </eventType>
+ </eventListener>
+ </extension>
+
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/activator/UIPlugin.java
index 30e7bada8..fd17b6e04 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/activator/UIPlugin.java
@@ -76,6 +76,8 @@ public class UIPlugin extends AbstractUIPlugin {
protected void initializeImageRegistry(ImageRegistry registry) {
URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "scriptpad_console.gif"); //$NON-NLS-1$
registry.put(ImageConsts.SCRIPT_PAD_CONSOLE, ImageDescriptor.createFromURL(url));
+ url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "monitor_console.gif"); //$NON-NLS-1$
+ registry.put(ImageConsts.MONITOR_CONSOLE, ImageDescriptor.createFromURL(url));
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/help/IContextHelpIds.java
index b524c1919..aff7669b2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/help/IContextHelpIds.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/help/IContextHelpIds.java
@@ -22,12 +22,17 @@ public interface IContextHelpIds {
public final static String PREFIX = UIPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$
/**
- * Script Pad console view.
+ * Script Pad console.
*/
- public final static String SCRIPT_PAD_CONSOLE_VIEW = PREFIX + "ScriptPadConsoleView"; //$NON-NLS-1$
+ public final static String SCRIPT_PAD_CONSOLE = PREFIX + "ScriptPadConsole"; //$NON-NLS-1$
/**
* Script Pad error: open failed
*/
public final static String SCRIPT_PAD_ERROR_OPEN_FILE = PREFIX + "ScriptPadErrorOpenFile"; //$NON-NLS-1$
+
+ /**
+ * Communication monitor console.
+ */
+ public final static String MONITOR_CONSOLE = PREFIX + "MonitorConsole"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/internal/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/internal/ImageConsts.java
index 982029b34..9810ae9ea 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/internal/ImageConsts.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/internal/ImageConsts.java
@@ -61,7 +61,12 @@ public interface ImageConsts {
// ***** The image constants *****
/**
- * The key to access the Script Pad console view image.
+ * The key to access the Script Pad console image.
*/
public static final String SCRIPT_PAD_CONSOLE = "ScriptPadConsole"; //$NON-NLS-1$
+
+ /**
+ * The key to access the Monitor console image.
+ */
+ public static final String MONITOR_CONSOLE = "MonitorConsole"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Console.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Console.java
new file mode 100644
index 000000000..3201e5659
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Console.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.monitor.console;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.tcf.ui.console.AbstractConsole;
+import org.eclipse.tcf.te.tcf.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.tcf.ui.views.help.IContextHelpIds;
+import org.eclipse.tcf.te.tcf.ui.views.internal.ImageConsts;
+import org.eclipse.tcf.te.tcf.ui.views.nls.Messages;
+
+/**
+ * Communication monitor console implementation.
+ */
+public class Console extends AbstractConsole {
+
+ /**
+ * Constructor.
+ *
+ * @param peer The peer. Must not be <code>null</code>.
+ */
+ public Console(final IPeer peer) {
+ super(Messages.Monitor_Console_name, UIPlugin.getImageDescriptor(ImageConsts.MONITOR_CONSOLE));
+
+ Assert.isNotNull(peer);
+
+ // Determine name and id of the peer
+ final AtomicReference<String> name = new AtomicReference<String>();
+ final AtomicReference<String> id = new AtomicReference<String>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ name.set(peer.getName());
+ id.set(peer.getID());
+ }
+ };
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ setName(NLS.bind(Messages.Monitor_Console_name_with_peer, name.get(), id.get()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.console.AbstractConsole#getHelpContextId()
+ */
+ @Override
+ public String getHelpContextId() {
+ return IContextHelpIds.MONITOR_CONSOLE;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Factory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Factory.java
new file mode 100644
index 000000000..ce74e91ac
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/console/Factory.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.monitor.console;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+
+/**
+ * Communication monitor console factory implementation.
+ */
+public class Factory {
+ // Map of active consoles per peer
+ private static final Map<IPeer, Console> CONSOLES = new HashMap<IPeer, Console>();
+
+ /**
+ * Show the console. Called by {@link Console}.
+ *
+ * @param peer The peer. Must not be <code>null</code>.
+ * @param createNew If <code>true</code>, a new console instance will be created and returned.
+ *
+ * @return The console instance or <code>null</code>.
+ */
+ public static Console showConsole(IPeer peer, boolean createNew) {
+ Assert.isNotNull(peer);
+ // Get the console for the channel
+ Console console = getConsole(peer, createNew);
+ if (console != null) {
+ // Get the console manager
+ IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
+ // Add the console to the manager if not yet done
+ if (!isConsoleAlreadyAdded(console)) manager.addConsoles(new IConsole[] {console});
+ // Show the console view with the TCF communication monitor console
+ manager.showConsoleView(console);
+ }
+
+ return console;
+ }
+
+ /**
+ * Checks if the given console is already added to the console manager.
+ *
+ * @param console The console. Must not be <code>null</code>.
+ * @return <code>True</code> if the console exist, <code>false</code> otherwise.
+ */
+ private static boolean isConsoleAlreadyAdded(IConsole console) {
+ Assert.isNotNull(console);
+ // Assume the console to be not yet added
+ boolean alreadyAdded = false;
+ // Check all consoles if it is the same instance as the passed in one
+ for (IConsole candidate : ConsolePlugin.getDefault().getConsoleManager().getConsoles()) {
+ if (candidate == console) {
+ alreadyAdded = true;
+ break;
+ }
+ }
+ return alreadyAdded;
+ }
+
+ /**
+ * Returns the communication monitor console instance associated with the given peer.
+ *
+ * @param peer The peer. Must not be <code>null</code>.
+ * @param createNew If <code>true</code>, a new console instance will be created and returned.
+ *
+ * @return The console instance or <code>null</code>.
+ */
+ public static Console getConsole(IPeer peer, boolean createNew) {
+ Assert.isNotNull(peer);
+ // Lookup the peer specific console
+ Console console = CONSOLES.get(peer);
+ if (console == null && createNew) {
+ // Create a new console instance
+ console = new Console(peer);
+ // And store the new console in the map
+ CONSOLES.put(peer, console);
+ }
+
+ return console;
+ }
+
+ /**
+ * Shutdown all known consoles.
+ */
+ public static void shutdown() {
+ // Shutdown all channel specific consoles
+ for (Console console : CONSOLES.values()) console.shutdown();
+ // Clear the map
+ CONSOLES.clear();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/events/EventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/events/EventListener.java
new file mode 100644
index 000000000..e483c7a68
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/monitor/events/EventListener.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.monitor.events;
+
+import java.util.EventObject;
+
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.tcf.log.core.events.MonitorEvent;
+import org.eclipse.tcf.te.tcf.ui.views.monitor.console.Console;
+import org.eclipse.tcf.te.tcf.ui.views.monitor.console.Factory;
+import org.eclipse.tcf.te.ui.events.AbstractEventListener;
+
+/**
+ * Communication monitor console event listener
+ */
+public class EventListener extends AbstractEventListener {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (event instanceof MonitorEvent) {
+ MonitorEvent monitorEvent = (MonitorEvent)event;
+
+ // Get the event type and message
+ MonitorEvent.Type type = monitorEvent.getType();
+ MonitorEvent.Message message = monitorEvent.getMessage();
+
+ switch (type) {
+ case OPEN:
+ break;
+ case CLOSE:
+ // Channel close messages are logged only if there is an error
+ if (message != null && message.text != null && !message.text.contains("(error=null)")) { //$NON-NLS-1$
+ Console console = Factory.showConsole((IPeer)monitorEvent.getSource(), true);
+ if (console != null) {
+ // Message type 'R' is an unknown type and will lead to print the
+ // message text using the error color.
+ console.appendMessage('R', message.text);
+ }
+ }
+ break;
+ case ACTIVITY:
+ Console console = Factory.showConsole((IPeer)monitorEvent.getSource(), true);
+ if (console != null && message != null) {
+ console.appendMessage(message.type, message.text);
+ }
+ break;
+ }
+ }
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.java
index 7cd7327fc..d5ad2f1ff 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.java
@@ -29,7 +29,10 @@ public class Messages extends NLS {
// **** Declare externalized string id's down here *****
- public static String Console_name;
+ public static String ScriptPad_Console_name;
+
+ public static String Monitor_Console_name;
+ public static String Monitor_Console_name_with_peer;
public static String ScriptPad_error_title;
public static String ScriptPad_error_openFile;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.properties
index 7e3068eea..5614f5e16 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/nls/Messages.properties
@@ -3,8 +3,12 @@
# Externalized Strings.
#
-Console_name=Script Pad Console
+ScriptPad_Console_name=Script Pad Console
+
+Monitor_Console_name=Monitor Console
+Monitor_Console_name_with_peer=Monitor Console: {0} [{1}]
ScriptPad_error_title=Error
ScriptPad_error_openFile=Failed to open file ''{0}''.\n\nPossible cause:\n{1}
ScriptPad_error_saveFile=Failed to save file ''{0}''.\n\nPossible cause:\n{1}
+
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/console/Console.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/console/Console.java
index a67ccc523..65b3d7fb8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/console/Console.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/console/Console.java
@@ -24,7 +24,7 @@ public class Console extends AbstractConsole {
* Constructor.
*/
public Console() {
- super(Messages.Console_name, UIPlugin.getImageDescriptor(ImageConsts.SCRIPT_PAD_CONSOLE));
+ super(Messages.ScriptPad_Console_name, UIPlugin.getImageDescriptor(ImageConsts.SCRIPT_PAD_CONSOLE));
}
/* (non-Javadoc)
@@ -32,6 +32,6 @@ public class Console extends AbstractConsole {
*/
@Override
public String getHelpContextId() {
- return IContextHelpIds.SCRIPT_PAD_CONSOLE_VIEW;
+ return IContextHelpIds.SCRIPT_PAD_CONSOLE;
}
}

Back to the top