Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracuccuru2011-05-19 08:46:25 +0000
committeracuccuru2011-05-19 08:46:25 +0000
commit06bbc6cc4a84f137ca2023a3097163c9066e04cc (patch)
tree741b46c00af8176234489d70329f24eb72401ad0
parent78283896c7c368be566b8a1dd5f6441b8eaed544 (diff)
downloadorg.eclipse.papyrus-06bbc6cc4a84f137ca2023a3097163c9066e04cc.tar.gz
org.eclipse.papyrus-06bbc6cc4a84f137ca2023a3097163c9066e04cc.tar.xz
org.eclipse.papyrus-06bbc6cc4a84f137ca2023a3097163c9066e04cc.zip
First commit
-rw-r--r--extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext.ui/src/org/eclipse/papyrus/operation/editor/xtext/ui/contributions/OperationPopupEditorConfigurationContribution.java2
-rw-r--r--extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext/src/org/eclipse/papyrus/operation/editor/xtext/utils/AlfParsingUtil.java5
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.classpath7
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.project28
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/META-INF/MANIFEST.MF20
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/build.properties5
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/icons/OCLModelFile.gifbin0 -> 558 bytes
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/plugin.xml17
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPartialModelEditor.java52
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupEditorConfiguration.java209
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupPlugin.java70
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupRuntimeModule.java25
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupUiModule.java29
-rw-r--r--plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/IXtextEMFReconciler2.java24
15 files changed, 502 insertions, 3 deletions
diff --git a/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext.ui/src/org/eclipse/papyrus/operation/editor/xtext/ui/contributions/OperationPopupEditorConfigurationContribution.java b/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext.ui/src/org/eclipse/papyrus/operation/editor/xtext/ui/contributions/OperationPopupEditorConfigurationContribution.java
index 362a1d37c21..6c231cbc588 100644
--- a/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext.ui/src/org/eclipse/papyrus/operation/editor/xtext/ui/contributions/OperationPopupEditorConfigurationContribution.java
+++ b/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext.ui/src/org/eclipse/papyrus/operation/editor/xtext/ui/contributions/OperationPopupEditorConfigurationContribution.java
@@ -85,7 +85,7 @@ public class OperationPopupEditorConfigurationContribution extends
// builds the text content and extension for a temporary file, to be edited by the xtext editor
String textToEdit = "" + this.getTextToEdit(graphicalEditPart.resolveSemanticElement());
String fileExtension = "" + ".operation";
-
+
// builds a new IXtextEMFReconciler.
// Its purpose is to extract any relevant information from the textual specification,
// and then merge it in the context UML model if necessary
diff --git a/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext/src/org/eclipse/papyrus/operation/editor/xtext/utils/AlfParsingUtil.java b/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext/src/org/eclipse/papyrus/operation/editor/xtext/utils/AlfParsingUtil.java
index 159adf7e11b..7f476046db1 100644
--- a/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext/src/org/eclipse/papyrus/operation/editor/xtext/utils/AlfParsingUtil.java
+++ b/extraplugins/alf/org.eclipse.papyrus.operation.editor.xtext/src/org/eclipse/papyrus/operation/editor/xtext/utils/AlfParsingUtil.java
@@ -55,12 +55,13 @@ public class AlfParsingUtil {
XtextResource xtextResource = (XtextResource)resourceFactory.createResource(
URI.createURI(SYNTHETIC_SCHEME + ":/" + grammarAccess.getGrammar().getName() + ".operation"));
-
+
try {
xtextResource.load(new StringInputStream(textualRepresentation, xtextResource.getEncoding()), Collections.emptyMap());
} catch (Exception e) {
throw new RuntimeException(e);
}
+
return xtextResource;
}
@@ -83,7 +84,7 @@ public class AlfParsingUtil {
}
XtextResource xtextResource = parseAlf.getXtextResource(actualRepresentation);
-
+
System.out.println("///////////////////////// Test begin") ;
// Display parsing errors
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.classpath b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.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/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.project b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.project
new file mode 100644
index 00000000000..58744a0a5c3
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.constraintwithessentialocl.editor.xtext</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/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.settings/org.eclipse.jdt.core.prefs b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..6b0e4a20312
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Wed May 18 14:49:57 CEST 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.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+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/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/META-INF/MANIFEST.MF b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..7ad6496e926
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Papyrus
+Bundle-SymbolicName: org.eclipse.papyrus.constraintwithessentialocl.editor.xtext;singleton:=true
+Bundle-Version: 3.1.0.qualifier
+Bundle-Activator: org.eclipse.ocl.examples.xtext.papyrus.EssentialOCLPopupPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.extensionpoints.editors,
+ org.eclipse.xtext.gmf.glue,
+ com.google.inject;bundle-version="2.0.0",
+ org.eclipse.uml2.uml;bundle-version="3.2.0",
+ org.eclipse.ocl.examples.xtext.essentialocl.ui;bundle-version="3.1.0",
+ org.eclipse.gef;bundle-version="3.7.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
+ org.eclipse.papyrus.properties.runtime;bundle-version="0.8.0",
+ org.eclipse.papyrus.core;bundle-version="0.8.0",
+ org.eclipse.core.expressions
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/build.properties b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/build.properties
new file mode 100644
index 00000000000..6f20375d6c7
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/icons/OCLModelFile.gif b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/icons/OCLModelFile.gif
new file mode 100644
index 00000000000..2945103032e
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/icons/OCLModelFile.gif
Binary files differ
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/plugin.xml b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/plugin.xml
new file mode 100644
index 00000000000..2db8823f50f
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/plugin.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
+ <DirectEditor
+ contributor="Eclipse Modeling Project"
+ icon="icons/OCLModelFile.gif"
+ language="Essential OCL constraint editor"
+ objectToEdit="org.eclipse.uml2.uml.Constraint">
+ <popupeditor
+ editorConfiguration="org.eclipse.ocl.examples.xtext.papyrus.EssentialOCLPopupEditorConfiguration">
+ </popupeditor>
+ </DirectEditor>
+ </extension>s
+
+</plugin>
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPartialModelEditor.java b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPartialModelEditor.java
new file mode 100644
index 00000000000..2ffe27451b5
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPartialModelEditor.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * E.D.Willink - Initial API and implementation
+ * CEA LIST - Architecture refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.ocl.examples.xtext.papyrus;
+
+import java.util.Collections;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.xtext.gmf.glue.edit.part.IXtextEMFReconciler;
+import org.eclipse.xtext.gmf.glue.partialEditing.ISyntheticResourceProvider;
+import org.eclipse.xtext.gmf.glue.partialEditing.PartialModelEditor;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.util.StringInputStream;
+
+public class EssentialOCLPartialModelEditor extends PartialModelEditor {
+
+ public EssentialOCLPartialModelEditor(SourceViewer viewer,
+ ISyntheticResourceProvider resourceProvider,
+ boolean insertLineBreaks,
+ EObject semanticElement,
+ IXtextEMFReconciler modelReconciler) {
+ super(viewer, resourceProvider, insertLineBreaks, semanticElement, modelReconciler);
+ }
+
+ @Override
+ public XtextResource createResource(String content) {
+ XtextResource result = resourceProvider.createResource();
+ if (modelReconciler instanceof IXtextEMFReconciler2) {
+ ((IXtextEMFReconciler2)modelReconciler).configureResource(result, semanticElement);
+ }
+ try {
+ result.load(new StringInputStream(content, result.getEncoding()), Collections.emptyMap());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupEditorConfiguration.java b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupEditorConfiguration.java
new file mode 100644
index 00000000000..3b9f599bc63
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupEditorConfiguration.java
@@ -0,0 +1,209 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * E.D.Willink - Initial API and implementation
+ * CEA LIST - Architecture refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.ocl.examples.xtext.papyrus;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.ocl.examples.pivot.evaluation.EvaluationContext;
+import org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot;
+import org.eclipse.ocl.examples.pivot.utilities.TypeManager;
+import org.eclipse.ocl.examples.pivot.utilities.TypeManagerResourceAdapter;
+import org.eclipse.ocl.examples.xtext.essentialocl.utilities.EssentialOCLPlugin;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.LiteralString;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.xtext.gmf.glue.edit.part.DefaultXtextSemanticValidator;
+import org.eclipse.xtext.gmf.glue.edit.part.IXTextSemanticValidator;
+import org.eclipse.xtext.gmf.glue.edit.part.IXtextEMFReconciler;
+import org.eclipse.xtext.gmf.glue.edit.part.PopupXtextEditorHelper;
+import org.eclipse.xtext.gmf.glue.partialEditing.SourceViewerHandle;
+import org.eclipse.xtext.resource.XtextResource;
+
+import com.google.inject.Injector;
+
+public class EssentialOCLPopupEditorConfiguration extends org.eclipse.xtext.gmf.glue.PopupEditorConfiguration
+{
+ public class Reconciler implements IXtextEMFReconciler2
+ {
+ public void configureResource(XtextResource resource, EObject umlObject) {
+ if (resource instanceof EvaluationContext) {
+ TypeManagerResourceAdapter.getAdapter(resource, typeManager);
+ org.eclipse.ocl.examples.pivot.Element pivotElement = getPivotModel(umlObject);
+ if (pivotElement instanceof org.eclipse.ocl.examples.pivot.NamedElement) {
+ ((EvaluationContext)resource).setContext((org.eclipse.ocl.examples.pivot.NamedElement)pivotElement, null);
+ }
+ }
+ }
+
+ public void reconcile(EObject modelObject, EObject xtextObject) {
+ if (!(modelObject instanceof org.eclipse.uml2.uml.Constraint)) {
+ return;
+ }
+ String newTextualRepresentation = editorHelper.getSourceViewerHandle().getDocument().get() ;
+ //
+ // Creates and executes the update command
+ //
+ UpdateConstraintCommand updateCommand = new UpdateConstraintCommand((org.eclipse.uml2.uml.Constraint)modelObject, newTextualRepresentation);
+ try {
+ OperationHistoryFactory.getOperationHistory().execute(updateCommand, new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ /* [AC] TODO AC => check why LogHelper is not visible
+ * org.eclipse.papyrus.properties.runtime.Activator.log.error(e);
+ */
+ e.printStackTrace() ;
+ }
+ //
+ }
+ }
+
+ protected class UpdateConstraintCommand extends AbstractTransactionalCommand
+ {
+ protected final org.eclipse.uml2.uml.Constraint constraint;
+ protected final String newTextualRepresentation;
+
+ public UpdateConstraintCommand(org.eclipse.uml2.uml.Constraint constraint, String newTextualRepresentation) {
+ super(EditorUtils.getTransactionalEditingDomain(), "Constraint Update", getWorkspaceFiles(constraint));
+ this.constraint = constraint;
+ this.newTextualRepresentation = newTextualRepresentation;
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException {
+ org.eclipse.uml2.uml.OpaqueExpression opaqueExpression = null ;
+ int indexOfOCLBody = -1 ;
+ if (constraint.getSpecification() == null || !(constraint.getSpecification() instanceof org.eclipse.uml2.uml.OpaqueExpression))
+ opaqueExpression = UMLFactory.eINSTANCE.createOpaqueExpression() ;
+ else {
+ opaqueExpression = (org.eclipse.uml2.uml.OpaqueExpression)constraint.getSpecification() ;
+ for (int i = 0 ; i < opaqueExpression.getLanguages().size() && indexOfOCLBody == -1 ; i++) {
+ if (opaqueExpression.getLanguages().get(i).equals("OCL"))
+ indexOfOCLBody = i ;
+ }
+ }
+ if (indexOfOCLBody == -1) {
+ opaqueExpression.getLanguages().add("OCL") ;
+ opaqueExpression.getBodies().add(newTextualRepresentation) ;
+ }
+ else {
+ opaqueExpression.getBodies().remove(indexOfOCLBody) ;
+ opaqueExpression.getBodies().add(indexOfOCLBody, newTextualRepresentation) ;
+ }
+ constraint.setSpecification(opaqueExpression) ;
+ return CommandResult.newOKCommandResult(constraint);
+ }
+ }
+
+ protected PopupXtextEditorHelper editorHelper = null ;
+ private TypeManager typeManager = null;
+
+ public EssentialOCLPopupEditorConfiguration() {}
+
+ @Override
+ public IPopupEditorHelper createPopupEditorHelper(Object editPart) {
+ if (!(editPart instanceof IGraphicalEditPart)) {
+ return null;
+ }
+ IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart)editPart;
+ Object model = graphicalEditPart.getModel();
+ if (model == null) {
+ return null;
+ }
+ if (!(model instanceof View)) {
+ return null;
+ }
+ View view = (View) model;
+ EObject element = view.getElement();
+ if (element == null) {
+ return null;
+ }
+ if (!(element instanceof org.eclipse.uml2.uml.Constraint)) {
+ return null;
+ }
+ org.eclipse.uml2.uml.Constraint constraint = (org.eclipse.uml2.uml.Constraint) element;
+ org.eclipse.uml2.uml.ValueSpecification specification = constraint.getSpecification();
+ if (specification == null) {
+ return null;
+ }
+ if (!(specification instanceof org.eclipse.uml2.uml.LiteralString || specification instanceof org.eclipse.uml2.uml.OpaqueExpression)) {
+ return null;
+ }
+ getPivotModel(constraint);
+ Injector xtextInjector = EssentialOCLPopupPlugin.getInstance().getInjector(EssentialOCLPlugin.LANGUAGE_ID);
+ IXtextEMFReconciler modelReconciler = new Reconciler();
+ String textToEdit = getTextToEdit(element);
+ String fileExtension = "essentialocl";
+ IXTextSemanticValidator semanticValidator = new DefaultXtextSemanticValidator();
+ SourceViewerHandle.bindPartialModelEditorClass(EssentialOCLPartialModelEditor.class) ;
+ editorHelper = (PopupXtextEditorHelper)super.createPopupEditorHelper(graphicalEditPart, xtextInjector, modelReconciler, textToEdit, fileExtension, semanticValidator);
+ return editorHelper ;
+ }
+
+ protected org.eclipse.ocl.examples.pivot.Element getPivotModel(EObject umlObject) {
+ if (!(umlObject instanceof org.eclipse.uml2.uml.Constraint)) {
+ return null;
+ }
+ Resource umlResource = umlObject.eResource();
+ if (umlResource == null) {
+ return null;
+ }
+ if (typeManager == null) {
+ typeManager = new TypeManager();
+ }
+ UML2Ecore2Pivot adapter = UML2Ecore2Pivot.getAdapter(umlResource, typeManager);
+ adapter.getPivotRoot();
+ org.eclipse.uml2.uml.Namespace umlContainer = ((org.eclipse.uml2.uml.Constraint)umlObject).getContext();
+ if (umlContainer instanceof org.eclipse.uml2.uml.Operation) {
+ umlContainer = ((org.eclipse.uml2.uml.Operation)umlObject).getNamespace();
+ }
+ return adapter.getCreated(org.eclipse.ocl.examples.pivot.Element.class, umlContainer);
+ }
+
+ @Override
+ public String getTextToEdit(Object editedObject) {
+ Constraint umlConstraint = (Constraint)editedObject ;
+ String value = "" ;
+ if (umlConstraint.getSpecification() != null) {
+ if (umlConstraint.getSpecification() instanceof LiteralString) {
+ if (((LiteralString)umlConstraint.getSpecification()).getValue() != null)
+ value += ((LiteralString)umlConstraint.getSpecification()).getValue() ;
+ }
+ else if (umlConstraint.getSpecification() instanceof org.eclipse.uml2.uml.OpaqueExpression) {
+ int indexOfOCLBody = -1 ;
+ org.eclipse.uml2.uml.OpaqueExpression opaqueExpression = (org.eclipse.uml2.uml.OpaqueExpression)umlConstraint.getSpecification() ;
+ for (int i = 0 ;
+ i < opaqueExpression.getLanguages().size() && indexOfOCLBody == -1 ;
+ i ++) {
+ if (opaqueExpression.getLanguages().get(i).equals("OCL")) {
+ value += opaqueExpression.getBodies().get(i) ;
+ indexOfOCLBody = i ;
+ }
+ }
+ }
+ }
+ return value;
+ }
+}
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupPlugin.java b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupPlugin.java
new file mode 100644
index 00000000000..e6a5e8f0dc6
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupPlugin.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * E.D.Willink - Initial API and implementation
+ * CEA LIST - Architecture refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.ocl.examples.xtext.papyrus;
+
+import org.eclipse.ocl.examples.xtext.essentialocl.ui.internal.EssentialOCLActivator;
+import org.eclipse.ocl.examples.xtext.essentialocl.utilities.EssentialOCLPlugin;
+
+import com.google.inject.Module;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class EssentialOCLPopupPlugin extends EssentialOCLActivator
+{
+ // The shared instance.
+ private static EssentialOCLPopupPlugin plugin;
+
+ /**
+ * Returns the shared instance.
+ */
+ public static EssentialOCLPopupPlugin getInstance() {
+ return plugin;
+ }
+
+ /**
+ * Obtains my plug-in ID.
+ *
+ * @return my plug-in ID
+ */
+ public static String getPluginId() {
+ return getInstance().getBundle().getSymbolicName();
+ }
+
+ /**
+ * The constructor.
+ */
+ public EssentialOCLPopupPlugin() {
+ super();
+ plugin = this;
+ }
+
+ protected Module getRuntimeModule(String grammar) {
+ if (EssentialOCLPlugin.LANGUAGE_ID.equals(grammar)) {
+ return new EssentialOCLPopupRuntimeModule();
+ }
+
+ throw new IllegalArgumentException(grammar);
+ }
+
+ protected Module getUiModule(String grammar) {
+ if (EssentialOCLPlugin.LANGUAGE_ID.equals(grammar)) {
+ return new EssentialOCLPopupUiModule(this);
+ }
+
+ throw new IllegalArgumentException(grammar);
+ }
+}
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupRuntimeModule.java b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupRuntimeModule.java
new file mode 100644
index 00000000000..a6140a009e9
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupRuntimeModule.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * E.D.Willink - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.ocl.examples.xtext.papyrus;
+
+import org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLRuntimeModule;
+
+/**
+ * Use this class to register components to be used within the IDE.
+ */
+public class EssentialOCLPopupRuntimeModule extends EssentialOCLRuntimeModule
+{
+
+}
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupUiModule.java b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupUiModule.java
new file mode 100644
index 00000000000..ec90a08abd0
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/EssentialOCLPopupUiModule.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * E.D.Willink - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.ocl.examples.xtext.papyrus;
+
+import org.eclipse.ocl.examples.xtext.essentialocl.ui.EssentialOCLUiModule;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Use this class to register components to be used within the IDE.
+ */
+public class EssentialOCLPopupUiModule extends EssentialOCLUiModule
+{
+ public EssentialOCLPopupUiModule(AbstractUIPlugin plugin) {
+ super(plugin);
+ }
+
+}
diff --git a/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/IXtextEMFReconciler2.java b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/IXtextEMFReconciler2.java
new file mode 100644
index 00000000000..8ffc92baecb
--- /dev/null
+++ b/plugins/ocl/org.eclipse.papyrus.constraintwithessentialocl.editor.xtext/src/org/eclipse/ocl/examples/xtext/papyrus/IXtextEMFReconciler2.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * E.D.Willink - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.ocl.examples.xtext.papyrus;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.gmf.glue.edit.part.IXtextEMFReconciler;
+import org.eclipse.xtext.resource.XtextResource;
+
+public interface IXtextEMFReconciler2 extends IXtextEMFReconciler
+{
+ void configureResource(XtextResource result, EObject semanticElement);
+}

Back to the top