Search in sources :

Example 6 with EObjectNode

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

the class OutlineFilterAndSorterTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final Injector injector = TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.outline.OutlineTestLanguage");
    with(new ISetup() {

        @Override
        public Injector createInjectorAndDoEMFRegistration() {
            return injector;
        }
    });
    Model model = OutlineTestFactory.eINSTANCE.createModel();
    nodes = Lists.newArrayList();
    nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "one", true));
    nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "two", true));
    nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "three", true));
    filterAndSorter = new OutlineFilterAndSorter();
}
Also used : Injector(com.google.inject.Injector) ISetup(org.eclipse.xtext.ISetup) Model(org.eclipse.xtext.ui.tests.editor.outline.outlineTest.Model) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) OutlineFilterAndSorter(org.eclipse.xtext.ui.editor.outline.impl.OutlineFilterAndSorter) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)

Example 7 with EObjectNode

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

the class OutlineNodeTest method testCreateChildrenLazily.

@Test
public void testCreateChildrenLazily() {
    DocumentRootNode rootNode = createRootNode();
    EObjectNode parentNode = new EObjectNode(parentElement, rootNode, (ImageDescriptor) null, "parent", false);
    assertFalse(parentNode.getChildren().isEmpty());
}
Also used : DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) Test(org.junit.Test)

Example 8 with EObjectNode

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

the class OutlineNodeTest method createRootNode.

protected DocumentRootNode createRootNode() {
    XtextDocument document = get(XtextDocument.class);
    document.setInput(resource);
    IOutlineTreeStructureProvider treeStructureProvider = new IOutlineTreeStructureProvider() {

        @Override
        public void createChildren(IOutlineNode parentNode, EObject modelElement) {
            new EObjectNode(child0Element, parentNode, (ImageDescriptor) null, "child", false);
        }
    };
    DocumentRootNode rootNode = new DocumentRootNode((ImageDescriptor) null, "root", document, treeStructureProvider);
    return rootNode;
}
Also used : IOutlineTreeStructureProvider(org.eclipse.xtext.ui.editor.outline.impl.IOutlineTreeStructureProvider) DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) EObject(org.eclipse.emf.ecore.EObject) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 9 with EObjectNode

use of org.eclipse.xtext.ui.editor.outline.impl.EObjectNode in project n4js by eclipse.

the class MetaTypeAwareComparator method getCategory.

private int getCategory(IOutlineNode node) {
    if (node instanceof EObjectNode) {
        EClass eclass = ((EObjectNode) node).getEClass();
        int id = eclass.getClassifierID();
        int key = 10000 + id;
        Integer sortKey = METATYPESORTORDER.get(id);
        if (sortKey != null) {
            key = sortKey * 1000;
        }
        if (node instanceof N4JSEObjectNode) {
            N4JSEObjectNode n4node = (N4JSEObjectNode) node;
            if (!n4node.isStatic) {
                key += 100;
            }
            if (n4node.isConstructor) {
                key -= 50;
            }
        }
        return key;
    }
    return -1;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)

Example 10 with EObjectNode

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

the class XtextElementSelectionListener method getSelectedElementType.

/**
 * Gets the EClass of the semantic element currently selected.
 *
 * @return EClass or null
 */
public EClass getSelectedElementType() {
    if (selection instanceof IStructuredSelection) {
        if (((IStructuredSelection) selection).getFirstElement() instanceof EObject) {
            // structured selection, e.g. GMFEditor
            EObject eObject = (EObject) ((IStructuredSelection) selection).getFirstElement();
            if (eObject.eResource() != null) {
                return eObject.eClass();
            }
        } else if (((IStructuredSelection) selection).getFirstElement() instanceof EObjectNode) {
            // selection in outline
            return ((EObjectNode) ((IStructuredSelection) selection).getFirstElement()).getEClass();
        }
    } else {
        ILeafNode node = nodeAtTextSelection();
        EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(node);
        if (semanticObject != null) {
            return semanticObject.eClass();
        }
    }
    return null;
}
Also used : ILeafNode(org.eclipse.xtext.nodemodel.ILeafNode) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)

Aggregations

EObjectNode (org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)20 Test (org.junit.Test)9 DocumentRootNode (org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode)7 IOutlineNode (org.eclipse.xtext.ui.editor.outline.IOutlineNode)6 EObject (org.eclipse.emf.ecore.EObject)5 EStructuralFeatureNode (org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode)3 InternalEObject (org.eclipse.emf.ecore.InternalEObject)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StyledString (org.eclipse.jface.viewers.StyledString)2 ILeafNode (org.eclipse.xtext.nodemodel.ILeafNode)2 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 Injector (com.google.inject.Injector)1 EClass (org.eclipse.emf.ecore.EClass)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 IXtendOutlineContext (org.eclipse.xtend.ide.common.outline.IXtendOutlineContext)1 ISetup (org.eclipse.xtext.ISetup)1