Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-11-24 10:18:42 +0000
committerUwe Stieber2011-11-24 10:18:42 +0000
commit32c5289b341814cba4a11fa17f6abdff7c12d0b2 (patch)
tree4f55e07bdb92934cc38a127d29539e56f4fe1d3e /target_explorer/plugins/org.eclipse.tcf.te.core
parentd16633ddda860badbc9265ddfa71137dda800fe1 (diff)
downloadorg.eclipse.tcf-32c5289b341814cba4a11fa17f6abdff7c12d0b2.tar.gz
org.eclipse.tcf-32c5289b341814cba4a11fa17f6abdff7c12d0b2.tar.xz
org.eclipse.tcf-32c5289b341814cba4a11fa17f6abdff7c12d0b2.zip
Target Explorer: Improve reference handling in ModelNodePersistableAdapter
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableAdapter.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableAdapter.java
index 2f2d1d896..b1064bbe0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableAdapter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/ModelNodePersistableAdapter.java
@@ -58,7 +58,7 @@ public class ModelNodePersistableAdapter implements IPersistable {
IModelNode node = (IModelNode) data;
if (node.getName() != null && !"".equals(node.getName().trim())) { //$NON-NLS-1$
// Get the node name and make it a valid file system name (no spaces etc).
- IPath path = getRoot().append(makeValidFileSystemName(((IModelNode) data).getName().trim()));
+ IPath path = getRoot().append(makeValidFileSystemName(node.getName().trim()));
if (!"ini".equals(path.getFileExtension())) path = path.addFileExtension("ini"); //$NON-NLS-1$ //$NON-NLS-2$
uri = path.toFile().toURI();
}
@@ -67,6 +67,12 @@ public class ModelNodePersistableAdapter implements IPersistable {
IPath path = new Path(node.getStringProperty("Path")); //$NON-NLS-1$
uri = path.toFile().toURI();
}
+ // Final fallback is to use the UUID
+ else if (node.getUUID() != null) {
+ IPath path = getRoot().append(makeValidFileSystemName(node.getUUID().toString().trim()));
+ if (!"ini".equals(path.getFileExtension())) path = path.addFileExtension("ini"); //$NON-NLS-1$ //$NON-NLS-2$
+ uri = path.toFile().toURI();
+ }
}
return uri;
@@ -193,22 +199,25 @@ public class ModelNodePersistableAdapter implements IPersistable {
IPersistable persistable = value instanceof IAdaptable ? (IPersistable)((IAdaptable)value).getAdapter(IPersistable.class) : null;
if (persistable == null) persistable = (IPersistable)Platform.getAdapterManager().getAdapter(value, IPersistable.class);
if (persistable != null) {
+ String storageID = persistable.getStorageID();
+ URI uri = persistable.getURI(value);
+
// Check if the persistable returns complete information to create the reference
- if (persistable.getStorageID() == null) {
+ if (storageID == null) {
throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_export_invalidPersistable, value.getClass().getCanonicalName(), "storageID")); //$NON-NLS-1$
}
- if (persistable.getURI(value) == null) {
+ if (uri == null) {
throw new IOException(NLS.bind(Messages.ModelNodePersistableAdapter_export_invalidPersistable, value.getClass().getCanonicalName(), "uri")); //$NON-NLS-1$
}
// Create a reference object
Map<String, String> reference = new HashMap<String, String>();
- reference.put("storageID", persistable.getStorageID()); //$NON-NLS-1$
- reference.put("uri", persistable.getURI(value).toString()); //$NON-NLS-1$
+ reference.put("storageID", storageID); //$NON-NLS-1$
+ reference.put("uri", uri.toString()); //$NON-NLS-1$
- IPersistenceDelegate delegate = PersistenceDelegateManager.getInstance().getDelegate(persistable.getStorageID(), false);
+ IPersistenceDelegate delegate = PersistenceDelegateManager.getInstance().getDelegate(storageID, false);
if (delegate != null) {
- delegate.write(persistable.getURI(value), persistable.exportFrom(value));
+ delegate.write(uri, persistable.exportFrom(value));
dst.put(key, reference);
continue;
}

Back to the top