本文整理汇总了Java中org.eclipse.xtext.ui.editor.outline.IOutlineNode类的典型用法代码示例。如果您正苦于以下问题:Java IOutlineNode类的具体用法?Java IOutlineNode怎么用?Java IOutlineNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IOutlineNode类属于org.eclipse.xtext.ui.editor.outline包,在下文中一共展示了IOutlineNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openOutlineView
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
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);
}
示例2: getCategory
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
private int getCategory(IOutlineNode node) {
if (node instanceof EObjectNode) {
EClass eclass = ((EObjectNode) node).getEClass();
int id = eclass.getClassifierID();
int key = 10000 + id;
Integer sortKey = METATYPESORTORDER.get(id);
if (sortKey != null) {
key = sortKey * 1000;
}
if (node instanceof N4JSEObjectNode) {
N4JSEObjectNode n4node = (N4JSEObjectNode) node;
if (!n4node.isStatic) {
key += 100;
}
if (n4node.isConstructor) {
key -= 50;
}
}
return key;
}
return -1;
}
示例3: findNode
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
/**
* 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;
}
示例4: assertEObjectInOutlineNodesExists
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
/**
* Inspects the outline nodes and checks that given condition applies to at least one of the represented model objects.
*
* @param <T>
* the generic type
* @param clazz
* the clazz
* @param predicate
* the predicate
*/
protected <T extends EObject> void assertEObjectInOutlineNodesExists(final Class<T> clazz, final Predicate<T> predicate) {
final List<T> result = Lists.newArrayList();
for (final IOutlineNode n : getOutlineMap().get(clazz)) {
result.add(n.readOnly(new IUnitOfWork<T, EObject>() {
@Override
@SuppressWarnings("unchecked")
public T exec(final EObject state) throws Exception { // NOPMD
return (T) state;
}
}));
}
try {
Assert.assertNotNull(NLS.bind("At least one outline node represents an object of type \"{0}\"", clazz.getName()), Iterables.find(result, predicate));
} catch (NoSuchElementException e) {
Assert.fail(NLS.bind("Could not find an object of type \"{0}\" in outline", clazz.getName()));
}
}
示例5: addToOutlineMap
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
/**
* 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);
}
示例6: findBestNode
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
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 || currentBestNode.getFullTextRegion()
.getLength() >= candidate.getFullTextRegion().getLength())) {
currentBestNode = candidate;
}
}
return currentBestNode;
}
return null;
}
示例7: getExpandedNodes
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
protected Set<IOutlineNode> getExpandedNodes(final TreeViewer treeViewer) {
final Set<IOutlineNode> expandedNodes = Sets.newHashSet();
DisplayRunHelper.runSyncInDisplayThread(new Runnable() {
public void run() {
if (!treeViewer.getTree().isDisposed()) {
Object[] expandedElements = treeViewer.getExpandedElements();
for (Object expandedElement : expandedElements) {
if (!(expandedElement instanceof IOutlineNode))
LOG.error("Content outline contains illegal node " + expandedElement);
else
expandedNodes.add((IOutlineNode) expandedElement);
}
}
}
});
return expandedNodes;
}
示例8: getSelectedNodes
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
protected Set<IOutlineNode> getSelectedNodes(final TreeViewer treeViewer) {
DisplayRunHelper.runSyncInDisplayThread(new Runnable() {
public void run() {
selectedNodes = Sets.newHashSet();
ISelection selection = treeViewer.getSelection();
if (selection instanceof IStructuredSelection) {
for (Iterator<?> selectionIter = ((IStructuredSelection) selection).iterator(); selectionIter
.hasNext();) {
Object selectedElement = selectionIter.next();
if (!(selectedElement instanceof IOutlineNode))
LOG.error("Content outline contains illegal node " + selectedElement);
else
selectedNodes.add((IOutlineNode) selectedElement);
}
}
}
});
return selectedNodes;
}
示例9: createEStructuralFeatureNode
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
protected EStructuralFeatureNode createEStructuralFeatureNode(IOutlineNode parentNode, EObject owner,
EStructuralFeature feature, Image image, Object text, boolean isLeaf) {
boolean isFeatureSet = owner.eIsSet(feature);
EStructuralFeatureNode eStructuralFeatureNode = new EStructuralFeatureNode(owner, feature, parentNode, image,
text, isLeaf || !isFeatureSet);
if (isFeatureSet) {
ITextRegion region = locationInFileProvider.getFullTextRegion(owner, feature, 0);
if (feature.isMany()) {
int numValues = ((Collection<?>) owner.eGet(feature)).size();
ITextRegion fullTextRegion = locationInFileProvider.getFullTextRegion(owner, feature, numValues - 1);
if (fullTextRegion != null)
region = region.merge(fullTextRegion);
}
eStructuralFeatureNode.setTextRegion(region);
}
return eStructuralFeatureNode;
}
示例10: getChildren
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
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);
}
示例11: open
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
public void open(IOutlineNode node, ISourceViewer textViewer) {
if (node != null) {
ITextRegion textRegion = node.getSignificantTextRegion();
if (textRegion != null && textRegion != ITextRegion.EMPTY_REGION) {
int offset = textRegion.getOffset();
int length = textRegion.getLength();
textViewer.setRangeIndication(offset, length, true);
textViewer.revealRange(offset, length);
textViewer.setSelectedRange(offset, length);
} else {
node.readOnly(new IUnitOfWork.Void<EObject>() {
@Override
public void process(EObject state) throws Exception {
openEObject(state);
}
});
}
}
}
示例12: createEStructuralFeatureNode
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
public EStructuralFeatureNode createEStructuralFeatureNode(IOutlineNode parentNode, EObject owner, EStructuralFeature feature,
ImageDescriptor imageDescriptor, Object text, boolean isLeaf) {
boolean isFeatureSet = owner.eIsSet(feature);
EStructuralFeatureNode eStructuralFeatureNode = new EStructuralFeatureNode(owner, feature, parentNode, imageDescriptor,
text, isLeaf || !isFeatureSet);
if (isFeatureSet) {
ITextRegion region = locationInFileProvider.getFullTextRegion(owner, feature, 0);
if (feature.isMany()) {
int numValues = ((Collection<?>) owner.eGet(feature)).size();
ITextRegion fullTextRegion = locationInFileProvider.getFullTextRegion(owner, feature, numValues - 1);
if(fullTextRegion != null)
region = region.merge(fullTextRegion);
}
eStructuralFeatureNode.setTextRegion(region);
}
return eStructuralFeatureNode;
}
示例13: refreshViewer
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
protected void refreshViewer(final IOutlineNode rootNode, final Collection<IOutlineNode> nodesToBeExpanded,
final Collection<IOutlineNode> selectedNodes) {
DisplayRunHelper.runAsyncInDisplayThread(new Runnable() {
public void run() {
try {
TreeViewer treeViewer = getTreeViewer();
if (!treeViewer.getTree().isDisposed()) {
treeViewer.setInput(rootNode);
treeViewer.expandToLevel(1);
treeViewer.setExpandedElements(Iterables.toArray(nodesToBeExpanded, IOutlineNode.class));
treeViewer.setSelection(new StructuredSelection(Iterables.toArray(selectedNodes,
IOutlineNode.class)));
treeUpdated();
}
} catch (Throwable t) {
LOG.error("Error refreshing outline", t);
}
}
});
}
示例14: isEquivalentIndex
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
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;
}
示例15: filterAndSort
import org.eclipse.xtext.ui.editor.outline.IOutlineNode; //导入依赖的package包/类
@Override
public IOutlineNode[] filterAndSort(Iterable<IOutlineNode> nodes) {
final Iterable<IFilter> enabledFilters = getEnabledFilters();
Iterable<IOutlineNode> filteredNodes;
if (Iterables.isEmpty(enabledFilters)) {
filteredNodes = nodes;
} else {
List<IOutlineNode> childrenFromFeatureNodes = extractChildrenFromStructuralFeatureNodes(nodes);
if (!childrenFromFeatureNodes.isEmpty()) {
filteredNodes = filterNodes(enabledFilters, childrenFromFeatureNodes);
} else {
filteredNodes = filterNodes(enabledFilters, nodes);
}
}
IOutlineNode[] nodesAsArray = Iterables.toArray(filteredNodes, IOutlineNode.class);
if (comparator != null && isSortingEnabled()) {
Arrays.sort(nodesAsArray, comparator);
}
return nodesAsArray;
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:22,代码来源:OutlineFlattenFilterAndSorter.java