Bug 564710 - Heap status indicator cannot be styled
Summary: Heap status indicator cannot be styled
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.17   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Pierre-Yves Bigourdan CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-27 23:49 EDT by Andrew Obuchowicz CLA
Modified: 2021-09-29 21:31 EDT (History)
3 users (show)

See Also:


Attachments
Styled heap status (3.18 KB, image/png)
2020-08-23 06:14 EDT, Pierre-Yves Bigourdan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Obuchowicz CLA 2020-06-27 23:49:00 EDT
It seems that the heap status indicator's colors cannot be modified as they are hard-coded, see: https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/HeapStatus.java#n133

It'd be nice to add a CSS element to the heap status or an Eclipse preference for the heap status colors. This way, it could be colored differently per-theme.

If this is okay, I can provide a Gerrit although I'd like to get confirmation on the proper approach :)

Downstream bug: https://github.com/AObuchow/Eclipse-Spectrum-Theme/issues/38
Comment 1 Pierre-Yves Bigourdan CLA 2020-08-05 03:38:01 EDT
(In reply to Andrew Obuchowicz from comment #0)
> If this is okay, I can provide a Gerrit although I'd like to get
> confirmation on the proper approach :)

Sounds like a good thing to have! I'm guessing you could add something very similar to what was done in bug 497586, by creating a few setters in the HeapStatus class and a new CSS property handler class. Feel free to add me to the reviewers on Gerrit :)
Comment 2 Eclipse Genie CLA 2020-08-23 06:11:48 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/168098
Comment 3 Pierre-Yves Bigourdan CLA 2020-08-23 06:14:48 EDT
Created attachment 283941 [details]
Styled heap status

Result with the following CSS properties:
HeapStatus {
  swt-free-mem-color: white;
  swt-used-mem-color: lightblue;
  swt-low-mem-color: purple;
}
Comment 4 Andrew Obuchowicz CLA 2020-08-23 14:26:00 EDT
That looks quite nice @Pierre-Yves :) I'll review your patch soon and it should get in when the merge window opens.
Comment 5 Matthias Becker CLA 2020-08-24 02:28:43 EDT
(In reply to Pierre-Yves B. from comment #3)
> Created attachment 283941 [details]
> Styled heap status
> 
> Result with the following CSS properties:
> HeapStatus {
>   swt-free-mem-color: white;
>   swt-used-mem-color: lightblue;
>   swt-low-mem-color: purple;
> }

Why did you decide not to use new preference values? Doing this the user could also easily change the colors. And via CSS you could also change these colors.
Comment 6 Pierre-Yves Bigourdan CLA 2020-08-24 03:59:54 EDT
(In reply to Matthias Becker from comment #5)
> Why did you decide not to use new preference values? Doing this the user
> could also easily change the colors. And via CSS you could also change these
> colors.

Good question. There are two aspects that come to my mind.

Firstly, in my opinion Eclipse preferences in the context of UI theming are evil. There's a risk that Oomph interferes with theming. If my understanding is correct, a common use case could be: use Light theme with default heap status preferences -> switch to Dark theme -> preferences no longer match defaults and get synchronized by Oomph -> switch back to Light theme -> on restart Oomph re-applies the heap status styling from the Dark theme. I'm not fully across how everything works underneath the hood, but I know this kind of behaviour happens a lot and causes confusion. Andrew and myself have been working on our own themes currently as well as contributing to the platforms ones, bug 563270, https://github.com/PyvesB/eclipse-planet-themes/issues/2 and https://github.com/AObuchow/Eclipse-Spectrum-Theme/issues/63 are just three examples where this kind of behaviour has led to a fair bit of head scratching and incomprehension. I'm sure that if it's challenging for two contributors and heavy users of the IDE, it will be for the standard user as well. :) Oomph really needs some mechanism to exclude UI preferences by default, or preferences contributed by themes.

Secondly, heap status didn't strike me as something that users were likely to want to want to change. It's really strongly tied to theming and typically the heap status style would be chosen to be harmonious with the colors of the bottom status bar as well as other background elements. If I'm not mistaken, all of these are controlled by CSS only, it would be artificial to be able to change the heap status but none of the other Composite elements around it.

To conclude, in my opinion making them preferences brings little value, but adds complexity and risk of misbehaving with Oomph. However, I'm happy to revisit my patch if there are strong opinions against the CSS-only approach. :)
Comment 7 Andrew Obuchowicz CLA 2020-08-24 21:10:54 EDT
I agree with Pierre-Yves reasoning on not using a preference.

Additionally, IMO there are too many eclipse color preferences already. I think that in the future, they should be cleaned up (maybe removing some, as I believe some may have been broken from changes in the platform themes). But that's for another bug :P
Comment 8 Lars Vogel CLA 2020-11-18 08:32:10 EST
Mass change to 4.19 M1, please update the target if you have other plans.
Comment 9 Alexander Kurtakov CLA 2021-01-07 03:07:52 EST
Mass move 4.19 M1 bugs to M3
Comment 10 Niraj Modi CLA 2021-02-19 07:58:50 EST
Removing milestone from 4.19 M3 to 4.19, please re-target accordingly.
Comment 11 Kalyan Prasad Tatavarthi CLA 2021-03-02 02:07:42 EST
Mass move out of 4.19
Comment 12 Kalyan Prasad Tatavarthi CLA 2021-06-04 00:55:04 EDT
Mass Move out of 4.20