Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320200 - [PropertiesView] LabelProvider#getText() is never called when element is null in PropertySheetEntry
Summary: [PropertiesView] LabelProvider#getText() is never called when element is null...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows Vista
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-18 15:42 EDT by Maksym Bykovskyy CLA
Modified: 2021-11-29 15:02 EST (History)
2 users (show)

See Also:


Attachments
Patch for property sheet entry (1.03 KB, patch)
2010-07-18 16:52 EDT, Maksym Bykovskyy CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maksym Bykovskyy CLA 2010-07-18 15:42:38 EDT
Build Identifier: 20100617-1415

This is not a bug but rather an implementation choice. I use the Properties view in my RCP and I have some properties with null values. For example when background color (RGB) is null it means its transparent. I want to be able to display text "Transparent" instead of having an empty cell.

I looked at PropertySheetEntry#getValueAsString() code and noticed that when value is null it explicitly returns an empty string instead of asking a client what they want to do with it.

I think it would much butter to let the user decide what they want their label to look like. "unknown", "n/a", "null", "---", "" etc. When getText() returns null then fair enought you can explicitely set an empty string.

Here the code from PropertySheetEntry:

	public String getValueAsString() {
		if (editValue == null) {
			return "";//$NON-NLS-1$
		}
		ILabelProvider provider = descriptor.getLabelProvider();
		if (provider == null) {
			return editValue.toString();
		}
		String text = provider.getText(editValue);
		if (text == null) {
			return "";//$NON-NLS-1$
		}
		return text;
	}

Reproducible: Always

Steps to Reproduce:
1. Create Properties view.
2. Set property source label provider.
3. Set the property value to null.
Comment 1 Maksym Bykovskyy CLA 2010-07-18 16:52:36 EDT
Created attachment 174587 [details]
Patch for property sheet entry

I'm attaching a patch to this issue. It simply gets the value from provider.getText() when provider is not null. Otherwise, it explicitly returns an empty string when editValue is null.
Comment 2 Eclipse Webmaster CLA 2019-09-06 16:13:56 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 3 Eclipse Genie CLA 2021-11-29 15:02:59 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.