Search in sources :

Example 1 with KifuEditorPlace

use of com.playshogi.website.gwt.client.place.KifuEditorPlace in project playshogi by Tellmarch.

the class KifuTable method getTableConfig.

private TableConfig<KifuDetails> getTableConfig(final AppPlaceHistoryMapper historyMapper) {
    TableConfig<KifuDetails> tableConfig = new TableConfig<>();
    tableConfig.addColumn(ColumnConfig.<KifuDetails>create("id", "#").styleCell(element -> element.style.setProperty("vertical-align", "top")).textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getTableRow().getIndex() + 1 + PAGE_SIZE * (paginationPlugin.getPagination().activePage() - 1))))).addColumn(ColumnConfig.<KifuDetails>create("name", "Name").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getName())).setSortable(true)).addColumn(ColumnConfig.<KifuDetails>create("type", "Type").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getRecord().getType()))).setSortable(true)).addColumn(ColumnConfig.<KifuDetails>create("lastModified", "Last Modified").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getRecord().getUpdateDate()))).setSortable(true)).addColumn(ColumnConfig.<KifuDetails>create("view", "View").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
        String href = cell.getRecord().getType() != KifuDetails.KifuType.PROBLEM ? "#" + historyMapper.getToken(new ViewKifuPlace(cell.getRecord().getId(), 0)) : "#" + historyMapper.getToken(new ProblemPlace(cell.getRecord().getId()));
        return Elements.a(href).add(Button.createPrimary("View")).element();
    })).addColumn(ColumnConfig.<KifuDetails>create("edit", "Edit").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
        String href = "#" + historyMapper.getToken(new KifuEditorPlace(cell.getRecord().getId(), cell.getRecord().getType(), null));
        return Elements.a(href).add(Button.createPrimary(Icons.ALL.edit()).setContent("Edit")).element();
    }));
    return tableConfig;
}
Also used : RequestKifuDeletionEvent(com.playshogi.website.gwt.client.events.kifu.RequestKifuDeletionEvent) ElementWidget(com.playshogi.website.gwt.client.util.ElementWidget) ListKifusEvent(com.playshogi.website.gwt.client.events.collections.ListKifusEvent) Arrays(java.util.Arrays) UsfFormat(com.playshogi.library.shogi.models.formats.usf.UsfFormat) GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails) Elements(org.jboss.elemento.Elements) ViewKifuPlace(com.playshogi.website.gwt.client.place.ViewKifuPlace) KifuService(com.playshogi.website.gwt.shared.services.KifuService) com.google.gwt.user.client.ui(com.google.gwt.user.client.ui) AppPlaceHistoryMapper(com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper) EventBinder(com.google.web.bindery.event.shared.binder.EventBinder) HTMLElement(elemental2.dom.HTMLElement) TextHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.TextHeaderFilter) Row(org.dominokit.domino.ui.grid.Row) UserPreferences(com.playshogi.website.gwt.client.UserPreferences) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) List(java.util.List) Row_12(org.dominokit.domino.ui.grid.Row_12) KifuEditorPlace(com.playshogi.website.gwt.client.place.KifuEditorPlace) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) Button(org.dominokit.domino.ui.button.Button) Icons(org.dominokit.domino.ui.icons.Icons) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) RecordsSorter(org.dominokit.domino.ui.datatable.store.RecordsSorter) ASC(org.dominokit.domino.ui.datatable.plugins.SortDirection.ASC) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) Column(org.dominokit.domino.ui.grid.Column) Elements.h(org.jboss.elemento.Elements.h) GWT(com.google.gwt.core.client.GWT) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) DataTable(org.dominokit.domino.ui.datatable.DataTable) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) SelectHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.SelectHeaderFilter) ProblemPlace(com.playshogi.website.gwt.client.place.ProblemPlace) Window(com.google.gwt.user.client.Window) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler) KifuServiceAsync(com.playshogi.website.gwt.shared.services.KifuServiceAsync) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextNode(org.dominokit.domino.ui.utils.TextNode) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) org.dominokit.domino.ui.datatable.plugins(org.dominokit.domino.ui.datatable.plugins) Elements.br(org.jboss.elemento.Elements.br) EventBus(com.google.web.bindery.event.shared.EventBus) ListProblemCollectionsEvent(com.playshogi.website.gwt.client.events.collections.ListProblemCollectionsEvent) KifuDetails(com.playshogi.website.gwt.shared.models.KifuDetails) GamePreview(com.playshogi.website.gwt.client.widget.board.GamePreview) ListGameCollectionsEvent(com.playshogi.website.gwt.client.events.collections.ListGameCollectionsEvent) HTMLDivElement(elemental2.dom.HTMLDivElement) RequestAddKifuToCollectionEvent(com.playshogi.website.gwt.client.events.collections.RequestAddKifuToCollectionEvent) Comparator(java.util.Comparator) KifuEditorPlace(com.playshogi.website.gwt.client.place.KifuEditorPlace) ViewKifuPlace(com.playshogi.website.gwt.client.place.ViewKifuPlace) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) KifuDetails(com.playshogi.website.gwt.shared.models.KifuDetails) ProblemPlace(com.playshogi.website.gwt.client.place.ProblemPlace)

Example 2 with KifuEditorPlace

use of com.playshogi.website.gwt.client.place.KifuEditorPlace in project playshogi by Tellmarch.

the class ProblemTable method getTableConfig.

