[420821] Complete OCL Registry patch
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/commands/LoadCompleteOCLResourceHandler.java b/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/commands/LoadCompleteOCLResourceHandler.java
index 21712f7..2f1d13d 100644
--- a/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/commands/LoadCompleteOCLResourceHandler.java
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/commands/LoadCompleteOCLResourceHandler.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2012, 2013 E.D.Willink and others.
+ * Copyright (c) 2012, 2014 E.D.Willink 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
@@ -9,11 +9,14 @@
*
* Contributors:
* E.D.Willink - Initial API and implementation
+ * Obeo - Enable export and re-use CompleteOCL files for validation
*
* </copyright>
*/
package org.eclipse.ocl.examples.xtext.completeocl.ui.commands;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -36,16 +39,19 @@
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.provider.EcoreEditPlugin;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.ocl.examples.domain.elements.DomainPackage;
import org.eclipse.ocl.examples.pivot.Element;
import org.eclipse.ocl.examples.pivot.ParserException;
@@ -57,7 +63,9 @@
import org.eclipse.ocl.examples.pivot.utilities.PivotUtil;
import org.eclipse.ocl.examples.pivot.validation.PivotEObjectValidator;
import org.eclipse.ocl.examples.xtext.completeocl.CompleteOCLStandaloneSetup;
+import org.eclipse.ocl.examples.xtext.completeocl.internal.registry.CompleteOCLRegistry;
import org.eclipse.ocl.examples.xtext.completeocl.ui.CompleteOCLUiModule;
+import org.eclipse.ocl.examples.xtext.completeocl.ui.messages.CompleteOCLUIMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
@@ -65,14 +73,19 @@
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISources;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.part.ResourceTransfer;
import org.eclipse.xtext.resource.XtextResource;
@@ -85,7 +98,7 @@
* A LoadCompleteOCLResourceHandler supports the OCL->Load Document command.
*
* It provides a pop-up dialog with DND capability for a Complete OCL document to be installed in the
- * ResourceSet associatied with the invoking selection.
+ * ResourceSet associated with the invoking selection.
*/
public class LoadCompleteOCLResourceHandler extends AbstractHandler
{
@@ -139,6 +152,7 @@
protected final Shell parent;
protected final @NonNull ResourceSet resourceSet;
private DropTarget target;
+ private Set<URI> registeredURIsForResourceSet;
protected ResourceDialog(Shell parent, EditingDomain domain, @NonNull ResourceSet resourceSet) {
super(parent, domain);
@@ -168,7 +182,27 @@
@Override
protected Control createDialogArea(Composite parent) {
Composite createDialogArea = (Composite) super.createDialogArea(parent);
-
+
+ // Button composite is the first children and we are expected to retrieve it as such...
+ Composite buttonComposite = (Composite)createDialogArea.getChildren()[0];
+
+ Button browseRegisteredOCLFiles = new Button(buttonComposite, SWT.PUSH);
+ browseRegisteredOCLFiles.setText(CompleteOCLUIMessages.LoadCompleteOCLResource_browseOCLFiles);
+ prepareBrowseRegisteredOCLFiles(browseRegisteredOCLFiles);
+ registeredURIsForResourceSet = CompleteOCLRegistry.getRegisteredResourceURIs(resourceSet);
+ if (registeredURIsForResourceSet.isEmpty()) {
+ browseRegisteredOCLFiles.setEnabled(false);
+ } else {
+ browseRegisteredOCLFiles.setEnabled(true);
+ }
+
+ {
+ FormData data = new FormData();
+ Control [] children = buttonComposite.getChildren();
+ data.right = new FormAttachment(children[0], -CONTROL_OFFSET);
+ browseRegisteredOCLFiles.setLayoutData(data);
+ }
+
Label helpLabel = new Label(createDialogArea, SWT.CENTER);
helpLabel.setText("You may Drag and Drop from an Eclipse or Operating System Explorer.");
{
@@ -182,6 +216,53 @@
return createDialogArea;
}
+ private void prepareBrowseRegisteredOCLFiles(Button browseRegisteredOCLFiles) {
+ browseRegisteredOCLFiles.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ RegisteredOCLFilesDialog registeredOCLFilesDialog = new RegisteredOCLFilesDialog(getShell());
+ registeredOCLFilesDialog.open();
+ Object[] result = registeredOCLFilesDialog.getResult();
+ if (result != null) {
+ StringBuffer uris = new StringBuffer();
+
+ for (int i = 0, length = result.length; i < length; i++) {
+ uris.append(result[i]);
+ uris.append(" ");
+ }
+ uriField.setText((uriField.getText() + " " + uris.toString()).trim());
+ }
+ }
+ });
+ }
+
+ private class RegisteredOCLFilesDialog extends ElementListSelectionDialog
+ {
+ public RegisteredOCLFilesDialog(Shell parent) {
+ super(parent, new LabelProvider() {
+ @Override
+ public Image getImage(Object element) {
+ return ExtendedImageRegistry.getInstance().getImage(EcoreEditPlugin.INSTANCE.getImage("full/obj16/EPackage"));
+ }
+ });
+
+ setMultipleSelection(true);
+ setMessage(CompleteOCLUIMessages.LoadCompleteOCLResource_SelectRegisteredOCLFileURI);
+ setFilter("*");
+ setTitle(CompleteOCLUIMessages.LoadCompleteOCLResource_OCLFileSelection_label);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite result = (Composite)super.createDialogArea(parent);
+ URI[] uris = registeredURIsForResourceSet.toArray(new URI[registeredURIsForResourceSet.size()]);
+ Arrays.sort(uris, new URIComparator());
+ setListElements(uris);
+ return result;
+ }
+ }
+
/**
* Generate a popup to display a primaryMessage and optionally a detailMessage too.
* @param primaryMessage
@@ -400,6 +481,12 @@
return asResource;
}
}
+
+ public static class URIComparator implements Comparator<URI> {
+ public int compare(URI o1, URI o2) {
+ return o1.toString().compareTo(o2.toString());
+ }
+ }
public @Nullable Object execute(ExecutionEvent event) throws ExecutionException {
Object applicationContext = event.getApplicationContext();
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.java b/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.java
index 10dcb08..c16d6ffe 100644
--- a/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.java
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2013 Obeo and others.
+ * Copyright (c) 2013, 2014 Obeo 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
@@ -32,4 +32,8 @@
public static String NewWizardPage_pageDescription;
public static String NewWizardPage_pageSummary;
public static String NewWizardPage_pageTitle;
+
+ public static String LoadCompleteOCLResource_browseOCLFiles;
+ public static String LoadCompleteOCLResource_SelectRegisteredOCLFileURI;
+ public static String LoadCompleteOCLResource_OCLFileSelection_label;
}
\ No newline at end of file
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.properties b/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.properties
index 0942f57..a0484de 100644
--- a/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.properties
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl.ui/src/org/eclipse/ocl/examples/xtext/completeocl/ui/messages/CompleteOCLUIMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2013 Obeo and others.
+# Copyright (c) 2013, 2014 Obeo 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
@@ -14,3 +14,7 @@
NewWizardPage_pageDescription=Creates a new Complete OCL file to complement a given metamodel.
NewWizardPage_pageSummary=Complete OCL File
NewWizardPage_pageTitle=New Complete OCL File
+
+LoadCompleteOCLResource_browseOCLFiles=Browse &Registered OCL Files...
+LoadCompleteOCLResource_SelectRegisteredOCLFileURI = &Select a registered OCL File URI:
+LoadCompleteOCLResource_OCLFileSelection_label = OCL File Selection
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl/META-INF/MANIFEST.MF b/examples/org.eclipse.ocl.examples.xtext.completeocl/META-INF/MANIFEST.MF
index 8fd3d18..b073c51 100644
--- a/examples/org.eclipse.ocl.examples.xtext.completeocl/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@
org.eclipse.ocl.examples.xtext.completeocl.completeoclcs.util,
org.eclipse.ocl.examples.xtext.completeocl.cs2as,
org.eclipse.ocl.examples.xtext.completeocl.formatting,
+ org.eclipse.ocl.examples.xtext.completeocl.internal.registry;x-friends:="org.eclipse.ocl.examples.xtext.completeocl.ui",
org.eclipse.ocl.examples.xtext.completeocl.parser.antlr,
org.eclipse.ocl.examples.xtext.completeocl.parser.antlr.internal;x-friends:="org.eclipse.ocl.examples.xtext.completeocl.ui",
org.eclipse.ocl.examples.xtext.completeocl.pivot2cs,
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl/plugin.xml b/examples/org.eclipse.ocl.examples.xtext.completeocl/plugin.xml
index 79a0209..226d2ea 100644
--- a/examples/org.eclipse.ocl.examples.xtext.completeocl/plugin.xml
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl/plugin.xml
@@ -2,6 +2,7 @@
<?eclipse version="3.0"?>
<plugin>
+ <extension-point id="complete_ocl_registry" name="Complete OCL Registry" schema="schema/complete_ocl_registry.exsd"/>
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type id="org.eclipse.ocl.examples.completeOCL" name="%completeOCLName"
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl/schema/complete_ocl_registry.exsd b/examples/org.eclipse.ocl.examples.xtext.completeocl/schema/complete_ocl_registry.exsd
new file mode 100644
index 0000000..9b5aa3b
--- /dev/null
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl/schema/complete_ocl_registry.exsd
@@ -0,0 +1,101 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ocl.examples.xtext.completeocl" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ocl.examples.xtext.completeocl" id="complete_ocl_registry" name="Complete OCL Registry"/>
+ </appInfo>
+ <documentation>
+ The complete OCL Registry allows clients to register their completeOCL files so that they can be reused to validate workspace models when the contributing plugin is installed.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="completeOCLResource"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="completeOCLResource">
+ <complexType>
+ <attribute name="resource" type="string" use="required">
+ <annotation>
+ <documentation>
+ A completeOCL file.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.4.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ This could be used to register the CompleteOCL file "EcoreValidation.ocl" located within a "model" subfolder at the root of the plugin :
+
+<extension point="org.eclipse.ocl.examples.xtext.completeocl.complete_ocl_registry">
+ <completeOCLResource resource="model/EcoreValidation.ocl">
+</completeOCLResource>
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2013 Obeo 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 <a
+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/internal/registry/CompleteOCLRegistry.java b/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/internal/registry/CompleteOCLRegistry.java
new file mode 100644
index 0000000..40b965a
--- /dev/null
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/internal/registry/CompleteOCLRegistry.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright (c) 2014 Obeo 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:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.ocl.examples.xtext.completeocl.internal.registry;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.ocl.examples.pivot.utilities.BaseResource;
+import org.eclipse.ocl.examples.xtext.base.basecs.impl.ImportCSImpl;
+
+/**
+ * This registry will be used to hold all complete ocl resources that have been
+ * made available through the extension point.
+ *
+ * @author <a href="mailto:marwa.rostren@obeo.fr">Marwa Rostren</a>
+ */
+public class CompleteOCLRegistry {
+ private static final Set<URI> REGISTERED_URIS = new LinkedHashSet<URI>();
+
+ private CompleteOCLRegistry() {
+ // prevents instantiation
+ }
+
+ public static void addURI(URI resourceURI) {
+ REGISTERED_URIS.add(resourceURI);
+ }
+
+ public static void removeURI(URI resourceURI) {
+ REGISTERED_URIS.remove(resourceURI);
+ }
+
+ public static void clear() {
+ REGISTERED_URIS.clear();
+ }
+
+ /**
+ * Returns all registered URIs for a specific resources in resourceSet
+ *
+ * @param resourceSet
+ * the resourceSet
+ * @return all registered URIs for all resources in resourceSet
+ */
+ public static Set<URI> getRegisteredResourceURIs(ResourceSet resourceSet) {
+ Set<URI> concernedRegisteredURIs = new LinkedHashSet<URI>();
+
+ for (Resource resource : resourceSet.getResources()) {
+ EPackage epack = resource.getContents().get(0).eClass().getEPackage();
+ concernedRegisteredURIs.addAll(CompleteOCLRegistry
+ .getRegisteredResourceURIs(epack.getNsURI()));
+ }
+ return Collections.unmodifiableSet(concernedRegisteredURIs);
+ }
+
+ /**
+ * Returns a set of registered URIs for a specific model nsURI
+ *
+ * @param modelNsURI
+ * a specific model nsURI
+ * @return A set of registered URIs for a specific model nsURI
+ */
+ private static Set<URI> getRegisteredResourceURIs(String modelNsURI) {
+ Set<URI> modelRegisteredURIs = new LinkedHashSet<URI>();
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ for (URI uri: REGISTERED_URIS){
+ final BaseResource xtextResource;
+ if (uri.isPlatformResource()) {
+ xtextResource = (BaseResource) resourceSet.getResource(URI.createPlatformPluginURI(uri.toPlatformString(false), false), true);
+ } else {
+ xtextResource = (BaseResource) resourceSet.getResource(uri, true);
+ }
+ for (TreeIterator<EObject> iterator = xtextResource.getAllContents(); iterator.hasNext(); ) {
+ EObject eObject = iterator.next();
+ if (eObject instanceof ImportCSImpl) {
+ ImportCSImpl importObject = (ImportCSImpl) eObject;
+ if (("'" + modelNsURI + "'").equals(importObject.getPathName().toString())){
+ modelRegisteredURIs.add(uri);
+ }
+ }
+ }
+ }
+ return Collections.unmodifiableSet(modelRegisteredURIs);
+ }
+}
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/internal/registry/CompleteOCLRegistryReader.java b/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/internal/registry/CompleteOCLRegistryReader.java
new file mode 100644
index 0000000..a0e4a57
--- /dev/null
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/internal/registry/CompleteOCLRegistryReader.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2014 Obeo 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:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.ocl.examples.xtext.completeocl.internal.registry;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.plugin.RegistryReader;
+import org.eclipse.ocl.examples.xtext.completeocl.utilities.CompleteOCLPlugin;
+
+/**
+ * A plugin extension reader that populates the complete OCL resource registry.
+ *
+ * @author <a href="mailto:marwa.rostren@obeo.fr">Marwa Rostren</a>
+ */
+public class CompleteOCLRegistryReader
+ extends RegistryReader {
+ private static final String TAG_RESOURCE = "completeOCLResource";
+
+ private static final String ATTRIBUTE_RESOURCE = "resource";
+
+ public CompleteOCLRegistryReader() {
+ super(Platform.getExtensionRegistry(), CompleteOCLPlugin.getPlugin()
+ .getBundle().getSymbolicName(),
+ CompleteOCLPlugin.OCL_RESOURCE_REGISTRY_PID);
+ }
+
+ @Override
+ protected boolean readElement(IConfigurationElement element, boolean add) {
+ if (!TAG_RESOURCE.equals(element.getName())) {
+ return false;
+ }
+
+ final String filePath = element.getAttribute(ATTRIBUTE_RESOURCE);
+ final boolean recognized;
+ if (filePath == null) {
+ logMissingAttribute(element, ATTRIBUTE_RESOURCE);
+ recognized = false;
+ } else {
+ final URI fileURI = makeFileURI(element, filePath);
+ if (add) {
+ CompleteOCLRegistry.addURI(fileURI);
+ } else {
+ CompleteOCLRegistry.removeURI(fileURI);
+ }
+ recognized = true;
+ }
+
+ return recognized;
+ }
+
+ private URI makeFileURI(IConfigurationElement element, String path) {
+ URI resourceURI = URI.createURI(path);
+ if (resourceURI.isRelative()) {
+ resourceURI = URI.createPlatformPluginURI(element
+ .getDeclaringExtension().getContributor().getName()
+ + '/' + path, true);
+ }
+ return resourceURI;
+ }
+}
diff --git a/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/utilities/CompleteOCLPlugin.java b/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/utilities/CompleteOCLPlugin.java
index 00c0b66..c23ab16 100644
--- a/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/utilities/CompleteOCLPlugin.java
+++ b/examples/org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/utilities/CompleteOCLPlugin.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2010, 2013 E.D.Willink and others.
+ * Copyright (c) 2010, 2014 E.D.Willink 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
@@ -9,6 +9,7 @@
*
* Contributors:
* E.D.Willink - Initial API and implementation
+ * Obeo - Add complete ocl registry to enable export and re-use CompleteOCL files
*
* </copyright>
*
@@ -21,6 +22,7 @@
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.ocl.examples.xtext.completeocl.CompleteOCLStandaloneSetup;
+import org.eclipse.ocl.examples.xtext.completeocl.internal.registry.CompleteOCLRegistryReader;
import org.osgi.framework.BundleContext;
/**
@@ -32,6 +34,7 @@
public final class CompleteOCLPlugin extends EMFPlugin {
public static final String PLUGIN_ID = "org.eclipse.ocl.examples.xtext.completeocl";
public static final String LANGUAGE_ID = "org.eclipse.ocl.examples.xtext.completeocl.CompleteOCL";
+ public static final String OCL_RESOURCE_REGISTRY_PID = "complete_ocl_registry";
/**
* Keep track of the singleton.
* <!-- begin-user-doc -->