Search in sources :

Example 1 with Category

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);
    }
}
Also used : Category(com.avaloq.tools.ddk.check.check.Category) IDocumentElementNode(org.eclipse.pde.internal.core.text.IDocumentElementNode) Check(com.avaloq.tools.ddk.check.check.Check) TocTopic(org.eclipse.pde.internal.ua.core.toc.text.TocTopic)

Example 2 with Category

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);
    }
}
Also used : Category(com.avaloq.tools.ddk.check.check.Category) EStructuralFeatureNode(org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode) Check(com.avaloq.tools.ddk.check.check.Check) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)

Aggregations

Category (com.avaloq.tools.ddk.check.check.Category)2 Check (com.avaloq.tools.ddk.check.check.Check)2 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)1 IDocumentElementNode (org.eclipse.pde.internal.core.text.IDocumentElementNode)1 TocTopic (org.eclipse.pde.internal.ua.core.toc.text.TocTopic)1 EObjectNode (org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)1 EStructuralFeatureNode (org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode)1