|
Carbide.c++ | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IModelProvider<Model extends IOwnedModel,SharedModel extends IModel>
Interface managing shared access to models.
The provider gives access to the factory, for creation of private Model instances, and provides shared instances through #findOrCreateModel(). The model provider is responsible for the real contents of the files provided to it through the #createModel(IPath) call, thus clients must use the provider for safe access to the file. Further, the provider exposes only the base interface IModel to limit inadvertent changes to shared models.
The domain of files managed is not specified by this interface –- a model provider may work entirely on memory buffers. But if an implementations of the model provider manage resources in the workspace, it is responsible for synchronizing the models with the workspace; e.g. persisting changes to IDocuments to the workspace and listening for changes to such resources outside its own APIs.
Method Summary | |
---|---|
Model |
createModel(IPath workspacePath)
Create a new model with an empty document, which is slated to live at the given workspace path. |
SharedModel |
findSharedModel(IPath workspacePath)
Find a registered Model instance for the given path. |
SharedModel |
getSharedModel(IPath workspacePath)
Load a model for shared use. |
void |
load(Model model)
Load the document of a model from persistent storage. |
void |
registerModel(Model model)
Make a model visible to clients of the provider and manage its contents. |
void |
releaseSharedModel(SharedModel model)
Indicate that the client is no longer using the model, which allows it to be eventually cleaned up. |
void |
save(Model model)
Deprecated. since 1.4 (Carbide 2.0), this variant is unsafe, since the model is no longer locked during a save, so the document map from a model might be changing. |
void |
save(Model model,
java.util.Map<IPath,IDocument> documentMap)
Save the contents of a model's document(s) to persistent storage. |
void |
unregisterModel(Model model)
Make a model invisible to clients of the provider and stop managing its contents. |
void |
updateModelDocumentMappings(Model model)
Update tracked files using the map of IPath -> IDocument mappings for the model. |
Method Detail |
---|
Model createModel(IPath workspacePath)
getSharedModel(IPath)
for the normal case of loading a model from an existing file.)
The returned model is not registered and its document is not tracked
until #registerModel(IOwnedModel))
is called.
workspacePath
- workspace-relative path.
void load(Model model) throws CoreException
model
-
CoreException
void save(Model model) throws CoreException
model
-
CoreException
void save(Model model, java.util.Map<IPath,IDocument> documentMap) throws CoreException
This variant is called directly from a model when views commit themselves. The model is no longer locked, but the provided document map is consistent and may be persisted as a group. This change was made to avoid deadlocks when a model save triggers a resource change event which also wants to reread the model.
model
- documentMap
- a copy of the documents generated by the last view commit
CoreException
void registerModel(Model model) throws CoreException
Once registered, the model's owned model is counted as a shared model
reference. The caller should release
this model eventually.
If the model has a null
IDocument, then it will be loaded
from storage. Otherwise, it will be persisted immediately from the document
contents. Then, the model will be parsed.
The registered model always has a document, though it may be empty if the load failed.
Once registered, changes to the model's document are persisted to underlying storage, and changes to the persisted storage cause reloads of the model.
model
- a newly created model
java.lang.IllegalArgumentException
- if already registered
CoreException
- if problems registering model, loading (when existing), or saving contentsvoid unregisterModel(Model model)
model
- a registered model
java.lang.IllegalArgumentException
- if not registeredSharedModel findSharedModel(IPath workspacePath)
The path is used to identify the model and is a key to its real contents (usually the given workspace resource, as implied by the name). The client has limited access to the model. The real work happens through IView.
The model must be released
after use.
workspacePath
-
SharedModel getSharedModel(IPath workspacePath) throws CoreException
This finds a registered model instance. If none registered, it loads a new model instance and registers it, then loads and parse its contents.
If the persisted resource does not exist, a null
model is returned.
The client is responsible for releasing
the model when done.
The client has limited (read-only) direct access to the model but may create views and make changes through them.
workspacePath
-
org.eclipse.core.runtime.CoreException
- if model cannot be created, e.g. due to a problem loading it
when it otherwise appears to exist
CoreException
void releaseSharedModel(SharedModel model) throws java.lang.IllegalStateException
View created on the model must be disposed first.
model
-
java.lang.IllegalStateException
- if all clients have released the model, but views are still
undisposed (this condition is delayed until all clients have
released the model, so the last client to release will be
blamed :( )void updateModelDocumentMappings(Model model)
|
Carbide.c++ | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |