Package org.jetbrains.mps.openapi.module
Interface ModelAccess
-
public interface ModelAccess
Grants access to objects in the repository (for example to models)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addCommandListener(CommandListener listener)
add/remove listeners to listen to the start/finish of command eventsvoid
addReadActionListener(ReadActionListener listener)
Get notified about start/finish of a model read actionvoid
addWriteActionListener(WriteActionListener listener)
add/remove listeners to listen to the start/finish of write action eventsboolean
canRead()
Indicates, whether the current thread holds the read lockboolean
canWrite()
Indicates, whether the current thread holds the write lockvoid
checkReadAccess()
Fails with an exception, if the current thread does not hold the read lockvoid
checkWriteAccess()
Fails with an exception, if the current thread does not hold the write lockdefault <T> T
computeWriteAction(Supplier<T> s)
void
executeCommand(Runnable r)
Represents a write action executed with respect to platform undo mechanism.void
executeCommandInEDT(Runnable r)
Represents a write action executed with respect to platform undo mechanism, runs asynchronously from EDT thread.default <T> Future<T>
executeCommandInEDT(Supplier<T> supplier)
void
executeUndoTransparentCommand(Runnable r)
FIXME need thorough documentation Executed code has model write, is treated as a command, the only difference is that changes from the transparent action merged with the that of the previous undoable commandboolean
isCommandAction()
void
removeCommandListener(CommandListener listener)
void
removeReadActionListener(ReadActionListener listener)
Cease notifications about start/finish of a model read actionvoid
removeWriteActionListener(WriteActionListener listener)
void
runReadAction(Runnable r)
Querying properties of models can only be performed from within managed actions, which hold the appropriate read lock.void
runReadInEDT(Runnable r)
Querying properties of models can only be performed from within managed actions, which hold the appropriate read lock.void
runWriteAction(Runnable r)
Modifications to models can only be performed from within managed actions, which hold the appropriate write lock.void
runWriteInEDT(Runnable r)
Modifications to models can only be performed from within managed actions, which hold the appropriate write lock.
-
-
-
Method Detail
-
canRead
boolean canRead()
Indicates, whether the current thread holds the read lock
-
checkReadAccess
void checkReadAccess()
Fails with an exception, if the current thread does not hold the read lock
-
canWrite
boolean canWrite()
Indicates, whether the current thread holds the write lock
-
checkWriteAccess
void checkWriteAccess()
Fails with an exception, if the current thread does not hold the write lock
-
runReadAction
void runReadAction(Runnable r)
Querying properties of models can only be performed from within managed actions, which hold the appropriate read lock. The method obtains such a lock and executes the provided action.
-
runReadInEDT
void runReadInEDT(Runnable r)
Querying properties of models can only be performed from within managed actions, which hold the appropriate read lock. The method obtains such a lock and executes the provided action asynchronously on the EDT UI thread. Inside the action it is safe to touch any UI elements and perform other EDT-bound actions of the IntelliJ platform.
-
runWriteAction
void runWriteAction(Runnable r)
Modifications to models can only be performed from within managed actions, which hold the appropriate write lock. The method obtains such a lock and executes the provided action. It should not be invoked from EDT, otherwise UI freeze may occur. Note: A lock cannot be upgraded. When owning the read lock it is not allowed to ask for the write lock through the runWriteAction() method.
-
computeWriteAction
default <T> T computeWriteAction(Supplier<T> s)
-
runWriteInEDT
void runWriteInEDT(Runnable r)
Modifications to models can only be performed from within managed actions, which hold the appropriate write lock. The method obtains such a lock and executes the provided action asynchronously on the EDT UI thread. Inside the action it is safe to touch any UI elements and perform other EDT-bound actions of the IntelliJ platform.
-
executeCommand
void executeCommand(Runnable r)
Represents a write action executed with respect to platform undo mechanism. This method shall be invoked from EDT thread only. UnlikeexecuteCommandInEDT(Runnable)
, this method executes synchronously
-
executeCommandInEDT
void executeCommandInEDT(@NotNull Runnable r)
Represents a write action executed with respect to platform undo mechanism, runs asynchronously from EDT thread. This method may be invoked from any thread.
-
executeCommandInEDT
@NotNull @Experimental default <T> Future<T> executeCommandInEDT(@NotNull Supplier<T> supplier)
-
executeUndoTransparentCommand
void executeUndoTransparentCommand(Runnable r)
FIXME need thorough documentation Executed code has model write, is treated as a command, the only difference is that changes from the transparent action merged with the that of the previous undoable command
-
isCommandAction
boolean isCommandAction()
- Returns:
true
if there's a command (either withexecuteCommand(Runnable)
orexecuteCommandInEDT(Runnable)
) being executed
-
addCommandListener
void addCommandListener(CommandListener listener)
add/remove listeners to listen to the start/finish of command events- Parameters:
listener
- listens to command- See Also:
executeCommand(Runnable)
-
removeCommandListener
void removeCommandListener(CommandListener listener)
-
addWriteActionListener
void addWriteActionListener(@NotNull WriteActionListener listener)
add/remove listeners to listen to the start/finish of write action events- Parameters:
listener
- listens to write action- See Also:
runWriteAction(Runnable)
-
removeWriteActionListener
void removeWriteActionListener(@NotNull WriteActionListener listener)
-
addReadActionListener
void addReadActionListener(@NotNull ReadActionListener listener)
Get notified about start/finish of a model read action- Since:
- 2018.3
-
removeReadActionListener
void removeReadActionListener(@NotNull ReadActionListener listener)
Cease notifications about start/finish of a model read action- Since:
- 2018.3
-
-