use of com.almuradev.almura.shared.client.ui.component.WYSIWYGTextBox in project Almura by AlmuraDev.
the class GuidePageViewScreen method construct.
@Override
public void construct() {
guiscreenBackground = false;
Keyboard.enableRepeatEvents(true);
final BasicForm form = new BasicForm(this, 582, 315, TextFormatting.WHITE + I18n.format("almura.guide.view.form.title"));
// Page list
this.pagesList = new BasicList<>(this, 156, BasicScreen.getPaddedHeight(form));
this.pagesList.setBorder(0xFFFFFF, 1, 215);
this.pagesList.setPadding(2, 2);
this.pagesList.setPosition(1, 0);
this.pagesList.setItemComponentSpacing(1);
this.pagesList.setItemComponentFactory(PageListEntryItemComponent::new);
this.pagesList.setItems(manager.getPageEntries());
this.pagesList.setSelectConsumer(i -> {
if (i == null) {
this.tbContent.getTextBox().setText("");
} else {
if (manager.getPage() != null && !manager.getPage().getId().equalsIgnoreCase(i.getId())) {
this.clearCursorSnapshot();
this.restoreCursorSnapshot();
}
manager.requestPage(i.getId());
}
});
if (this.canModify) {
this.pagesList.setHeight(this.pagesList.getHeight() - 17);
this.buttonAdd = new UIButtonBuilder(this).text(TextFormatting.GREEN + "+").onClick(() -> this.runScheduledTask("add")).anchor(Anchor.BOTTOM | Anchor.LEFT).position(0, 0).visible(this.canAdd).tooltip(I18n.format("almura.guide.view.button.add.tooltip")).build("button.add");
this.buttonRemove = new UIButtonBuilder(this).text(TextFormatting.RED + "-").onClick(() -> this.runScheduledTask("remove")).anchor(Anchor.BOTTOM | Anchor.LEFT).position(BasicScreen.getPaddedX(this.buttonAdd, 2), 0).visible(this.canRemove).tooltip(I18n.format("almura.guide.view.button.remove.tooltip")).build("button.remove");
this.buttonDetails = new UIButtonBuilder(this).text(TextFormatting.YELLOW + "?").onClick(() -> this.runScheduledTask("details")).anchor(Anchor.BOTTOM | Anchor.LEFT).position(BasicScreen.getPaddedX(this.buttonRemove, 2), 0).visible(this.canModify).tooltip(I18n.format("almura.guide.view.button.details.tooltip")).build("button.details");
}
this.tbContent = new WYSIWYGTextBox(this, BasicScreen.getPaddedHeight(form), "");
this.tbContent.setPosition(BasicScreen.getPaddedX(this.pagesList, 2), 0);
this.tbContent.getTextBox().setEditable(this.canModify);
this.tbContent.getTextBox().setOptions(0x555555, 0xc8c8c8, 0x00000);
if (!this.canModify) {
this.tbContent.hideToolbar();
}
final UIButton buttonClose = new UIButtonBuilder(this).width(50).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(I18n.format("almura.button.close")).onClick(this::close).build("button.close");
form.add(this.pagesList, this.tbContent, this.buttonAdd, buttonRemove, buttonDetails, buttonClose);
this.tbContent.setHeight(BasicScreen.getPaddedHeight(form) - 17);
if (this.canModify) {
this.buttonSave = new UIButtonBuilder(this).width(50).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(BasicScreen.getPaddedX(buttonClose, 2, Anchor.RIGHT), 0).text(I18n.format("almura.button.save")).onClick(() -> {
if (manager.getPage() != null) {
if (!manager.preSnapshot.equalsIgnoreCase(this.tbContent.getTextBox().getText())) {
manager.getPage().setContent(this.tbContent.getTextBox().getText());
manager.requestSavePage();
}
}
}).build("button.save");
form.add(buttonSave);
}
this.addToScreen(form);
}
Aggregations