-
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.
Browse files
Browse the repository at this point in the history
#56 Kategorien: Verwaltungsansichten in MDV überführen
- Loading branch information
Showing
27 changed files
with
407 additions
and
419 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
15 changes: 15 additions & 0 deletions
15
bb.domain/src/main/java/timkodiert/budgetBook/domain/adapter/CategoryAdapter.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,15 @@ | ||
package timkodiert.budgetBook.domain.adapter; | ||
|
||
import lombok.Getter; | ||
|
||
import timkodiert.budgetBook.domain.model.Category; | ||
|
||
public class CategoryAdapter implements Adapter<Category> { | ||
|
||
@Getter | ||
private final Category bean; | ||
|
||
public CategoryAdapter(Category bean) { | ||
this.bean = bean; | ||
} | ||
} |
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
77 changes: 77 additions & 0 deletions
77
...-infrastructure/src/main/java/timkodiert/budgetBook/view/mdv_base/BaseListManageView.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,77 @@ | ||
package timkodiert.budgetBook.view.mdv_base; | ||
|
||
import java.net.URL; | ||
import java.util.Optional; | ||
import java.util.ResourceBundle; | ||
import java.util.function.Supplier; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.control.Alert; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.control.TableRow; | ||
import javafx.scene.control.TableView; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import timkodiert.budgetBook.dialog.DialogFactory; | ||
import timkodiert.budgetBook.domain.adapter.Adaptable; | ||
import timkodiert.budgetBook.domain.adapter.Adapter; | ||
import timkodiert.budgetBook.domain.model.BaseEntity; | ||
import timkodiert.budgetBook.domain.repository.Repository; | ||
import timkodiert.budgetBook.i18n.LanguageManager; | ||
|
||
public abstract class BaseListManageView<T extends BaseEntity & Adaptable<A>, A extends Adapter<T>> extends BaseManageView<T, A> { | ||
|
||
@FXML | ||
protected TableView<A> entityTable; | ||
|
||
protected final Repository<T> repository; | ||
private final DialogFactory dialogFactory; | ||
|
||
public BaseListManageView(Supplier<T> emptyEntityProducer, | ||
Repository<T> repository, | ||
FXMLLoader fxmlLoader, | ||
DialogFactory dialogFactory, | ||
LanguageManager languageManager) { | ||
super(fxmlLoader, languageManager, repository, emptyEntityProducer); | ||
this.repository = repository; | ||
this.dialogFactory = dialogFactory; | ||
} | ||
|
||
@Override | ||
public void initialize(URL location, ResourceBundle resources) { | ||
super.initialize(location, resources); | ||
|
||
entityTable.setRowFactory(tableView -> { | ||
TableRow<A> row = new TableRow<>(); | ||
row.setOnMouseClicked(event -> { | ||
if (event.getClickCount() == 1 && !row.isEmpty()) { | ||
if (detailView.isDirty()) { | ||
Alert alert = dialogFactory.buildConfirmationDialog(); | ||
Optional<ButtonType> result = alert.showAndWait(); | ||
if (result.get().equals(DialogFactory.CANCEL)) { | ||
entityTable.getSelectionModel().select(detailView.getEntity().get().getAdapter()); | ||
return; | ||
} | ||
if (result.get().equals(DialogFactory.SAVE_CHANGES) && !detailView.save()) { | ||
entityTable.getSelectionModel().select(detailView.getEntity().get().getAdapter()); | ||
return; | ||
} | ||
} | ||
|
||
detailView.setEntity(row.getItem().getBean()); | ||
} | ||
}); | ||
return row; | ||
}); | ||
|
||
initControls(); | ||
} | ||
|
||
@Override | ||
protected void reloadTable(@Nullable T updatedEntity) { | ||
entityTable.getItems().setAll(repository.findAll().stream().map(T::getAdapter).toList()); | ||
entityTable.sort(); | ||
} | ||
|
||
} |
Oops, something went wrong.