Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Edit->Validate and EVL in EOL(Is there a way to perform the action Validate (in the Edit menu) by code ?)
Edit->Validate and EVL in EOL [message #759479] Mon, 28 November 2011 14:25 Go to next message
Paulo Alexandre is currently offline Paulo Alexandre
Messages: 17
Registered: November 2011
Junior Member
Hi everybody.

I've wrote some constraint in .evl file and in a gmf editor(result of a new eclipse instance) by clicking Edit->Validate those constraints defined in the .evl file are checked normally. As far as good.

Now, I want to do a second step but it could be made just if the Edit->Validate was performed.

Is there a way to check this ?


Thank you in advance for the support.

Re: Edit->Validate and EVL in EOL [message #759485 is a reply to message #759479] Mon, 28 November 2011 14:35 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 794
Registered: July 2009
Senior Member
Hi,

Do you mean that you want this step to be performed automatically after validation is performed?

Cheers,
Dimitris
Re: Edit->Validate and EVL in EOL [message #759502 is a reply to message #759485] Mon, 28 November 2011 15:05 Go to previous messageGo to next message
Paulo Alexandre is currently offline Paulo Alexandre
Messages: 17
Registered: November 2011
Junior Member
Hi Dimitrius

Thank you for the answer.

I didn't mean that (<<this step to be performed automatically after validation is performed>>) but it would be a interesting possibily. Is there a way to do that ?

Originally, there are two steps;
1->User click Edit->Validate (the eclipse will read and execute my evl constraints)
2->User chooses an action by a Wizard

The step 2 is an action in wizard (piece of ewl file) must be performed just if the step 1 is done. Until now, I couldn't think in a way to do it.

Anyway, thanks for the reply!

[Updated on: Mon, 28 November 2011 15:06]

Report message to a moderator

Re: Edit->Validate and EVL in EOL [message #782948 is a reply to message #759502] Tue, 24 January 2012 14:43 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 151
Registered: October 2009
Senior Member

Hi Paulo,

From what I understand is more like a condition (pseudo code):
if (the user has validated) then
Wizard.enable = true
else
Wizard.enable = false
end


So basically you need to save a flag to know if the user has executed the validation. You could add some code at the end of the operation that invokes the validation (in java) to enable the wizard entry in the menu. Another way would be to use a properties file. This is the "java" way of storing information in a file from which you can later retrieve it. Much like saving your preferences. A before add some code to save the "validated" flag to a file. Then, add some code to the operation that invokes the wizard and query the file for the flag value. If not set, you could show an error message instructing the user to validate the model first.

Hope it helps,


Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: Edit->Validate and EVL in EOL [message #820144 is a reply to message #782948] Tue, 13 March 2012 15:42 Go to previous messageGo to next message
Paulo Alexandre is currently offline Paulo Alexandre
Messages: 17
Registered: November 2011
Junior Member
Hi, Horacio Hoyos

first, I thank you for your support! It is of great help.

That pseudocode depicts almost perfectly my idea. But I'm not calling any java code. I'm just using just epsilon and a single .evl file (and wizards through EWL too).

I've had this idea:
In each evl constraint , in the 'check' I've added a dumb function like

context AnyClass
{
constraint anyConstraint
{
check: dumb(self.name<>'')//self.name<>'' is the real constraint I want to check
message: 'Any message'
}
}

operation dumb(x:Boolean, a:AnyClass)
{
//storage the value of x in any variable
a.error:=x; //It raises an error!!!!
return x;
}


So, every time any constraint was checked the dumb function would be called allowing to store the value of the verification.
But, at the line ''a.error:=x;'' an error is raised.

In few words, this is the error:
an runtime erro was raised during the evaluation ... Internal Error: java.lang.IllegalStateException: Cannot modify resource set without a write transaction

Apparently, I need to declare a write transaction but I have absolutely no idea of where to start.

Anyway, I thank you again for your time and attention!


Best regards
Re: Edit->Validate and EVL in EOL [message #820247 is a reply to message #820144] Tue, 13 March 2012 18:37 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-Dominguez
Messages: 304
Registered: January 2010
Senior Member
If I understood correctly, I believe that your problem is that the EVL script is run with a read-only view of the models in some circumstances. Your script *may* work when run from the tree-based editor Ecore generated, but not from a GMF-based editor.

In fact, I reported a bug regarding that issue a while ago, but regarding the fact that read-only views should be used everywhere, and not just in some places:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=287542

However, we concluded that it was probably an upstream issue. In any case, I'd advise you against modifying your models in an EVL script. It doesn't work everywhere, and it feels a bit wrong. I don't think you should be modifying your models during a validation.
Re: Edit->Validate and EVL in EOL [message #820879 is a reply to message #820247] Wed, 14 March 2012 13:33 Go to previous message
Paulo Alexandre is currently offline Paulo Alexandre
Messages: 17
Registered: November 2011
Junior Member
Hi, Antonio Garcia-Dominguez

you're right! Modifying a model in a evl file sounds like a workaround.

For a moment, I tought extended properties (http: / / www.eclipse.org/epsilon/doc/articles/extended-properties/) would solve my problem, but apparently extended properties keep their values just during the method call.

So, I'll use the solution proposed by Horacio Hoyos in the previous post. Using this post http: / / www.eclipse.org/epsilon/doc/articles/call-java-from-epsilon/ (calling java from eol) I can be able to save a flag with the following code.

To write the flag
Preferences prefsRoot = Preferences.userRoot();
Preferences myPrefs = prefsRoot.node("PreferenceExample");
myPrefs.put("Flag name goes here", flag_value_goes_here);
To read the the flag
String s=myPrefs.get("Flag name goes here", "default_value_when_no found");


I hope this solves my problem Smile . Anyway, I'll give you a feedback about the results.

thank you very much!!!

Previous Topic:GMF Tooling update site url disabled?
Next Topic:[announcement] ACademics Modelling with Eclipse Workshop - ECMFA 2012
Goto Forum:
  


Current Time: Fri Jul 25 05:09:18 EDT 2014

Powered by FUDForum. Page generated in 0.07935 seconds