-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sitemap] Provide information about widget label source to clients #3804
[sitemap] Provide information about widget label source to clients #3804
Conversation
Open question: How can I actually test this in a development environment, IOW, how can I run the locally built core classes? There's documentation on how to run locally built bindings, but I haven't found the same (or generally, any kind of development documentation) for -core. Did I miss something? |
public static WidgetLabelSource forWidget(Widget w, String label) { | ||
if (label == null || label.isEmpty()) { | ||
return None; | ||
} else if (w.getLabel() != null) { | ||
return SitemapDefinition; | ||
} else { | ||
return ItemLabel; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case the label is set to "[%s]" for example, either on sitemap element or on item, your method will return SitemapDefinition or ItemLabel, but not None. Is it really what you expect ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. After all, there is a label to work with, even if it almost only consists of the item state. I introduced NONE
only because if there's no label at all, neither ITEM
nor SITEMAP
do really fit.
SitemapDefinition, | ||
ItemLabel, | ||
None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention is rather to use uppercase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
You probably forgot one origin: the linked channel. |
d8ce4c5
to
b20d2f8
Compare
As far as I can tell from the code there's only the widget, the item label and the item name which the label can be taken from. I've forgotten the latter, so I completely revamped the approach to also cover that one. |
bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/items/ItemUIRegistry.java
Outdated
Show resolved
Hide resolved
The label can be populated from a label specified on the respective sitemap widget, or (if no label was specified) from the label of the backing item. Allow clients to differentiate between both cases. Related to openhab/openhab-webui#2065 Signed-off-by: Danny Baumann <dannybaumann@web.de>
d93cebb
to
b3c7734
Compare
The force-push to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me. Just one comment to be added to clearly explain what means NONE source. Because NONE covers two different things in your implementation.
...org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Danny Baumann <dannybaumann@web.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Signed-off-by: Danny Baumann <dannybaumann@web.de>
Last commit just added some documentation for the enum values. |
@openhab/core-maintainers : is it possible to review and merge this PR ? I have already done a full pre-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
The label can be populated from a label specified on the respective sitemap widget, or (if no label was specified) from the label of the backing item. Allow clients to differentiate between both cases. This allows clients (BasicUI, mobile apps) to e.g. show the label for charts if they were specified on the sitemap widget and to hide it when it just was populated from the item label.
Related to openhab/openhab-webui#2065