|
Carbide.c++ | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IView<Model>
The base interface for a filtered view onto a model.
It allows for transactions of changes to be applied back to the model's DOM.
Multiple views may hold changes at the same time (for instance, a dirty editor and a project change listener updating SOURCE statements).
The updating model follows the CVS model for handling simultaneous changes:
Method Summary | |
---|---|
void |
addListener(IViewListener listener)
Add listener, ignore duplicates |
void |
commit()
Commits changes to the underlying translation unit (visible from IOwnedModel#getTranslationUnit() and IView#getFilteredTranslationUnit()) When a view is committed, changes may or may not be made to the owning model's document. |
IPath |
convertModelToProjectPath(IPath prjPath)
Convert a model-relative path to an project-relative path. |
IPath |
convertProjectToModelPath(IPath prjPath)
Convert a project-relative path to an model-relative path. |
void |
dispose()
Dispose view, removing its listeners and detaching it from model and losing any changes. |
void |
forceSynchronized()
Forces view to be marked synchronized, a last resort if #merge() returns false and you don’t want to #revert(). |
IData<IView<Model>> |
getData()
Get a copy of cacheable data for the view. |
IMessage[] |
getMessages()
Get all messages associated with parsing the filtered TU. |
Model |
getModel()
Get the model we're viewing |
IPath |
getProjectPath()
Get the project root from the view configuration. |
IPath[] |
getReferencedFiles()
Get the array of filesystem paths for files read while creating the filtered translation units |
IViewConfiguration |
getViewConfiguration()
Get the configuration used to create the view |
void |
markUnsynchronized()
Mark a view out-of-sync due to changes in the model. |
boolean |
merge()
Merges uncommitted changes with the current model. |
boolean |
needsSynchonize()
Tell whether the view needs to be synchronized (merged) with the model. |
void |
removeListener(IViewListener listener)
Remove listener, ignore if not present |
void |
revert()
Reverts changes to mirror model contents and marks the view synchronized. |
void |
setDebug(boolean debug)
Enable debugging, if supported. |
Method Detail |
---|
Model getModel()
void dispose()
IViewConfiguration getViewConfiguration()
IMessage[] getMessages()
IPath[] getReferencedFiles()
void revert()
void commit() throws java.lang.IllegalStateException
When a view is committed, changes may or may not be made to the owning model's document. A document change event will be sent if the contents change, and that event will cause the model to mark any open views (except this one) unsynchronized.
During a commit, the contents of the view may be recreated. Any references to objects provided by the view should be considered stale.
A commit can throw IllegalStateException if it is unsynchronized. The code for a commit should be structured like this:
// commit changes while (true) { try { view.commit(); break; } catch (IllegalStateException e) { // happens when third party has committed in-between // usually UI around this... if (!view.merge()) { // worst case (could try view.forceSynchronized() too) view.revert(); } // further failures should not occur, but loop just in case the // UI above took long enough for someone else to sneak in } }
java.lang.IllegalStateException
- if out of syncneedsSynchonize()
,
merge()
,
revert()
void markUnsynchronized()
needsSynchonize()
boolean needsSynchonize()
A newly created view never needs synchronization, and a view with changes does not necessarily need synchronization.
Only when the model is changed underneath (e.g. other views commit, the DOM is changed directly, or the document is changed) and the view has uncommited changes and wants to commit is synchronization needed.
boolean merge()
Returns true if pending changes merge cleanly, with view left in synchronized state. Returns false otherwise, leaving view in a unsynchronized state, possibly with partial updates.
needsSynchonize()
void forceSynchronized()
void addListener(IViewListener listener)
void removeListener(IViewListener listener)
IPath getProjectPath()
void setDebug(boolean debug)
debug
- true to debug, false to stopIPath convertProjectToModelPath(IPath prjPath)
Null or full paths returned as identity.
prjPath
- project-relative path (or null or full path)
IPath convertModelToProjectPath(IPath prjPath)
Null or full paths returned as identity.
modelPath
- model-relative path (or null or full path)
IData<IView<Model>> getData()
null
if such data cannot be created
|
Carbide.c++ | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |