Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-11-09 11:03:28 +0000
committerTobias Schwarz2012-11-09 11:03:28 +0000
commit6535aaec17b30ef774bc430900e902a4930eeb1d (patch)
tree6445e1b4ecfdf43eff3249e63df16b522b4211df /target_explorer
parent43c76cddca331f5cf3bd3aff837c1c9a6299b2dc (diff)
downloadorg.eclipse.tcf-6535aaec17b30ef774bc430900e902a4930eeb1d.tar.gz
org.eclipse.tcf-6535aaec17b30ef774bc430900e902a4930eeb1d.tar.xz
org.eclipse.tcf-6535aaec17b30ef774bc430900e902a4930eeb1d.zip
[Target Explorer] automatically import and export remote debugger launch
config when peer is imported/exported
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml23
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchConfigAttributesPersistenceDelegate.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListPersistenceDelegate.java548
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceDelegate.java125
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/URIPersistenceService.java238
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IExportPersistenceService.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IImportPersistenceService.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java67
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java74
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java12
20 files changed, 696 insertions, 540 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
index adbf37550..756dde536 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
@@ -128,20 +128,19 @@
delegateId="org.eclipse.tcf.te.launch.core.persistence.gson.launchConfigAttributes"
id="org.eclipse.tcf.te.launch.core.binding.gson.launchConfigAttributes">
<enablement>
- <with variable="container">
+ <and>
+ <with variable="containerClass">
+ <equals value="java.lang.String"/>
+ </with>
<or>
- <instanceof value="java.lang.String"/>
- <and>
- <instanceof value="java.lang.Class"/>
- <with variable="containerClass">
- <equals value="java.lang.String"/>
- </with>
- </and>
+ <with variable="context">
+ <instanceof value="org.eclipse.debug.core.ILaunchConfiguration"/>
+ </with>
+ <with variable="contextClass">
+ <equals value="org.eclipse.debug.core.ILaunchConfigurationWorkingCopy"/>
+ </with>
</or>
- </with>
- <with variable="context">
- <instanceof value="org.eclipse.debug.core.ILaunchConfiguration"/>
- </with>
+ </and>
</enablement>
</binding>
</extension>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchConfigAttributesPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchConfigAttributesPersistenceDelegate.java
index 5722a78b4..2fc1317b5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchConfigAttributesPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonLaunchConfigAttributesPersistenceDelegate.java
@@ -61,6 +61,7 @@ public class GsonLaunchConfigAttributesPersistenceDelegate extends GsonMapPersis
if (context instanceof ILaunchConfigurationWorkingCopy) {
((ILaunchConfigurationWorkingCopy)context).setAttributes(map);
}
+
return context;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListPersistenceDelegate.java
index ea74b65b0..a7e74f11d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListPersistenceDelegate.java
@@ -1,274 +1,274 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.launch.core.persistence;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
-import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
-
-/**
- * Item list persistence delegate.
- */
-public abstract class AbstractItemListPersistenceDelegate<ItemType> {
-
- private final String tagName;
- private final String key;
-
- public AbstractItemListPersistenceDelegate(String tagName, String key) {
- super();
-
- Assert.isNotNull(tagName);
- Assert.isNotNull(key);
- this.tagName = tagName;
- this.key = key;
- }
-
- /**
- * Saves the selectedr items to the specified launch configuration working copy. If the
- * selected items are <code>null</code> or empty, the attribute will be removed from
- * the specified launch configuration working copy.
- * @param <ItemType>
- *
- * @param wc The launch configuration working copy. Must not be <code>null</code>.
- * @param items The items to save or <code>null</code>.
- */
- public final void setItems(ILaunchConfigurationWorkingCopy wc, ItemType[] items) {
- Assert.isNotNull(wc);
-
- if (items == null || items.length == 0) {
- DefaultPersistenceDelegate.setAttribute(wc, key, (String)null);
- return;
- }
-
- // Get the encoded XML representation
- String xml = encodeItems(items);
- // And save them to the launch configuration. If XML == null, the
- // items will be removed from the launch configuration
- DefaultPersistenceDelegate.setAttribute(wc, key, xml);
- }
-
- /**
- * Saves the selected items to the specified launch specification. If the selected
- * items are <code>null</code> or empty, the attribute will be removed from the
- * specified launch specification.
- *
- * @param launchSpec The launch specification. Must not be <code>null</code>.
- * @param items The items to save or <code>null</code>.
- */
- public final void setItems(ILaunchSpecification launchSpec, ItemType[] items) {
- Assert.isNotNull(launchSpec);
-
- if (items == null || items.length == 0) {
- launchSpec.removeAttribute(key);
- return;
- }
-
- // Get the encoded XML representation
- String xml = encodeItems(items);
- // And save them to the launch specification. If XML == null, the
- // items will be removed from the launch specification
- launchSpec.addAttribute(key, xml);
- }
-
- /**
- * Writes the given items into a string encoded in XML.
- *
- * @param items The items to encode. Must not be <code>null</code>.
- * @return The full XML representation of the given items or <code>null</code>.
- */
- public final String encodeItems(ItemType[] items) {
- Assert.isNotNull(items);
-
- // The final result
- String result = null;
-
- // First, we write the selected items as XML representation into a string
- StringWriter writer = new StringWriter();
-
- try {
- // Write the header and get the initial indentation
- String indentation = writeHeader(writer);
- // Iterate over the given selected items and write them out.
- for (ItemType item : items) {
- writeItem(writer, indentation, item);
- }
- // Write the footer
- writeFooter(writer);
-
- // Convert into a string
- result = writer.toString();
- }
- catch (IOException e) {
- // Export to the string writer failed --> remove attribute from launch configuration
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- result = null;
- }
- finally {
- try {
- writer.close();
- }
- catch (IOException e) { /* ignored on purpose */
- }
- }
-
- return result;
- }
-
- /**
- * Writes the header to the given writer and returns the indentation to be used for following
- * elements.
- *
- * @param writer The writer instance. Must not be <code>null</code>.
- * @throws IOException in case the write failed.
- */
- private String writeHeader(Writer writer) throws IOException {
- Assert.isNotNull(writer);
- writer.write("<" + tagName + "s>\n"); //$NON-NLS-1$ //$NON-NLS-2$
- return "\t"; //$NON-NLS-1$
- }
-
- /**
- * Writes the footer to the given writer and returns the indentation to be used for following
- * elements.
- *
- * @param writer The writer instance. Must not be <code>null</code>.
- * @throws IOException in case the write failed.
- */
- private String writeFooter(Writer writer) throws IOException {
- Assert.isNotNull(writer);
- writer.write("</" + tagName + "s>\n"); //$NON-NLS-1$ //$NON-NLS-2$
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Writes the item to the given writer.
- *
- * @param writer The writer instance. Must not be <code>null</code>.
- * @param indentation The indentation to prefix each exported line with. Must not be <code>null</code>.
- * @param item The item instance. Must not be <code>null</code>.
- *
- * @throws IOException in case the write failed.
- */
- private void writeItem(Writer writer, String indentation, ItemType item) throws IOException {
- Assert.isNotNull(writer);
- Assert.isNotNull(indentation);
- Assert.isNotNull(item);
-
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(item, String.class, false);
- if (delegate != null) {
- writer.write(indentation + "<" + tagName + " " + AbstractItemListXMLParser.ATTR_TYPE + "=\"" + delegate.getPersistedClass(item).getName() + "\">\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- writer.write(indentation + "\t" + delegate.write(item, String.class, null) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- writer.write(indentation + "</" + tagName + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Reads the selected items from the given XML encoded string.
- *
- * @param encodedItems The selected items encoded as XML string. Must not be <code>null</code>.
- * @return The selected items or an empty array.
- */
- public final List<ItemType> decodeItems(String encodedItems) {
- Assert.isNotNull(encodedItems);
-
- List<ItemType> items = new ArrayList<ItemType>();
-
- if (!"".equals(encodedItems.trim())) { //$NON-NLS-1$
- // We have to parse the items from the string
- InputStream input = new ByteArrayInputStream(encodedItems.getBytes());
- // Instantiate the XML parser
- AbstractItemListXMLParser<ItemType> xmlParser = getXMLParser();
- xmlParser.initXMLParser();
- xmlParser.setItems(items);
- try {
- xmlParser.getXMLReader().parse(input, xmlParser);
- }
- catch (Exception e) {
- // Import failed --> remove attribute from launch configuration
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- items = null;
- }
- }
-
- return items;
- }
-
- protected abstract AbstractItemListXMLParser<ItemType> getXMLParser();
-
- /**
- * Returns the list of configured items from the given launch configuration.
- * <p>
- * If the given launch configuration is <code>null</code> and the method will return an empty
- * array.
- *
- * @param configuration The launch configuration or <code>null</code>.
- * @param ItemType
- * @return The list of configured items or an empty array.
- */
- public final List<ItemType> getItems(ILaunchConfiguration configuration) {
- List<ItemType> items = new ArrayList<ItemType>();
-
- if (configuration != null) {
- // Read the attribute from the launch configuration
- String encodedItems = DefaultPersistenceDelegate.getAttribute(configuration, key, (String) null);
- if (encodedItems != null) {
- items = decodeItems(encodedItems);
- }
- }
-
- return items;
- }
-
- /**
- * Returns the list of configured items from the given launch specification.
- * <p>
- * If the given launch specification is <code>null</code> and the method will return an empty
- * array.
- *
- * @param launchSpec The launch specification or <code>null</code>.
- * @return The list of configured items or an empty array.
- */
- public final List<ItemType> getItems(ILaunchSpecification launchSpec) {
- List<ItemType> items = new ArrayList<ItemType>();
-
- if (launchSpec != null) {
- // Read the attribute from the launch specification
- String encodedItems = (String) launchSpec.getAttribute(key, null);
- if (encodedItems != null) {
- items = decodeItems(encodedItems);
- }
- }
-
- return items;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 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.launch.core.persistence;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+
+/**
+ * Item list persistence delegate.
+ */
+public abstract class AbstractItemListPersistenceDelegate<ItemType> {
+
+ private final String tagName;
+ private final String key;
+
+ public AbstractItemListPersistenceDelegate(String tagName, String key) {
+ super();
+
+ Assert.isNotNull(tagName);
+ Assert.isNotNull(key);
+ this.tagName = tagName;
+ this.key = key;
+ }
+
+ /**
+ * Saves the selectedr items to the specified launch configuration working copy. If the
+ * selected items are <code>null</code> or empty, the attribute will be removed from
+ * the specified launch configuration working copy.
+ * @param <ItemType>
+ *
+ * @param wc The launch configuration working copy. Must not be <code>null</code>.
+ * @param items The items to save or <code>null</code>.
+ */
+ public final void setItems(ILaunchConfigurationWorkingCopy wc, ItemType[] items) {
+ Assert.isNotNull(wc);
+
+ if (items == null || items.length == 0) {
+ DefaultPersistenceDelegate.setAttribute(wc, key, (String)null);
+ return;
+ }
+
+ // Get the encoded XML representation
+ String xml = encodeItems(items);
+ // And save them to the launch configuration. If XML == null, the
+ // items will be removed from the launch configuration
+ DefaultPersistenceDelegate.setAttribute(wc, key, xml);
+ }
+
+ /**
+ * Saves the selected items to the specified launch specification. If the selected
+ * items are <code>null</code> or empty, the attribute will be removed from the
+ * specified launch specification.
+ *
+ * @param launchSpec The launch specification. Must not be <code>null</code>.
+ * @param items The items to save or <code>null</code>.
+ */
+ public final void setItems(ILaunchSpecification launchSpec, ItemType[] items) {
+ Assert.isNotNull(launchSpec);
+
+ if (items == null || items.length == 0) {
+ launchSpec.removeAttribute(key);
+ return;
+ }
+
+ // Get the encoded XML representation
+ String xml = encodeItems(items);
+ // And save them to the launch specification. If XML == null, the
+ // items will be removed from the launch specification
+ launchSpec.addAttribute(key, xml);
+ }
+
+ /**
+ * Writes the given items into a string encoded in XML.
+ *
+ * @param items The items to encode. Must not be <code>null</code>.
+ * @return The full XML representation of the given items or <code>null</code>.
+ */
+ public final String encodeItems(ItemType[] items) {
+ Assert.isNotNull(items);
+
+ // The final result
+ String result = null;
+
+ // First, we write the selected items as XML representation into a string
+ StringWriter writer = new StringWriter();
+
+ try {
+ // Write the header and get the initial indentation
+ String indentation = writeHeader(writer);
+ // Iterate over the given selected items and write them out.
+ for (ItemType item : items) {
+ writeItem(writer, indentation, item);
+ }
+ // Write the footer
+ writeFooter(writer);
+
+ // Convert into a string
+ result = writer.toString();
+ }
+ catch (IOException e) {
+ // Export to the string writer failed --> remove attribute from launch configuration
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ result = null;
+ }
+ finally {
+ try {
+ writer.close();
+ }
+ catch (IOException e) { /* ignored on purpose */
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Writes the header to the given writer and returns the indentation to be used for following
+ * elements.
+ *
+ * @param writer The writer instance. Must not be <code>null</code>.
+ * @throws IOException in case the write failed.
+ */
+ private String writeHeader(Writer writer) throws IOException {
+ Assert.isNotNull(writer);
+ writer.write("<" + tagName + "s>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return "\t"; //$NON-NLS-1$
+ }
+
+ /**
+ * Writes the footer to the given writer and returns the indentation to be used for following
+ * elements.
+ *
+ * @param writer The writer instance. Must not be <code>null</code>.
+ * @throws IOException in case the write failed.
+ */
+ private String writeFooter(Writer writer) throws IOException {
+ Assert.isNotNull(writer);
+ writer.write("</" + tagName + "s>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Writes the item to the given writer.
+ *
+ * @param writer The writer instance. Must not be <code>null</code>.
+ * @param indentation The indentation to prefix each exported line with. Must not be <code>null</code>.
+ * @param item The item instance. Must not be <code>null</code>.
+ *
+ * @throws IOException in case the write failed.
+ */
+ private void writeItem(Writer writer, String indentation, ItemType item) throws IOException {
+ Assert.isNotNull(writer);
+ Assert.isNotNull(indentation);
+ Assert.isNotNull(item);
+
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(item, String.class);
+ if (delegate != null) {
+ writer.write(indentation + "<" + tagName + " " + AbstractItemListXMLParser.ATTR_TYPE + "=\"" + delegate.getPersistedClass(item).getName() + "\">\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ writer.write(indentation + "\t" + delegate.write(item, String.class) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.write(indentation + "</" + tagName + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Reads the selected items from the given XML encoded string.
+ *
+ * @param encodedItems The selected items encoded as XML string. Must not be <code>null</code>.
+ * @return The selected items or an empty array.
+ */
+ public final List<ItemType> decodeItems(String encodedItems) {
+ Assert.isNotNull(encodedItems);
+
+ List<ItemType> items = new ArrayList<ItemType>();
+
+ if (!"".equals(encodedItems.trim())) { //$NON-NLS-1$
+ // We have to parse the items from the string
+ InputStream input = new ByteArrayInputStream(encodedItems.getBytes());
+ // Instantiate the XML parser
+ AbstractItemListXMLParser<ItemType> xmlParser = getXMLParser();
+ xmlParser.initXMLParser();
+ xmlParser.setItems(items);
+ try {
+ xmlParser.getXMLReader().parse(input, xmlParser);
+ }
+ catch (Exception e) {
+ // Import failed --> remove attribute from launch configuration
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ items = null;
+ }
+ }
+
+ return items;
+ }
+
+ protected abstract AbstractItemListXMLParser<ItemType> getXMLParser();
+
+ /**
+ * Returns the list of configured items from the given launch configuration.
+ * <p>
+ * If the given launch configuration is <code>null</code> and the method will return an empty
+ * array.
+ *
+ * @param configuration The launch configuration or <code>null</code>.
+ * @param ItemType
+ * @return The list of configured items or an empty array.
+ */
+ public final List<ItemType> getItems(ILaunchConfiguration configuration) {
+ List<ItemType> items = new ArrayList<ItemType>();
+
+ if (configuration != null) {
+ // Read the attribute from the launch configuration
+ String encodedItems = DefaultPersistenceDelegate.getAttribute(configuration, key, (String) null);
+ if (encodedItems != null) {
+ items = decodeItems(encodedItems);
+ }
+ }
+
+ return items;
+ }
+
+ /**
+ * Returns the list of configured items from the given launch specification.
+ * <p>
+ * If the given launch specification is <code>null</code> and the method will return an empty
+ * array.
+ *
+ * @param launchSpec The launch specification or <code>null</code>.
+ * @return The list of configured items or an empty array.
+ */
+ public final List<ItemType> getItems(ILaunchSpecification launchSpec) {
+ List<ItemType> items = new ArrayList<ItemType>();
+
+ if (launchSpec != null) {
+ // Read the attribute from the launch specification
+ String encodedItems = (String) launchSpec.getAttribute(key, null);
+ if (encodedItems != null) {
+ items = decodeItems(encodedItems);
+ }
+ }
+
+ return items;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java
index 0203d7265..fe3b6dcc8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java
@@ -152,10 +152,10 @@ public abstract class AbstractItemListXMLParser<ItemType> extends DefaultHandler
}
if (clazz != null) {
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(clazz, lastData, false);
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(clazz, lastData);
if (delegate != null) {
try {
- ItemType item = (ItemType)delegate.read(getReadClass(), lastData, null);
+ ItemType item = (ItemType)delegate.read(getReadClass(), lastData);
if (items != null && !items.contains(item)) {
items.add(item);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
index b89b29d3f..8dd39d08b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
@@ -96,16 +96,15 @@ public class PersistenceManager extends AbstractExtensionPointManager<IPersisten
* delegate with the specified id is registered, <code>null</code> is returned.
*
* @param id The unique id of the persistence delegate or <code>null</code>
- * @param unique If <code>true</code>, the method returns new instances of the persistence delegate contribution.
*
* @return The persistence delegate instance or <code>null</code>.
*/
- protected IPersistenceDelegate getDelegate(String id, boolean unique) {
+ protected IPersistenceDelegate getDelegate(String id) {
IPersistenceDelegate contribution = null;
if (getExtensions().containsKey(id)) {
ExecutableExtensionProxy<IPersistenceDelegate> proxy = getExtensions().get(id);
// Get the extension instance
- contribution = unique ? proxy.newInstance() : proxy.getInstance();
+ contribution = proxy.getInstance();
}
return contribution;
@@ -119,7 +118,7 @@ public class PersistenceManager extends AbstractExtensionPointManager<IPersisten
* @param container The persistence container or <code>null</code>.
* @return The persistence delegate which is enabled or <code>null</code>.
*/
- public IPersistenceDelegate getDelegate(Object context, Object container, boolean unique) {
+ public IPersistenceDelegate getDelegate(Object context, Object container) {
Assert.isNotNull(context);
List<IPersistenceDelegate> delegates = new ArrayList<IPersistenceDelegate>();
@@ -127,7 +126,7 @@ public class PersistenceManager extends AbstractExtensionPointManager<IPersisten
// Get the list of applicable bindings
PersistenceDelegateBinding[] bindings = PersistenceDelegateBindingExtensionPointManager.getInstance().getApplicableBindings(context, container);
for (PersistenceDelegateBinding binding : bindings) {
- IPersistenceDelegate delegate = getDelegate(binding.getDelegateId(), unique);
+ IPersistenceDelegate delegate = getDelegate(binding.getDelegateId());
if (delegate != null && !delegates.contains(delegate)) {
delegates.add(delegate);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java
index 8427fcdee..737183b5b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java
@@ -77,10 +77,10 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#write(java.lang.Object, java.lang.Object, java.lang.String)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#write(java.lang.Object, java.lang.Object)
*/
@Override
- public final Object write(Object context, Object container, String key) throws IOException {
+ public final Object write(Object context, Object container) throws IOException {
Assert.isNotNull(context);
Assert.isNotNull(container);
@@ -118,7 +118,7 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
}
}
}
- else if (container instanceof String || String.class.equals(container)) {
+ else if (String.class.equals(container)) {
Gson gson = new GsonBuilder().create();
container = gson.toJson(internalToMap(context));
@@ -154,10 +154,10 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#read(java.lang.Object, java.lang.Object, java.lang.String)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#read(java.lang.Object, java.lang.Object)
*/
@Override
- public final Object read(Object context, Object container, String key) throws IOException {
+ public final Object read(Object context, Object container) throws IOException {
Assert.isNotNull(container);
Gson gson = new GsonBuilder().create();
@@ -208,10 +208,10 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#delete(java.lang.Object, java.lang.Object, java.lang.String)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#delete(java.lang.Object, java.lang.Object)
*/
@Override
- public boolean delete(Object context, Object container, String key) throws IOException {
+ public boolean delete(Object context, Object container) throws IOException {
Assert.isNotNull(container);
if (container instanceof URI) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceDelegate.java
index f0392a452..bf8a72c70 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceDelegate.java
@@ -1,64 +1,61 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 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.runtime.persistence.interfaces;
-
-import java.io.IOException;
-
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
-
-/**
- * Interface to be implemented by persistence delegates.
- */
-public interface IPersistenceDelegate extends IExecutableExtension {
-
- /**
- * Writes the given context to the given persistence container using the key.
- * If the container does not exist yet, the class needs to be given.
- *
- * @param context The context to persist. Must not be <code>null</code>.
- * @param container The persistence container or class for a new one. Must not be <code>null</code>.
- * @param key The key for the context inside the container or <code>null</code>.
- *
- * @return The new or updated container instance.
- */
- public Object write(Object context, Object container, String key) throws IOException;
-
- /**
- * Get the class or interface for the context.
- *
- * @param context The context to persist. Must not be <code>null</code>.
- * @return The class or interface for the given context.
- */
- public Class<?> getPersistedClass(Object context);
-
- /**
- * Reads the context from the given persistence container.
- * If the context does not exist yet, the class needs to be given.
- *
- * @param context The context to update or class for a new context. Must not be <code>null</code>.
- * @param container The persistence container. Must not be <code>null</code>.
- * @param key The key for the context inside the container or <code>null</code>.
- *
- * @return The new or updated context instance.
- */
- public Object read(Object context, Object container, String key) throws IOException;
-
- /**
- * Deletes the given context inside the container or the whole container.
- *
- * @param context The context to delete inside the storage or <code>null</code>.
- * @param container The persistence container. Must not be <code>null</code>.
- * @param key The key for the context inside the container or <code>null</code>.
- *
- * @return <code>True</code> if the persistence context or the whole storage was successfully deleted;
- * <code>false</code> otherwise.
- */
- public boolean delete(Object context, Object container, String key) throws IOException;
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.runtime.persistence.interfaces;
+
+import java.io.IOException;
+
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+
+/**
+ * Interface to be implemented by persistence delegates.
+ */
+public interface IPersistenceDelegate extends IExecutableExtension {
+
+ /**
+ * Writes the given context to the given persistence container using the key.
+ * If the container does not exist yet, the class needs to be given.
+ *
+ * @param context The context to persist. Must not be <code>null</code>.
+ * @param container The persistence container or class for a new one. Must not be <code>null</code>.
+ *
+ * @return The new or updated container instance.
+ */
+ public Object write(Object context, Object container) throws IOException;
+
+ /**
+ * Get the class or interface for the context.
+ *
+ * @param context The context to persist. Must not be <code>null</code>.
+ * @return The class or interface for the given context.
+ */
+ public Class<?> getPersistedClass(Object context);
+
+ /**
+ * Reads the context from the given persistence container.
+ * If the context does not exist yet, the class needs to be given.
+ *
+ * @param context The context to update or class for a new context. Must not be <code>null</code>.
+ * @param container The persistence container. Must not be <code>null</code>.
+ *
+ * @return The new or updated context instance.
+ */
+ public Object read(Object context, Object container) throws IOException;
+
+ /**
+ * Deletes the given context inside the container or the whole container.
+ *
+ * @param context The context to delete inside the storage or <code>null</code>.
+ * @param container The persistence container. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the persistence context or the whole storage was successfully deleted;
+ * <code>false</code> otherwise.
+ */
+ public boolean delete(Object context, Object container) throws IOException;
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/URIPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/URIPersistenceService.java
index 5308aab3c..91cb851bd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/URIPersistenceService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/URIPersistenceService.java
@@ -1,119 +1,119 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 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.runtime.persistence.services;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
-import org.eclipse.tcf.te.runtime.services.AbstractService;
-
-/**
- * Persistence service implementation.
- */
-public class URIPersistenceService extends AbstractService implements IURIPersistenceService {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#write(java.lang.Object, java.net.URI)
- */
- @Override
- public void write(Object context, URI uri) throws IOException {
- Assert.isNotNull(context);
-
- uri = uri != null ? uri : getURI(context);
-
- // Determine the persistence delegate
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri, false);
- // If the persistence delegate could not be determined, throw an IOException
- if (delegate == null) {
- throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Pass on to the delegate for writing
- delegate.write(context, uri, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#read(java.lang.Object, java.net.URI)
- */
- @Override
- public Object read(Object context, URI uri) throws IOException {
- Assert.isNotNull(context);
-
- uri = uri != null ? uri : getURI(context);
-
- // Determine the persistence delegate
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri, false);
- // If the persistence delegate could not be determined, throw an IOException
- if (delegate == null) {
- throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Pass on to the delegate for reading
- return delegate.read(context, uri, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#delete(java.lang.Object, java.net.URI)
- */
- @Override
- public boolean delete(Object context, URI uri) throws IOException {
- Assert.isNotNull(context);
-
- uri = uri != null ? uri : getURI(context);
-
- // Determine the persistence delegate
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri, false);
- // If the persistence delegate could not be determined, throw an IOException
- if (delegate == null) {
- throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return delegate.delete(context, uri, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#getURI(java.lang.Object)
- */
- @Override
- public URI getURI(Object context) throws IOException {
- Assert.isNotNull(context);
-
- // Determine the persistable element for the given data object
- IPersistableURIProvider persistableURIProvider = context instanceof IPersistableURIProvider ? (IPersistableURIProvider)context : null;
- // If the element isn't a persistable by itself, try to adapt the element
- if (persistableURIProvider == null) {
- persistableURIProvider = context instanceof IAdaptable ? (IPersistableURIProvider) ((IAdaptable)context).getAdapter(IPersistableURIProvider.class) : null;
- }
- if (persistableURIProvider == null) {
- persistableURIProvider = (IPersistableURIProvider) Platform.getAdapterManager().getAdapter(context, IPersistableURIProvider.class);
- }
-
- // If the persistable could be still not determined, throw an IOException
- if (persistableURIProvider == null) {
- throw new IOException("'context' must be adaptable to IPersistableURIProvider."); //$NON-NLS-1$
- }
-
- URI uri = persistableURIProvider.getURI(context);
-
- if (uri == null) {
- throw new IOException("The URI cannot be determined for context '" + context.getClass().getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Determine the URI
- return uri;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.runtime.persistence.services;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+
+/**
+ * Persistence service implementation.
+ */
+public class URIPersistenceService extends AbstractService implements IURIPersistenceService {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#write(java.lang.Object, java.net.URI)
+ */
+ @Override
+ public void write(Object context, URI uri) throws IOException {
+ Assert.isNotNull(context);
+
+ uri = uri != null ? uri : getURI(context);
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri);
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) {
+ throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Pass on to the delegate for writing
+ delegate.write(context, uri);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#read(java.lang.Object, java.net.URI)
+ */
+ @Override
+ public Object read(Object context, URI uri) throws IOException {
+ Assert.isNotNull(context);
+
+ uri = uri != null ? uri : getURI(context);
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri);
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) {
+ throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Pass on to the delegate for reading
+ return delegate.read(context, uri);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#delete(java.lang.Object, java.net.URI)
+ */
+ @Override
+ public boolean delete(Object context, URI uri) throws IOException {
+ Assert.isNotNull(context);
+
+ uri = uri != null ? uri : getURI(context);
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri);
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) {
+ throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return delegate.delete(context, uri);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#getURI(java.lang.Object)
+ */
+ @Override
+ public URI getURI(Object context) throws IOException {
+ Assert.isNotNull(context);
+
+ // Determine the persistable element for the given data object
+ IPersistableURIProvider persistableURIProvider = context instanceof IPersistableURIProvider ? (IPersistableURIProvider)context : null;
+ // If the element isn't a persistable by itself, try to adapt the element
+ if (persistableURIProvider == null) {
+ persistableURIProvider = context instanceof IAdaptable ? (IPersistableURIProvider) ((IAdaptable)context).getAdapter(IPersistableURIProvider.class) : null;
+ }
+ if (persistableURIProvider == null) {
+ persistableURIProvider = (IPersistableURIProvider) Platform.getAdapterManager().getAdapter(context, IPersistableURIProvider.class);
+ }
+
+ // If the persistable could be still not determined, throw an IOException
+ if (persistableURIProvider == null) {
+ throw new IOException("'context' must be adaptable to IPersistableURIProvider."); //$NON-NLS-1$
+ }
+
+ URI uri = persistableURIProvider.getURI(context);
+
+ if (uri == null) {
+ throw new IOException("The URI cannot be determined for context '" + context.getClass().getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Determine the URI
+ return uri;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF
index fc3042d8d..daf75910d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF
@@ -10,7 +10,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.tcf;bundle-version="1.1.0",
org.eclipse.tcf.core;bundle-version="1.1.0",
org.eclipse.tcf.te.runtime;bundle-version="1.1.0",
- org.eclipse.tcf.te.core;bundle-version="1.1.0"
+ org.eclipse.tcf.te.core;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.persistence;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.services;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IExportPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IExportPersistenceService.java
new file mode 100644
index 000000000..ae68a10e9
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IExportPersistenceService.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.core.interfaces;
+
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
+
+/**
+ * IExportPersistenceService
+ */
+public interface IExportPersistenceService extends IURIPersistenceService {
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IImportPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IImportPersistenceService.java
new file mode 100644
index 000000000..c52e08a8b
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IImportPersistenceService.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.core.interfaces;
+
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
+
+/**
+ * IImportExportPersistenceService
+ */
+public interface IImportPersistenceService extends IURIPersistenceService {
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
index 273a48cc5..c1c711f54 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
@@ -29,6 +29,7 @@ Export-Package: org.eclipse.tcf.te.tcf.launch.core.activator;x-internal:=true,
org.eclipse.tcf.te.tcf.launch.core.filetransfer,
org.eclipse.tcf.te.tcf.launch.core.interfaces,
org.eclipse.tcf.te.tcf.launch.core.internal.adapters;x-internal:=true,
+ org.eclipse.tcf.te.tcf.launch.core.internal.services,
org.eclipse.tcf.te.tcf.launch.core.lm.delegates,
org.eclipse.tcf.te.tcf.launch.core.nls;x-internal:=true,
org.eclipse.tcf.te.tcf.launch.core.steps,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
index 4fda2ac58..783b383b4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
@@ -17,6 +17,20 @@
</factory>
</extension>
+<!-- Service contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.services.services">
+ <service
+ id="org.eclipse.tcf.te.tcf.launch.services.persistence.import"
+ class="org.eclipse.tcf.te.tcf.launch.core.internal.services.ImportPersistenceService">
+ <serviceType class="org.eclipse.tcf.te.tcf.core.interfaces.IImportPersistenceService"/>
+ </service>
+ <service
+ id="org.eclipse.tcf.te.tcf.launch.services.persistence.export"
+ class="org.eclipse.tcf.te.tcf.launch.core.internal.services.ExportPersistenceService">
+ <serviceType class="org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService"/>
+ </service>
+ </extension>
+
<!-- Launch Configuration Type contributions -->
<extension point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java
deleted file mode 100644
index 8814fd406..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 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.launch.core.interfaces;
-
-
-/**
- * Default set of custom peer properties.
- */
-public interface IPeerModelProperties {
-
- /**
- * Property: The peers launch configuration "Template" for new attach launch.
- */
- public static final String PROP_LAUNCH_CONFIG_ATTRIBUTES = "LaunchConfigAttributes"; //$NON-NLS-1$
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java
new file mode 100644
index 000000000..ea67e28fa
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.launch.core.internal.services;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.tcf.core.TransientPeer;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.services.URIPersistenceService;
+import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService;
+import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+
+/**
+ * Persistence service implementation for import/export.
+ */
+public class ExportPersistenceService extends URIPersistenceService implements IExportPersistenceService {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#write(java.lang.Object, java.net.URI)
+ */
+ @Override
+ public void write(Object context, URI uri) throws IOException {
+ Assert.isNotNull(context);
+
+ uri = uri != null ? uri : getURI(context);
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri);
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) {
+ throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (context instanceof IPeerModel) {
+ final IPeerModel node = (IPeerModel)context;
+ ILaunchConfiguration launchConfig = (ILaunchConfiguration)Platform.getAdapterManager().getAdapter(node, ILaunchConfiguration.class);
+ if (launchConfig != null) {
+ IPersistenceDelegate launchDelegate = PersistenceManager.getInstance().getDelegate(launchConfig, String.class);
+ if (launchDelegate != null) {
+ final String launchConfigString = (String)launchDelegate.write(launchConfig, String.class);
+ Map<String,String> attrs = new HashMap<String, String>(node.getPeer().getAttributes());
+ attrs.put(ILaunchTypes.ATTACH, launchConfigString);
+ delegate.write(new TransientPeer(attrs), uri);
+ return;
+ }
+ }
+ }
+
+ // Pass on to the delegate for writing
+ delegate.write(context, uri);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java
new file mode 100644
index 000000000..9f096d99f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.launch.core.internal.services;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.core.TransientPeer;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.services.URIPersistenceService;
+import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService;
+import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes;
+
+/**
+ * Persistence service implementation for import/export.
+ */
+public class ImportPersistenceService extends URIPersistenceService implements IExportPersistenceService {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#write(java.lang.Object, java.net.URI)
+ */
+ @Override
+ public void write(Object context, URI uri) throws IOException {
+ Assert.isNotNull(context);
+
+ uri = uri != null ? uri : getURI(context);
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri);
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) {
+ throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (context instanceof IPeer) {
+ final String launchConfigString = ((IPeer)context).getAttributes().get(ILaunchTypes.ATTACH);
+ if (launchConfigString != null && launchConfigString.trim().length() > 0) {
+ IPersistenceDelegate launchDelegate = PersistenceManager.getInstance().getDelegate(ILaunchConfigurationWorkingCopy.class, launchConfigString);
+ if (launchDelegate != null) {
+ Map<String,String> attrs = new HashMap<String, String>(((IPeer)context).getAttributes());
+ attrs.remove(ILaunchTypes.ATTACH);
+ IPeer peer = new TransientPeer(attrs);
+ delegate.write(peer, uri);
+
+ try {
+ ILaunchConfigurationWorkingCopy config = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(ILaunchTypes.ATTACH).newInstance(null, peer.getName());
+ config = (ILaunchConfigurationWorkingCopy)launchDelegate.read(config, launchConfigString);
+ config.doSave();
+ }
+ catch (Exception e) {
+ }
+ return;
+ }
+ }
+ }
+
+ // Pass on to the delegate for writing
+ delegate.write(context, uri);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java
index 49ede291e..72043a891 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java
@@ -13,25 +13,18 @@ package org.eclipse.tcf.te.tcf.launch.core.lm.delegates;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate;
import org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchContextLaunchAttributes;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.selection.interfaces.IRemoteSelectionContext;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
import org.eclipse.tcf.te.tcf.launch.core.interfaces.IAttachLaunchAttributes;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
/**
* RemoteAppLaunchManagerDelegate
@@ -106,25 +99,6 @@ public class AttachLaunchManagerDelegate extends DefaultLaunchManagerDelegate {
LaunchContextsPersistenceDelegate.setLaunchContexts(launchSpec, launchContexts.toArray(new IModelNode[launchContexts.size()]));
}
- if (remoteCtx instanceof IPeerModel) {
- String launchConfigAttributes = ((IPeerModel)remoteCtx).getPeer().getAttributes().get(IPeerModelProperties.PROP_LAUNCH_CONFIG_ATTRIBUTES);
- if (launchConfigAttributes != null) {
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(Map.class, launchConfigAttributes, false);
- try {
- Map<String, String> attributes = delegate != null ? (Map<String,String>)delegate.read(Map.class, launchConfigAttributes, null) : null;
- if (attributes != null) {
- attributes.remove(ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS);
- attributes.remove(ICommonLaunchAttributes.ATTR_UUID);
- attributes.remove(ICommonLaunchAttributes.ATTR_LAST_LAUNCHED);
- for (Entry<String, String> entry : attributes.entrySet()) {
- launchSpec.addAttribute(entry.getKey(), entry.getValue(), true);
- }
- }
- }
- catch (Exception e) { /* ignored on purpose */ }
- }
- }
-
launchSpec.setLaunchConfigName(getDefaultLaunchName(launchSpec));
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java
index efcc16e9a..1d1699ff2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java
@@ -62,10 +62,10 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
wc = (ILaunchConfigurationWorkingCopy)Platform.getAdapterManager().loadAdapter(peerModel, "org.eclipse.debug.core.ILaunchConfigurationWorkingCopy"); //$NON-NLS-1$
}
service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, wc);
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(wc, String.class, false);
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(wc, String.class);
String launchConfigAttributes = null;
try {
- launchConfigAttributes = (String)delegate.write(wc, String.class, null);
+ launchConfigAttributes = (String)delegate.write(wc, String.class);
}
catch (Exception e) {
}
@@ -122,10 +122,10 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
IPeerModel peerModel = getPeerModel(getEditorInput());
IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class);
String oldLaunchConfigAttributes = (String)service.getProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES);
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(getLaunchConfig(peerModel), String.class, false);
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(getLaunchConfig(peerModel), String.class);
String launchConfigAttributes = null;
try {
- launchConfigAttributes = (String)delegate.write(getLaunchConfig(peerModel), String.class, null);
+ launchConfigAttributes = (String)delegate.write(getLaunchConfig(peerModel), String.class);
dirty = !launchConfigAttributes.equals(oldLaunchConfigAttributes);
}
catch (Exception e) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java
index 957a15848..9da1a03f8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java
@@ -50,6 +50,7 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.model.Model;
@@ -334,7 +335,10 @@ public class PeerExportWizardPage extends WizardPage {
boolean toggleState = false;
int toggleResult = -1;
for (Object config : configs) {
- IURIPersistenceService service = ServiceManager.getInstance().getService(config, IURIPersistenceService.class);
+ IURIPersistenceService service = ServiceManager.getInstance().getService(config, IExportPersistenceService.class);
+ if (service == null) {
+ service = ServiceManager.getInstance().getService(config, IURIPersistenceService.class);
+ }
if (service != null) {
try {
URI uri = service.getURI(config);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java
index da35b8c74..af891c237 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java
@@ -55,6 +55,7 @@ import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.core.interfaces.IImportPersistenceService;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
@@ -151,8 +152,10 @@ public class PeerImportWizardPage extends WizardPage {
for (File candidate : candidates) {
try {
IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class);
- IPeer tempPeer = (IPeer)service.read(IPeer.class, candidate.getAbsoluteFile().toURI());
- elements.add(tempPeer);
+ if (service != null) {
+ IPeer tempPeer = (IPeer)service.read(IPeer.class, candidate.getAbsoluteFile().toURI());
+ elements.add(tempPeer);
+ }
}
catch (Exception e) {
}
@@ -373,7 +376,10 @@ public class PeerImportWizardPage extends WizardPage {
}
});
// And create a new one if we cannot find it
- IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ IURIPersistenceService service = ServiceManager.getInstance().getService(IImportPersistenceService.class);
+ if (service == null) {
+ service = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ }
if (peerModel.get() != null) {
if (!toggleState || toggleResult < 0) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(

Back to the top