use of com.avaloq.tools.ddk.check.check.Category in project dsl-devkit by dsldevkit.
the class CheckTocGenerator method addTopicToToc.
/**
* Adds the topic to toc model.
*
* @param model
* the model
* @param label
* topic label
* @param reference
* topic reference
* @param uri
* the uri
* @param buildContext
* the context
* @throws CoreException
* CoreException
*/
private void addTopicToToc(final TocModel model, final String label, final String reference, final URI uri, final IBuildContext buildContext) throws CoreException {
TocTopic topic = model.getFactory().createTocTopic();
topic.setFieldLabel(label);
topic.setFieldRef(reference);
topic.setXMLAttribute(SORT_KEY, "false");
// Add catalogs and checks as sub-topics
TocTopic categoryTopic;
TocTopic checkTopic;
for (Category category : projectHelper.getCatalog(buildContext, uri).getCategories()) {
categoryTopic = model.getFactory().createTocTopic();
categoryTopic.setFieldLabel(category.getLabel());
categoryTopic.setFieldRef(reference + '#' + generatorNaming.getContextId(category));
for (Check check : category.getChecks()) {
checkTopic = model.getFactory().createTocTopic();
checkTopic.setFieldLabel(check.getLabel());
checkTopic.setFieldRef(reference + '#' + generatorNaming.getContextId(check));
categoryTopic.addChild(checkTopic);
}
topic.addChild(categoryTopic);
}
for (Check check : projectHelper.getCatalog(buildContext, uri).getChecks()) {
checkTopic = model.getFactory().createTocTopic();
checkTopic.setFieldLabel(check.getLabel());
checkTopic.setFieldRef(reference + '#' + generatorNaming.getContextId(check));
topic.addChild(checkTopic);
}
// Add TOC at the right position (to have them sorted alphabetically by label)
IDocumentElementNode[] children = model.getToc().getChildNodes();
String childLabel;
boolean added = false;
for (IDocumentElementNode child : children) {
if (child instanceof TocTopic) {
childLabel = ((TocTopic) child).getFieldLabel();
if (childLabel.compareTo(label) > 0) {
// childLabel is alphabetically after the label of the new toc
model.getToc().addChild(topic, (TocTopic) child, true);
added = true;
break;
}
}
}
if (!added) {
model.getToc().addChild(topic);
}
}
use of com.avaloq.tools.ddk.check.check.Category in project dsl-devkit by dsldevkit.
the class CheckOutlineTreeProvider method internalCreateChildren.
@Override
protected void internalCreateChildren(final DocumentRootNode parentNode, final EObject modelElement) {
CheckCatalog catalog = (CheckCatalog) modelElement;
if (catalog.getPackageName() != null) {
getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, catalog, CheckPackage.Literals.CHECK_CATALOG__PACKAGE_NAME, ImageDescriptor.createFromImage(checkImages.forPackage()), catalog.getPackageName(), true);
}
if (catalog.getImports() != null && !catalog.getImports().getImportDeclarations().isEmpty()) {
EStructuralFeatureNode importNode = getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, catalog, CheckPackage.Literals.CHECK_CATALOG__IMPORTS, ImageDescriptor.createFromImage(checkImages.forImportContainer()), "Import declarations", false);
for (final org.eclipse.xtext.xtype.XImportDeclaration imported : catalog.getImports().getImportDeclarations()) {
createNode(importNode, imported);
}
}
EObjectNode catalogNode = createNode(parentNode, catalog);
for (final Category category : catalog.getCategories()) {
createNode(catalogNode, category);
}
for (final Check check : catalog.getChecks()) {
createNode(catalogNode, check);
}
}
Aggregations