Search in sources :

Example 96 with IStructuredDocument

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();
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) Document(org.w3c.dom.Document) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 97 with IStructuredDocument

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();
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 98 with IStructuredDocument

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);
}
Also used : IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) Point(org.eclipse.swt.graphics.Point) IDocument(org.eclipse.jface.text.IDocument)

Example 99 with IStructuredDocument

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);
    }
}
Also used : IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IDocument(org.eclipse.jface.text.IDocument)

Example 100 with IStructuredDocument

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;
}
Also used : IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Aggregations

IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)432 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)96 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)79 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)68 CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)44 Node (org.w3c.dom.Node)42 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)41 Document (org.w3c.dom.Document)36 BadLocationException (org.eclipse.jface.text.BadLocationException)35 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)34 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)34 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)33 Element (org.w3c.dom.Element)30 IDocument (org.eclipse.jface.text.IDocument)29 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)28 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)26 StructuredDocumentEvent (org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent)23 Test (org.junit.Test)22 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)20 RegionChangedEvent (org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent)20