private TableConfig<ProblemDetails> getTableConfig(final AppPlaceHistoryMapper historyMapper) {
    TableConfig<ProblemDetails> tableConfig = new TableConfig<>();
    tableConfig.addColumn(ColumnConfig.<ProblemDetails>create("id", "#").styleCell(element -> element.style.setProperty("vertical-align", "top")).textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getRecord().getIndexInCollection())))).addColumn(ColumnConfig.<ProblemDetails>create("updown", "Order").setCellRenderer(cell -> getUpDownIcons(cell.getRecord()))).addColumn(ColumnConfig.<ProblemDetails>create("nummoves", "Number of Moves").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getRecord().getNumMoves())))).addColumn(ColumnConfig.<ProblemDetails>create("tags", "Tags").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
        HtmlContentBuilder<HTMLElement> span = Elements.span();
        String[] tags = cell.getRecord().getTags();
        if (tags != null) {
            for (String tag : tags) {
                span.add(Badge.create(tag).setBackground(ColorScheme.GREEN.color()).style().setMarginRight("1em").element());
            }
        }
        return span.element();
    })).addColumn(ColumnConfig.<ProblemDetails>create("view", "View").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
        String href = "#" + historyMapper.getToken(new ProblemPlace(cell.getRecord().getKifuId()));
        return Elements.a(href).add(Button.createPrimary(Icons.ALL.play_circle_filled()).setContent("Show")).element();
    })).addColumn(ColumnConfig.<ProblemDetails>create("edit", "Edit").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
        String href = "#" + historyMapper.getToken(new KifuEditorPlace(cell.getRecord().getKifuId(), KifuDetails.KifuType.PROBLEM, collectionDetails.getId()));
        return Elements.a(href).add(Button.createPrimary(Icons.ALL.edit()).setContent("Edit")).element();
    }));
    return tableConfig;
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) ElementWidget(com.playshogi.website.gwt.client.util.ElementWidget) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) UsfFormat(com.playshogi.library.shogi.models.formats.usf.UsfFormat) Badge(org.dominokit.domino.ui.badges.Badge) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) Elements(org.jboss.elemento.Elements) Column(org.dominokit.domino.ui.grid.Column) KifuService(com.playshogi.website.gwt.shared.services.KifuService) GWT(com.google.gwt.core.client.GWT) MoveProblemUpEvent(com.playshogi.website.gwt.client.events.collections.MoveProblemUpEvent) AppPlaceHistoryMapper(com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper) DataTable(org.dominokit.domino.ui.datatable.DataTable) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) HTMLElement(elemental2.dom.HTMLElement) ProblemPlace(com.playshogi.website.gwt.client.place.ProblemPlace) Row(org.dominokit.domino.ui.grid.Row) Window(com.google.gwt.user.client.Window) KifuServiceAsync(com.playshogi.website.gwt.shared.services.KifuServiceAsync) SimplePaginationPlugin(org.dominokit.domino.ui.datatable.plugins.SimplePaginationPlugin) TextNode(org.dominokit.domino.ui.utils.TextNode) UserPreferences(com.playshogi.website.gwt.client.UserPreferences) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) ColorScheme(org.dominokit.domino.ui.style.ColorScheme) EventBus(com.google.web.bindery.event.shared.EventBus) BoardPreview(com.playshogi.website.gwt.client.widget.board.BoardPreview) KifuDetails(com.playshogi.website.gwt.shared.models.KifuDetails) RecordDetailsPlugin(org.dominokit.domino.ui.datatable.plugins.RecordDetailsPlugin) Widget(com.google.gwt.user.client.ui.Widget) List(java.util.List) HTMLDivElement(elemental2.dom.HTMLDivElement) Node(elemental2.dom.Node) Row_12(org.dominokit.domino.ui.grid.Row_12) ProblemDetails(com.playshogi.website.gwt.shared.models.ProblemDetails) KifuEditorPlace(com.playshogi.website.gwt.client.place.KifuEditorPlace) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) RemoveProblemFromCollectionEvent(com.playshogi.website.gwt.client.events.collections.RemoveProblemFromCollectionEvent) MoveProblemDownEvent(com.playshogi.website.gwt.client.events.collections.MoveProblemDownEvent) Button(org.dominokit.domino.ui.button.Button) KifuEditorPlace(com.playshogi.website.gwt.client.place.KifuEditorPlace) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) ProblemDetails(com.playshogi.website.gwt.shared.models.ProblemDetails) ProblemPlace(com.playshogi.website.gwt.client.place.ProblemPlace)

Aggregations

GWT (com.google.gwt.core.client.GWT)2 Window (com.google.gwt.user.client.Window)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 EventBus (com.google.web.bindery.event.shared.EventBus)2 UsfFormat (com.playshogi.library.shogi.models.formats.usf.UsfFormat)2 UserPreferences (com.playshogi.website.gwt.client.UserPreferences)2 AppPlaceHistoryMapper (com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper)2 KifuEditorPlace (com.playshogi.website.gwt.client.place.KifuEditorPlace)2 ProblemPlace (com.playshogi.website.gwt.client.place.ProblemPlace)2 ElementWidget (com.playshogi.website.gwt.client.util.ElementWidget)2 KifuDetails (com.playshogi.website.gwt.shared.models.KifuDetails)2 ProblemCollectionDetails (com.playshogi.website.gwt.shared.models.ProblemCollectionDetails)2 KifuService (com.playshogi.website.gwt.shared.services.KifuService)2 KifuServiceAsync (com.playshogi.website.gwt.shared.services.KifuServiceAsync)2 HTMLDivElement (elemental2.dom.HTMLDivElement)2 HTMLElement (elemental2.dom.HTMLElement)2 List (java.util.List)2 Button (org.dominokit.domino.ui.button.Button)2 ColumnConfig (org.dominokit.domino.ui.datatable.ColumnConfig)2 DataTable (org.dominokit.domino.ui.datatable.DataTable)2