Search in sources :

Example 1 with DocumentRootNode

use of org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode 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 2 with DocumentRootNode

use of org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode 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 3 with DocumentRootNode

use of org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode 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 4 with DocumentRootNode

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

the class OutlineNodeTest method testStateAccess.

@Test
public void testStateAccess() {
    DocumentRootNode rootNode = createRootNode();
    EObjectNode parentNode = new EObjectNode(parentElement, rootNode, (ImageDescriptor) null, "parent", false);
    EStructuralFeatureNode featureNode = new EStructuralFeatureNode(parentElement, OutlineTestPackage.Literals.ELEMENT__XREFS, parentNode, (ImageDescriptor) null, "eClassifiers", true);
    IUnitOfWork<Boolean, EObject> work = new IUnitOfWork<Boolean, EObject>() {

        @Override
        public Boolean exec(EObject state) throws Exception {
            return state != null;
        }
    };
    assertTrue(rootNode.readOnly(work));
    assertTrue(parentNode.readOnly(work));
    assertTrue(featureNode.readOnly(work));
}
Also used : IUnitOfWork(org.eclipse.xtext.util.concurrent.IUnitOfWork) DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) EObject(org.eclipse.emf.ecore.EObject) EStructuralFeatureNode(org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) Test(org.junit.Test)

Example 5 with DocumentRootNode

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

the class OutlineNodeTest method testMethodsDelegateToParent.

@Test
public void testMethodsDelegateToParent() {
    DocumentRootNode rootNode = createRootNode();
    EObjectNode parentNode = new EObjectNode(parentElement, rootNode, (ImageDescriptor) null, "parent", false);
    assertNotNull(parentNode.getDocument());
    assertNotNull(parentNode.getTreeProvider());
    assertEquals(rootNode.getDocument(), parentNode.getDocument());
    assertEquals(rootNode.getTreeProvider(), parentNode.getTreeProvider());
}
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

DocumentRootNode (org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode)8 EObjectNode (org.eclipse.xtext.ui.editor.outline.impl.EObjectNode)7 Test (org.junit.Test)6 EObject (org.eclipse.emf.ecore.EObject)3 IOutlineNode (org.eclipse.xtext.ui.editor.outline.IOutlineNode)3 StyledString (org.eclipse.jface.viewers.StyledString)2 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)2 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 IXtendOutlineContext (org.eclipse.xtend.ide.common.outline.IXtendOutlineContext)1 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)1 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)1 EStructuralFeatureNode (org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode)1 IOutlineTreeStructureProvider (org.eclipse.xtext.ui.editor.outline.impl.IOutlineTreeStructureProvider)1 TextRegion (org.eclipse.xtext.util.TextRegion)1 IUnitOfWork (org.eclipse.xtext.util.concurrent.IUnitOfWork)1