Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345330

Summary: [General] Papyrus shall integrate the Essential OCL Xtext editor
Product: [Modeling] Papyrus Reporter: Ed Willink <ed>
Component: CoreAssignee: Patrick Tessier <Patrick.Tessier>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: arnaud.cuccuru, erche, faure.tristan, klaas.gadeyne, pierre.gaufillet, roch.bertucat, sebastien.gerard
Version: unspecifiedKeywords: plan
Target Milestone: ---Flags: sebastien.gerard: indigo+
rschnekenburger: juno+
Hardware: PC   
OS: Windows Vista   
Whiteboard: Usability
Attachments:
Description Flags
First experiment
none
Update with Write transaction and getTextToEdit
none
IXtextEMFReconciler2 workaround
none
Model lookup working none

Description Ed Willink CLA 2011-05-10 16:04:58 EDT
Created attachment 195270 [details]
First experiment

Attached is a first pass at the integration.

It has three obvious problems:

a) getTextToEdit is not implemented, since I've yet to see it being called

b) reconcile barfs with a write transaction needed

c) no UML context is yet passed to the editor, so only 'constant' expressions such as 'true or false' can be entered at present.

I'll work on c). Perhaps you can sort out b).

I'm also unclear whether the direct edit is for the Constraint Name or the Constraint Specification. I suspect that distinct graphical edit parts are needed in some way.

I think we need scroll bars since OCL expressions could be huge.
Comment 1 Arnaud Cuccuru CLA 2011-05-10 23:39:37 EDT
Created attachment 195293 [details]
Update with Write transaction and getTextToEdit

Hi Ed,

Thank you for this first version.

I have made a second pass to add the write transaction and an implementation for getTextToEdit. I realize that in the other papyrus/xtext editors, getTextToEdit is never called from outside the configuration class (so it does not need to be part of the API). Nevertheless, I have kept this method, and it is probable that gmf/glue will be refactored one day to take it into account. For the implementation, I have just made a copy/paste of your code to get the text associated with the literalString specification.

For the reconciliation, I found some problems with this statement: 

String string = ElementUtil.getText((ElementCS) xtextObject); 

It raises something like "NoSuchMethodException". For the moment, I replaced it by getting the string of the Document associated with the editor:

getSourceViewerHandle().getDocument().get()

Finally, I have added some plug-in dependencies to get things working.

Regarding the need for the scroll bars, I must have a look at gmf/glue. I will tell you when I change something.

Regards,

Arnaud
Comment 2 Ed Willink CLA 2011-05-11 02:46:37 EDT
Created attachment 195301 [details]
IXtextEMFReconciler2 workaround

Thanks for UpdateConstraint.

Your elimination of ElementUtil to solve the MNFE provides a nice solution that seems to hide (for now) the difference between Xtext 2.0 and Xtext 1.0. Can you move to Xtext 2.0?

The display does not update after editing an OCL constraint.

I think I have the UML model preparation mostly working, but there is one plumbing problem:

The OCL name resolution occurs in 'afterModelLinked' and so it is necessary to intervene between 'create xtext resource', and 'load resource with string' to configure the resource with the 'self' element. I have therefore introduced an extended IXtextEMFReconciler2 to provide a configureResource, and a variety of MyPopupXtextEditorHelper classes to ensure that IXtextEMFReconciler2.configureResource is invoked appropriately. I can use these for now, but it would be good if you could support some related API in the main functionality to avoid these cloned fudges.
Comment 3 Ed Willink CLA 2011-05-11 02:49:19 EDT
(In reply to comment #1)
> Regarding the need for the scroll bars, I must have a look at gmf/glue. I will
> tell you when I change something.

For the Xtext OCL Console the following style settings work

editor = new EmbeddedXtextEditor(editorComposite, injector,
SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
Comment 4 Ed Willink CLA 2011-05-11 14:46:52 EDT
Created attachment 195409 [details]
Model lookup working

The attached is now working; at least self.name for a class with a name property is valid and gets completion assist on "na" and error markers.

The required OCL changes to the UML2Ecore2Pivot class will be in RC1.

There are a variety of ergonomic issues to resolve, mostly in the Xtext invoking context so I leave them to you.

There is no initial validation of the popup.

The updated text does not change till the constraint is moved.

Hovering over a red squiggle gives an NPE because the annotation URI does not seem to be correctly registered.

I have no plans to do further work on this code until many other items on my 'stack' are resolved. Some improvements may be made to the model translation by UML2Ecore2Pivot.
Comment 5 Ed Willink CLA 2011-05-11 15:02:57 EDT
Bug 318076 calls for an Essential OCL Xtext editor contribution for editing in the UML editor properties view. Do you have this technology in Papyrus?
Comment 6 Patrick Tessier CLA 2012-06-05 12:56:36 EDT
Constraint can be directly with essential OCL for model or profile.

A plugin to display the result of a constraint in a model will be added. It reuse some parts of the Xtext OCL Console (without listener to update to the selection and without the editor of constraint).
Ed I will send you some screenshots ;-)
Comment 7 Patrick Tessier CLA 2013-01-28 09:30:16 EST
Can I close this bugs?
Comment 8 Ed Willink CLA 2013-01-28 10:16:06 EST
Yes.
Comment 9 Patrick Tessier CLA 2013-03-15 09:27:44 EDT
I close the bug
Comment 10 Klaas Gadeyne CLA 2013-04-02 08:41:57 EDT
(In reply to comment #9)
> I close the bug

Doesn't seem fully solved.  See bug #404720 (I have created a new bug and no dependency from this bug yet nor reopened it because I don't know what the default papyrus-dealing-with-bugs-policy is.  Feel free :-).