Pokazywanie postów oznaczonych etykietą eclipse. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą eclipse. Pokaż wszystkie posty

wtorek, 17 marca 2015

How to run a long operation with a spinner/hourglass indicator within eclipse plugin (swt application) ?

From time to time there is a need to run some relatively long operation synchronously. In such a case will be good to indicate the fact to the user. There is very simple way of doing this with BusyIndicator class. Just replace syncExec with BusyIndicator.showWhile.
Display.getCurrent().syncExec(new Runnable() {
    @Override
    public void run() {
           // long operation
    }
});
with the following:
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
    @Override
    public void run() {
           // long operation
    }
});

poniedziałek, 2 lutego 2015

How to obtain Eclipse absolute installation path programmatically

The easiest way is to use org.eclipse.core.runtime.Platform class and its static getInstallLocation method.
Location installLocation = Platform.getInstallLocation();
A Location interface is defined in OSGi specification and basically represents an java.net.URL object. Additionally it allows creating nested locations and mechanism for locking locations. The default and the only one shipped implementation is BasicLocation, but it is internal class and just pure implementation (no other fancy features ;) To obtain path as a String user the following code:
String absolutePath = Platform.getInstallLocation().getURL().getFile();
Alternatively you can read the content
InputStream is = Platform.getInstallLocation().getURL().getContent();

wtorek, 7 października 2014

Ubuntu 14.04 and Eclipse - how to change black tooltip background with light yellow

If you are using the default Ambience theme there are couple of config files you need to modify for changing the black tooltip color with the lightyellow one. First lets identify file where background is defined:
$ grep -R "tooltip_bg_color" /usr/share/themes/Ambiance
you should be output with the following
/usr/share/themes/Ambiance/gtk-3.0/settings.ini:gtk-color-scheme = "base_color:#ffffff\nbg_color:#f2f1f0\ntooltip_bg_color:#000000\nselected_bg_color:#f07746\ntext_color:#3C3C3C\nfg_color:#4c4c4c\ntooltip_fg_color:#ffffff\nselected_fg_color:#ffffff\nlink_color:#DD4814\nbg_color_dark:#3c3b37\nfg_color_dark:#dfdbd2"
/usr/share/themes/Ambiance/gtk-3.0/gtk-main.css:@define-color tooltip_bg_color #f5f5b5;
/usr/share/themes/Ambiance/gtk-3.0/gtk-widgets.css:                                     from (alpha (mix (@tooltip_bg_color, #ffffff, 0.2), 0.86)),
/usr/share/themes/Ambiance/gtk-3.0/gtk-widgets.css:                                     to (alpha (@tooltip_bg_color, 0.86)));
/usr/share/themes/Ambiance/gtk-2.0/gtkrc:gtk-color-scheme = "base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#000000\nselected_bg_color:#f07746\nselected_fg_color:#FFFFFF\ntext_color:#3C3C3C\nbg_color:#F2F1F0\ntooltip_bg_color:#f5f5b5\nlink_color:#DD4814"
/usr/share/themes/Ambiance/gtk-2.0/gtkrc: bg[NORMAL]        = @tooltip_bg_color
/usr/share/themes/Ambiance/gtk-2.0/gtkrc: bg[SELECTED]      = @tooltip_bg_color
We are interested with
  • /usr/share/themes/Ambiance/gtk-3.0/settings.ini
  • /usr/share/themes/Ambiance/gtk-3.0/gtk-main.css

Now lets replace
tooltip_bg_color:#000000 with tooltip_bg_color:#f5f5b5, and
tooltip_fg_color:#ffffff with tooltip_fg_color:#000000

$ sudo sed -i 's/tooltip_bg_color:#000000/tooltip_bg_color:#f5f5bf/' /usr/share/themes/Ambiance/gtk-3.0/settings.ini
$ sudo sed -i 's/tooltip_fg_color:#ffffff/tooltip_fg_color:#000000/' /usr/share/themes/Ambiance/gtk-3.0/settings.ini
$ sudo sed -i 's/tooltip_bg_color #000000/tooltip_bg_color #f5f5b50/' /usr/share/themes/Ambiance/gtk-3.0/gtk-main.css
$ sudo sed -i 's/tooltip_bg_color #ffffff/tooltip_bg_color #000000/' /usr/share/themes/Ambiance/gtk-3.0/gtk-main.css
Finally you need to change theme to some other and back to Ambience and after that full restart of Eclipse is required (soft one (by File->Restart) may be not enough).