Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2011-03-24 10:23:57 +0000
committerlgoubet2011-03-24 10:23:57 +0000
commit472c819c28d956b590b780fcae899d6dc2962ea6 (patch)
tree80d3bd1bbf5277a8fd2612c8a6c95868f074244c
parent6142205dff543eb26ed0c9689294654457fabba7 (diff)
downloadorg.eclipse.emf.compare-472c819c28d956b590b780fcae899d6dc2962ea6.tar.gz
org.eclipse.emf.compare-472c819c28d956b590b780fcae899d6dc2962ea6.tar.xz
org.eclipse.emf.compare-472c819c28d956b590b780fcae899d6dc2962ea6.zip
Tries and properly add the logical resources project without removing
the core
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.classpath7
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.gitignore4
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.project28
-rw-r--r--plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.emf.compare.logical/build.properties5
-rw-r--r--plugins/org.eclipse.emf.compare.logical/plugin.xml43
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/Activator.java23
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/ContentTypePropertyTester.java55
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFAdapterFactory.java29
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFModelProvider.java41
-rw-r--r--plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFResourceMapping.java54
12 files changed, 309 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.compare.logical/.classpath b/plugins/org.eclipse.emf.compare.logical/.classpath
new file mode 100644
index 000000000..2d1a4302f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.compare.logical/.gitignore b/plugins/org.eclipse.emf.compare.logical/.gitignore
new file mode 100644
index 000000000..2db576b4a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.gitignore
@@ -0,0 +1,4 @@
+bin/
+*~
+*.rej
+*.bak
diff --git a/plugins/org.eclipse.emf.compare.logical/.project b/plugins/org.eclipse.emf.compare.logical/.project
new file mode 100644
index 000000000..1f1aead90
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.compare.logical</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..d985ed6cb
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Mar 16 16:04:49 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..2740060ca
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Logical Resources Mapping
+Bundle-SymbolicName: org.eclipse.emf.compare.logical;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.emf.compare.logical.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources;bundle-version="3.7.100",
+ org.eclipse.emf.ecore;bundle-version="2.7.0",
+ org.eclipse.core.expressions;bundle-version="3.4.200"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.emf.compare.logical/build.properties b/plugins/org.eclipse.emf.compare.logical/build.properties
new file mode 100644
index 000000000..6f20375d6
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/org.eclipse.emf.compare.logical/plugin.xml b/plugins/org.eclipse.emf.compare.logical/plugin.xml
new file mode 100644
index 000000000..5cb321a8e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/plugin.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ id="org.eclipse.emf.compare.model.provider"
+ name="EMF Compare Model Provider"
+ point="org.eclipse.core.resources.modelProviders">
+ <modelProvider
+ class="org.eclipse.emf.compare.logical.EMFModelProvider">
+ </modelProvider>
+ <enablement>
+ <and>
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ </adapt>
+ <or>
+ <test
+ property="org.eclipse.emf.compare.contentType.contentTypeId"
+ value="org.eclipse.emf.compare.ui.contenttype.ModelContentType">
+ </test>
+ <test
+ property="org.eclipse.emf.compare.contentType.contentTypeId"
+ value="org.eclipse.emf.ecore">
+ </test>
+ <test
+ property="org.eclipse.emf.compare.contentType.contentTypeId"
+ value="org.eclipse.emf.ecore.xmi">
+ </test>
+ </or>
+ </and>
+ </enablement>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.emf.compare.logical.ContentTypePropertyTester"
+ id="org.eclipse.emf.compare.contentTypeTester"
+ namespace="org.eclipse.emf.compare.contentType"
+ properties="contentTypeId"
+ type="org.eclipse.core.resources.IResource">
+ </propertyTester>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/Activator.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/Activator.java
new file mode 100644
index 000000000..c4ccc9521
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/Activator.java
@@ -0,0 +1,23 @@
+package org.eclipse.emf.compare.logical;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public static final String PLUGIN_ID = "org.eclipse.emf.compare.logical"; //$NON-NLS-1$
+
+ private static BundleContext context;
+
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+ static BundleContext getContext() {
+ return context;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/ContentTypePropertyTester.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/ContentTypePropertyTester.java
new file mode 100644
index 000000000..3e92aa341
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/ContentTypePropertyTester.java
@@ -0,0 +1,55 @@
+package org.eclipse.emf.compare.logical;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+
+public class ContentTypePropertyTester extends PropertyTester {
+ private static final String PROPERTY_CONTENT_TYPE_ID = "contentTypeId"; //$NON-NLS-1$
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (receiver instanceof IFile && expectedValue instanceof String) {
+ if (PROPERTY_CONTENT_TYPE_ID.equals(property)) {
+ return hasContentType((IFile)receiver, (String)expectedValue);
+ }
+ }
+ return false;
+ }
+
+ private boolean hasContentType(IFile resource, String contentTypeId) {
+ IContentTypeManager ctManager = Platform.getContentTypeManager();
+ InputStream resourceContent = null;
+ IContentType[] contentTypes = null;
+ try {
+ resourceContent = resource.getContents();
+ contentTypes = ctManager.findContentTypesFor(resourceContent, resource.getName());
+ } catch (CoreException e) {
+ ctManager.findContentTypesFor(resource.getName());
+ } catch (IOException e) {
+ ctManager.findContentTypesFor(resource.getName());
+ } finally {
+ if (resourceContent != null) {
+ try {
+ resourceContent.close();
+ } catch (IOException e) {
+ // would have already been catched by the outer try, leave the stream open
+ }
+ }
+ }
+
+ if (contentTypes != null) {
+ for (IContentType type : contentTypes) {
+ if (type.getId().equals(contentTypeId)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFAdapterFactory.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFAdapterFactory.java
new file mode 100644
index 000000000..d4dc96cfa
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFAdapterFactory.java
@@ -0,0 +1,29 @@
+package org.eclipse.emf.compare.logical;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.IAdapterFactory;
+
+public class EMFAdapterFactory implements IAdapterFactory {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType == ResourceMapping.class && adaptableObject instanceof IResource) {
+ new EMFResourceMapping((IResource)adaptableObject);
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ public Class[] getAdapterList() {
+ return new Class[] {ResourceMapping.class,};
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFModelProvider.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFModelProvider.java
new file mode 100644
index 000000000..f1a0df711
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFModelProvider.java
@@ -0,0 +1,41 @@
+package org.eclipse.emf.compare.logical;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class EMFModelProvider extends ModelProvider {
+ public static final String PROVIDER_ID = "org.eclipse.emf.compare.model.provider"; //$NON-NLS-1$
+
+ public EMFModelProvider() {
+ System.out.println();
+ }
+
+ @Override
+ public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ return super.getMappings(resource, context, monitor);
+ }
+
+ @Override
+ public ResourceMapping[] getMappings(IResource[] resources, ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ return super.getMappings(resources, context, monitor);
+ }
+
+ @Override
+ public ResourceMapping[] getMappings(ResourceTraversal[] traversals, ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ return super.getMappings(traversals, context, monitor);
+ }
+
+ @Override
+ public ResourceTraversal[] getTraversals(ResourceMapping[] mappings, ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ return super.getTraversals(mappings, context, monitor);
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFResourceMapping.java b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFResourceMapping.java
new file mode 100644
index 000000000..2beb01f64
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.logical/src/org/eclipse/emf/compare/logical/EMFResourceMapping.java
@@ -0,0 +1,54 @@
+package org.eclipse.emf.compare.logical;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class EMFResourceMapping extends ResourceMapping {
+ private final IResource resource;
+
+ public EMFResourceMapping(IResource resource) {
+ this.resource = resource;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ResourceMapping#getModelObject()
+ */
+ @Override
+ public Object getModelObject() {
+ return resource;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ResourceMapping#getModelProviderId()
+ */
+ @Override
+ public String getModelProviderId() {
+ return EMFModelProvider.PROVIDER_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.resources.mapping.ResourceMapping#getProjects()
+ */
+ @Override
+ public IProject[] getProjects() {
+ return new IProject[] {resource.getProject(),};
+ }
+
+ @Override
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor)
+ throws CoreException {
+ return new ResourceTraversal[] {new ResourceTraversal(new IResource[] {resource,},
+ IResource.DEPTH_INFINITE, IResource.NONE)};
+ }
+}

Back to the top