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 |
Ryana Karaki 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 #1842115 is a reply to message #1842108] |
Wed, 09 June 2021 14:41 |
Ryana Karaki 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.
|
|
| | | | |
Goto Forum:
Current Time: Tue Sep 24 13:02:01 GMT 2024
Powered by FUDForum. Page generated in 0.04989 seconds
|