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);
}
}
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);
}
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;
}
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);
}
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);
}
Aggregations