use of com.amalto.workbench.widgets.xmlviewer.model.XMLNode in project tmdm-studio-se by Talend.
the class XMLFormattingStrategy method format.
/* (non-Javadoc)
* @see org.eclipse.jface.text.formatter.IFormattingStrategy#format(java.lang.String, boolean, java.lang.String, int[])
*/
public String format(String content, boolean isLineStart, String indentation, int[] positions) {
IDocument document = sourceViewer.getDocument();
sourceViewer.getTreeModel().createTree(document);
XMLNode rootNode = sourceViewer.getTreeModel().getTree().getRootNode();
int initialOffset = rootNode.getOffset();
int length = rootNode.getCorrespondingNode().getOffset() + rootNode.getCorrespondingNode().getLength();
this.visitor.reset();
rootNode.accept(visitor);
sourceViewer.getTreeModel().createTree(document);
return visitor.getString();
}
use of com.amalto.workbench.widgets.xmlviewer.model.XMLNode in project tmdm-studio-se by Talend.
the class XMLDocumentPartitioner method findPreviousNonWhiteSpacePosition.
public TypedPosition findPreviousNonWhiteSpacePosition(int offset) {
try {
int index = document.computeIndexInCategory(positionCategory, offset);
Position[] positions = document.getPositions(positionCategory);
if (positions.length == 0) {
return null;
}
if (index == positions.length) {
index--;
}
for (; index >= 0; index--) {
TypedPosition position = (TypedPosition) positions[index];
if (position instanceof XMLNode) {
XMLNode node = (XMLNode) position;
if (!node.isEmpty())
return node;
}
}
} catch (BadLocationException e) {
e.printStackTrace();
} catch (BadPositionCategoryException e) {
e.printStackTrace();
}
return null;
}
Aggregations