Problems while modifying EList of string [message #1773828] |
Thu, 05 October 2017 08:07  |
Eclipse User |
|
|
|
I'm creating an property section to edit a list of string within an EMF model.
The emf model is
class MergeNode extends Node {
ref Node[1] left;
ref Node[1] right;
attr String[*] columns;
attr JoinType[1] type;
}
I've made a property section which contains of a List (org.eclipse.swt.widgets.List;) and two buttons + and - to add or remove items to the list.
When the + is pressed a popup is shown where the column name can be entered. This is then added to the list:
void addToList(String value) {
MergeNode node = getObject();
if (node != null) {
((EList<String>) node.eGet(node.eClass().getEStructuralFeature("columns"), true)).add(value);
}
}
This throwns an Exception:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:349)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:303)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processObjectNotification(TransactionChangeRecorder.java:285)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:241)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:304)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:305)
at com.adchieve.bigdata.diagrams.plugin.property.MultiStringSection.addToList(MultiStringSection.java:85)
at com.adchieve.bigdata.diagrams.plugin.property.MultiStringSection$1.handleEvent(MultiStringSection.java:58)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4257)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1502)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1525)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1510)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1314)
at ...
The value is added to the list however... but the widget (org.eclipse.swt.widgets.List) which contains the items doesnt show it. After reloading the diagram the items are there...
when I ignore the error by catching it... and do a manual refresh of the widget all seems to work fine. Except that it doesn't detect that there has been a change (and no save is possible). When I move other items in the diagram (and the save button enables) I can save and the saves works.
void addToList(String value) {
MergeNode node = getObject();
if (node != null) {
try {
((EList<String>) node.eGet(node.eClass().getEStructuralFeature("columns"), true)).add(value);
} catch (IllegalStateException e) {
}
refresh();
}
}
How can I fix this?
|
|
|
|
|
Re: Problems while modifying EList of string [message #1773905 is a reply to message #1773898] |
Fri, 06 October 2017 11:04  |
Eclipse User |
|
|
|
What do you mean with "we already did that"? Changing the string values in the same way as you add an entry to the list or wrapping into transaction or feature?
All I can say is that you need a write transaction in order to perform any change operation, so first way will not work, second will. In both the above coding and the stack trace I do not see that a transaction or a feature is used.
Michael
|
|
|
Powered by
FUDForum. Page generated in 0.03140 seconds