Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Cell Editor
Xtext Cell Editor [message #1737985] Thu, 14 July 2016 16:33 Go to next message
Philipp Heisig is currently offline Philipp HeisigFriend
Messages: 26
Registered: November 2014
Junior Member
Hi,

I just tried to implement a xtext editor within my emf editor. Therefore, I followed the approach described in this blog post (http://muelder.blogspot.de/2011/04/xtext-celleditor-integration.html). However, the proposed XtextCellEditor within this example seems to be outdated, as several packages, e. g. org.eclipse.xtext.parser.antlr.IAntlrParser, couldn't be resolved. Is there a new implementation for an xtext based cell editor and if so where can I find it?

Cheers,
Phil
Re: Xtext Cell Editor [message #1737987 is a reply to message #1737985] Thu, 14 July 2016 17:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Phil Hei <forums-noreply@xxxxxxxx> wrote:
> Hi,
>
> I just tried to implement a xtext editor within my emf editor. Therefore,
> I followed the approach described in this blog post
> (http://muelder.blogspot.de/2011/04/xtext-celleditor-integration.html).
> However, the proposed XtextCellEditor within this example seems to be
> outdated, as several packages, e. g.
> org.eclipse.xtext.parser.antlr.IAntlrParser, couldn't be resolved. Is
> there a new implementation for an xtext based cell editor and if so where can I find it?
>
> Cheers,
> Phil
>

Hi I have no idea on that but did you have a look at
https://github.com/Yakindu/statecharts/blob/master/plugins/org.yakindu.base.xtext.utils.jface/src/org/yakindu/base/xtext/utils/jface/viewers/XtextStyledTextCellEditor.java


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Cell Editor [message #1738069 is a reply to message #1737985] Fri, 15 July 2016 14:14 Go to previous messageGo to next message
Philipp Heisig is currently offline Philipp HeisigFriend
Messages: 26
Registered: November 2014
Junior Member
Hi Christian,

thx for the suggestion, that's probably exatly what I was looking for. Unfortunately, I get a AssertionFailedException (details see below) when I try to open the XtextStyledTextCellEditor from the properties view. I'm not sure if my implementation (see below) is right or if I'm missing something. Is there maybe an example implementation somewhere? As the XtextStyledTextCellEditor is primarly used in GMF editors, I assume that EMF editors should work the same.

public class CustomPropertyDescriptor extends PropertyDescriptor {
	private AdapterFactory adapterFactory;

	public CustomPropertyDescriptor(AdapterFactory adapterFactory, Object object,
			IItemPropertyDescriptor itemPropertyDescriptor) {
		super(object, itemPropertyDescriptor);
		this.adapterFactory = adapterFactory;
}

       public CellEditor createPropertyEditor(Composite composite) {
		Injector injector = SpdependencyActivator.getInstance().getInjector("...");		
		XtextStyledTextCellEditor xtextStyledTextCellEditor  = new XtextStyledTextCellEditor (SWT.SINGLE, injector);
		xtextStyledTextCellEditor.create(composite);		
		return xtextStyledTextCellEditor;
        }
}


!ENTRY org.eclipse.ui 4 0 2016-07-15 16:00:19.741
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
	at org.yakindu.base.utils.jface.viewers.StyledTextCellEditor.doSetValue(StyledTextCellEditor.java:209)
	at org.yakindu.base.xtext.utils.jface.viewers.XtextStyledTextCellEditor.doSetValue(XtextStyledTextCellEditor.java:169)
	at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.java:861)
	at org.eclipse.ui.views.properties.PropertySheetEntry.getEditor(PropertySheetEntry.java:375)
	at org.eclipse.ui.views.properties.PropertySheetViewer.activateCellEditor(PropertySheetViewer.java:166)
	at org.eclipse.ui.views.properties.PropertySheetViewer.handleSelect(PropertySheetViewer.java:738)
	at org.eclipse.ui.views.properties.PropertySheetViewer.access$8(PropertySheetViewer.java:718)
	at org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseDown(PropertySheetViewer.java:824)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:192)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Re: Xtext Cell Editor [message #1738070 is a reply to message #1738069] Fri, 15 July 2016 14:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you please share something i can just import and execute?
i dont have the time to build an example myself.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Cell Editor [message #1738083 is a reply to message #1738070] Fri, 15 July 2016 15:40 Go to previous messageGo to next message
Philipp Heisig is currently offline Philipp HeisigFriend
Messages: 26
Registered: November 2014
Junior Member
Hi Christian,

please find attached a small example. The integration of xtext happens in the org.test.editor project, package org.test.presentation.custom, class CustomPropertyDescriptor. There is also an example for another custom cell editor which is working. I assume that you are familiar with EMF editors. Thanks for your support so far!
Re: Xtext Cell Editor [message #1738511 is a reply to message #1737985] Wed, 20 July 2016 13:16 Go to previous messageGo to next message
Philipp Heisig is currently offline Philipp HeisigFriend
Messages: 26
Registered: November 2014
Junior Member
Any updates on this?

One of my assumptions was that the missing Tabbed Properties View, which is used in GMF but not EMF (https://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html), is causing the exception. But trying to implement the XtextStyledTextCellEditor in a combined EMF/GMF editor results in the same exception.
Re: Xtext Cell Editor [message #1738521 is a reply to message #1738511] Wed, 20 July 2016 14:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
sry i have no clue. i asked the colleagues the code comes from but they seem not to have time

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Cell Editor [message #1738522 is a reply to message #1738521] Wed, 20 July 2016 14:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s. i dont get it running at all. if i open the cell eclipse completely hangs

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Cell Editor [message #1738652 is a reply to message #1738522] Thu, 21 July 2016 17:01 Go to previous messageGo to next message
Philipp Heisig is currently offline Philipp HeisigFriend
Messages: 26
Registered: November 2014
Junior Member
Hi Christian,

no worries! I've attached an update of the example (there was some unresolved dependencies). Hope that it's running now.

I started some debugging today and probably found out what's causing the exception. When returning the created XtextStyledTextCellEditor, PropertySheetEntry calls setValue() at a certain point. Within the class StyledTextCellEditor, the method doSetValue() is called later, where Assert.isTrue(text != null && (value instanceof String)) throws the exception because value is null. Value is forwarded originally from the class PropertySheetEntry and the attribute editValue, which seems to be never initialized.

To summarize: In StyledTextCellEditor , the method Assert.isTrue(text != null && (value instanceof String)) is called within protected void doSetValue(Object value), but value is null.

A workaround would probably be to override setValue(Object value) from the super class CellEditor and therein initialize an empty string. What do you think?

Re: Xtext Cell Editor [message #1738654 is a reply to message #1738652] Thu, 21 July 2016 18:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
sounds a good idea. does that work?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Cell Editor [message #1738691 is a reply to message #1738654] Fri, 22 July 2016 10:02 Go to previous message
Philipp Heisig is currently offline Philipp HeisigFriend
Messages: 26
Registered: November 2014
Junior Member
I created a CustomXtextStyledTextCellEditor class which extends the XtextStyledTextCellEditor and overides the doSetValue method:

protected void doSetValue(Object value) {
		if(value == null){
			value = "";
		}
		super.doSetValue(value);
}


This removes the AssertionFailedException, but the Xtext Editor don't pop up. Instead, I can just write every String into my property. However, I've right now no clue how to get it run.

---Edit---
I attached a new example to represent the current state

[Updated on: Wed, 27 July 2016 13:19]

Report message to a moderator

Previous Topic:Xtext/Xtend in C Language
Next Topic:Xtext with content dependent grammar
Goto Forum:
  


Current Time: Thu Apr 25 17:43:25 GMT 2024

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

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

Back to the top