Koodin siivousta
Signed-off-by: laurimaaninka <lauri.maaninka@gmail.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package fi.lpam.gui.tableCell;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user