use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class ParserTest2 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
IStructuredDocument structuredDocument = model.getStructuredDocument();
Document document = model.getDocument();
structuredDocument.replaceText(null, 0, 0, "<a b=\"\" c=\"c\">");
printSource(model);
printTree(model);
Element a = (Element) document.getFirstChild();
NamedNodeMap attributes = a.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
String name = attr.getNodeName();
String value = attr.getNodeValue();
fOutputWriter.writeln(name + "=[" + value + "]");
}
structuredDocument.replaceText(null, 8, 0, "d");
printSource(model);
printTree(model);
a = (Element) document.getFirstChild();
attributes = a.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
String name = attr.getNodeName();
String value = attr.getNodeValue();
fOutputWriter.writeln(name + "=[" + value + "]");
}
structuredDocument.replaceText(null, 8, 1, "");
printSource(model);
printTree(model);
a = (Element) document.getFirstChild();
attributes = a.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
String name = attr.getNodeName();
String value = attr.getNodeValue();
fOutputWriter.writeln(name + "=[" + value + "]");
}
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class ParserTest4 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
IStructuredDocument structuredDocument = model.getStructuredDocument();
// Document document = model.getDocument();
structuredDocument.replaceText(null, 0, 0, "<a>\n\n<% a %>\n<% b %>\n</a>");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 4, 0, "<");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 5, 0, "b");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 6, 0, "c");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 7, 0, "d");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 8, 0, "e");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 9, 0, ">");
printSource(model);
printTree(model);
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class ReadOnlyAwareDropTargetAdapter method drop.
public void drop(DropTargetEvent event) {
IDocument document = getTextViewer().getDocument();
if (document instanceof IStructuredDocument) {
Point range = getTextViewer().getSelectedRange();
if (((IStructuredDocument) document).containsReadOnly(range.x, range.y)) {
event.operations = DND.DROP_NONE;
event.detail = DND.DROP_NONE;
getTextViewer().getTextWidget().redraw();
getTextViewer().getTextWidget().update();
getTextViewer().getTextWidget().getDisplay().beep();
}
}
super.drop(event);
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class StructuredTextViewerUndoManager method connect.
/**
* Associates a viewer to this undo manager and also attempts to get the
* correct document-specific undo manager.
*
* @param viewer -
* Assumes viewer instanceof StructuredTextViewer
*/
public void connect(ITextViewer viewer) {
// future_TODO could probably optimize this to check if already
// connected to same viewer/undo manager, dont do anything
// disconnect from any old manager/viewer
disconnect();
// connect to new viewer/undo manager
fTextViewer = (StructuredTextViewer) viewer;
IDocument doc = fTextViewer.getDocument();
if (doc instanceof IStructuredDocument) {
IStructuredDocument structuredDocument = (IStructuredDocument) doc;
setDocument(structuredDocument);
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class HTMLValidationReporter method translateMessage.
/**
* Translate ValidationMessage to IMessage and generate result log
*/
private IMessage translateMessage(ValidationMessage message) {
int severity = IMessage.LOW_SEVERITY;
switch(message.getSeverity()) {
case ValidationMessage.ERROR:
severity = IMessage.HIGH_SEVERITY;
break;
case ValidationMessage.WARNING:
severity = IMessage.NORMAL_SEVERITY;
break;
case ValidationMessage.INFORMATION:
break;
default:
break;
}
IMessage mes = new LocalizedMessage(severity, message.getMessage(), this.file);
mes.setOffset(message.getOffset());
mes.setLength(message.getLength());
if (this.model != null) {
IStructuredDocument flatModel = this.model.getStructuredDocument();
if (flatModel != null) {
int line = flatModel.getLineOfOffset(message.getOffset());
mes.setLineNo(line + 1);
}
}
return mes;
}
Aggregations