Search in sources :

Example 1 with InferredGrammarBuildingCMDocumentLoader

use of org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader in project webtools.sourceediting by eclipse.

the class DOMObserver method invokeCMDocumentLoad.

public void invokeCMDocumentLoad() {
    if (fIsDisabled)
        return;
    try {
        fIsLoading = true;
        ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fDocument);
        if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
            CMDocumentLoader loader = isGrammarInferenceEnabled ? new InferredGrammarBuildingCMDocumentLoader(fDocument, modelQuery) : new CMDocumentLoader(fDocument, modelQuery);
            loader.loadCMDocuments();
        }
    } finally {
        fIsLoading = false;
    }
}
Also used : InferredGrammarBuildingCMDocumentLoader(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader) CMDocumentLoader(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader) InferredGrammarBuildingCMDocumentLoader(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)

Example 2 with InferredGrammarBuildingCMDocumentLoader

use of org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader in project webtools.sourceediting by eclipse.

the class ReloadDependenciesHandler method execute.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    ITextEditor textEditor = null;
    if (editor instanceof ITextEditor)
        textEditor = (ITextEditor) editor;
    else {
        Object o = editor.getAdapter(ITextEditor.class);
        if (o != null)
            textEditor = (ITextEditor) o;
    }
    if (textEditor != null) {
        IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
        IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
        if (model != null) {
            ModelQuery modelQuery = null;
            try {
                modelQuery = ModelQueryUtil.getModelQuery(model);
            } finally {
                model.releaseFromRead();
            }
            Document domDocument = ((IDOMModel) model).getDocument();
            if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
                modelQuery.getCMDocumentManager().getCMDocumentCache().clear();
                // TODO... need to figure out how to access the
                // DOMObserver via ModelQuery
                // ...why?
                CMDocumentLoader loader = new InferredGrammarBuildingCMDocumentLoader(domDocument, modelQuery);
                loader.loadCMDocuments();
            }
        }
    }
    return null;
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) InferredGrammarBuildingCMDocumentLoader(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) CMDocumentLoader(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader) InferredGrammarBuildingCMDocumentLoader(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IDocument(org.eclipse.jface.text.IDocument) Document(org.w3c.dom.Document) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)2 CMDocumentLoader (org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader)2 InferredGrammarBuildingCMDocumentLoader (org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader)2 IDocument (org.eclipse.jface.text.IDocument)1 IEditorPart (org.eclipse.ui.IEditorPart)1 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)1 Document (org.w3c.dom.Document)1