Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-09-13 10:53:03 +0000
committerEike Stepper2012-09-13 10:53:03 +0000
commit60bd9db3a11ef8619f73069628e3317fe6bfb288 (patch)
tree23b461e622959fd3ea72b05d6d7b1a9db6eb13bf /plugins/org.eclipse.emf.cdo.transfer.workspace/src
parent7e37ab497ef46dfd7441815b17df74609f8ebb72 (diff)
downloadcdo-60bd9db3a11ef8619f73069628e3317fe6bfb288.tar.gz
cdo-60bd9db3a11ef8619f73069628e3317fe6bfb288.tar.xz
cdo-60bd9db3a11ef8619f73069628e3317fe6bfb288.zip
[388928] Develop a resource transfer framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388928
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.transfer.workspace/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer.workspace/src/org/eclipse/emf/cdo/transfer/spi/workspace/WorkspaceTransferSystem.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.transfer.workspace/src/org/eclipse/emf/cdo/transfer/spi/workspace/WorkspaceTransferSystem.java b/plugins/org.eclipse.emf.cdo.transfer.workspace/src/org/eclipse/emf/cdo/transfer/spi/workspace/WorkspaceTransferSystem.java
index c71312d0a9..6ce0e21ed3 100644
--- a/plugins/org.eclipse.emf.cdo.transfer.workspace/src/org/eclipse/emf/cdo/transfer/spi/workspace/WorkspaceTransferSystem.java
+++ b/plugins/org.eclipse.emf.cdo.transfer.workspace/src/org/eclipse/emf/cdo/transfer/spi/workspace/WorkspaceTransferSystem.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.transfer.spi.workspace;
import org.eclipse.emf.cdo.transfer.CDOTransferElement;
import org.eclipse.emf.cdo.transfer.CDOTransferSystem;
+import org.eclipse.emf.cdo.transfer.CDOTransferType;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.io.IORuntimeException;
@@ -35,6 +36,8 @@ import java.io.InputStream;
*/
public class WorkspaceTransferSystem extends CDOTransferSystem
{
+ public static final WorkspaceTransferSystem INSTANCE = new WorkspaceTransferSystem();
+
public static final String TYPE = "workspace";
private static final IWorkspaceRoot ROOT = ResourcesPlugin.getWorkspace().getRoot();
@@ -62,6 +65,46 @@ public class WorkspaceTransferSystem extends CDOTransferSystem
}
}
+ protected String getEncoding(IFile file)
+ {
+ try
+ {
+ return file.getCharset();
+ }
+ catch (CoreException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ @Override
+ public CDOTransferType getDefaultTransferType(CDOTransferElement element)
+ {
+ if (element instanceof Element)
+ {
+ Element node = (Element)element;
+ if (node.isDirectory())
+ {
+ return CDOTransferType.FOLDER;
+ }
+
+ IFile file = (IFile)node.getNativeObject();
+
+ // TODO Team is optional, handle its absence.
+ int type = org.eclipse.team.core.Team.getFileContentManager().getType(file);
+ switch (type)
+ {
+ case org.eclipse.team.core.Team.BINARY:
+ return CDOTransferType.FOLDER;
+ case org.eclipse.team.core.Team.TEXT:
+ String encoding = getEncoding(file);
+ return CDOTransferType.text(encoding);
+ }
+ }
+
+ return super.getDefaultTransferType(element);
+ }
+
@Override
public URI getURI(IPath path)
{

Back to the top