/** * 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); }
@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); } }
@Override public int getCategory(final IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { EStructuralFeature eStructuralFeature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (eStructuralFeature == ValidPackage.Literals.VALID_MODEL__IMPORTS) { return IMPORTS_ORDER; } } return 0; }
@Override public int getCategory(final IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { EStructuralFeature eStructuralFeature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (eStructuralFeature == ExportPackage.Literals.EXPORT_MODEL__IMPORTS) { return IMPORTS_ORDER; } } return 0; }
@Override public int getCategory(final IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { EStructuralFeature eStructuralFeature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (eStructuralFeature == ScopePackage.Literals.SCOPE_MODEL__IMPORTS) { return IMPORTS_ORDER; } } return 0; }
/** * 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); } } }
private static List<IOutlineNode> extractChildrenFromStructuralFeatureNodes(Iterable<IOutlineNode> nodes) { List<IOutlineNode> nodesToFilter = new ArrayList<>(); for (IOutlineNode node : nodes) { if (node instanceof EStructuralFeatureNode) { EStructuralFeatureNode parent = (EStructuralFeatureNode) node; nodesToFilter.addAll(parent.getChildren()); } } return nodesToFilter; }
protected void _createChildren(EStructuralFeatureNode parentNode, EObject node) { if (node instanceof Plan || node instanceof Agent || node instanceof Belief) super._createChildren(parentNode, node); }
/** * 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; }
@Override protected boolean apply(IOutlineNode node) { return !(node instanceof EStructuralFeatureNode); }