Skip to content

Instantly share code, notes, and snippets.

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