Search in sources :

Example 51 with IModelManager

use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.

the class UnitTests method setUpXML.

/**
 * Set up an XML model
 */
protected void setUpXML() {
    IModelManager mm = StructuredModelManager.getModelManager();
    try {
        fModel = mm.createStructuredDocumentFor("dummy.xml", (InputStream) null, null);
    } catch (IOException e) {
    // do nothing, since dummy
    }
    fModel.addDocumentChangedListener(proxy);
    tree = new DOMModelImpl();
    if (tree != null) {
        fModel.addDocumentChangingListener((IStructuredDocumentListener) tree);
        tree.setStructuredDocument(fModel);
    }
}
Also used : InputStream(java.io.InputStream) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl) IOException(java.io.IOException)

Example 52 with IModelManager

use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.

the class UnitTests method setUpJSP.

/**
 * Set up a JSP model
 */
protected void setUpJSP() {
    IModelManager mm = StructuredModelManager.getModelManager();
    try {
        fModel = mm.createStructuredDocumentFor("dummy.jsp", (InputStream) null, null);
    } catch (IOException e) {
    // do nothing, since dummy
    }
    fModel = StructuredDocumentFactory.getNewStructuredDocumentInstance(new JSPSourceParser());
    fModel.addDocumentChangedListener(proxy);
    tree = new DOMModelImpl();
    if (tree != null) {
        fModel.addDocumentChangingListener((IStructuredDocumentListener) tree);
        tree.setStructuredDocument(fModel);
    }
}
Also used : InputStream(java.io.InputStream) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl) IOException(java.io.IOException) JSPSourceParser(org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser)

Example 53 with IModelManager

use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.

the class ModelModifications method createXMLModel.

/**
 * Be sure to release any models obtained from this method.
 *
 * @return
 * @throws IOException
 * @throws UnsupportedEncodingException
 */
private static IDOMModel createXMLModel() throws UnsupportedEncodingException, IOException {
    IStructuredModel model = null;
    IModelManager modelManager = StructuredModelManager.getModelManager();
    model = modelManager.getModelForEdit("test.xml", new NullInputStream(), null);
    // always use the same line delimiter for these tests, regardless
    // of
    // plaform or preference settings
    model.getStructuredDocument().setLineDelimiter(TestWriter.commonEOL);
    return (IDOMModel) model;
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) NullInputStream(org.eclipse.wst.sse.core.internal.encoding.util.NullInputStream)

Example 54 with IModelManager

use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.

the class TestCSSContentAssist method loadFile.

protected void loadFile() throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
    IModelManager modelManager = StructuredModelManager.getModelManager();
    model = modelManager.getModelForEdit(file);
    document = model.getStructuredDocument();
}
Also used : IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager)

Example 55 with IModelManager

use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.

the class TestXSLHyperlinkDetector method loadXSLFile.

protected void loadXSLFile() throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
    IModelManager modelManager = StructuredModelManager.getModelManager();
    model = modelManager.getNewModelForEdit(file, true);
    document = model.getStructuredDocument();
    IDocumentPartitioner partitioner = defaultPartitioner.newInstance();
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager)

Aggregations

IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)139 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)102 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)45 IOException (java.io.IOException)37 InputStream (java.io.InputStream)27 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)27 IFile (org.eclipse.core.resources.IFile)23 CoreException (org.eclipse.core.runtime.CoreException)21 BadLocationException (org.eclipse.jface.text.BadLocationException)13 FileNotFoundException (java.io.FileNotFoundException)12 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)11 Document (org.w3c.dom.Document)10 ArrayList (java.util.ArrayList)9 IProject (org.eclipse.core.resources.IProject)9 StringBufferInputStream (java.io.StringBufferInputStream)8 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)7 IDocument (org.eclipse.jface.text.IDocument)6 PageDirectiveAdapter (org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)6 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5