Search in sources :

Example 46 with IStructuredDocument

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

the class WebResourceChangeHandler method initialize.

private void initialize() {
    IStructuredModel xmlModel = getModel();
    ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
    xmlModel.addModelLifecycleListener(this);
    IStructuredDocument fJspDocument = xmlModel.getStructuredDocument();
    if (fJspDocument != null) {
        fJspDocument.addDocumentListener(this);
    }
    irritator = new ModelIrritantThread();
}
Also used : IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 47 with IStructuredDocument

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

the class EMF2DOMSSEAdapter method getNewlineString.

protected String getNewlineString(Node node) {
    /*
		 * We should always have IDOMNode, and IStructuredDocument, and
		 * consquently a valid "preferred" line delimiter, but just to be
		 * safe, we'll assign something by default.
		 */
    if (node instanceof IDOMNode) {
        IDOMNode xmlNode = (IDOMNode) node;
        IStructuredDocument document = xmlNode.getStructuredDocument();
        if (document != null) {
            return document.getLineDelimiter();
        }
    }
    return DOMUtilities.NEWLINE_STRING;
}
Also used : IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 48 with IStructuredDocument

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

the class FileBufferModelManager method getModel.

public IStructuredModel getModel(IFile file) {
    if (file == null) {
        // $NON-NLS-1$
        Exception iae = new IllegalArgumentException("can not get/create a model without an IFile");
        Logger.logException(iae);
        return null;
    }
    IStructuredModel model = null;
    ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
    try {
        if (Logger.DEBUG_FILEBUFFERMODELMANAGEMENT) {
            // $NON-NLS-1$
            Logger.log(Logger.INFO, "FileBufferModelManager connecting to IFile " + file.getFullPath());
        }
        // see TextFileDocumentProvider#createFileInfo about why we use
        // IFile#getFullPath
        // here, not IFile#getLocation.
        IPath location = file.getFullPath();
        if (location != null) {
            bufferManager.connect(location, LocationKind.IFILE, getProgressMonitor());
            ITextFileBuffer buffer = bufferManager.getTextFileBuffer(location, LocationKind.IFILE);
            if (buffer != null) {
                DocumentInfo info = (DocumentInfo) fDocumentMap.get(buffer.getDocument());
                if (info != null) {
                    /*
						 * Note: "info" being null at this point is a slight
						 * error.
						 * 
						 * The connect call from above (or at some time
						 * earlier in the session) would have notified the
						 * FileBufferMapper of the creation of the
						 * corresponding text buffer and created the
						 * DocumentInfo object for IStructuredDocuments.
						 */
                    info.selfConnected = true;
                    info.locationKind = LocationKind.IFILE;
                }
                /*
					 * Check the document type. Although returning null for
					 * unknown documents would be fair, try to get a model if
					 * the document is at least a valid type.
					 */
                IDocument bufferDocument = buffer.getDocument();
                if (bufferDocument instanceof IStructuredDocument) {
                    model = getModel((IStructuredDocument) bufferDocument);
                } else {
                    /*
						 * 190768 - Quick diff marks do not disappear in the
						 * vertical ruler of JavaScript editor and
						 * 
						 * 193805 - Changes are not thrown away when close
						 * with no save for files with no structured model
						 * associated with them (text files, javascript files,
						 * etc) in web project
						 */
                    bufferManager.disconnect(location, LocationKind.IFILE, getProgressMonitor());
                }
            }
        }
    } catch (CoreException e) {
        // $NON-NLS-1$
        Logger.logException("Error getting model for " + file.getFullPath(), e);
    }
    return model;
}
Also used : IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ITextFileBufferManager(org.eclipse.core.filebuffers.ITextFileBufferManager) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) CoreException(org.eclipse.core.runtime.CoreException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) IDocument(org.eclipse.jface.text.IDocument)

Example 49 with IStructuredDocument

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

the class ClearReadOnlyDelegate method run.

public void run(IAction action) {
    ITextEditor editor = fEditor.getAdapter(ITextEditor.class);
    IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    if (document instanceof IStructuredDocument) {
        ((IStructuredDocument) document).clearReadOnly(0, document.getLength());
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IDocument(org.eclipse.jface.text.IDocument)

Example 50 with IStructuredDocument

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

the class JSONArrayCreationTest method createEmptyArrayNotClosed.

@Test
public void createEmptyArrayNotClosed() throws Exception {
    IJSONModel model = (IJSONModel) TestUtil.createModel();
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    IJSONDocument document = model.getDocument();
    assertNull(document.getFirstChild());
    // Load JSON Array
    structuredDocument.set("[");
    assertNotNull(document.getFirstChild());
    Assert.assertTrue(document.getFirstChild() instanceof IJSONArray);
    // The JSON array is not closed.
    IJSONArray array = (IJSONArray) document.getFirstChild();
    Assert.assertFalse(array.isClosed());
}
Also used : IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) Test(org.junit.Test)

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