use of org.jboss.elemento.HtmlContentBuilder in project playshogi by Tellmarch.
the class KifuTable method getDetails.
private HTMLElement getDetails(final KifuDetails details) {
Row<Row_12> rowElement = Row.create();
rowElement.style().setMarginLeft("40px").setMarginRight("40px").setMarginTop("10px").setMarginBottom("10px");
rowElement.addColumn(Column.span4().appendChild(h(5).add("Description:")).appendChild(TextNode.of("Name: " + details.getName())).appendChild(br()));
HtmlContentBuilder<HTMLDivElement> previewDiv = Elements.div();
kifuService.getKifuUsf(null, details.getId(), new AsyncCallback<String>() {
@Override
public void onFailure(final Throwable throwable) {
}
@Override
public void onSuccess(final String usf) {
GamePreview gamePreview = new GamePreview(userPreferences, UsfFormat.INSTANCE.readSingle(usf), 0.5);
previewDiv.add(gamePreview.asElement());
}
});
rowElement.addColumn(Column.span4().appendChild(previewDiv));
rowElement.addColumn(Column.span4().appendChild(Button.createDanger(Icons.ALL.delete_forever()).setContent("Delete").addClickListener(evt -> confirmDeletion(details)).style().setMarginRight("20px")).appendChild(Button.createPrimary(Icons.ALL.playlist_add()).setContent("Add to collection").addClickListener(evt -> addKifuToCollection(details)).style().setMarginRight("20px")));
return rowElement.element();
}
use of org.jboss.elemento.HtmlContentBuilder in project playshogi by Tellmarch.
the class ProblemTable method getUpDownIcons.
private Node getUpDownIcons(final ProblemDetails record) {
HtmlContentBuilder<HTMLDivElement> difficulty = div();
difficulty.add(Button.createPrimary(Icons.ALL.transfer_up_mdi()).addClickListener(e -> eventBus.fireEvent(new MoveProblemUpEvent(record, collectionDetails))));
difficulty.add(Button.createPrimary(Icons.ALL.transfer_down_mdi()).addClickListener(e -> eventBus.fireEvent(new MoveProblemDownEvent(record, collectionDetails))));
return difficulty.element();
}
use of org.jboss.elemento.HtmlContentBuilder in project playshogi by Tellmarch.
the class LessonsView method showLessonSelection.
private void showLessonSelection() {
if (sessionInformation.isLoggedIn()) {
int total = 0;
int completed = 0;
for (TreeItem<LessonDetails> lesson : treeItems.values()) {
if (lesson.getValue().getKifuId() != null || lesson.getValue().getProblemCollectionId() != null) {
total++;
if (lesson.getValue().isCompleted()) {
completed++;
}
}
}
HtmlContentBuilder<HTMLUListElement> perDifficulty = Elements.ul();
for (int difficulty = 1; difficulty <= 5; difficulty++) {
int todo = 0;
TreeItem<LessonDetails> suggested = null;
for (TreeItem<LessonDetails> treeItem : treeItems.values()) {
LessonDetails lesson = treeItem.getValue();
if (lesson.getDifficulty() == difficulty && (lesson.getKifuId() != null || lesson.getProblemCollectionId() != null) && !lesson.isCompleted()) {
todo++;
if (suggested == null) {
suggested = treeItem;
}
}
}
if (todo > 0) {
HtmlContentBuilder<HTMLDivElement> div = Elements.div();
for (int i = 1; i <= 5; i++) {
if (i > difficulty) {
div.add(Icons.ALL.star_border());
} else {
div.add(Icons.ALL.star());
}
}
TreeItem<LessonDetails> finalSuggested = suggested;
perDifficulty.add(Elements.li().add(div).add((todo == 1 ? "There is 1 new lesson" : "There are " + todo + " new lessons") + " for the difficulty " + getDifficulty(difficulty) + "!").add(Elements.p()).add("Suggested next: ").add(Button.createPrimary(suggested.getTitle()).addClickListener(e -> selectLesson(finalSuggested))).add(Elements.p()));
}
}
previewCard.setTitle("Welcome back, " + sessionInformation.getUsername() + "!");
previewDescription.textContent("");
previewDescription.add(TextNode.of("In total, you have completed " + completed + " out of " + total + " " + "available lessons."));
previewDescription.add(Elements.p());
previewDescription.add(perDifficulty);
difficulty.textContent("");
previewTags.textContent("");
boardPreview.showPosition(ShogiInitialPositionFactory.READ_ONLY_INITIAL_POSITION);
boardPreview.setVisible(false);
openButton.hidden(true);
} else {
previewCard.setTitle("Select a Lesson on the left");
previewDescription.textContent("");
difficulty.textContent("");
previewTags.textContent("");
boardPreview.showPosition(ShogiInitialPositionFactory.READ_ONLY_INITIAL_POSITION);
boardPreview.setVisible(true);
openButton.hidden(true);
}
}
use of org.jboss.elemento.HtmlContentBuilder in project domino-ui-demo by DominoKit.
the class MdiIconsViewImpl method createDemoIcon.
private HtmlContentBuilder<HTMLDivElement> createDemoIcon(BaseIcon icon, String... moreClasses) {
HtmlContentBuilder<HTMLElement> element = span().css("icon-name").textContent(icon.getName());
if (moreClasses.length > 0) {
element.css(moreClasses);
}
HtmlContentBuilder<HTMLDivElement> iconContainer = div().css("demo-google-material-icon").add(icon).add(element);
String iconName = icon.getName();
iconContainer.element().addEventListener("click", evt -> {
String name = (iconName.replace("mdi-", "").replace("-", "_")) + (iconName.contains("mdi") ? "_mdi" : "");
copyInput.value = "Icons.ALL." + name + "()";
copyInput.select();
EventListener copyListener = e -> {
ClipboardEvent clipboardEvent = Js.uncheckedCast(e);
clipboardEvent.clipboardData.setData("text/plain", copyInput.value);
e.preventDefault();
};
DomGlobal.document.addEventListener("copy", copyListener);
DominoDom.document.execCommand("copy");
DomGlobal.document.removeEventListener("copy", copyListener);
Notification.createInfo("Copied to clipboard").show();
});
return iconContainer;
}
use of org.jboss.elemento.HtmlContentBuilder in project domino-ui-demo by DominoKit.
the class IconsViewImpl method createDemoIcon.
private HtmlContentBuilder<HTMLDivElement> createDemoIcon(BaseIcon icon, String... moreClasses) {
HtmlContentBuilder<HTMLElement> element = span().css("icon-name").textContent(icon.getName());
if (moreClasses.length > 0) {
element.css(moreClasses);
}
HtmlContentBuilder<HTMLDivElement> iconContainer = div().css("demo-google-material-icon").add(icon).add(element);
String iconName = icon.getName();
iconContainer.element().addEventListener("click", evt -> {
String name = (iconName.replace("mdi-", "").replace("-", "_")) + (iconName.contains("mdi") ? "_mdi" : "");
copyInput.value = "Icons.ALL." + name + "()";
copyInput.select();
EventListener copyListener = e -> {
ClipboardEvent clipboardEvent = Js.uncheckedCast(e);
clipboardEvent.clipboardData.setData("text/plain", copyInput.value);
e.preventDefault();
};
DomGlobal.document.addEventListener("copy", copyListener);
DominoDom.document.execCommand("copy");
DomGlobal.document.removeEventListener("copy", copyListener);
Notification.createInfo("Copied to clipboard").show();
});
return iconContainer;
}
Aggregations