org.eclipse.xtext.ui.editor.outline.IOutlineNode Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.outline.IOutlineNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IOutlineNodeComparer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean isEquivalentIndex(IOutlineNode node1, IOutlineNode node2) {
	IOutlineNode parent1 = node1.getParent();
	IOutlineNode parent2 = node2.getParent();
	if (parent1 == null && parent2 == null)
		return true;
	if (parent1 != null && parent2 != null) {
		List<IOutlineNode> siblings1 = parent1.getChildren();
		List<IOutlineNode> siblings2 = parent2.getChildren();
		int index1 = siblings1.indexOf(node1);
		int index2 = siblings2.indexOf(node2);
		// same siblings =>  same index
		// sibling inserted after => same index
		// sibling inserted before => same # of following siblings
		if (index1 == index2 || siblings1.size() - index1 == siblings2.size() - index2)
			return true;
	}
	return false;
}
 
Example #2
Source File: DotHtmlLabelOutlineTreeProvider.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void _createNode(IOutlineNode parentNode, EObject modelElement) {
	if (modelElement instanceof HtmlContent) {
		HtmlContent htmlContent = (HtmlContent) modelElement;
		/**
		 * Skip the empty (containing nothing or only white-spaces)
		 * htmlContent elements, but process their tag children.
		 */
		if (htmlContent.getText() != null
				&& !htmlContent.getText().trim().isEmpty()) {
			super._createNode(parentNode, htmlContent);
		} else {
			if (htmlContent.getTag() != null) {
				super._createNode(parentNode, htmlContent.getTag());
			}
		}
	} else {
		super._createNode(parentNode, modelElement);
	}
}
 
Example #3
Source File: AbstractOutlineNode.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public List<IOutlineNode> getChildren() {
	if (isLeaf)
		return Collections.emptyList();
	if (children == null) {
		readOnly(new IUnitOfWork.Void<EObject>() {
			@Override
			public void process(EObject eObject) throws Exception {
				getTreeProvider().createChildren(AbstractOutlineNode.this, eObject);
			}
		});
		if (children == null) {
			// tree provider did not create any child
			isLeaf = true;
			return Collections.emptyList();
		}
	}
	return Collections.unmodifiableList(children);
}
 
Example #4
Source File: OutlineWithEditorLinker.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void selectInTreeView(ISelection selection) {
	if (selection instanceof ITextSelection && !treeViewer.getTree().isDisposed()) {
		ITextSelection textSelection = (ITextSelection) selection;
		ITextRegion selectedTextRegion = new TextRegion(textSelection.getOffset(), textSelection.getLength());
		Object input = treeViewer.getInput();
		if (input instanceof IOutlineNode) {
			try {
				IOutlineNode nodeToBeSelected = findBestNode((IOutlineNode) input, selectedTextRegion);
				if (nodeToBeSelected != null)
					treeViewer.setSelection(new StructuredSelection(nodeToBeSelected));
			} catch(Exception exc) {
				// ignore, editor can have a different state than the tree
			}
		}
	}
}
 
Example #5
Source File: AbstractOutlineWorkbenchTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
protected void openOutlineView() throws PartInitException, InterruptedException {
	outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
	executeAsyncDisplayJobs();
	Object adapter = editor.getAdapter(IContentOutlinePage.class);
	assertTrue(adapter instanceof OutlinePage);
	outlinePage = new SyncableOutlinePage((OutlinePage) adapter);
	outlinePage.resetSyncer();
	try {
		outlinePage.waitForUpdate(EXPECTED_TIMEOUT);
	} catch (TimeoutException e) {
		System.out.println("Expected timeout exceeded: " + EXPECTED_TIMEOUT);// timeout is OK here
	}
	treeViewer = outlinePage.getTreeViewer();
	assertSelected(treeViewer);
	assertExpanded(treeViewer);
	assertTrue(treeViewer.getInput() instanceof IOutlineNode);
	IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
	List<IOutlineNode> children = rootNode.getChildren();
	assertEquals(1, children.size());
	modelNode = children.get(0);
}
 
