Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2008-05-19 18:38:52 +0000
committereutarass2008-05-19 18:38:52 +0000
commita14d5f1565f99ed710c8c65c24f2408519fe14eb (patch)
tree39adf235616742c9ab8378996a9f92200d3791b3 /plugins/org.eclipse.tm.tcf.debug
parentc77daaffd45e5ddf9d64f728b62d32c7734e5576 (diff)
downloadorg.eclipse.tcf-a14d5f1565f99ed710c8c65c24f2408519fe14eb.tar.gz
org.eclipse.tcf-a14d5f1565f99ed710c8c65c24f2408519fe14eb.tar.xz
org.eclipse.tcf-a14d5f1565f99ed710c8c65c24f2408519fe14eb.zip
Added UI that allows manual configuration of remote TCF peers
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug')
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java8
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFUserDefPeer.java88
2 files changed, 96 insertions, 0 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java
index 6294a5665..80a7ef4b2 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java
@@ -13,7 +13,9 @@ package org.eclipse.tm.internal.tcf.debug;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.tm.internal.tcf.debug.launch.TCFUserDefPeer;
import org.eclipse.tm.internal.tcf.debug.model.TCFBreakpointsModel;
+import org.eclipse.tm.tcf.protocol.Protocol;
import org.osgi.framework.BundleContext;
@@ -37,6 +39,12 @@ public class Activator extends Plugin {
public void start(BundleContext context) throws Exception {
super.start(context);
bp_model = new TCFBreakpointsModel();
+ Protocol.invokeLater(new Runnable() {
+
+ public void run() {
+ TCFUserDefPeer.loadPeers();
+ }
+ });
}
@Override
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFUserDefPeer.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFUserDefPeer.java
new file mode 100644
index 000000000..1a757ad49
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFUserDefPeer.java
@@ -0,0 +1,88 @@
+package org.eclipse.tm.internal.tcf.debug.launch;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.tm.internal.tcf.debug.Activator;
+import org.eclipse.tm.tcf.core.AbstractPeer;
+import org.eclipse.tm.tcf.protocol.IPeer;
+import org.eclipse.tm.tcf.protocol.Protocol;
+
+/**
+ * The class represents manually configured (user defined) TCF peers (targets).
+ * Unlike auto-discovered peers, manually configured ones are persistent -
+ * they exist until explicitly deleted by user.
+ * Eclipse plug-in state storage is used to keep the configuration data.
+ */
+public class TCFUserDefPeer extends AbstractPeer {
+
+ public TCFUserDefPeer(Map<String, String> attrs) {
+ super(attrs);
+ }
+
+ /**
+ * Load manually configured peers from persistent storage.
+ */
+ public static void loadPeers() {
+ try {
+ assert Protocol.isDispatchThread();
+ IPath path = Activator.getDefault().getStateLocation();
+ File f = path.append("peers.ini").toFile();
+ if (!f.exists()) return;
+ HashMap<String,String> attrs = new HashMap<String,String>();
+ BufferedReader rd = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
+ for (;;) {
+ String s = rd.readLine();
+ if (s == null) break;
+ if (s.length() == 0) {
+ new TCFUserDefPeer(attrs);
+ attrs = new HashMap<String,String>();
+ }
+ else {
+ int i = s.indexOf('=');
+ if (i > 0) attrs.put(s.substring(0, i), s.substring(i + 1));
+ }
+ }
+ rd.close();
+ }
+ catch (Exception x) {
+ Activator.log("Cannot read peer list", x);
+ }
+ }
+
+ /**
+ * Save manually configured peers to persistent storage.
+ */
+ public static void savePeers() {
+ try {
+ assert Protocol.isDispatchThread();
+ IPath path = Activator.getDefault().getStateLocation();
+ File f = path.append("peers.ini").toFile();
+ BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), "UTF-8"));
+ for (IPeer peer : Protocol.getLocator().getPeers().values()) {
+ if (peer instanceof TCFUserDefPeer) {
+ Map<String,String> attrs = peer.getAttributes();
+ for (String nm : attrs.keySet()) {
+ wr.write(nm);
+ wr.write('=');
+ wr.write(attrs.get(nm));
+ wr.newLine();
+ }
+ wr.newLine();
+ }
+ }
+ wr.close();
+ }
+ catch (Exception x) {
+ Activator.log("Cannot read peer list", x);
+ }
+ }
+}

Back to the top