Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problems changing hover size & colors (Xtext 2.24)
Problems changing hover size & colors (Xtext 2.24) [message #1842106] Wed, 09 June 2021 11:38 Go to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

I am new to Xtext, and am trying to write custom hovers, but I have an issue changing the hover's default size. What I did :

I have a HoverProviderXtend class, that extends DefaultEObjectHoverProvider and implements ITextHover.

I override getHoverInfoAsHtml(EObject o){ //text displayed depending on the object } to show hover information.
Following this thread : https://www.eclipse.org/forums/index.php/m/901294/?srch=hover+size#msg_901294 I override getHoverControlCreator() like this :

	override getHoverControlCreator() {
		var informationControl = new IInformationControlCreator() {
			override createInformationControl(Shell parent) {
				var defaultInfoControl = new DefaultInformationControl(parent)
				defaultInfoControl.backgroundColor = new Color(0,255,0)
				defaultInfoControl.setSize(500,500)
				return defaultInfoControl
			}
		}
		return informationControl
	}


However, this does not change my hover's color or size. Instead, my hover displays this :

<html><head><style CHARSET="ISO-8859-1" TYPE="text/css">/* Font definitions */
html         { font-family: 'Ubuntu',sans-serif; font-size: 13pt; font-style: normal; font-weight: normal; }
body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }
pre          { font-family: monospace; }

/* Margins */
body	     { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }
h1           { margin-top: 0.3em; margin-bottom: 0.04em; }	
h2           { margin-top: 2em; margin-bottom: 0.25em; }
h3           { margin-top: 1.7em; margin-bottom: 0.25em; }
h4           { margin-top: 2em; margin-bottom: 0.3em; }
h5           { margin-top: 0px; margin-bottom: 0px; }
p            { margin-top: 1em; margin-bottom: 1em; }
pre          { margin-left: 0.6em; }
ul	         { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}
li	         { margin-top: 0px; margin-bottom: 0px; } 
li p	     { margin-top: 0px; margin-bottom: 0px; } 
ol	         { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }
dl	         { margin-top: 0px; margin-bottom: 1em; }
dt	         { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }
dd	         { margin-top: 0px; margin-bottom: 0px; }

/* Styles and colors */
a:link	     { color: #0000FF; }
a:hover	     { color: #000080; }
a:visited    { text-decoration: underline; }
a.header:link    { text-decoration: none; color: #eeeeee }
a.header:visited { text-decoration: none; color: #eeeeee }
a.header:hover   { text-decoration: underline; color: #000080; }
h4           { font-style: italic; }
strong	     { font-weight: bold; }
em	         { font-style: italic; }
var	         { font-style: italic; }
th	         { font-weight: bold; }
</style></head><body text="#eeeeee" bgcolor="#34393d"><p style="color:red">This is a TargetDecl.</p></body></html>


If I erase the getHoverControlCreator(), my text is correctly displayed (but the hover size is still too small). What should I do to have a correct hover size/change colors ?


Thank you for your help.
Re: Problems changing hover size & colors (Xtext 2.24) [message #1842108 is a reply to message #1842106] Wed, 09 June 2021 11:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
the default (org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider.HoverControlCreator.doCreateInformationControl(Shell))
does create an XtextBrowserInformationControl, not a DefaultInformationControl


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problems changing hover size & colors (Xtext 2.24) [message #1842115 is a reply to message #1842108] Wed, 09 June 2021 14:41 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

Thanks for your quick answer ! I tried doing this :
	override getHoverControlCreator() {
		var informationControl = new IInformationControlCreator() {
			override createInformationControl(Shell parent) {
				var infoControl = new XtextBrowserInformationControl(parent, definedFont, true)
				infoControl.backgroundColor = new Color(0,255,0)
				infoControl.setSize(10,10)
				return infoControl
			}
		}
		return informationControl
	}


However, my runtime Eclipse freezes when I try to Hover. I debugged to see where was the problem and saw that the infoControl was well created, but in the AbstractInformationControlManager, there is an exception thrown when trying to do the computeTrim() method (last line):
	private void internalShowInformationControl(Rectangle subjectArea, Object information) {
		if (this instanceof InformationControlReplacer) {
			((InformationControlReplacer) this).showInformationControl(subjectArea, information);
			return;
		}

		IInformationControl informationControl= getInformationControl();
		if (informationControl != null) {

			Point sizeConstraints= computeSizeConstraints(fSubjectControl, fSubjectArea, informationControl);
			if (informationControl instanceof IInformationControlExtension3) {
				IInformationControlExtension3 iControl3= (IInformationControlExtension3) informationControl;
				Rectangle trim= iControl3.computeTrim();


Do you know why is this happening ? My runtime Eclipse just freezes when I hover, and no exceptions are shown.
Re: Problems changing hover size & colors (Xtext 2.24) [message #1842116 is a reply to message #1842115] Wed, 09 June 2021 14:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
sry have no idea on this

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problems changing hover size & colors (Xtext 2.24) [message #1842122 is a reply to message #1842116] Wed, 09 June 2021 16:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
Hi

A recursive method call is very easy when overriding frameworks and often results in a hang. Eclipse is really bad at dealing with Stack Overflow. Too often it finds it has run out of memory and so cannot call a routine to diagnose.

Use a debugger or JVisualVM to break and see what is executing a few seconds after the hang starts.

Regards

Ed Willink
Re: Problems changing hover size & colors (Xtext 2.24) [message #1842276 is a reply to message #1842122] Tue, 15 June 2021 09:30 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

I discovered that my problem comes from
return new XtextBrowserInformationControl(parent, font, true)

if i change the 'resizable' parameter to 'false', my hovers appear again...
But obviously, the 'setSize()' method does not apply afterwards.

[Updated on: Tue, 15 June 2021 09:30]

Report message to a moderator

Re: Problems changing hover size & colors (Xtext 2.24) [message #1843177 is a reply to message #1842276] Mon, 19 July 2021 09:50 Go to previous message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

Concerning the customizable hovers, I managed to achieve this by using instead SWT tools : I create a SWT browser that I customize and set to Visible when needed.

Thank you all for you propositions !
Previous Topic:Customizing XtextAnnotation
Next Topic:Xtext and Java 16
Goto Forum:
  


Current Time: Sun Sep 19 00:06:31 GMT 2021

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

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

Back to the top