How to Change background Color while Hovering in Eclipse Editor

Napster

I am building a eclipse plugin with custom editor. I have implemented text hovering functionality in which user hover on some text then that text will be shown on tooltip like javadocs.

Now i want to change the background color of that hovering text in editor. How i can implement that? I tried some code. But i didn't working.

Color blueColor = new Color(PlatformUI.getWorkbench().getDisplay(),0,0,255);
textViewer.setTextColor(blueColor, startRegion, finalStr.length(), false);

Here finalStr is a String that i will get when i hover on some text. I want to change the background and foreground color of finalStr.

Napster

I resolved my question. Above code wasn't working for me because i was accessing it outside SWT thread. So i have to make a new thread and write code in that thread. Following is the code i used to make it work.

new Thread(new Runnable() {
@SuppressWarnings("static-access")
public void run() {
    try {Thread.sleep(10); } catch (Exception e) { }
    PlatformUI.getWorkbench().getDisplay().getDefault().asyncExec(new Runnable() {
    public void run() {
          textViewer.invalidateTextPresentation();
          Color lightColor = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_GRAY);
          Color blueColor=new Color(PlatformUI.getWorkbench().getDisplay(),0,0,255);
          TextPresentation presentation = new TextPresentation();
          TextAttribute attr = new TextAttribute(blueColor,lightColor , 0);
          presentation.addStyleRange(new StyleRange(startRegion, finalStr.length(), attr.getForeground(),attr.getBackground()));
          textViewer.changeTextPresentation(presentation, true); 
    }
   });
  }
}).start();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to change color of Editor in Eclipse

From Dev

How to change PyCharm code editor background color?

From Dev

How to change the MySQL Workbench editor background color?

From Dev

How to change the background color of a ListBox Item when hovering?

From Dev

How to change text color (and background) on nav bar links when hovering?

From Dev

How to change text color (and background) on nav bar links when hovering?

From Dev

How to change the background color of a ListBox Item when hovering?

From Dev

How to change hover background and foreground color in eclipse?

From Dev

Change background color of row when hovering

From Dev

How to change background color while swiping on an view?

From Dev

Change Xmlspy editor background color

From Java

How to change background color in the Notepad++ text editor?

From Dev

Eclipse Theme - How to change the color of the main editor text

From Dev

Eclipse - Change Console background color

From Dev

Maintaining the hover state background color while hovering its submenu items

From Dev

While loop: Change Background color

From Dev

Change BODY background color when hovering over a table cell

From Dev

How to change span style while hovering a div?

From Dev

How to change every character while hovering?

From Java

How to change the background color of a UIButton while it's highlighted?

From Dev

Cannot change color of Eclipse editor tabs

From Dev

Change color of text while hovering over different text?

From Dev

How to change Vi editor background

From Dev

How to change editor background in TFVC

From Dev

Eclipse Background Color will not change OSX, Pydev

From Dev

Change the app background color by using a ToggleButton in Eclipse

From Dev

Background changes color when hovering

From Dev

How to change the background color around the visual design/layout editor in Android Studio

From Dev

How to do background color in Froala WYSIWYG editor?

Related Related

  1. 1

    How to change color of Editor in Eclipse

  2. 2

    How to change PyCharm code editor background color?

  3. 3

    How to change the MySQL Workbench editor background color?

  4. 4

    How to change the background color of a ListBox Item when hovering?

  5. 5

    How to change text color (and background) on nav bar links when hovering?

  6. 6

    How to change text color (and background) on nav bar links when hovering?

  7. 7

    How to change the background color of a ListBox Item when hovering?

  8. 8

    How to change hover background and foreground color in eclipse?

  9. 9

    Change background color of row when hovering

  10. 10

    How to change background color while swiping on an view?

  11. 11

    Change Xmlspy editor background color

  12. 12

    How to change background color in the Notepad++ text editor?

  13. 13

    Eclipse Theme - How to change the color of the main editor text

  14. 14

    Eclipse - Change Console background color

  15. 15

    Maintaining the hover state background color while hovering its submenu items

  16. 16

    While loop: Change Background color

  17. 17

    Change BODY background color when hovering over a table cell

  18. 18

    How to change span style while hovering a div?

  19. 19

    How to change every character while hovering?

  20. 20

    How to change the background color of a UIButton while it's highlighted?

  21. 21

    Cannot change color of Eclipse editor tabs

  22. 22

    Change color of text while hovering over different text?

  23. 23

    How to change Vi editor background

  24. 24

    How to change editor background in TFVC

  25. 25

    Eclipse Background Color will not change OSX, Pydev

  26. 26

    Change the app background color by using a ToggleButton in Eclipse

  27. 27

    Background changes color when hovering

  28. 28

    How to change the background color around the visual design/layout editor in Android Studio

  29. 29

    How to do background color in Froala WYSIWYG editor?

HotTag

Archive