Example #6
Source File: DotOutlineTreeProvider.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected EObjectNode createEObjectNode(IOutlineNode parentNode,
		EObject modelElement, Image image, Object text, boolean isLeaf) {
	if (EcoreUtil2.getContainerOfType(modelElement,
			HtmlLabel.class) != null) {
		// in case of a html-like label addition offset should be calculated
		EObjectNode eObjectNode = new EObjectNode(modelElement, parentNode,
				image, text, isLeaf);
		ICompositeNode parserNode = NodeModelUtils.getNode(modelElement);
		if (parserNode != null) {
			ITextRegion parserNodeTextRegion = parserNode.getTextRegion();
			ITextRegion newTextRegion = new TextRegion(
					parserNodeTextRegion.getOffset()
							+ attributeValueStartOffset,
					parserNodeTextRegion.getLength());
			eObjectNode.setTextRegion(newTextRegion);
		}
		if (isLocalElement(parentNode, modelElement)) {
			ITextRegion significantTextRegion = locationInFileProvider
					.getSignificantTextRegion(modelElement);
			ITextRegion shortTextRegion = new TextRegion(
					significantTextRegion.getOffset()
							+ attributeValueStartOffset,
					significantTextRegion.getLength());
			eObjectNode.setShortTextRegion(shortTextRegion);
		}
		return eObjectNode;
	} else {
		return super.createEObjectNode(parentNode, modelElement, image,
				text, isLeaf);
	}

}
 
Example #7
Source File: DotOutlineTreeProvider.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Skip the empty (containing nothing or only white-spaces) htmlContent
 * elements, but process their tag children.
 */
protected void _createNode(IOutlineNode parent, HtmlContent htmlContent) {
	if (htmlContent.getText() != null
			&& !htmlContent.getText().trim().isEmpty()) {
		super._createNode(parent, htmlContent);
	} else {
		if (htmlContent.getTag() != null) {
			super._createNode(parent, htmlContent.getTag());
		}
	}
}
 
Example #8
Source File: DotOutlineTreeProvider.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Skip the 'AttrList' wrapper element in the outline structure.
 *
 * @param parent
 *            The outline parent node.
 * @param stmt
 *            The attribute statement.
 */
protected void _createChildren(IOutlineNode parent, AttrStmt stmt) {
	if (stmt.getAttrLists().size() > 0) {
		EList<Attribute> attributes = stmt.getAttrLists().get(0)
				.getAttributes(); // skip the 'AttrList'
		for (Attribute attribute : attributes) {
			createNode(parent, attribute);
		}
	}
}
 
Example #9
Source File: OutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testNoNames() throws Exception {
	final DefaultOutlineTreeProvider noNamesTreeProvider = new DefaultOutlineTreeProvider(new DefaultEObjectLabelProvider(),
			new DefaultLocationInFileProvider()) {
		@Override
		protected Object _text(Object modelElement) {
			return null;
		}
	};
	final String modelAsText = "element1 { element11 {}} element2 {}";
	IXtextDocument document = createXtextDocument(modelAsText);
	final IOutlineNode rootNode = noNamesTreeProvider.createRoot(document);
	document.readOnly(new IUnitOfWork.Void<XtextResource>() {
		@Override
		public void process(XtextResource state) throws Exception {
			noNamesTreeProvider.createChildren(rootNode, state.getContents().get(0));
			
			assertEquals(1, rootNode.getChildren().size());
			IOutlineNode modelNode = rootNode.getChildren().get(0);
			assertEquals(state.getURI().trimFileExtension().lastSegment(), modelNode.getText());
			assertTrue(modelNode.hasChildren());
			
			assertEquals(1, modelNode.getChildren().size());
			IOutlineNode element1 = modelNode.getChildren().get(0);
			assertEquals("<unnamed>", element1.getText().toString());
			assertEquals(new TextRegion(0, 8), element1.getSignificantTextRegion());
			assertEquals(new TextRegion(0, 24), element1.getFullTextRegion());
			assertEquals(modelNode, element1.getParent());
			// node does not know that its children will be skipped
			assertTrue(element1.hasChildren());
			assertTrue(element1.getChildren().isEmpty());
		}
	});
}
 
