Package org.jetbrains.mps.openapi.model
Interface EditableSModel
-
- All Superinterfaces:
SModel
public interface EditableSModel extends SModel
Model deemed for editing. Dispatches change events.- See Also:
evgeny, 2/14/13
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jetbrains.mps.openapi.model.SModel
SModel.Problem
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description boolean
isChanged()
boolean
needsReloading()
void
reloadFromSource()
reloads the model from the storageSModel.getSource()
the current model changes (isChanged()
) might be lost as a result fixme why it is so not symmetric tosave()
?void
rename(String newModelName, boolean changeFile)
fixme ! I do not understand this API, why can we rename model here but other kind of changes we do not see (like #addRootNode for example)default void
save()
needs the write action lock, this method will save the model into the storage (located atSModel.getSource()
).default CompletionStage<SaveResult>
save(SaveOptions options)
void
setChanged(boolean changed)
void
updateTimestamp()
Deprecated.use #save(new SaveOptionsBuilder().force().build()) instead-
Methods inherited from interface org.jetbrains.mps.openapi.model.SModel
addAccessListener, addChangeListener, addModelListener, addRootNode, createNode, createNode, getModelId, getModelName, getModelRoot, getModule, getName, getNode, getProblems, getReference, getRepository, getRootNodes, getSource, isLoaded, isReadOnly, load, removeAccessListener, removeChangeListener, removeModelListener, removeRootNode, unload
-
-
-
-
Method Detail
-
isChanged
boolean isChanged()
-
setChanged
void setChanged(boolean changed)
-
save
default void save()
needs the write action lock, this method will save the model into the storage (located atSModel.getSource()
). IfneedsReloading()
is false then as a result of this methodisChanged()
returns true Otherwise the actual save can happen much later.- See Also:
save(SaveOptions)
-
save
default CompletionStage<SaveResult> save(@NotNull SaveOptions options)
- Parameters:
options
- describe how to behave in case of conflict where 'conflict' is the scenario when we save a changed model ({isChanged()
} is true) and it happens that {needsReloading()
} is true.- Returns:
- a CompletionStage with the result inside.
yes, the save might not happen right away after the invocation,
for example if there is a conflict with data source ({
needsReloading()
returned true} and the implementor might overwrite the data coming from the data source which is not good (losing data is never good). Realistically in 2020.3 this is the only case when the result is async, but still. Perhaps, the api could be more solid with all the {needsReloading()
} logic happening outside of EditableSModel implementations (@see EditableSModelBase#areThereAnyConflictsOnSave). But as always I doubt that changing the semantics of such a popular method is the right way
-
rename
void rename(@NotNull String newModelName, boolean changeFile)
fixme ! I do not understand this API, why can we rename model here but other kind of changes we do not see (like #addRootNode for example)- Parameters:
changeFile
- I do not like either it must be generalized or moved to a lower level (where files data sources are in place)
-
updateTimestamp
@Deprecated @ScheduledForRemoval(inVersion="2021.2") void updateTimestamp()
Deprecated.use #save(new SaveOptionsBuilder().force().build()) instead
-
needsReloading
boolean needsReloading()
-
reloadFromSource
void reloadFromSource()
reloads the model from the storageSModel.getSource()
the current model changes (isChanged()
) might be lost as a result fixme why it is so not symmetric tosave()
?
-
-