本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.IModelManager类的典型用法代码示例。如果您正苦于以下问题:Java IModelManager类的具体用法?Java IModelManager怎么用?Java IModelManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IModelManager类属于org.eclipse.wst.sse.core.internal.provisional包,在下文中一共展示了IModelManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModelForResource
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
/**
*
* @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;
}
示例2: doGetModelForRead
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
@Override
protected IDOMModel doGetModelForRead() throws IOException, CoreException {
IModelManager modelManager = StructuredModelManager.getModelManager();
IFile storageFile = ResourcesPlugin.getWorkspace().getRoot().getFile(storage.getFullPath());
IDOMModel model = (IDOMModel) modelManager.getModelForRead(storageFile);
return model;
}
示例3: clone
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
public IStructuredDocument clone(IDocument original) {
IModelManager modelManager = StructuredModelManager.getModelManager();
String modelId = getModelId(original);
if (modelId == null) {
GWTPluginLog.logError("Could not get a model ID for the document to be formatted.");
return null;
}
/*
* The XML formatter requires a managed model (discovered by it crashing
* when given an unmanaged model.) Unfortunately, we cannot create a managed
* in-memory (i.e. non-file backed) model via IModelManager API (there is
* one method that may work, but it is deprecated.) Instead, we copy the
* existing model into a temp model with ID "temp".
*/
try {
IStructuredModel modelClone = modelManager.copyModelForEdit(modelId,
"structuredDocumentClonerModel" + nextId.getAndIncrement());
modelClone.setBaseLocation(getModelBaseLocation(original));
IStructuredDocument documentClone = modelClone.getStructuredDocument();
documentClone.set(original.get());
// Create and connect the partitioner to the document
IDocumentPartitioner tempPartitioner = documentPartitionerFactory.createDocumentPartitioner();
((IDocumentExtension3) documentClone).setDocumentPartitioner(
partitioning, tempPartitioner);
tempPartitioner.connect(documentClone);
// Save the cloned model so we can release it later
modelClones.put(documentClone, modelClone);
return documentClone;
} catch (ResourceInUse e1) {
GWTPluginLog.logError(e1,
"Could not copy the original model to be formatted.");
return null;
}
}
示例4: getModelBaseLocation
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
private String getModelBaseLocation(IDocument document) {
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = null;
try {
model = modelManager.getExistingModelForRead(document);
return model.getBaseLocation();
} finally {
if (model != null) {
model.releaseFromRead();
}
}
}
示例5: getModelId
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
private String getModelId(IDocument document) {
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = null;
try {
model = modelManager.getExistingModelForRead(document);
return model.getId();
} finally {
if (model != null) {
model.releaseFromRead();
}
}
}
示例6: getWidgetForEdit
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
public Widget getWidgetForEdit() throws CoreException {
long enter = System.currentTimeMillis();
if (editableWidget == null) {
synchronized (this) {
IFile configXml = configXMLtoIFile();
if (configXml == null) {
return null;
}
IModelManager manager = StructuredModelManager.getModelManager();
try {
underLyingModel = manager.getModelForEdit(configXml);
if ((underLyingModel != null) && (underLyingModel instanceof IDOMModel)) {
underLyingModel.addModelStateListener(this);
IDOMModel domModel = (IDOMModel) underLyingModel;
editableWidget = load(domModel.getDocument());
lastWidget = load(domModel.getDocument());
}
} catch (IOException e) {
throw new CoreException(
new Status(IStatus.ERROR, HybridCore.PLUGIN_ID, "Error creating widget model", e));
}
}
}
HybridCore.trace("Completed WidgetModel.getWidgetForEdit it "
+ Long.toString(System.currentTimeMillis() - enter) + "ms");
return editableWidget;
}
示例7: getFileName
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
public static String getFileName(ICSSNode cssNode, IDOMNode node) {
String fileName = cssNode.getOwnerDocument().getModel()
.getBaseLocation();
if (IModelManager.UNMANAGED_MODEL.equals(fileName)) {
if (node != null) {
return node.getModel().getBaseLocation();
}
return null;
}
return fileName;
}
示例8: getModelForEdit
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
private IDOMModel getModelForEdit() throws IOException, CoreException {
IModelManager modelManager = StructuredModelManager.getModelManager();
return (IDOMModel) modelManager.getModelForEdit(getFile());
}
示例9: doGetModelForRead
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
@Override
protected IDOMModel doGetModelForRead() throws IOException, CoreException {
IModelManager modelManager = StructuredModelManager.getModelManager();
return (IDOMModel) modelManager.getModelForRead(getFile());
}
示例10: createModel
import org.eclipse.wst.sse.core.internal.provisional.IModelManager; //导入依赖的package包/类
public static IStructuredModel createModel() {
IModelManager manager = StructuredModelManager.getModelManager();
return manager
.createUnManagedStructuredModelFor(ContentTypeIdForJSON.ContentTypeID_JSON);
}