Commit 3d8aec77 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added validation plugins



Change-Id: Ife97fa933ebbef7c05346551ba5b7c1a34a438ec
Signed-off-by: Philip Makedonski's avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent d5a8d4a9
<?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/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.etsi.mts.tdl.constraints.ui</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>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: org.etsi.mts.tdl.constraints.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.etsi.mts.tdl.constraints.ui.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.ui.editors;bundle-version="3.5.0",
org.eclipse.ui.ide;bundle-version="3.5.0",
org.eclipse.ui.workbench,
org.etsi.mts.tdl.constraints,
org.eclipse.epsilon.common,
org.eclipse.epsilon.emc.emf,
org.eclipse.epsilon.eol.engine,
org.eclipse.epsilon.erl.engine,
org.eclipse.epsilon.evl.engine,
org.eclipse.epsilon.evl.emf.validation,
org.eclipse.epsilon.etl.engine,
org.eclipse.epsilon.profiling,
org.eclipse.epsilon.eol.tools,
com.google.inject,
org.eclipse.xtext.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
name="TDL"
id="org.etsi.mts.tdl.constraints.ui.commands.category">
</category>
<command
categoryId="org.etsi.mts.tdl.constraints.ui.commands.category"
id="org.etsi.mts.tdl.constraints.ui.commands.validateCommand"
name="Validate TDL model">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="org.etsi.mts.tdl.constraints.ui.commands.validateCommand"
class="org.etsi.mts.tdl.constraints.ui.handlers.ValidationHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="org.etsi.mts.tdl.constraints.ui.commands.validateCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="TDL"
mnemonic="T"
id="org.etsi.mts.tdl.tools.menus.TDLMenu">
<command
commandId="org.etsi.mts.tdl.constraints.ui.commands.validateCommand"
mnemonic="V"
id="org.etsi.mts.tdl.constraints.ui.menus.validateCommand">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="org.etsi.mts.tdl.constraints.ui.toolbars.validate">
<command
commandId="org.etsi.mts.tdl.constraints.ui.commands.validateCommand"
icon="icons/ValidateIcon.png"
tooltip="Validate TDL model"
id="org.etsi.mts.tdl.constraints.ui.toolbars.validateCommand">
</command>
</toolbar>
</menuContribution>
</extension>
</plugin>
package org.etsi.mts.tdl.constraints.ui;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.etsi.mts.tdl.constraints.ui"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
<?xml version="1.0" encoding="UTF-8"?><projectDescription><name>DUMMY</name><comment></comment><projects></projects><buildSpec></buildSpec><natures></natures></projectDescription>
\ No newline at end of file
package org.etsi.mts.tdl.constraints.ui.handlers;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.common.util.URI;
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.epsilon.evl.execute.UnsatisfiedConstraint;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
import org.etsi.mts.tdl.constraints.evl.Validator;
import com.google.inject.Inject;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class ValidationHandler extends AbstractHandler {
@Inject
IResourceSetProvider resourceSetProvider;
private IWorkbenchWindow window;
/**
* The constructor.
*/
public ValidationHandler() {
}
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IEditorInput input = HandlerUtil.getActiveEditorInput(event);
IFile file = null;
IProject project = null;
if (input != null && input instanceof FileEditorInput) {
file = ((FileEditorInput) input).getFile();
project = file.getProject();
} else if (selection !=null && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof IFile) {
file = (IFile) firstElement;
project = file.getProject();
}
}
if (file !=null) {
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(uri, true);
Validator validator = new Validator();
List<UnsatisfiedConstraint> violations = validator.validate(r);
String messages = "";
for (UnsatisfiedConstraint v : violations) {
messages += v.getMessage()+"\n";
}
if (violations.size() == 0) {
messages = "No violations!";
}
MessageDialog.openInformation(
Display.getDefault().getActiveShell(),
// window.getShell(),
"Validation Results",
messages);
}
return null;
}
public void init(IWorkbenchWindow window) {
this.window = window;
}
@Override
public boolean isEnabled() {
return true;
}
}
<?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/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="epsilon"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.etsi.mts.tdl.constraints</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>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Constraints
Bundle-SymbolicName: org.etsi.mts.tdl.constraints
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.emf.common,
org.eclipse.epsilon.common,
org.eclipse.epsilon.emc.emf,
org.eclipse.epsilon.eol.engine,
org.eclipse.epsilon.erl.engine,
org.eclipse.epsilon.evl.engine,
org.eclipse.epsilon.evl.emf.validation,
org.eclipse.epsilon.etl.engine,
org.eclipse.epsilon.profiling,
org.eclipse.epsilon.eol.tools,
org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.emf.ecore.xmi,
org.etsi.mts.tdl.model
Export-Package: org.etsi.mts.tdl.constraints.evl
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
import "../library/common.eol";
import "../library/helper.eol";
import "../library/debug.eol";
//Combining Multiple 'PICSReference's
//A 'Comment' with body containing an 'and' or 'or' shall be attached to the 'PICSReference' as a Boolean operand if there are two or more 'PICSReference's and it is not the first 'PICSReference'.
context PICSReference {
constraint MultiplePICS {
check:
self.container().picsReference->size() < 2
or self.container().picsReference->forAll(p |
self.container().picsReference->at(0) = p
or (not p.comment->isEmpty()
and (p.comment->first().body = 'and'
or p.comment->first().body = 'or')))
message:
"A 'Comment' with body containing an 'and' or 'or' shall be attached to the 'PICSReference' as a Boolean operand if there are two or more 'PICSReference's and it is not the first 'PICSReference'."
}
}
//Either ‘repetition’, or ‘interval’ or neither shall be specified
//At most one of the optional properties ‘repetition’ or ‘interval’ shall be defined.
context RepeatedEventSequence {
constraint RepetitionOrInterval {
check:
self.repetitions.oclIsUndefined() or self.interval.oclIsUndefined()
message:
"At most one of the optional properties ‘repetition’ or ‘interval’ shall be defined."
}
}
//Combining Multiple 'EventOccurrence's
//A 'Comment' with body containing an 'and' or 'or' shall be attached to the 'EventOccurrence' as an operand if there are two or more 'EventOccurrence's and it is not the first 'EventOccurrence'.
context EventOccurrence {
constraint MultipleEventOccurrences{
check:
self.container().oclIsTypeOf(EventSpecificationTemplate)
or self.container().events->size() < 2
or self.container().events->forAll(o |
self.container().events->at(0) = o
or (not o.comment->isEmpty()
and (o.comment->first().body = 'and'
or o.comment->first().body = 'or')))
message:
"A 'Comment' with body containing an 'and' or 'or' shall be attached to the 'EventOccurrence' as an operand if there are two or more 'EventOccurrence's and it is not the first 'EventOccurrence'."
}
}
//An 'Entity' or a 'ComponentInstance' shall be referenced.
//There shall be a reference to an 'Entity' or a 'ComponentInstance' but not both.
context EntityReference {
constraint EntityOrComponentInstance {
check:
(not self.entity.oclIsUndefined() and self.component.oclIsUndefined())
or (self.entity.oclIsUndefined() and not self.component.oclIsUndefined())
message:
"There shall be a reference to an 'Entity' or a 'ComponentInstance' but not both."
}
}
//No nested 'Content's if 'Value' is provided
//Either nested 'Content's or 'Value' may be specified within 'Content', but not both.
context Content {
constraint ContentOrValue {
check:
self.content->isEmpty() or self.value.oclIsUndefined()
message:
"Either nested 'Content's or 'Value' may be specified within 'Content', but not both."
}
}
//Referenced 'LiteralValue' visibility
//Only 'LiteralValue's defined within previous 'EventOccurrence's of the containing 'StructuredTestObjective' may be referenced.
context LiteralValueReference {
constraint VisibleValue {
check:
self.getTestObjective().contains(self.content)
and self.getTestObjective().indexOf(self.content) < self.getTestObjective().indexOf(self)
message:
"Only 'LiteralValue's defined within previous 'EventOccurrence's of the containing 'StructuredTestObjective' may be referenced."
}
}
//Referenced 'Content' visibility
//Only 'Content's defined within previous 'EventOccurrence's of the containing 'StructuredTestObjective' may be referenced.
context ContentReference {
constraint VisibleContent {
check:
self.getTestObjective().contains(self.content)
and self.getTestObjective().indexOf(self.content) < self.getTestObjective().indexOf(self)
message:
"Only 'Content's defined within previous 'EventOccurrence's of the containing 'StructuredTestObjective' may be referenced."
}
}
//'DataInstanceUse' restrictions within 'DataReference'
//Only simple and structured data instances may be referenced directly or indirectly in 'ParameterBinding's of the 'StaticDataUse' within a 'DataReference'.
context DataReference {
constraint DataReferenceContents {
check:
self.content.oclIsKindOf(StaticDataUse)
and self.content.argument->forAll(a | a.dataUse.oclIsKindOf(StaticDataUse))
and self.content.argument->closure(a | a.dataUse.argument)->forAll(a|a.dataUse.oclIsKindOf(StaticDataUse))
message:
"Only simple and structured data instances may be referenced directly or indirectly in 'ParameterBinding's of the 'StaticDataUse' within a 'DataReference'."
}
}
//‘EntityReference’ of referenced ‘EventSpecificationTemplate’
//If ‘EntityBinding’s are provided, he ‘Entity’s referenced in the ‘templateEntity’ properties shall also be referenced by one of the ‘EntityReferences’ in the ‘EventOccurrenceSpecification’ of the 'EventSpecificationTemplate' referenced in the ‘EventTemplateOccurrence’.
context EventTemplateOccurrence {
constraint EntityTemplateOccurrenceConsistency {
check:
self.entityBinding->forAll(b |
(not b.templateEntity.entity.oclIsUndefined() and (b.templateEntity.entity = self.eventTemplate.eventSpecification.entityReference.entity))
or (not b.templateEntity.component.oclIsUndefined() and (b.templateEntity.component = self.eventTemplate.eventSpecification.entityReference.component)
or self.eventTemplate.eventSpecification.oppositeEntityReference->exists(e |
(not b.templateEntity.entity.oclIsUndefined() and (e.entity = b.templateEntity.entity))
or (not b.templateEntity.component.oclIsUndefined() and (e.component = b.templateEntity.component)))))
message:
"If ‘EntityBinding’s are provided, he ‘Entity’s referenced in the ‘templateEntity’ properties shall also be referenced by one of the ‘EntityReferences’ in the ‘EventOccurrenceSpecification’ of the 'EventSpecificationTemplate' referenced in the ‘EventTemplateOccurrence’."
}
}
//Supporting operation aliases for OCL
operation Any oclIsUndefined() : Boolean {
return self.isUndefined();
}
operation Any oclIsTypeOf(t:Any) : Boolean {
return self.isTypeOf(t);
}
operation Any oclIsKindOf(t:Any) : Boolean {
return self.isKindOf(t);
}
operation Any oclAsType(t:Any) : Any {
return self;
}
operation Any notEmpty() : Boolean {
return not self.isEmpty();
}
operation Any container() : Any {
return self.eContainer;
}
operation String size() : Integer {
return self.length();
}
//Supporting operations
operation Any getTestDescription() : Any {
if (self.eContainer.isDefined()) {
if (not self.eContainer.isKindOf(TestDescription)) {
return self.eContainer.getTestDescription();
} else {
return self.eContainer;
}
}
}
operation Any getTestObjective() : Any {
if (self.eContainer.isDefined()) {
if (not self.eContainer.isKindOf(StructuredTestObjective)) {
return self.eContainer.getTestObjective();
} else {
return self.eContainer;
}
}
}
operation Any contains(object : Any) : Boolean {
return self.eAllContents().includes(object);
}
operation TDL!StructuredTestObjective indexOf(object : Any) : Integer {
return self.eAllContents().indexOf(object);
}
//QualifiedNames
operation Any qualifiedName() : String {
var p = self.getNamedParent();
if (p.isDefined()) {
var suffix = "";
if (self.name.isDefined()) {
suffix = "::"+self.name;
}
return p.qualifiedName()+suffix;
} else {
return self.name;
}
}