|
@ -12,6 +12,10 @@ import com.vaadin.flow.component.grid.Grid; |
|
|
import com.vaadin.flow.component.grid.GridVariant; |
|
|
import com.vaadin.flow.component.grid.GridVariant; |
|
|
import com.vaadin.flow.component.html.Div; |
|
|
import com.vaadin.flow.component.html.Div; |
|
|
import com.vaadin.flow.component.html.Label; |
|
|
import com.vaadin.flow.component.html.Label; |
|
|
|
|
|
import com.vaadin.flow.component.icon.Icon; |
|
|
|
|
|
import com.vaadin.flow.component.icon.VaadinIcon; |
|
|
|
|
|
import com.vaadin.flow.component.orderedlayout.FlexComponent; |
|
|
|
|
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
|
import java.util.NoSuchElementException; |
|
|
import java.util.NoSuchElementException; |
|
@ -59,10 +63,9 @@ public class TableCard extends Div implements ContentConfigurable { |
|
|
|
|
|
|
|
|
Label headerDiff = new Label("Diff"); |
|
|
Label headerDiff = new Label("Diff"); |
|
|
|
|
|
|
|
|
grid.addColumn(VaadinUtils.getBoldStringRenderer(PlayerForTable::getPlaceString)) |
|
|
|
|
|
|
|
|
grid.addComponentColumn(this::getPlaceColumnItem) |
|
|
.setHeader(headerPlace) |
|
|
.setHeader(headerPlace) |
|
|
.setTextAlign(ColumnTextAlign.CENTER) |
|
|
|
|
|
// .setClassNameGenerator(playerForTable -> "leftmost-column-cell") |
|
|
|
|
|
|
|
|
.setTextAlign(ColumnTextAlign.START) |
|
|
.setWidth("5em"); |
|
|
.setWidth("5em"); |
|
|
|
|
|
|
|
|
grid.addColumn(VaadinUtils.getPlayerRenderer(PlayerForTable::getPlayer)) |
|
|
grid.addColumn(VaadinUtils.getPlayerRenderer(PlayerForTable::getPlayer)) |
|
@ -105,13 +108,32 @@ public class TableCard extends Div implements ContentConfigurable { |
|
|
.setTextAlign(ColumnTextAlign.CENTER) |
|
|
.setTextAlign(ColumnTextAlign.CENTER) |
|
|
.setWidth("5em"); |
|
|
.setWidth("5em"); |
|
|
|
|
|
|
|
|
grid.setWidth("51em"); |
|
|
|
|
|
|
|
|
grid.setWidth("55em"); |
|
|
grid.setHeightByRows(true); |
|
|
grid.setHeightByRows(true); |
|
|
|
|
|
|
|
|
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, |
|
|
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, |
|
|
GridVariant.LUMO_NO_ROW_BORDERS, GridVariant.LUMO_ROW_STRIPES); |
|
|
GridVariant.LUMO_NO_ROW_BORDERS, GridVariant.LUMO_ROW_STRIPES); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Icon getPlaceDiffIcon(PlayerForTable playerForTable) { |
|
|
|
|
|
int placeDiff = playerForTable.getPlaceDiffToLastMatchday(); |
|
|
|
|
|
if (placeDiff < -1) return VaadinIcon.ANGLE_DOUBLE_DOWN.create(); |
|
|
|
|
|
if (placeDiff == -1) return VaadinIcon.ANGLE_DOWN.create(); |
|
|
|
|
|
if (placeDiff == 0) return VaadinIcon.MINUS.create(); |
|
|
|
|
|
if (placeDiff == 1) return VaadinIcon.ANGLE_UP.create(); |
|
|
|
|
|
return VaadinIcon.ANGLE_DOUBLE_UP.create(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private HorizontalLayout getPlaceColumnItem(PlayerForTable playerForTable) { |
|
|
|
|
|
Label label = new Label(playerForTable.getPlaceString()); |
|
|
|
|
|
Icon icon = getPlaceDiffIcon(playerForTable); |
|
|
|
|
|
icon.setSize("1em"); |
|
|
|
|
|
HorizontalLayout horizontalLayout = new HorizontalLayout(label, icon); |
|
|
|
|
|
horizontalLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.BETWEEN); |
|
|
|
|
|
horizontalLayout.setAlignItems(FlexComponent.Alignment.CENTER); |
|
|
|
|
|
return horizontalLayout; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private String getResultString(PlayerForTable player) { |
|
|
private String getResultString(PlayerForTable player) { |
|
|
return StringUtils.getResultString(":", player.getGamePointsForSelf(), player.getGamePointsForOpponents()); |
|
|
return StringUtils.getResultString(":", player.getGamePointsForSelf(), player.getGamePointsForOpponents()); |
|
|
} |
|
|
} |
|
|