-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into update-from-template-merged
- Loading branch information
Showing
31 changed files
with
521 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 1.1.0 | ||
* Do not depend on Vaadin's I18N / Allow custom path to text translation #1 | ||
* Updated dependencies | ||
|
||
# 1.0.0 | ||
_Initial release_ |
This file contains 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
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
vaadin-breadcrumbs-demo/src/main/java/software/xdev/vaadin/ui/HomeView.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package software.xdev.vaadin.ui; | ||
|
||
import com.vaadin.flow.component.UI; | ||
import com.vaadin.flow.component.button.Button; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.dom.Element; | ||
import com.vaadin.flow.router.Route; | ||
|
||
|
||
@Route("") | ||
public class HomeView extends VerticalLayout | ||
{ | ||
public HomeView() | ||
{ | ||
this.add(new Button("Toggle theme", ev -> { | ||
final Element uiElement = UI.getCurrent().getElement(); | ||
uiElement.setAttribute("theme", "dark".equals(uiElement.getAttribute("theme")) ? "" : "dark"); | ||
})); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
vaadin-breadcrumbs-demo/src/main/java/software/xdev/vaadin/ui/MainLayout.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package software.xdev.vaadin.ui; | ||
|
||
import java.util.Objects; | ||
|
||
import com.vaadin.flow.component.HasElement; | ||
import com.vaadin.flow.component.applayout.AppLayout; | ||
import com.vaadin.flow.component.applayout.DrawerToggle; | ||
import com.vaadin.flow.component.icon.VaadinIcon; | ||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.component.sidenav.SideNav; | ||
import com.vaadin.flow.component.sidenav.SideNavItem; | ||
import com.vaadin.flow.router.Layout; | ||
import com.vaadin.flow.router.PageTitle; | ||
|
||
import software.xdev.vaadin.breadcrumbs.Breadcrumbs; | ||
import software.xdev.vaadin.ui.cars.CarsView; | ||
import software.xdev.vaadin.ui.cars.brand.ElectricView; | ||
import software.xdev.vaadin.ui.cars.brand.GasolineView; | ||
import software.xdev.vaadin.ui.cars.brand.HybridView; | ||
|
||
|
||
@Layout | ||
@PageTitle("Breadcrumb Demo") | ||
public class MainLayout extends AppLayout | ||
{ | ||
private final Breadcrumbs breadcrumbs = new Breadcrumbs() | ||
.withHomeBreadcrumbName(this.getTranslation(TranslationKeys.HOME)) | ||
.withBreadcrumbNameResolver((full, part) -> this.getTranslation(part)); | ||
|
||
public MainLayout() | ||
{ | ||
final SideNav sideNav = new SideNav(); | ||
sideNav.addItem(new SideNavItem( | ||
this.getTranslation(TranslationKeys.HOME), | ||
"", | ||
VaadinIcon.HOME_O.create())); | ||
|
||
final SideNavItem carsItem = new SideNavItem( | ||
this.getTranslation(TranslationKeys.CARS), | ||
CarsView.class, | ||
VaadinIcon.CAR.create()); | ||
carsItem.addItem(new SideNavItem( | ||
this.getTranslation(TranslationKeys.GASOLINE), | ||
GasolineView.class, | ||
VaadinIcon.FIRE.create())); | ||
carsItem.addItem(new SideNavItem( | ||
this.getTranslation(TranslationKeys.HYBRID), | ||
HybridView.class, | ||
VaadinIcon.GLOBE.create())); | ||
carsItem.addItem(new SideNavItem( | ||
this.getTranslation(TranslationKeys.ELECTRIC), | ||
ElectricView.class, | ||
VaadinIcon.BOLT.create())); | ||
|
||
sideNav.addItem(Objects.requireNonNull(carsItem)); | ||
|
||
this.setPrimarySection(Section.DRAWER); | ||
|
||
final VerticalLayout navWrapper = new VerticalLayout(sideNav); | ||
sideNav.setWidthFull(); | ||
navWrapper.setSpacing(true); | ||
this.addToDrawer(navWrapper); | ||
|
||
final HorizontalLayout vlHeader = new HorizontalLayout(new DrawerToggle(), this.breadcrumbs); | ||
vlHeader.setSpacing(false); | ||
this.addToNavbar(vlHeader); | ||
} | ||
|
||
@Override | ||
public void showRouterLayoutContent(final HasElement content) | ||
{ | ||
super.showRouterLayoutContent(content); | ||
this.breadcrumbs.updateFromCurrentPath(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
vaadin-breadcrumbs-demo/src/main/java/software/xdev/vaadin/ui/TranslationKeys.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package software.xdev.vaadin.ui; | ||
|
||
public final class TranslationKeys | ||
{ | ||
public static final String HOME = "home"; | ||
|
||
public static final String CARS = "cars"; | ||
public static final String ELECTRIC = "electric"; | ||
public static final String HYBRID = "hybrid"; | ||
public static final String GASOLINE = "gasoline"; | ||
public static final String PLUTONIUM = "plutonium"; | ||
|
||
public static final String FUEL = "fuel"; | ||
public static final String MODEL = "model"; | ||
public static final String HP = "hp"; | ||
|
||
private TranslationKeys() | ||
{ | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
vaadin-breadcrumbs-demo/src/main/java/software/xdev/vaadin/ui/cars/AbstractCarView.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package software.xdev.vaadin.ui.cars; | ||
|
||
import static software.xdev.vaadin.ui.TranslationKeys.ELECTRIC; | ||
import static software.xdev.vaadin.ui.TranslationKeys.GASOLINE; | ||
import static software.xdev.vaadin.ui.TranslationKeys.HYBRID; | ||
import static software.xdev.vaadin.ui.TranslationKeys.PLUTONIUM; | ||
|
||
import java.util.List; | ||
|
||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
|
||
|
||
public abstract class AbstractCarView extends VerticalLayout | ||
{ | ||
protected AbstractCarView() | ||
{ | ||
final CarGrid carGrid = new CarGrid(this.getCars()); | ||
carGrid.setAllRowsVisible(true); | ||
this.add(carGrid); | ||
} | ||
|
||
protected abstract List<Car> getCars(); | ||
|
||
protected static List<Car> getCarsByFuel(final String fuel) | ||
{ | ||
return getAllCars().stream() | ||
.filter(c -> fuel.equals(c.fuelI18N())) | ||
.toList(); | ||
} | ||
|
||
@SuppressWarnings("checkstyle:MagicNumber") | ||
protected static List<Car> getAllCars() | ||
{ | ||
return List.of( | ||
new Car(GASOLINE, "Opel Astra K", 110), | ||
new Car(GASOLINE, "Skoda Octavia 4", 150), | ||
new Car(GASOLINE, "VW Golf 7 GTI", 220), | ||
new Car(GASOLINE, "Porsche GT3 RS", 525), | ||
new Car(HYBRID, "Mercedes A250", 160), | ||
new Car(HYBRID, "VW Golf 8 eTSI", 150), | ||
new Car(ELECTRIC, "Tesla Model 3", 460), | ||
new Car(ELECTRIC, "BMW i4", 540), | ||
new Car(PLUTONIUM, "DeLorean DMC-12", 1_620_000) | ||
); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
vaadin-breadcrumbs-demo/src/main/java/software/xdev/vaadin/ui/cars/Car.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package software.xdev.vaadin.ui.cars; | ||
|
||
public record Car(String fuelI18N, String model, int hp) | ||
{ | ||
} |
21 changes: 21 additions & 0 deletions
21
vaadin-breadcrumbs-demo/src/main/java/software/xdev/vaadin/ui/cars/CarGrid.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package software.xdev.vaadin.ui.cars; | ||
|
||
import java.util.List; | ||
|
||
import com.vaadin.flow.component.grid.Grid; | ||
|
||
import software.xdev.vaadin.ui.TranslationKeys; | ||
|
||
|
||
public class CarGrid extends Grid<Car> | ||
{ | ||
|
||
public CarGrid(final List<Car> cars) | ||
{ | ||
this.setItems(cars); | ||
this.addColumn(car -> this.getTranslation(car.fuelI18N())) | ||
.setHeader(this.getTranslation(TranslationKeys.FUEL)); | ||
this.addColumn(Car::model).setHeader(this.getTranslation(TranslationKeys.MODEL)); | ||
this.addColumn(Car::hp).setHeader(this.getTranslation(TranslationKeys.HP)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
vaadin-breadcrumbs-demo/src/main/java/software/xdev/vaadin/ui/cars/CarsView.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package software.xdev.vaadin.ui.cars; | ||
|
||
import java.util.List; | ||
|
||
import com.vaadin.flow.router.Route; | ||
|
||
|
||
@Route("cars") | ||
public class CarsView extends AbstractCarView | ||
{ | ||
@Override | ||
protected List<Car> getCars() | ||
{ | ||
return getAllCars(); | ||
} | ||
} |
Oops, something went wrong.