Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » e4 app based on Contact demo has problem with IEclipseContext(e4 app based on Contact demo has problem with IEclipseContext)
e4 app based on Contact demo has problem with IEclipseContext [message #524501] Thu, 01 April 2010 04:02 Go to next message
David Wynter is currently offline David Wynter
Messages: 4541
Registered: July 2009
Senior Member
Hi,

I cloned the Contacts demo for my own app. I get an error with the IEclipseContext on selecting from the ListView as follows:

Exception occurred
java.lang.IllegalArgumentException: Variable selection is not modifiable in the context Anonymous Context
	at org.eclipse.e4.core.services.internal.context.EclipseContext.internalModify(EclipseContext.java:499)
	at org.eclipse.e4.core.services.internal.context.EclipseContext.modify(EclipseContext.java:489)
	at com.hsbcib.grds.testui.views.ListViewer$1.selectionChanged(ListViewer.java:51)
	at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:162)
	at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:128)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:160)
	at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2132)
	at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:1160)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:1190)
	at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:228)
	at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:222)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:389)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1050)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4037)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3628)
	at org.eclipse.e4.ui.workbench.swt.internal.PartRenderingEngine$5.run(PartRenderingEngine.java:554)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.workbench.swt.internal.PartRenderingEngine.run(PartRenderingEngine.java:478)
	at org.eclipse.e4.workbench.ui.internal.E4Workbench.createAndRunUI(E4Workbench.java:100)
	at org.eclipse.e4.ui.workbench.swt.internal.E4Application.start(E4Application.java:84)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1406)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1382)


the method looks like this

	@Inject
	public ListViewer(Composite parent) {
		// Table composite (because of TableColumnLayout)
		final Composite tableComposite = new Composite(parent, SWT.NONE);
		tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		final TableColumnLayout tableColumnLayout = new TableColumnLayout();
		tableComposite.setLayout(tableColumnLayout);

		// Table viewer
		testCaseViewer = new TableViewer(tableComposite, SWT.FULL_SELECTION);
		testCaseViewer.getTable().setHeaderVisible(true);
		// contactsViewer.getTable().setLinesVisible(true);
		testCaseViewer.setComparator(new TestCaseViewerComparator());

		testCaseViewer.addSelectionChangedListener(
			new ISelectionChangedListener() {
				public void selectionChanged(SelectionChangedEvent event) {
					IStructuredSelection selection = (IStructuredSelection)event.getSelection();
					context.modify(IServiceConstants.SELECTION, selection.getFirstElement());
				}
			});


The exception only occurs on the 2nd or later seelction of an item in the list. Unlike the Contacts demo the List only has one column. The difficulty with an @Inject is it is hard to see the larger context for a problem like this. Any suggestions?

Thx.

David

Re: e4 app based on Contact demo has problem with IEclipseContext [message #524601 is a reply to message #524501] Thu, 01 April 2010 10:52 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you are using modify then your model has to list that variable in its
variables attribute. Have a look at the matching model entry in the
contacts demo for the ListViewer.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: e4 app based on Contact demo has problem with IEclipseContext [message #524615 is a reply to message #524601] Thu, 01 April 2010 11:36 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4541
Registered: July 2009
Senior Member
Hi,

Thx for that. I built my UI with the Workbench Designer and Workbenchmodel Editor. I did not see an entry for variables in these. It was not until I opened the Application.e4xmi in an XML editor did I see the variables element. Did I miss some documentation on this?

David
Re: e4 app based on Contact demo has problem with IEclipseContext [message #524876 is a reply to message #524601] Sat, 03 April 2010 06:36 Go to previous messageGo to next message
Sebastian is currently offline Sebastian
Messages: 61
Registered: March 2010
Member
Hi,

couldn't you use method declareModifiable(String name) of IEclipseContext?
This way you don't have to explicitly declare the variable in Appliction.e4xmi.

Sebastian
Re: e4 app based on Contact demo has problem with IEclipseContext [message #572576 is a reply to message #524601] Thu, 01 April 2010 11:36 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4541
Registered: July 2009
Senior Member
Hi,

Thx for that. I built my UI with the Workbench Designer and Workbenchmodel Editor. I did not see an entry for variables in these. It was not until I opened the Application.e4xmi in an XML editor did I see the variables element. Did I miss some documentation on this?

David
Re: e4 app based on Contact demo has problem with IEclipseContext [message #572717 is a reply to message #524601] Sat, 03 April 2010 06:36 Go to previous message
Sebastian is currently offline Sebastian
Messages: 61
Registered: March 2010
Member
Hi,

couldn't you use method declareModifiable(String name) of IEclipseContext?
This way you don't have to explicitly declare the variable in Appliction.e4xmi.

Sebastian
Previous Topic:DI Question
Next Topic:Bye bye Eclipse?
Goto Forum:
  


Current Time: Sat Jul 26 13:13:13 EDT 2014

Powered by FUDForum. Page generated in 0.01932 seconds