use of org.eclipse.sirius.components.view.DiagramDescription 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.DiagramDescription in project sirius-components by eclipse-sirius.
the class DiagramDescriptionValidator method hasProperDomainType.
private boolean hasProperDomainType(DiagramDescription diagramDescription, DiagnosticChain diagnostics) {
boolean isValid = false;
ResourceSet resourceSet = diagramDescription.eResource().getResourceSet();
List<Entity> entities = this.getDomainEntitiesFromResourceSet(resourceSet);
List<EPackage> ePackages = this.getEPackagesFromRegistry(resourceSet.getPackageRegistry());
// $NON-NLS-1$
String domainType = Optional.ofNullable(diagramDescription.getDomainType()).orElse("");
isValid = entities.stream().anyMatch(entity -> this.describesEntity(domainType, entity));
if (!isValid && !domainType.isBlank()) {
// @formatter:off
isValid = ePackages.stream().map(EPackage::getEClassifiers).flatMap(Collection::stream).filter(EClass.class::isInstance).map(EClass.class::cast).anyMatch(classifier -> new DomainClassPredicate(domainType).test(classifier));
// @formatter:off
}
if (!isValid && diagnostics != null) {
// @formatter:off
BasicDiagnostic basicDiagnostic = new BasicDiagnostic(Diagnostic.ERROR, SIRIUS_COMPONENTS_EMF_PACKAGE, 0, String.format(DIAGRAM_DESCRIPTION_INVALID_DOMAIN_TYPE_ERROR_MESSAGE, domainType), new Object[] { diagramDescription, ViewPackage.Literals.REPRESENTATION_DESCRIPTION__DOMAIN_TYPE });
// @formatter:on
diagnostics.add(basicDiagnostic);
}
return isValid;
}
use of org.eclipse.sirius.components.view.DiagramDescription in project sirius-components by eclipse-sirius.
the class ViewItemProvider 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);
DiagramDescription newDiagramDescription = ViewFactory.eINSTANCE.createDiagramDescription();
// $NON-NLS-1$
newDiagramDescription.setName("New Diagram Description");
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.VIEW__DESCRIPTIONS, newDiagramDescription));
}
use of org.eclipse.sirius.components.view.DiagramDescription in project sirius-web by eclipse-sirius.
the class StereotypeDescriptionRegistryConfigurer method getEmptyViewContent.
private String getEmptyViewContent() {
View newView = ViewFactory.eINSTANCE.createView();
DiagramDescription diagramDescription = ViewFactory.eINSTANCE.createDiagramDescription();
// $NON-NLS-1$
diagramDescription.setName("New Diagram Description");
newView.getDescriptions().add(diagramDescription);
return this.stereotypeBuilder.getStereotypeBody(newView);
}
use of org.eclipse.sirius.components.view.DiagramDescription in project sirius-components by eclipse-sirius.
the class DynamicDiagramsTests method testRenderUnsynchronizedEcoreDiagram.
@Test
void testRenderUnsynchronizedEcoreDiagram() 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.UNSYNCHRONIZED);
// $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()).isEmpty();
}
Aggregations