Example #10
Source File: OutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testCreateChildren() throws Exception {
	final String modelAsText = "element1 { element11 {}} element2 {}";
	IXtextDocument document = createXtextDocument(modelAsText);
	final IOutlineNode rootNode = treeProvider.createRoot(document);
	document.readOnly(new IUnitOfWork.Void<XtextResource>() {
		@Override
		public void process(XtextResource state) throws Exception {
			treeProvider.createChildren(rootNode, state.getContents().get(0));
			assertEquals(1, rootNode.getChildren().size());
			IOutlineNode modelNode = rootNode.getChildren().get(0);
			assertEquals(state.getURI().trimFileExtension().lastSegment(), modelNode.getText());
			assertEquals(new TextRegion(0, modelAsText.length()), modelNode.getSignificantTextRegion());
			assertEquals(new TextRegion(0, modelAsText.length()), modelNode.getFullTextRegion());
			assertEquals(rootNode, modelNode.getParent());
			assertTrue(modelNode.hasChildren());
			
			assertEquals(2, modelNode.getChildren().size());
			IOutlineNode element1 = modelNode.getChildren().get(0);
			assertEquals("element1", element1.getText().toString());
			assertEquals(new TextRegion(0, 8), element1.getSignificantTextRegion());
			assertEquals(new TextRegion(0, 24), element1.getFullTextRegion());
			assertEquals(modelNode, element1.getParent());
			assertTrue(element1.hasChildren());
			
			IOutlineNode element2 = modelNode.getChildren().get(1);
			assertEquals("element2", element2.getText().toString());
			assertEquals(new TextRegion(25, 8), element2.getSignificantTextRegion());
			assertEquals(new TextRegion(25, 11), element2.getFullTextRegion());
			assertEquals(modelNode, element2.getParent());
			assertFalse(element2.hasChildren());
		}
	});
}
 
Example #11
Source File: AbstractOutlineWorkbenchTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void assertSelected(TreeViewer treeViewer, IOutlineNode... expectedSelection) {
	ISelection selection = treeViewer.getSelection();
	assertTrue(selection instanceof IStructuredSelection);
	assertEquals(expectedSelection.length, ((IStructuredSelection) selection).size());
	OUTER: for (Iterator<?> i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
		Object selectedObject = i.next();
		assertTrue(selectedObject instanceof IOutlineNode);
		for (IOutlineNode expectedSelected : expectedSelection) {
			if (nodeComparer.equals((IOutlineNode) selectedObject, expectedSelected))
				continue OUTER;
		}
		fail("Unexpected selection " + selectedObject.toString());
	}
}
 
Example #12
Source File: OutlineCopyQualifiedNameHandler.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected String getQualifiedName(ExecutionEvent event) {
	IOutlineNode outlineNode = getOutlineNode(event);
	if (outlineNode == null) {
		return null;
	}
	return outlineNode.tryReadOnly(new IUnitOfWork<String, EObject>() {

		@Override
		public String exec(EObject selectedElement) throws Exception {
			return getQualifiedName(selectedElement);
		}

	});
}
 
Example #13
Source File: AbstractMultiModeOutlineTreeProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IXtendOutlineContext buildResolvedFeatureNode(JvmDeclaredType inferredType,
		IResolvedFeature resolvedFeature, IXtendOutlineContext context) {
	EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
	IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
	int inheritanceDepth = eclipseXtendOutlineContext.getInheritanceDepth();
	XtendFeatureNode node = createNodeForResolvedFeature(parentNode, inferredType, resolvedFeature, inheritanceDepth);
	return eclipseXtendOutlineContext.withParentNode(node);
}
 
Example #14
Source File: AbstractSARLOutlineTreeProviderTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Assert the number of children for the node is strictly lower
 * than the given value.
 *
 * @param num expected number of children.
 * @return this
 */
public OutlineAsserts numChildrenLowerThan(int num) {
	IOutlineNode[] filteredAndSortedChildren = getSorter().filterAndSort(
			this.node.getChildren());
	assertTrue("Wrong number of children\n" //$NON-NLS-1$
			+ Joiner.on("\n").join(filteredAndSortedChildren), //$NON-NLS-1$
			filteredAndSortedChildren.length < num);
	return this;
}
 
Example #15
Source File: XtendOutlineJvmTreeProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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;
}
 
Example #16
Source File: AbstractSARLOutlineTreeProviderTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Assert the number of children for the node is equal
 * to the given value.
 *
 * @param num expected number of children.
 * @return this
 */
public OutlineAsserts numChildren(int num) {
	IOutlineNode[] filteredAndSortedChildren = getSorter().filterAndSort(
			this.node.getChildren());
	assertEquals("Wrong number of children\n" //$NON-NLS-1$
			+ Joiner.on("\n").join(filteredAndSortedChildren), num, //$NON-NLS-1$
			filteredAndSortedChildren.length);
	return this;
}
 
