"You can only read model inside of read action"
Hi everyone,
I'm currently trying to build an editor for a simple test language using Swing components. I want to have a Swing table with all values from child nodes and a "Delete" button. I tried to build a custom table model for it where I get the values from the node, but I get the IDE exception "You can only read model inside of read action". Here are some screenshots of my code:
(The rest of the DailyTimeRecord editor - besides the Swing component - are remnants of the old implementation).
Do I need to refactor the TableModel so it will take a list of column values instead of the node itself? If so, how do I edit the node values when the table is edited? Or is it a completely wrong approach and I should use something entirely different?
Please sign in to leave a comment.
You need to get access to the read/write lock before you read/modify the model. See https://confluence.jetbrains.com/display/MPSD20172/Open+API+-+accessing+models+from+code
node.model/.getRepository().getModelAccess().runWriteAction(new Runnable() {
public void run() {
<no statements>
}
});
or after importing j.m.lang.access:
write action with global repository {
<no statements>
}