-
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.
- Loading branch information
1 parent
1ba1777
commit 74f9397
Showing
18 changed files
with
232 additions
and
561 deletions.
There are no files selected for viewing
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
|
||
import { AppComponent } from './app.component'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; | ||
import { AppComponent } from './app.component'; | ||
import { BoardGameListComponent } from './boardgame/boardgame-list/boardgame-list.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
AppComponent | ||
], | ||
imports: [ | ||
BrowserModule | ||
], | ||
providers: [ | ||
provideAnimationsAsync() | ||
], | ||
bootstrap: [AppComponent] | ||
declarations: [AppComponent, BoardGameListComponent], | ||
imports: [BrowserModule, HttpClientModule], | ||
providers: [provideAnimationsAsync()], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule { } | ||
export class AppModule {} |
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
93 changes: 36 additions & 57 deletions
93
application/javafx/src/main/java/fr/sciam/backtofront/FxApplication.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
29 changes: 29 additions & 0 deletions
29
application/javafx/src/main/java/fr/sciam/backtofront/component/BoardGameCategoriesCell.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,29 @@ | ||
package fr.sciam.backtofront.component; | ||
|
||
import fr.sciam.backtofront.domain.Category; | ||
import fr.sciam.backtofront.viewmodel.BoardGameViewData; | ||
import javafx.collections.ObservableList; | ||
import javafx.scene.control.TableCell; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
public class BoardGameCategoriesCell extends TableCell<BoardGameViewData, ObservableList<Category>> { | ||
|
||
private BoardGameCategoriesCell() { | ||
// Instantiated by factory | ||
} | ||
|
||
public static TableCell<BoardGameViewData, ObservableList<Category>> newBoardGameImageCell() { | ||
return new BoardGameCategoriesCell(); | ||
} | ||
|
||
@Override | ||
protected void updateItem(final ObservableList<Category> categories, final boolean empty) { | ||
super.updateItem(categories, empty); | ||
if (empty || categories == null || categories.isEmpty()) { | ||
this.setText(null); | ||
} else { | ||
this.setText(categories.stream().map(Category::name).collect(Collectors.joining(", "))); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
application/javafx/src/main/java/fr/sciam/backtofront/component/BoardGameImageCell.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,35 @@ | ||
package fr.sciam.backtofront.component; | ||
|
||
import fr.sciam.backtofront.ImageResourceUtils; | ||
import fr.sciam.backtofront.viewmodel.BoardGameViewData; | ||
import javafx.scene.control.TableCell; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
|
||
import java.net.URL; | ||
|
||
public class BoardGameImageCell extends TableCell<BoardGameViewData, Number> { | ||
private final ImageView imageView; | ||
|
||
private BoardGameImageCell() { | ||
this.imageView = new ImageView(); | ||
this.imageView.setPreserveRatio(true); | ||
} | ||
|
||
public static TableCell<BoardGameViewData, Number> newBoardGameImageCell() { | ||
return new BoardGameImageCell(); | ||
} | ||
|
||
@Override | ||
protected void updateItem(final Number id, final boolean empty) { | ||
super.updateItem(id, empty); | ||
if (empty || id == null) { | ||
this.setGraphic(null); | ||
} else { | ||
URL resource = ImageResourceUtils.getImageResource(String.valueOf(id)); | ||
Image image = new Image(resource.toExternalForm(), true); | ||
this.imageView.setImage(image); | ||
this.setGraphic(this.imageView); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
application/javafx/src/main/java/fr/sciam/backtofront/mapper/BoardGameMapper.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,25 @@ | ||
package fr.sciam.backtofront.mapper; | ||
|
||
import fr.sciam.backtofront.persistence.entities.BoardGameEntity; | ||
import fr.sciam.backtofront.viewmodel.BoardGameViewData; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
public class BoardGameMapper implements ViewModelMapper<BoardGameEntity, BoardGameViewData> { | ||
|
||
@Override | ||
public BoardGameViewData newViewModelInstance() { | ||
return new BoardGameViewData(); | ||
} | ||
|
||
@Override | ||
public void update( | ||
final BoardGameEntity domainObject, | ||
final BoardGameViewData viewModelObject) { | ||
|
||
viewModelObject.getId().set(domainObject.id); | ||
viewModelObject.getName().set(domainObject.name); | ||
viewModelObject.getReleaseYear().set(domainObject.releaseYear); | ||
viewModelObject.getCategories().setAll(domainObject.categories); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
application/javafx/src/main/java/fr/sciam/backtofront/mapper/ViewModelMapper.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,33 @@ | ||
package fr.sciam.backtofront.mapper; | ||
|
||
/** | ||
* Mapper used to map a domain object to a JavaFX view model object | ||
* @param <D> domain object | ||
* @param <V> view model object | ||
*/ | ||
public interface ViewModelMapper<D, V> { | ||
|
||
/** | ||
* Create the view model object from a domain object | ||
* @param domainObject the domain object | ||
* @return created view model object | ||
*/ | ||
default V create(final D domainObject) { | ||
V viewModelObject = this.newViewModelInstance(); | ||
this.update(domainObject, viewModelObject); | ||
return viewModelObject; | ||
} | ||
|
||
/** | ||
* Factory to create a new view model object instance | ||
* @return newly created view model object instance | ||
*/ | ||
V newViewModelInstance(); | ||
|
||
/** | ||
* Update a view model object with a domain object | ||
* @param domainObject the domain object | ||
* @param viewModelObject the view model object to be updated | ||
*/ | ||
void update(D domainObject, V viewModelObject); | ||
} |
22 changes: 22 additions & 0 deletions
22
application/javafx/src/main/java/fr/sciam/backtofront/viewmodel/BoardGameViewData.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,22 @@ | ||
package fr.sciam.backtofront.viewmodel; | ||
|
||
import fr.sciam.backtofront.domain.Category; | ||
import javafx.beans.property.IntegerProperty; | ||
import javafx.beans.property.LongProperty; | ||
import javafx.beans.property.SimpleIntegerProperty; | ||
import javafx.beans.property.SimpleLongProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class BoardGameViewData { | ||
|
||
private final LongProperty id = new SimpleLongProperty(); | ||
private final StringProperty name = new SimpleStringProperty(); | ||
private final IntegerProperty releaseYear = new SimpleIntegerProperty(); | ||
private final ObservableList<Category> categories = FXCollections.observableArrayList(); | ||
|
||
} |
Oops, something went wrong.