Example #17
Source File: AbstractMultiModeOutlineTreeProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected XtendFeatureNode createNodeForFeature(IOutlineNode parentNode, final JvmDeclaredType inferredType, EObject featureElement, int inheritanceDepth) {
	boolean synthetic = false;
	if (featureElement instanceof JvmFeature) {
		synthetic = typeExtensions.isSynthetic((JvmIdentifiableElement) featureElement);		
	}
	Object text = computeDecoratedText(featureElement, inheritanceDepth);
	ImageDescriptor image = getImageDescriptor(featureElement);
	if (isShowInherited()) {
		return getOutlineNodeFactory().createXtendFeatureNode(parentNode, featureElement, image, text, true, synthetic, inheritanceDepth);
	}
	return getOutlineNodeFactory().createXtendFeatureNode(parentNode, featureElement, image, text, true, synthetic, inheritanceDepth);
}
 
Example #18
Source File: OutlineCopyQualifiedNameHandler.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private IOutlineNode getOutlineNode(ExecutionEvent event) {
	ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
	if (!(currentSelection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
	return (IOutlineNode) structuredSelection.getFirstElement();
}
 
Example #19
Source File: XtendOutlineSourceTreeProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IXtendOutlineContext newContext(IOutlineNode parentNode) {
	EclipseXtendOutlineSourceContext context = xtendOutlineContextProvider.get();
	context.setShowInherited(isShowInherited());
	context.setParentNode(parentNode);
	return context;
}
 
Example #20
Source File: AbstractOutlineWorkbenchTest.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected TreeViewer getOutlineTreeViewer() throws PartInitException {
	document = editor.getDocument();
	outlineView = editor.getEditorSite().getPage()
			.showView("org.eclipse.ui.views.ContentOutline");
	executeAsyncDisplayJobs();
	Object adapter = editor.getAdapter(IContentOutlinePage.class);
	assertTrue(adapter instanceof OutlinePage);
	outlinePage = (OutlinePage) adapter;
	TreeViewer treeViewer = outlinePage.getTreeViewer();

	awaitForTreeViewer(treeViewer);

	assertTrue(treeViewer.getInput() instanceof IOutlineNode);
	return treeViewer;
}
 
Example #21
Source File: AbstractMultiModeOutlineTreeProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected XtendEObjectNode createXtendNode(IOutlineNode parentNode, EObject modelElement, int inheritanceDepth) {
	Object text = computeDecoratedText(modelElement, inheritanceDepth);

	ImageDescriptor image = getImageDescriptor(modelElement);
	XtendEObjectNode objectNode = getOutlineNodeFactory().createXtendEObjectNode(parentNode, modelElement, image,
			text, true, inheritanceDepth);
	return objectNode;
}
 
Example #22
Source File: XtextOutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testNonInheritMode() throws Exception {
	IOutlineNode node = assertNoException("grammar Foo with org.eclipse.xtext.common.Terminals " +
			"generate foo 'Foo' " +
			"Foo: 'foo'; " +
			"Bar: 'bar';");
	assertEquals(1, node.getChildren().size());
	IOutlineNode grammar = node.getChildren().get(0);
	assertNode(grammar, "grammar Foo", 3);
	assertNode(grammar.getChildren().get(0), "generate foo", 0);
	assertNode(grammar.getChildren().get(1), "Foo", 0);
	assertNode(grammar.getChildren().get(2), "Bar", 0);
}
 
Example #23
Source File: XtextOutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testInheritModeWithOverride() throws Exception {
	setShowInherited(true);
	String model = "grammar Foo with org.eclipse.xtext.common.Terminals " +
			"generate foo 'Foo' " +
			"Foo: 'foo'; " +
			"terminal ID: 'bar';";
	IOutlineNode node = assertNoException(model);
	assertEquals(1, node.getChildren().size());
	IOutlineNode grammar = node.getChildren().get(0);
	assertNode(grammar, "grammar Foo", 10);
	assertNode(grammar.getChildren().get(0), "generate foo", 0);
	IOutlineNode foo = grammar.getChildren().get(1);
	assertNode(foo, "Foo", 0);
	assertEquals(model.lastIndexOf("Foo"), foo.getFullTextRegion().getOffset());
	assertEquals(11, foo.getFullTextRegion().getLength());
	assertEquals(model.lastIndexOf("Foo"), foo.getSignificantTextRegion().getOffset());
	assertEquals(3, foo.getSignificantTextRegion().getLength());
	assertNode(grammar.getChildren().get(2), "ID", 0);
	IOutlineNode id = grammar.getChildren().get(3);
	assertNode(id, "ID (org.eclipse.xtext.common.Terminals)", 0);
	assertNull(id.getSignificantTextRegion());
	assertEquals(ITextRegion.EMPTY_REGION, id.getFullTextRegion());
	assertNode(grammar.getChildren().get(4), "INT (org.eclipse.xtext.common.Terminals)", 0);
	assertNode(grammar.getChildren().get(5), "STRING (org.eclipse.xtext.common.Terminals)", 0);
	assertNode(grammar.getChildren().get(6), "ML_COMMENT (org.eclipse.xtext.common.Terminals)", 0);
	assertNode(grammar.getChildren().get(7), "SL_COMMENT (org.eclipse.xtext.common.Terminals)", 0);
	assertNode(grammar.getChildren().get(8), "WS (org.eclipse.xtext.common.Terminals)", 0);
	assertNode(grammar.getChildren().get(9), "ANY_OTHER (org.eclipse.xtext.common.Terminals)", 0);	
}
 
Example #24
Source File: AbstractOutlineTreeProvider.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Default for createChildrenDispatcher with outline node as a parent node.
 *
 * @param parentNode
 *          the {@link IOutlineNode}
 * @param modelElement
 *          the {@link EObject} model element
 */
// CHECKSTYLE:CHECK-OFF Name (dispatcher enforces names starting with underscore)
public void _createChildren(final IOutlineNode parentNode, final EObject modelElement) {
  // CHECKSTYLE:CHECK-ON
  if (modelElement != null && parentNode.hasChildren()) {
    if (parentNode instanceof DocumentRootNode) {
      internalCreateChildren((DocumentRootNode) parentNode, modelElement);
    } else if (parentNode instanceof EStructuralFeatureNode) {
      internalCreateChildren((EStructuralFeatureNode) parentNode, modelElement);
    } else {
      internalCreateChildren(parentNode, modelElement);
    }
  }
}
 
Example #25
Source File: XtendOutlineWithEditorLinker.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void findNodesInRange(final IOutlineNode input, final ITextRegion selectedTextRegion, final List<IOutlineNode> nodes) {
  final ITextRegion textRegion = input.getFullTextRegion();
  if (((textRegion == null) || textRegion.contains(selectedTextRegion))) {
    nodes.add(input);
  }
  List<IOutlineNode> _children = input.getChildren();
  for (final IOutlineNode child : _children) {
    this.findNodesInRange(child, selectedTextRegion, nodes);
  }
}
 
Example #26
Source File: BackgroundOutlineTreeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected EObjectNode createNode(IOutlineNode parentNode, EObject modelElement) {
	checkCanceled();
	Object text = getText(modelElement);
	boolean isLeaf = isLeaf(modelElement);
	if (text == null && isLeaf)
		return null;
	ImageDescriptor image = getImageDescriptor(modelElement);
	return factory.createEObjectNode(parentNode, modelElement, image, text, isLeaf);
}
 
Example #27
Source File: AbstractMultiModeOutlineTreeProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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);
}
 
