Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-12-29 15:32:18 +0000
committerUwe Stieber2011-12-30 07:00:57 +0000
commitbf5444c63f70a5e104c5bc7c186be8c20fb25697 (patch)
treeabd11592326cbd366da2d9c8df4c70099e622ea3 /target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence
parent27f153c0570bcc14e18221ebec20ebdbbbdfdd71 (diff)
downloadorg.eclipse.tcf-bf5444c63f70a5e104c5bc7c186be8c20fb25697.tar.gz
org.eclipse.tcf-bf5444c63f70a5e104c5bc7c186be8c20fb25697.tar.xz
org.eclipse.tcf-bf5444c63f70a5e104c5bc7c186be8c20fb25697.zip
Target Explorer: Static peer nodes can be renamed via the new editor implementation
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceService.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/PersistenceService.java25
2 files changed, 36 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceService.java
index 02d1419be..67b77254f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistenceService.java
@@ -10,6 +10,7 @@
package org.eclipse.tcf.te.runtime.persistence.interfaces;
import java.io.IOException;
+import java.net.URI;
import org.eclipse.tcf.te.runtime.services.interfaces.IService;
@@ -54,4 +55,14 @@ public interface IPersistenceService extends IService {
*/
public boolean delete(Object data) throws IOException;
+ /**
+ * Returns the persistence storage URI for the given data object. The persistence delegate to
+ * use will be determined by adapting the given data object to an {@link IPersistable}.
+ *
+ * @param data The data object. Must not be <code>null</code>.
+ * @return The URI or <code>null</code>.
+ *
+ * @throws IOException - if the operation fails
+ */
+ public URI getURI(Object data) throws IOException;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/PersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/PersistenceService.java
index aeb65a4c1..cf4d9fe29 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/PersistenceService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/services/PersistenceService.java
@@ -124,4 +124,29 @@ public class PersistenceService extends AbstractService implements IPersistenceS
// Pass on to the delegate for deleting
return delegate.delete(uri);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceService#getURI(java.lang.Object)
+ */
+ @Override
+ public URI getURI(Object data) throws IOException {
+ Assert.isNotNull(data);
+
+ // Determine the persistable element for the given data object
+ IPersistable persistable = data instanceof IPersistable ? (IPersistable)data : null;
+ // If the element isn't a persistable by itself, try to adapt the element
+ if (persistable == null) persistable = data instanceof IAdaptable ? (IPersistable) ((IAdaptable)data).getAdapter(IPersistable.class) : null;
+ if (persistable == null) persistable = (IPersistable) Platform.getAdapterManager().getAdapter(data, IPersistable.class);
+
+ // If the persistable could be still not determined, throw an IOException
+ if (persistable == null) throw new IOException("'data' must be adaptable to IPersistable."); //$NON-NLS-1$
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = persistable.getStorageID() != null ? PersistenceDelegateManager.getInstance().getDelegate(persistable.getStorageID(), false) : null;
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) throw new IOException("The persistence delegate for ID '" + persistable.getStorageID() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Determine the URI
+ return persistable.getURI(data);
+ }
}

Back to the top