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

Bug 329735

Summary: [Validation] It should be possible to validate graphical rules (on Notation)
Product: [Modeling] Papyrus Reporter: Yann Tanguy <yann.tanguy>
Component: DiagramAssignee: Ansgar Radermacher <ansgar.radermacher>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: cletavernier, papyrus-bugs, sebastien.gerard
Version: 0.8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 313986    

Description Yann Tanguy CLA 2010-11-09 04:17:54 EST
It should be possible to specify and validate graphical rules (on Notation).

e.g. Same color expected for every representation of a specific type of element.
Comment 1 Yann Tanguy CLA 2011-02-02 12:49:13 EST
It is currently possible to verify some graphical info by using the cross referencer (example below). 

public class PortShownInNoDiagram extends AbstractModelConstraint {

	@Override
	public IStatus validate(IValidationContext ctx)
	{
		Port elt = (Port) ctx.getTarget ();
		EReference[] ref = { NotationPackage.eINSTANCE.getView_Element() };
		Collection<?> refs = EMFCoreUtil.getReferencers(elt, ref);
		
		if (refs.isEmpty()) {	
			return ctx.createFailureStatus ("Port should be shown at least in one diagram ("+elt.getQualifiedName()+")");
		}

		return ctx.createSuccessStatus();
	}
}
Comment 2 Camille Letavernier CLA 2013-10-16 07:03:01 EDT
Cross referencers are dangerous for performances, but I guess they may be required in this case.

The validation should run on Notation elements (This would not cover this specific example however).

I think that currently, the validation only runs for semantic (UML) elements and stereotype applications.