Projektin moduulirakenteen formatointi

Signed-off-by: laurimaaninka <lauri.maaninka@gmail.com>
This commit is contained in:
2026-04-12 20:25:49 +03:00
parent 8cf1d03e5c
commit e83bdee4d0
33 changed files with 82 additions and 92 deletions
@@ -1,69 +0,0 @@
package fi.lpam.gui.elementit;
import com.dlsc.gemsfx.MultiColumnListView;
import fi.lpam.dataluokat.Asiakas;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
public class AsiakasListCell extends MultiColumnListView.ColumnListCell<Asiakas> {
private final StackPane wrapper;
public AsiakasListCell(MultiColumnListView multiColumnListView) {
//noinspection unchecked
super(multiColumnListView);
this.setHeight(150);
this.setPrefHeight(50);
VBox content = new VBox();
content.visibleProperty().bind(placeholder.not().and(emptyProperty().not()));
content.managedProperty().bind(placeholder.not().and(emptyProperty().not()));
VBox contentPlaceholder = new VBox();
contentPlaceholder.visibleProperty().bind(placeholder);
contentPlaceholder.managedProperty().bind(placeholder);
Label label = new Label();
label.textProperty().bind(textProperty());
wrapper = new StackPane(content, contentPlaceholder, label);
setGraphic(wrapper);
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
@Override
protected Node getSnapshotNode() {
return wrapper;
}
private final BooleanProperty placeholder = new SimpleBooleanProperty(this, "placeholder", false);
@Override
protected void updateItem(Asiakas asiakas, boolean empty) {
super.updateItem(asiakas, empty);
placeholder.set(false);
if (asiakas != null && !empty) {
if (asiakas == getMultiColumnListView().getPlaceholderFrom()) {
placeholder.set(true);
setText("");
} else if (asiakas == getMultiColumnListView().getPlaceholderTo()) {
placeholder.set(true);
setText("");
} else {
setText(asiakas.getNimi() + ": " + asiakas.getOsoite());
}
} else {
setText("");
}
}
}
@@ -1,24 +0,0 @@
package fi.lpam.gui.elementit;
import javafx.scene.control.Spinner;
import javafx.scene.control.SpinnerValueFactory;
public class IntegerSpinner extends Spinner<Integer> {
/**
* Min 0, Max 50
*/
public IntegerSpinner() {
super(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 50));
this.setEditable(true);
}
/**
*
* @param min _
* @param max _
*/
public IntegerSpinner(int min, int max) {
super(new SpinnerValueFactory.IntegerSpinnerValueFactory(min, max));
this.setEditable(true);
}
}
@@ -1,45 +0,0 @@
package fi.lpam.gui.elementit;
import fi.lpam.dataluokat.Asiakas;
import fi.lpam.dataluokat.Kuljetus;
import fi.lpam.gui.KuljetusListat;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.TableCell;
import javafx.scene.layout.StackPane;
import java.util.HashMap;
public class KuljetaTableCell extends TableCell<Kuljetus, Boolean> {
private final StackPane paddedNappi = new StackPane();
public KuljetaTableCell(HashMap<Integer, Asiakas> asiakkaat) {
paddedNappi.setPadding(new Insets(3));
Button nappi = new Button("Muuta");
paddedNappi.getChildren().add(nappi);
nappi.setOnMouseClicked(_ -> {
getTableView().getSelectionModel().select(getIndex());
Kuljetus kuljetus = getTableRow().getItem();
if (kuljetus == null) return;
if (kuljetus.kuljetetaan()) {
kuljetus.nollaa();
} else {
kuljetus.palautaMäärät(asiakkaat.get(kuljetus.getAsiakasID()));
}
getTableRow().setItem(new Kuljetus(kuljetus));
KuljetusListat.tallennusStatus.setText("Tallennettu: Ei");
});
}
@Override protected void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
if (!empty) {
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
setGraphic(paddedNappi);
} else {
setGraphic(null);
}
}
}
@@ -1,12 +0,0 @@
package fi.lpam.gui.elementit;
import javafx.scene.control.TableColumn;
public class MaaraTableColumn<Asiakas, Integer> extends TableColumn<Asiakas, Integer> {
public MaaraTableColumn(String columnLabel, int minWidth) {
super(columnLabel);
this.setResizable(false);
this.setReorderable(false);
this.setMinWidth(minWidth);
}
}
@@ -1,23 +0,0 @@
package fi.lpam.gui.elementit;
import fi.lpam.dataluokat.RaporttiRivi;
import javafx.scene.control.TableCell;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* Kustomoitu TableCell, joka päivitäTietokantaan sen sisältämän LocalDaten muotoon dd.MM.yyyy
*/
public class PaivamaaraTableCell extends TableCell<RaporttiRivi, LocalDate> {
public PaivamaaraTableCell() {}
@Override
protected void updateItem(LocalDate aika, boolean empty) {
super.updateItem(aika, empty);
if (empty || aika == null) return;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
String muokattuAika = aika.format(formatter);
setText(muokattuAika);
}
}
@@ -1,25 +0,0 @@
package fi.lpam.gui.elementit;
import javafx.geometry.Insets;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
/**
* Käyttöliittymän pohja
*/
public class TabPohja extends StackPane {
public static final Insets oletusInsets = new Insets(5);
public static final String oletusStyle = "-fx-background-color: lightgray;";
public static final Font otsikkoFont = Font.font("Open Sans", FontWeight.BOLD, 18);
public static final Font buttonFont = Font.font("Open Sans", FontWeight.BOLD, 16);
public static final Font tekstiFont = Font.font("Open Sans", FontWeight.NORMAL, 16);
public static final Border oletusBorder = new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), BorderWidths.DEFAULT));
public TabPohja() {
this.setStyle(oletusStyle);
this.setPadding(oletusInsets);
this.setBorder(oletusBorder);
}
}