use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class DelegatingSourceValidator method getModelForResource.
/**
* @param file
* the file to get the model for
* @return the file's XMLModel or null
*/
protected IDOMModel getModelForResource(IFile file) {
IStructuredModel model = null;
IModelManager manager = StructuredModelManager.getModelManager();
try {
model = manager.getModelForRead(file);
// TODO.. HTML validator tries again to get a model a 2nd way
} catch (Exception e) {
Logger.log(Logger.ERROR_DEBUG, file.getFullPath().toString(), e);
}
if (model instanceof IDOMModel)
return (IDOMModel) model;
if (model != null)
model.releaseFromRead();
return null;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class JsTranslation method setBaseLocation.
private void setBaseLocation() {
IDOMModel xmlModel = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
xmlModel = (IDOMModel) modelManager.getExistingModelForRead(fHtmlDocument);
if (xmlModel == null) {
xmlModel = (IDOMModel) modelManager.getModelForRead(fHtmlDocument);
}
if (xmlModel != null) {
fModelBaseLocation = xmlModel.getBaseLocation();
}
} finally {
if (xmlModel != null)
xmlModel.releaseFromRead();
}
// return xmlModel;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class AddJavaDocStubOperation method applyChanges.
protected void applyChanges() {
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = null;
IStructuredDocument doc = node.getStructuredDocument();
try {
MultiTextEdit edits = textEditListener.getTextEdits();
model = modelManager.getExistingModelForEdit(doc);
model.aboutToChangeModel();
// $NON-NLS-1$ //$NON-NLS-2$
model.beginRecording(this, Messages.getString("AddJavaDocStubOperation.0"), Messages.getString("AddJavaDocStubOperation.1"));
edits.apply(doc);
} catch (MalformedTreeException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
} catch (BadLocationException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
} finally {
if (model != null) {
model.endRecording(this);
model.changedModel();
model.releaseFromEdit();
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class StructuredTextUndoManager method findStructuredModel.
/**
* Utility method to find model given document
*/
private IStructuredModel findStructuredModel(IDocument document) {
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel structuredModel = modelManager.getExistingModelForRead(document);
return structuredModel;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class DelegatingSourceValidator method getModelForResource.
/**
* @param file
* the file to get the model for
* @return the file's JSONModel or null
*/
protected IJSONModel getModelForResource(IFile file) {
IStructuredModel model = null;
IModelManager manager = StructuredModelManager.getModelManager();
try {
model = manager.getModelForRead(file);
// TODO.. HTML validator tries again to get a model a 2nd way
} catch (Exception e) {
Logger.log(Logger.ERROR_DEBUG, file.getFullPath().toString(), e);
}
if (model instanceof IJSONModel)
return (IJSONModel) model;
if (model != null)
model.releaseFromRead();
return null;
}
Aggregations