Search in sources :

Example 81 with IModelManager

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

the class URLModelProviderCSS method getModelForRead.

/**
 */
private IStructuredModel getModelForRead(IFile file) throws IOException {
    if (file == null)
        return null;
    IModelManager manager = getModelManager();
    // create a fake InputStream
    IStructuredModel model = null;
    try {
        model = manager.getModelForRead(file);
    } catch (UnsupportedCharsetException ex) {
        try {
            model = manager.getModelForRead(file, EncodingRule.FORCE_DEFAULT);
        } catch (IOException ioe) {
        } catch (CoreException ce) {
        }
    } catch (CoreException ce) {
    }
    return model;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) UnsupportedCharsetException(java.nio.charset.UnsupportedCharsetException) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException)

Example 82 with IModelManager

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

the class URLModelProviderCSS method getNewModelForRead.

public IStructuredModel getNewModelForRead(IFile iFile) {
    if (iFile == null)
        return null;
    IModelManager manager = getModelManager();
    if (manager == null)
        return null;
    IStructuredModel model = null;
    try {
        model = manager.getNewModelForEdit(iFile, false);
    } catch (IOException ex) {
    } catch (ResourceInUse riu) {
    } catch (ResourceAlreadyExists rae) {
    } catch (CoreException ce) {
    }
    return model;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException) ResourceAlreadyExists(org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceAlreadyExists) ResourceInUse(org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse)

Example 83 with IModelManager

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

the class URLModelProviderCSS method getModelForEdit.

/**
 */
private IStructuredModel getModelForEdit(IFile file) throws IOException {
    if (file == null)
        return null;
    IModelManager manager = getModelManager();
    // create a fake InputStream
    IStructuredModel model = null;
    try {
        model = manager.getModelForEdit(file);
    } catch (UnsupportedCharsetException ex) {
        try {
            model = manager.getModelForEdit(file, EncodingRule.FORCE_DEFAULT);
        } catch (IOException ioe) {
        } catch (CoreException ce) {
        }
    } catch (CoreException ce) {
    }
    return model;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) UnsupportedCharsetException(java.nio.charset.UnsupportedCharsetException) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException)

Example 84 with IModelManager

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

the class URLModelProviderCSS method getNewModelForEdit.

public IStructuredModel getNewModelForEdit(IFile iFile) {
    if (iFile == null)
        return null;
    IModelManager manager = getModelManager();
    if (manager == null)
        return null;
    IStructuredModel model = null;
    try {
        model = manager.getNewModelForEdit(iFile, false);
    } catch (IOException ex) {
    } catch (ResourceInUse riu) {
    } catch (ResourceAlreadyExists rae) {
    } catch (CoreException ce) {
    }
    return model;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException) ResourceAlreadyExists(org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceAlreadyExists) ResourceInUse(org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse)

Example 85 with IModelManager

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

the class StructuredDocumentToDOMUnitTests method testNodeDeletion4.

/**
 * Unit test -- test insert followed by delete at beginning of string.
 */
void testNodeDeletion4() {
    String initialString = getTestString4();
    // print out what we always can
    System.out.println();
    System.out.println("----------------");
    System.out.println("Test Node Insert and Delete");
    String outString = StringUtils.escape(initialString);
    System.out.println("Initial String: " + outString);
    // always start with fresh model
    IStructuredDocument f = null;
    IModelManager mm = StructuredModelManager.getModelManager();
    try {
        f = mm.createStructuredDocumentFor("dummy.xml", (InputStream) null, null);
    } catch (IOException e) {
    // do nothing, since dummy
    }
    // 
    // we'll listen to structuredDocument events to print out diagnostics
    f.addDocumentChangedListener(this);
    // 
    IDOMModel tree = new DOMModelImpl();
    f.addDocumentChangingListener((IStructuredDocumentListener) tree);
    // set text to structuredDocument (which updates tree)
    f.setText(null, initialString);
    // dump initial structuredDocument
    Debug.dump(f);
    // dump initial dom
    DebugDocument.dump(tree.getDocument());
    // 
    // 
    f.replaceText(null, 0, 0, "a");
    System.out.println(" ==== Results after insert");
    // display resulting text
    System.out.println("resultString (from structuredDocument): ");
    System.out.println(StringUtils.escape(f.getText()));
    // 
    // 
    // dump post change structuredDocument
    Debug.dump(f);
    // dump post change DOM
    DebugDocument.dump(tree.getDocument());
    // 
    f.replaceText(null, 0, 1, "");
    System.out.println(" ==== Results after delete");
    // display resulting text
    System.out.println("resultString (from structuredDocument): ");
    System.out.println(StringUtils.escape(f.getText()));
    // 
    // 
    // dump post change structuredDocument
    Debug.dump(f);
    // dump post change DOM
    DebugDocument.dump(tree.getDocument());
// 
}
Also used : InputStream(java.io.InputStream) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IOException(java.io.IOException)

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