Java Code Examples for org.eclipse.xtext.ui.editor.outline.IOutlineNode#getChildren()
The following examples show how to use
org.eclipse.xtext.ui.editor.outline.IOutlineNode#getChildren() .
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: AbstractOutlineWorkbenchTest.java From n4js with Eclipse Public License 1.0 | 6 votes |
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 2
Source File: OutlineWithEditorLinker.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected IOutlineNode findBestNode(IOutlineNode input, ITextRegion selectedTextRegion) { ITextRegion textRegion = input.getFullTextRegion(); if (textRegion == null || textRegion.contains(selectedTextRegion)) { IOutlineNode currentBestNode = input; for (IOutlineNode child : input.getChildren()) { IOutlineNode candidate = findBestNode(child, selectedTextRegion); if (candidate != null && (currentBestNode.getFullTextRegion() == null || candidate.getFullTextRegion() != null && currentBestNode.getFullTextRegion().getLength() >= candidate.getFullTextRegion().getLength())) { currentBestNode = candidate; } } return currentBestNode; } return null; }
Example 3
Source File: IOutlineNodeComparer.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
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 4
Source File: AbstractOutlineTest.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Recursively searches for a node with the given name and type. * * @param node * a root node of a subtree where the desired node is searched for * @param nodeName * the name of the node to search, must not be {@code null} * @param nodeType * the name of the type of the node to search, may be {@code null} if only the name of the node is to be tested * @return * a node with the given name and type (if specified). If such a node is not found, returns null. */ private IOutlineNode findNode(final IOutlineNode node, final String nodeName, final String nodeType) { IOutlineNode fieldNode = null; String[] textParts = node.getText().toString().split(":"); if (nodeName.equals(textParts[0].trim()) && (nodeType == null || (textParts.length > 1 && nodeType.equals(textParts[1].trim())))) { fieldNode = node; } else { List<IOutlineNode> children = node.getChildren(); for (IOutlineNode child : children) { fieldNode = findNode(child, nodeName, nodeType); if (fieldNode != null) { break; } } } return fieldNode; }
Example 5
Source File: SARLOutlinePage.java From sarl with Apache License 2.0 | 6 votes |
@Override protected List<IOutlineNode> getInitiallyExpandedNodes() { // Automatically expend the rot nodes into the outline. final IOutlineNode rootNode = getTreeProvider().createRoot(getXtextDocument()); final List<IOutlineNode> result = newArrayList(rootNode); for (final IOutlineNode firstLevelNode: rootNode.getChildren()) { if (firstLevelNode instanceof EStructuralFeatureNode) { final EStructuralFeatureNode snode = (EStructuralFeatureNode) firstLevelNode; final EStructuralFeature feature = snode.getEStructuralFeature(); if (XtendTypeDeclaration.class.isAssignableFrom(feature.getContainerClass())) { result.add(firstLevelNode); } } } return result; }
Example 6
Source File: AbstractOutlineWorkbenchTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public void setUp() throws Exception { super.setUp(); preferenceStore = new ScopedPreferenceStore(new InstanceScope(), getEditorId()); comparer = new IOutlineNodeComparer.Default(); modelAsText = "one { two {} three {} } four {}"; file = IResourcesSetupUtil.createFile("test/test.outlinetestlanguage", modelAsText); editor = openEditor(file); document = editor.getDocument(); outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline"); executeAsyncDisplayJobs(); Object adapter = editor.getAdapter(IContentOutlinePage.class); assertTrue(adapter instanceof SyncableOutlinePage); outlinePage = (SyncableOutlinePage) 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); assertEquals(2, modelNode.getChildren().size()); oneNode = modelNode.getChildren().get(0); assertEquals(2, oneNode.getChildren().size()); twoNode = oneNode.getChildren().get(0); threeNode = oneNode.getChildren().get(1); fourNode = modelNode.getChildren().get(1); }
Example 7
Source File: OutlineRefreshJob.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.7 */ protected void restoreChildrenSelectionAndExpansion(IOutlineNode parent, Resource resource, OutlineTreeState formerState, OutlineTreeState newState, CancelIndicator cancelIndicator) { List<IOutlineNode> children = parent.getChildren(); for(IOutlineNode child: children) { if(cancelIndicator.isCanceled()) throw new OperationCanceledException(); if(containsUsingComparer(formerState.getExpandedNodes(), child)) { restoreChildrenSelectionAndExpansion(child, resource, formerState, newState, cancelIndicator); newState.addExpandedNode(child); } if(containsUsingComparer(formerState.getSelectedNodes(), child)) { newState.addSelectedNode(child); } } }
Example 8
Source File: OutlinePage.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void addChildren(List<IOutlineNode> nodes, List<IOutlineNode> allChildren, int depth) { if (depth > 1) { for (IOutlineNode node : nodes) { List<IOutlineNode> children = node.getChildren(); allChildren.addAll(children); addChildren(children, allChildren, depth - 1); } } }
Example 9
Source File: AbstractOutlineTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void outlineStringRepresentation(IOutlineNode node, StringBuffer buffer, int tabs) { if (getNodeText(node) != "<unnamed>") { addToStringRepresentation(node, buffer, tabs); tabs += TAB_INDENT; } for (IOutlineNode child : node.getChildren()) { addToStringRepresentation(child, buffer, tabs); if (child.hasChildren()) { for (IOutlineNode child2 : child.getChildren()) { outlineStringRepresentation(child2, buffer, tabs + TAB_INDENT); } } } }
Example 10
Source File: AbstractOutlineTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void outlineStringRepresentation(IOutlineNode node, StringBuffer buffer, int tabs) { if (getNodeText(node) != "<unnamed>") { addToStringRepresentation(node, buffer, tabs); tabs += TAB_INDENT; } for (IOutlineNode child : node.getChildren()) { addToStringRepresentation(child, buffer, tabs); if (child.hasChildren()) { for (IOutlineNode child2 : child.getChildren()) { outlineStringRepresentation(child2, buffer, tabs + TAB_INDENT); } } } }
Example 11
Source File: XtendOutlinePage.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected List<IOutlineNode> getInitiallyExpandedNodes() { IOutlineNode rootNode = getTreeProvider().createRoot(getXtextDocument()); List<IOutlineNode> result = newArrayList(rootNode); for(IOutlineNode firstLevelNode: rootNode.getChildren()) if(firstLevelNode instanceof EObjectNode) result.add(firstLevelNode); return result; }
Example 12
Source File: XtendOutlineWithEditorLinker.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
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 13
Source File: AbstractOutlineTest.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Traverse the outline tree node recursively and build up the outlineMap. * * @param node * the outline tree node to traverse. */ private void buildOutlineMap(final IOutlineNode node) { addToOutlineMap(node); // add node's children List<IOutlineNode> children = node.getChildren(); for (IOutlineNode child : children) { buildOutlineMap(child); } }
Example 14
Source File: OutlineXpectMethod.java From n4js with Eclipse Public License 1.0 | 4 votes |
private void traverseChildren(IOutlineNode node) { for (IOutlineNode child : node.getChildren()) { traverseChildren(child); } }
Example 15
Source File: XtextOutlineTreeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private void traverseChildren(IOutlineNode node) { for (IOutlineNode child : node.getChildren()) { traverseChildren(child); } }
Example 16
Source File: AbstractOutlineWorkbenchTest.java From xsemantics with Eclipse Public License 1.0 | 4 votes |
private void outlineRepresentChildren(IOutlineNode node, StringBuffer buffer, int tabs) { for (IOutlineNode child : node.getChildren()) { outlineStringRepresentation(child, buffer, tabs); } }