use of org.eclipse.sirius.components.view.NodeDescription in project sirius-components by eclipse-sirius.
the class ViewValidatorTests method testNodeStyleDescriptionValidQualifiedDomainInResourceSet.
@Test
public void testNodeStyleDescriptionValidQualifiedDomainInResourceSet() {
Map<Object, Object> defaultContext = Diagnostician.INSTANCE.createDefaultContext();
NodeDescription nodeDescription = ViewFactory.eINSTANCE.createNodeDescription();
// $NON-NLS-1$
nodeDescription.setDomainType(SAMPLE_DOMAIN_NAME + "::" + SAMPLE_ENTITY_NAME);
ResourceSetImpl resourceSet = new ResourceSetImpl();
XMIResourceImpl viewResource = new XMIResourceImpl();
viewResource.getContents().add(nodeDescription);
XMIResourceImpl domainResource = new XMIResourceImpl();
Domain domain = DomainFactory.eINSTANCE.createDomain();
domain.setName(SAMPLE_DOMAIN_NAME);
domainResource.getContents().add(domain);
Entity entity = DomainFactory.eINSTANCE.createEntity();
entity.setName(SAMPLE_ENTITY_NAME);
domain.getTypes().add(entity);
resourceSet.getResources().add(viewResource);
resourceSet.getResources().add(domainResource);
BasicDiagnostic diagnosticChain = new BasicDiagnostic(Diagnostic.OK, null, 0, null, null);
boolean validationResult = new DiagramDescriptionValidator().validate(nodeDescription.eClass(), nodeDescription, diagnosticChain, defaultContext);
assertThat(validationResult).isTrue();
assertThat(diagnosticChain).isEqualTo(new BasicDiagnostic(Diagnostic.OK, null, 0, null, null));
}
use of org.eclipse.sirius.components.view.NodeDescription in project sirius-components by eclipse-sirius.
the class DynamicDiagramsTests method testRenderSynchronizedEcoreDiagram.
@Test
void testRenderSynchronizedEcoreDiagram() throws Exception {
DiagramDescription diagramDescription = ViewFactory.eINSTANCE.createDiagramDescription();
// $NON-NLS-1$
diagramDescription.setName("Simple Ecore Diagram");
diagramDescription.setTitleExpression(NAME_EXPRESSION);
diagramDescription.setAutoLayout(false);
// $NON-NLS-1$
diagramDescription.setDomainType("ecore::EPackage");
NodeDescription eClassNode = ViewFactory.eINSTANCE.createNodeDescription();
// $NON-NLS-1$
eClassNode.setName("EClass Node");
// $NON-NLS-1$
eClassNode.setDomainType("ecore::EClass");
eClassNode.setLabelExpression(NAME_EXPRESSION);
// $NON-NLS-1$
eClassNode.setSemanticCandidatesExpression("aql:self.eClassifiers");
eClassNode.setSynchronizationPolicy(SynchronizationPolicy.SYNCHRONIZED);
// $NON-NLS-1$
this.setBasicNodeStyle(eClassNode, "red");
diagramDescription.getNodeDescriptions().add(eClassNode);
Diagram result = this.render(diagramDescription, this.fixture);
assertThat(result).isNotNull();
assertThat(result.getEdges()).isEmpty();
assertThat(result.getNodes()).hasSize(2);
// $NON-NLS-1$ //$NON-NLS-2$
assertThat(result.getNodes()).extracting(node -> node.getLabel().getText()).containsExactlyInAnyOrder("Class1", "Class2");
}
use of org.eclipse.sirius.components.view.NodeDescription in project sirius-components by eclipse-sirius.
the class DiagramDescriptionItemProvider method collectNewChildDescriptors.
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created
* under this object. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
NodeDescription nodeChild = ViewFactory.eINSTANCE.createNodeDescription();
// $NON-NLS-1$
nodeChild.setName("Node");
nodeChild.setStyle(ViewFactory.eINSTANCE.createNodeStyle());
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.DIAGRAM_DESCRIPTION__NODE_DESCRIPTIONS, nodeChild));
EdgeDescription edgeChild = ViewFactory.eINSTANCE.createEdgeDescription();
// $NON-NLS-1$
edgeChild.setName("Edge");
EdgeStyle newEdgeStyle = ViewFactory.eINSTANCE.createEdgeStyle();
// $NON-NLS-1$
newEdgeStyle.setColor("#002639");
edgeChild.setStyle(newEdgeStyle);
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.DIAGRAM_DESCRIPTION__EDGE_DESCRIPTIONS, edgeChild));
DropTool dropTool = ViewFactory.eINSTANCE.createDropTool();
// $NON-NLS-1$
dropTool.setName("On Drop");
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.DIAGRAM_DESCRIPTION__ON_DROP, dropTool));
}
use of org.eclipse.sirius.components.view.NodeDescription in project sirius-components by eclipse-sirius.
the class ViewValidatorTests method testNodeDescriptionInvalidDomain.
@Test
public void testNodeDescriptionInvalidDomain() {
Map<Object, Object> defaultContext = Diagnostician.INSTANCE.createDefaultContext();
NodeDescription nodeDescription = ViewFactory.eINSTANCE.createNodeDescription();
ResourceSetImpl resourceSet = new ResourceSetImpl();
XMIResourceImpl xmiResource = new XMIResourceImpl();
xmiResource.getContents().add(nodeDescription);
resourceSet.getResources().add(xmiResource);
BasicDiagnostic expected = new BasicDiagnostic(Diagnostic.ERROR, null, 0, null, null);
// @formatter:off
expected.add(new BasicDiagnostic(Diagnostic.ERROR, SIRIUS_COMPONENTS_EMF_PACKAGE, 0, // $NON-NLS-1$
String.format(DiagramDescriptionValidator.DIAGRAM_ELEMENT_DESCRIPTION_INVALID_DOMAIN_TYPE_ERROR_MESSAGE, Optional.ofNullable(nodeDescription.getDomainType()).orElse("")), new Object[] { nodeDescription, ViewPackage.Literals.DIAGRAM_ELEMENT_DESCRIPTION__DOMAIN_TYPE }));
// @formatter:on
BasicDiagnostic diagnosticChain = new BasicDiagnostic(Diagnostic.OK, null, 0, null, null);
boolean validationResult = new DiagramDescriptionValidator().validate(nodeDescription.eClass(), nodeDescription, diagnosticChain, defaultContext);
assertThat(validationResult).isFalse();
assertThat(diagnosticChain).isEqualTo(expected);
}
use of org.eclipse.sirius.components.view.NodeDescription in project sirius-components by eclipse-sirius.
the class ViewValidatorTests method testNodeStyleDescriptionValidDomainInResourceSet.
@Test
public void testNodeStyleDescriptionValidDomainInResourceSet() {
Map<Object, Object> defaultContext = Diagnostician.INSTANCE.createDefaultContext();
NodeDescription nodeDescription = ViewFactory.eINSTANCE.createNodeDescription();
nodeDescription.setDomainType(SAMPLE_ENTITY_NAME);
ResourceSetImpl resourceSet = new ResourceSetImpl();
XMIResourceImpl viewResource = new XMIResourceImpl();
viewResource.getContents().add(nodeDescription);
XMIResourceImpl domainResource = new XMIResourceImpl();
Domain domain = DomainFactory.eINSTANCE.createDomain();
domain.setName(SAMPLE_DOMAIN_NAME);
domainResource.getContents().add(domain);
Entity entity = DomainFactory.eINSTANCE.createEntity();
entity.setName(SAMPLE_ENTITY_NAME);
domain.getTypes().add(entity);
resourceSet.getResources().add(viewResource);
resourceSet.getResources().add(domainResource);
BasicDiagnostic diagnosticChain = new BasicDiagnostic(Diagnostic.OK, null, 0, null, null);
boolean validationResult = new DiagramDescriptionValidator().validate(nodeDescription.eClass(), nodeDescription, diagnosticChain, defaultContext);
assertThat(validationResult).isTrue();
assertThat(diagnosticChain).isEqualTo(new BasicDiagnostic(Diagnostic.OK, null, 0, null, null));
}
Aggregations