Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Problems while modifying EList of string
Problems while modifying EList of string [message #1773828] Thu, 05 October 2017 08:07 Go to next message
Jan van Dijk is currently offline Jan van DijkFriend
Messages: 2
Registered: October 2017
Junior Member
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 #1773890 is a reply to message #1773828] Fri, 06 October 2017 07:59 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1894
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Jan,

this i more a question of using EMF Transactions which Graphiti uses under the hood. For each modifying operation you do to the EMF model you need to wrap that within an EMF write transaction. This can either be done directly on EMF Transaction level or you may use Grapiti's feature execution option as descibed on our FAQ page under point 3).
https://www.eclipse.org/graphiti/developers/faq.php

Michael
Re: Problems while modifying EList of string [message #1773898 is a reply to message #1773890] Fri, 06 October 2017 09:59 Go to previous messageGo to next message
Jan van Dijk is currently offline Jan van DijkFriend
Messages: 2
Registered: October 2017
Junior Member
Thank you for reply.

We already did that for the basis string values, which works just as expected...

( https://www.eclipse.org/graphiti/developers/resources/ModifyListener.txt )

But it doesn't work for the list...

((EList<String>) node.eGet(node.eClass().getEStructuralFeature("columns"), true)).add(value);

Re: Problems while modifying EList of string [message #1773905 is a reply to message #1773898] Fri, 06 October 2017 11:04 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1894
Registered: July 2009
Location: Walldorf, Germany
Senior Member
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
Previous Topic:could't save the Graphiti
Next Topic:Alignment actions
Goto Forum:
  


Current Time: Sun Jul 22 20:05:49 GMT 2018

Powered by FUDForum. Page generated in 0.02093 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top