use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project liferay-ide by liferay.
the class AlloyJSPDocumentFactory method createDocument.
@Override
public IDocument createDocument() {
IModelHandler handler = null;
IContentType contentType = Platform.getContentTypeManager().getContentType("com.liferay.ide.alloy.core.alloyjspsource");
while ((handler == null) && !IContentTypeManager.CT_TEXT.equals(contentType.getId())) {
handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId(contentType.getId());
contentType = contentType.getBaseType();
}
if (handler != null) {
return handler.getDocumentLoader().createNewStructuredDocument();
} else {
return new JobSafeStructuredDocument();
}
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createNewStructuredDocumentFor.
/**
* Factory method, since a proper IStructuredDocument must have a proper
* parser assigned. Note: its assume that IFile does not actually exist as
* a resource yet. If it does, ResourceAlreadyExists exception is thrown.
* If the resource does already exist, then createStructuredDocumentFor is
* the right API to use.
*
* @throws ResourceInUse
*/
public IStructuredDocument createNewStructuredDocumentFor(IFile iFile) throws ResourceAlreadyExists, IOException, CoreException {
if (iFile.exists()) {
throw new ResourceAlreadyExists(iFile.getFullPath().toOSString());
}
// Will reconsider in future version
// String id = calculateId(iFile);
// if (isResourceInUse(id)) {
// throw new ResourceInUse(iFile.getFullPath().toOSString());
// }
IDocumentLoader loader = null;
IModelHandler handler = calculateType(iFile);
loader = handler.getDocumentLoader();
// for this API, "createNew" we assume the IFile does not exist yet
// as checked above, so just create empty document.
IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
return result;
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method reinitialize.
/*
* @see IModelManager#reinitialize(IStructuredModel)
*/
public IStructuredModel reinitialize(IStructuredModel model) {
// getHandler (assume its the "new one")
IModelHandler handler = model.getModelHandler();
// getLoader for that new one
IModelLoader loader = handler.getModelLoader();
// ask it to reinitialize
model = loader.reinitialize(model);
// its embedded content checking and initialization
return model;
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method calculateType.
private IModelHandler calculateType(String filename, InputStream inputStream) throws IOException {
ModelHandlerRegistry cr = getModelHandlerRegistry();
IModelHandler cd = cr.getHandlerFor(filename, inputStream);
return cd;
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method getModelForEdit.
public IStructuredModel getModelForEdit(String id, InputStream inputStream, URIResolver resolver) throws IOException {
if (id == null) {
// $NON-NLS-1$
throw new IllegalArgumentException("Program Error: id may not be null");
}
IStructuredModel result = null;
InputStream istream = Utilities.getMarkSupportedStream(inputStream);
IModelHandler handler = calculateType(id, istream);
if (handler != null) {
result = _commonCreateModel(istream, id, handler, resolver, EDIT, null, null);
} else {
// $NON-NLS-1$
Logger.log(Logger.INFO, "no model handler found for id");
}
return result;
}
Aggregations