Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » show validation view programmatically
show validation view programmatically [message #1740855] Fri, 19 August 2016 06:58 Go to next message
Leila S is currently offline Leila SFriend
Messages: 36
Registered: January 2015
Member
Hi,
I want to know how I can show the validation view with unsatisfied constraints programmatically.

Bests,
Leila.
Re: show validation view programmatically [message #1740975 is a reply to message #1740855] Mon, 22 August 2016 04:29 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1498
Registered: July 2009
Location: York, UK
Senior Member

Hi Leila,

The following line of code (copied from [1]) should do the trick.

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.epsilon.evl.dt.views.ValidationView");


Cheers,
Dimitris

[1] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/plain/plugins/org.eclipse.epsilon.evl.dt/src/org/eclipse/epsilon/evl/dt/views/ValidationViewFixer.java
Re: show validation view programmatically [message #1741135 is a reply to message #1740975] Tue, 23 August 2016 09:44 Go to previous messageGo to next message
Leila S is currently offline Leila SFriend
Messages: 36
Registered: January 2015
Member
Hi Dimitris,
Thank you for your response.
I use the below code to show unsatisfied constraints on the validation view:
ValidationView validationView = (ValidationView) PlatformUI.getWorkbench().
				getActiveWorkbenchWindow().getActivePage().
				showView("org.eclipse.epsilon.evl.dt.views.ValidationView");
			
ValidationViewFixer fixer = new ValidationViewFixer();
validationView.fix(module, fixer);


Now, how can I fix the constraints via validation view window? Is the above code sufficient?

Bests,
Leila.
Re: show validation view programmatically [message #1741145 is a reply to message #1741135] Tue, 23 August 2016 10:49 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1498
Registered: July 2009
Location: York, UK
Senior Member

It should be.

Cheers,
Dimitris
Re: show validation view programmatically [message #1741205 is a reply to message #1741145] Tue, 23 August 2016 16:34 Go to previous messageGo to next message
Leila S is currently offline Leila SFriend
Messages: 36
Registered: January 2015
Member
Thanks Dimitris.
But it doesn't work for me.
For example, in the below constraint:
context GeneralTrace!TraceModel {
- - TraceModel name cannot be empty
constraint notEmptyTraceModelName {
check : self.name.isDefined()
message : getMessageNotEmptyName("TraceModel")
fix {
title : getTitleNotEmptyName("TraceModel")
do {
self.name := getInputNotEmptyName("TraceModel");
}}
}
}
------------------------------------
operation getMessageNotEmptyName(objectClass : String) {
return 'The name of \'' + objectClass + '\' should be filled';
}

operation getTitleNotEmptyName(objectClass : String){
return 'The title of \''+objectClass+'\' should be filled';
}

operation getInputNotEmptyName(objectClass : String) {
return System.user.prompt('Name of \'' + objectClass+'\'');
}

If the trace model name is empty, it shows an unsatisfied constraint on the validation view :
The name of 'TraceModel' should be filled.

when the fix is clicked, and an arbitrary name is set, the below error is presented:
Property 'name' not found in object org.eclipse.emf.ecore.impl.DynamicEObjectImpl@10d47db [eClass: org.eclipse.emf.ecore.impl.EClassImpl@1d3d49c [name: TraceModel] [instanceClassName: null] [abstract: false, interface: false]]
	at (bundleentry://1027.fwk20565276/usedResource/Transformation/WeavingValidation.evl@10:0-10:48)


However the TraceModel has an attribute 'name':
<eClassifiers xsi:type="ecore:EClass" name="TraceModel">
    <eAnnotations source="exeed">
      <details key="classIcon" value="links"/>
      <details key="label" value="return self.name;"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EReference" name="links" upperBound="-1"
        eType="#//TraceLink" containment="true" eOpposite="#//TraceLink/model"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>

I cannot create a minimal example to reproduce the error. When I inject the code that you mentioned in the minimal example of the below link
https://www.eclipse.org/forums/index.php/t/1080196/
(attached to this topic) and run the validation.java the below error occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/e4/ui/workbench/IWorkbench
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.access$100(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:91)
	at files.Validation.execute(Validation.java:70)
	at files.Validation.main(Validation.java:43)
Caused by: java.lang.ClassNotFoundException: org.eclipse.e4.ui.workbench.IWorkbench
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 15 more


Bests,
Leila.
  • Attachment: TestEVL.zip
    (Size: 17.96KB, Downloaded 34 times)
Re: show validation view programmatically [message #1741257 is a reply to message #1741205] Wed, 24 August 2016 08:31 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1498
Registered: July 2009
Location: York, UK
Senior Member

Hi Leila,

Does calling

module.setUnsatisfiedConstraintFixer(new ValidationViewFixer());


before module.execute() do the trick? You may want to have a look at the code behind EvlLaunchConfigurationDelegate [1] (and its EpsilonLaunchConfigurationDelegate superclass).

Cheers,
Dimitris

[1] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/plain/plugins/org.eclipse.epsilon.evl.dt/src/org/eclipse/epsilon/evl/dt/launching/EvlLaunchConfigurationDelegate.java
Re: show validation view programmatically [message #1741300 is a reply to message #1741205] Wed, 24 August 2016 08:31 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1498
Registered: July 2009
Location: York, UK
Senior Member

Hi Leila,

Does calling


module.setUnsatisfiedConstraintFixer(new ValidationViewFixer());


before module.execute() do the trick? You may want to have a look at the code behind EvlLaunchConfigurationDelegate [1] (and its EpsilonLaunchConfigurationDelegate superclass).

Cheers,
Dimitris

[1] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/plain/plugins/org.eclipse.epsilon.evl.dt/src/org/eclipse/epsilon/evl/dt/launching/EvlLaunchConfigurationDelegate.java
Previous Topic:Validating a weaving model programmatically
Next Topic:news.eclipse.org is shutting down.
Goto Forum:
  


Current Time: Mon Jan 22 22:35:03 GMT 2018

Powered by FUDForum. Page generated in 0.02159 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software