Example #28
Source File: EStructuralFeatureNode.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * A {@link BackgroundOutlineTreeProvider} must use
 * {@link #EStructuralFeatureNode(EObject, EStructuralFeature, IOutlineNode, ImageDescriptor, Object, boolean)} instead.
 */
public EStructuralFeatureNode(EObject owner, EStructuralFeature feature, IOutlineNode parent, Image image, Object text,
		boolean isLeaf) {
	super(parent, image, text, isLeaf);
	this.ownerURI = EcoreUtil.getURI(owner);
	this.feature = feature;
}
 
Example #29
Source File: XtendOutlineNodeFactory.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void configureNode(IOutlineNode parentNode, EObject modelElement, int inheritanceDepth,
		XtendEObjectNode featureNode) {
	EObject primarySourceElement = associations.getPrimarySourceElement(modelElement);
	ICompositeNode parserNode = NodeModelUtils.getNode(primarySourceElement==null?modelElement:primarySourceElement);
	if (parserNode != null)
		featureNode.setTextRegion(parserNode.getTextRegion());
	if (isLocalElement(parentNode, modelElement))
		featureNode.setShortTextRegion(getLocationInFileProvider().getSignificantTextRegion(primarySourceElement==null?modelElement:primarySourceElement));
	featureNode.setStatic(isStatic(modelElement));
	featureNode.setInheritanceDepth(inheritanceDepth);
}
 
Example #30
Source File: OutlineNodeLabelProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Object doGetImage(Object element) {
	if (element instanceof IOutlineNode.Extension) {
		ImageDescriptor imageDescriptor = ((IOutlineNode.Extension) element).getImageDescriptor();
		if (imageDescriptor != null)
			return imageDescriptor;
	}
	if (element instanceof IOutlineNode) {
		Image image = ((IOutlineNode) element).getImage();
		if (image != null) 
			return image;
	}
	return super.doGetImage(element);
}