Search in sources :

Example 11 with EObjectNode

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

the class XtendOutlineJvmTreeProvider method buildXtendNode.

@Override
public IXtendOutlineContext buildXtendNode(EObject modelElement, IXtendOutlineContext context) {
    IXtendOutlineContext resultedContext = super.buildXtendNode(modelElement, context);
    if (!context.isShowInherited()) {
        EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
        IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
        if (parentNode instanceof DocumentRootNode) {
            if (modelElement instanceof JvmDeclaredType) {
                JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) modelElement;
                String packageName = jvmDeclaredType.getPackageName();
                if (packageName != null) {
                    EObject rootElement = modelElement.eResource().getContents().get(0);
                    if (rootElement instanceof XtendFile) {
                        XtendFile xtendFile = (XtendFile) rootElement;
                        String primaryPackage = xtendFile.getPackage();
                        if (!packageName.equals(primaryPackage)) {
                            EObjectNode typeNode = (EObjectNode) ((EclipseXtendOutlineContext) resultedContext).getParentNode();
                            if (typeNode.getText() instanceof StyledString) {
                                typeNode.setText(((StyledString) typeNode.getText()).append(new StyledString(" - " + packageName, StyledString.QUALIFIER_STYLER)));
                            }
                        }
                    }
                }
            }
        }
    }
    return resultedContext;
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext) EObject(org.eclipse.emf.ecore.EObject) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 12 with EObjectNode

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

the class AbstractMultiModeOutlineTreeProvider method buildEObjectNode.

@Override
public IXtendOutlineContext buildEObjectNode(EObject modelElement, IXtendOutlineContext context) {
    EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
    IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
    EObjectNode node = createNode(parentNode, modelElement);
    return eclipseXtendOutlineContext.withParentNode(node);
}
Also used : EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 13 with EObjectNode

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

the class AbstractMultiModeOutlineTreeProvider method buildXtendNode.

@Override
public IXtendOutlineContext buildXtendNode(EObject modelElement, IXtendOutlineContext context) {
    EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
    IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
    int inheritanceDepth = eclipseXtendOutlineContext.getInheritanceDepth();
    EObjectNode xtendNode = createXtendNode(parentNode, modelElement, inheritanceDepth);
    return eclipseXtendOutlineContext.withParentNode(xtendNode);
}
Also used : EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 14 with EObjectNode

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

the class OutlineNodeComparerTest method testPropertyEquality.

@Test
public void testPropertyEquality() {
    EObjectNode node = new EObjectNode(eObject, null, image, new StyledString("Node"), false);
    assertFalse(comparer.equals(node, new DocumentRootNode(image, new StyledString("Node"), null, null)));
    assertTrue(comparer.equals(node, new EObjectNode(OutlineTestFactory.eINSTANCE.createElement(), null, image, new StyledString("Node"), false)));
    assertFalse(comparer.equals(node, new EObjectNode(eObject, node, image, new StyledString("Node"), false)));
    assertFalse(comparer.equals(node, new EObjectNode(eObject, null, image2, new StyledString("Node"), false)));
    assertFalse(comparer.equals(node, new EObjectNode(eObject, null, image, new StyledString("Node2"), false)));
    assertTrue(comparer.equals(node, new EObjectNode(eObject, null, image, "Node", false)));
}
Also used : DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) StyledString(org.eclipse.jface.viewers.StyledString) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) Test(org.junit.Test)

Example 15 with EObjectNode

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

the class OutlineNodeComparerTest method testEquivalentIndex.

@SuppressWarnings("unused")
@Test
public void testEquivalentIndex() throws Exception {
    DocumentRootNode rootNode = new DocumentRootNode(image, "Root", null, null);
    EObjectNode node = new EObjectNode(eObject, rootNode, image, "Node", false);
    DocumentRootNode rootNode2 = new DocumentRootNode(image, "Root", null, null);
    EObjectNode node2 = new EObjectNode(eObject, rootNode2, image, "Node", false);
    assertTrue(comparer.equals(node, node2));
    EObjectNode node3 = new EObjectNode(eObject, rootNode2, image, "OtherNode", false);
    assertTrue(comparer.equals(node, node2));
    DocumentRootNode rootNode3 = new DocumentRootNode(image, "Root", null, null);
    EObjectNode node4 = new EObjectNode(eObject, rootNode3, image, "OtherNode", false);
    EObjectNode node5 = new EObjectNode(eObject, rootNode3, image, "Node", false);
    assertTrue(comparer.equals(node, node5));
    EObjectNode node6 = new EObjectNode(eObject, rootNode3, image, "OtherNode", false);
    assertFalse(comparer.equals(node, node5));
}
Also used : DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) Test(org.junit.Test)

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