Skip to content

Instantly share code, notes, and snippets.

@yateam
Last active January 17, 2017 00:38
Show Gist options
  • Save yateam/b57ed93659516ba27201c90125ecb6aa to your computer and use it in GitHub Desktop.
Save yateam/b57ed93659516ba27201c90125ecb6aa to your computer and use it in GitHub Desktop.
div(
id(widget.getRenderId()),
classNames(getWidgetTypeCssClass(widget), getModeClass()),
div(
title(widget.getTooltip()),
className("gw-header--icon"),
event(getMode() == Mode.ACTION, Tag.Event.CLICK, "id:" + widget.getRenderId()),
!Strings.isNullOrEmpty(icon.getSource()) ?
img().src(icon.getSource()) :
text(widget.getLabel())),
div(!grouping().orElse(true), //Ability to ungroup means this is the grouped cell
title("Grouped column. Click to ungroup"),
classNames("gw-header--grouping-icon", "gw-column--grouped-icon"),
event(Tag.Event.CLICK,
"ListView.group", "groupAction:ungroup",
"renderId:" + widget.getRenderId(),
"actionEventType:" + ActionWidgetUpdateHandler.ACTION_EVENT_TYPE)
),
div(getMode() == Mode.ACTION && sortDirection != null,
title("Sort direction. Click to reverse sort"),
classNames("gw-header--sorting-icon", sortingIcons.get(sortDirection)),
event(Tag.Event.CLICK, "fireEvent", "id:" + widget.getRenderId())),
div(getMode() == Mode.ACTION, //TODO: Localization for labels,
id(widget.getRenderId() + "-menu"),
classNames("gw-header--menu-container", "gw-putSubMenusBelow"),
data("gw-hover-submenu"),
div(
id(widget.getRenderId() + "-dropDownButton"),
className("gw-header--menu-icon"))
div(
id(widget.getRenderId() + "-subMenu"),
className("gw-subMenu"),
div(
className("gw-menuItem"),
event(Tag.Event.CLICK, "fireEvent", "id:" + widget.getRenderId())
div(
classNames("gw-header--sorting-icon", sortingIcons.get(WidgetSortDirection.ASCENDING)),
className(sortDirection == WidgetSortDirection.ASCENDING, "gw-disabled")),
div(
className("gw-menuItem--label"),
text("Sort Ascending"))),
div(
className("gw-menuItem"),
event(Tag.Event.CLICK, "fireEvent", "id:" + widget.getRenderId()),
div(
classNames("gw-header--sorting-icon", sortingIcons.get(WidgetSortDirection.DESCENDING)),
className(sortDirection == WidgetSortDirection.DESCENDING, "gw-disabled")),
div(
className("gw-menuItem--label"),
text("Sort Descending"))),
div(grouping().isPresent(), () ->
Lists.newArrayList(
className("gw-menuItem"),
event(Tag.Event.CLICK,
"ListView.group",
grouping().get() ? "groupAction:group" : "groupAction:ungroup",
"renderId:" + widget.getRenderId(),
"actionEventType:" + ActionWidgetUpdateHandler.ACTION_EVENT_TYPE),
div(
classNames("gw-header--grouping-icon", grouping().get() ? "gw-column--groupable-icon" : "gw-column--grouped-icon")),
div(
className("gw-menuItem--label"),
text(grouping().get() ? "Group" : "Ungroup")))))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment