Search in sources :

Example 1 with EStructuralFeatureNode

use of org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode 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)

Example 2 with EStructuralFeatureNode

use of org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode in project dsl-devkit by dsldevkit.

the class AbstractOutlineTest method addToOutlineMap.

/**
 * Add the given outline node to the outline map.
 *
 * @param node
 *          IOutlineNode to add.
 */
private void addToOutlineMap(final IOutlineNode node) {
    EStructuralFeature eFeature = null;
    if (node instanceof EObjectNode) {
        eFeature = ((EObjectNode) node).getEObject(getTestSource().getXtextResource()).eContainingFeature();
        // TODO : remove the following part once all tests have been refactored
        Class<?> nodeClazz = ((EObjectNode) node).getEClass().getInstanceClass();
        if (!getOutlineMap().containsKey(nodeClazz)) {
            getOutlineMap().put(nodeClazz, new ArrayList<IOutlineNode>());
        }
        getOutlineMap().get(nodeClazz).add(node);
    } else if (node instanceof EStructuralFeatureNode) {
        eFeature = ((EStructuralFeatureNode) node).getEStructuralFeature();
    }
    if (eFeature == null) {
        return;
    }
    if (!getOutlineMap().containsKey(eFeature)) {
        getOutlineMap().put(eFeature, new ArrayList<IOutlineNode>());
    }
    getOutlineMap().get(eFeature).add(node);
}
Also used : EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) EStructuralFeatureNode(org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 3 with EStructuralFeatureNode

use of org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode in project dsl-devkit by dsldevkit.

the class AbstractOutlineTreeProvider method createEStructuralFeatureNode.

/**
 * Creates a new structural feature node with a given image description and label.
 *
 * @param parentNode
 *          the parent {@link IOutlineNode}
 * @param owner
 *          a valid model element as {@link EObject}
 * @param feature
 *          a structural feature {@link EStructuralFeature}
 * @param image
 *          an image descriptor {@link ImageDescriptor}
 * @param text
 *          the label text
 * @param isLeaf
 *          true if feature is a leaf
 * @return newly created structural feature node
 */
protected EStructuralFeatureNode createEStructuralFeatureNode(final IOutlineNode parentNode, final EObject owner, final EStructuralFeature feature, final ImageDescriptor image, final Object text, final boolean isLeaf) {
    boolean isFeatureSet = owner.eIsSet(feature);
    EStructuralFeatureNode eStructuralFeatureNode = new EStructuralFeatureNode(owner, feature, parentNode, image, text, isLeaf || !isFeatureSet);
    if (isFeatureSet) {
        ITextRegion region = getLocationInFileProvider().getFullTextRegion(owner, feature, 0);
        if (feature.isMany()) {
            int numValues = ((Collection<?>) owner.eGet(feature)).size();
            ITextRegion fullTextRegion = getLocationInFileProvider().getFullTextRegion(owner, feature, numValues - 1);
            if (fullTextRegion != null) {
                region = region.merge(fullTextRegion);
            }
        }
        eStructuralFeatureNode.setTextRegion(region);
    }
    return eStructuralFeatureNode;
}
Also used : ITextRegion(org.eclipse.xtext.util.ITextRegion) EStructuralFeatureNode(org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode) Collection(java.util.Collection)

Example 4 with EStructuralFeatureNode

use of org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode in project xtext-xtend by eclipse.

the class AbstractMultiModeOutlineTreeProvider method buildImportSectionNode.

@Override
public IXtendOutlineContext buildImportSectionNode(XtendFile xtendFile, IXtendOutlineContext context) {
    EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
    IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
    EStructuralFeatureNode node = getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, xtendFile.getImportSection(), XtypePackage.Literals.XIMPORT_SECTION__IMPORT_DECLARATIONS, images.forImportContainer(), "import declarations", false);
    return eclipseXtendOutlineContext.withParentNode(node);
}
Also used : EStructuralFeatureNode(org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 5 with EStructuralFeatureNode

use of org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode in project xtext-xtend by eclipse.

the class AbstractMultiModeOutlineTreeProvider method buildPackageNode.

@Override
public IXtendOutlineContext buildPackageNode(XtendFile xtendFile, IXtendOutlineContext context) {
    EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
    IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
    String primaryPackage = xtendFile.getPackage();
    EStructuralFeatureNode node = getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, xtendFile, XtendPackage.Literals.XTEND_FILE__PACKAGE, images.forPackage(), primaryPackage, true);
    return eclipseXtendOutlineContext.withParentNode(node);
}
Also used : EStructuralFeatureNode(org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode) StyledString(org.eclipse.jface.viewers.StyledString) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Aggregations

EStructuralFeatureNode (org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode)6 IOutlineNode (org.eclipse.xtext.ui.editor.outline.IOutlineNode)3 EObjectNode (org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)3 Category (com.avaloq.tools.ddk.check.check.Category)1 Check (com.avaloq.tools.ddk.check.check.Check)1 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)1 Collection (java.util.Collection)1 EObject (org.eclipse.emf.ecore.EObject)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 StyledString (org.eclipse.jface.viewers.StyledString)1 DocumentRootNode (org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode)1 ITextRegion (org.eclipse.xtext.util.ITextRegion)1 IUnitOfWork (org.eclipse.xtext.util.concurrent.IUnitOfWork)1 Test (org.junit.Test)1