This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class ThemeBoostrapListener implements | |
VaadinServiceInitListener, IndexHtmlRequestListener { | |
@Override | |
public void serviceInit(ServiceInitEvent event) { | |
event.addIndexHtmlRequestListener(this); | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum ThemeVariant { | |
STANDARD("Standard"), CARROT_INC("Carrot Inc"), CLEAN("Clean"); | |
private final String caption; | |
Theme(String caption) { | |
this.caption = caption; | |
} | |
public String getCaption() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThemeUtil { | |
private static final String THEME_ATTRIBUTE = "theme"; | |
public static void selectThemeVariant(ThemeVariant themeVariant) { | |
VaadinSession.getCurrent().setAttribute(THEME_ATTRIBUTE, themeVariant); | |
UI ui = UI.getCurrent(); | |
ui.getElement().setAttribute(THEME_ATTRIBUTE, themeVariant.getAttribute()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.vaadin.erik; | |
import com.vaadin.flow.component.AbstractField; | |
import com.vaadin.flow.component.HasValue; | |
import com.vaadin.flow.component.grid.Grid; | |
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; | |
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | |
import com.vaadin.flow.component.treegrid.TreeGrid; | |
import com.vaadin.flow.data.provider.hierarchy.TreeData; | |
import com.vaadin.flow.data.provider.hierarchy.TreeDataProvider; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<custom-style><style include="lumo-color"></style></custom-style> | |
<custom-style><style include="lumo-typography"></style></custom-style> | |
... | |
<body theme="dark"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private removeButtonRenderer: Function = this.renderRemoveButton.bind(this); | |
... | |
<vaadin-grid-column text-align="end" .renderer=${this.removeButtonRenderer}></vaadin-grid-column> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private renderRemoveButton(root: any, _column: any, rowData: any) { | |
render( | |
html`<vaadin-button @click=${() => this.onRemoveFromList(rowData.item.symbol)}>Remove</vaadin-button>`, | |
root | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private onRemoveFromList(symbol: string) { | |
StockService.removeStock({ symbol }).then(_ => this.updateGrid()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<vaadin-button theme="primary" @click=${this.onAddToList}>Add stock</vaadin-button> | |
... | |
private onAddToList() { | |
let symbol = this.stockSearchBox.selectedItem?.symbol; | |
if (symbol) { | |
StockService.addStock({ symbol }).then(_ => this.updateGrid()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<vaadin-horizontal-layout theme="spacing" style="align-items: baseline"> | |
<vaadin-combo-box | |
@filter-changed=${this.onStockSearchStringChanged} | |
.renderer=${this.renderSearchBoxItems} | |
id="stock-search" | |
label="Search for a stock symbol" | |
item-label-path="symbol"> | |
</vaadin-combo-box> | |
<vaadin-button theme="primary">Add stock</vaadin-button> | |
</vaadin-horizontal-layout> |