Package org.jetbrains.mps.openapi.module
Interface ModelAccess
-
public interface ModelAccessGrants 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 voidaddCommandListener(CommandListener listener)add/remove listeners to listen to the start/finish of command eventsvoidaddReadActionListener(ReadActionListener listener)Get notified about start/finish of a model read actionvoidaddWriteActionListener(WriteActionListener listener)add/remove listeners to listen to the start/finish of write action eventsbooleancanRead()Indicates, whether the current thread holds the read lockbooleancanWrite()Indicates, whether the current thread holds the write lockvoidcheckReadAccess()Fails with an exception, if the current thread does not hold the read lockvoidcheckWriteAccess()Fails with an exception, if the current thread does not hold the write lockdefault <T> TcomputeWriteAction(Supplier<T> s)voidexecuteCommand(Runnable r)Represents a write action executed with respect to platform undo mechanism.voidexecuteCommandInEDT(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)voidexecuteUndoTransparentCommand(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 commandbooleanisCommandAction()voidremoveCommandListener(CommandListener listener)voidremoveReadActionListener(ReadActionListener listener)Cease notifications about start/finish of a model read actionvoidremoveWriteActionListener(WriteActionListener listener)voidrunReadAction(Runnable r)Querying properties of models can only be performed from within managed actions, which hold the appropriate read lock.voidrunReadInEDT(Runnable r)Querying properties of models can only be performed from within managed actions, which hold the appropriate read lock.voidrunWriteAction(Runnable r)Modifications to models can only be performed from within managed actions, which hold the appropriate write lock.voidrunWriteInEDT(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:
trueif 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
-
-