Koodin siivousta
Signed-off-by: laurimaaninka <lauri.maaninka@gmail.com>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
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<Asiakas> multiColumnListView) {
|
||||
super(multiColumnListView);
|
||||
this.setMinHeight(60);
|
||||
this.setMaxHeight(60);
|
||||
|
||||
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.setFont(TabPohja.tekstiFont);
|
||||
label.textProperty().bind(textProperty());
|
||||
|
||||
wrapper = new StackPane(content, contentPlaceholder, label);
|
||||
wrapper.setAlignment(Pos.CENTER_LEFT);
|
||||
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() + "\n" + asiakas.getOsoite());
|
||||
}
|
||||
} else {
|
||||
setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package fi.lpam.gui.elementit;
|
||||
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.SpinnerValueFactory;
|
||||
|
||||
public class IntegerSpinner extends Spinner<Integer> {
|
||||
public IntegerSpinner() {
|
||||
super(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 500));
|
||||
this.setEditable(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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, int maxWidth) {
|
||||
super(columnLabel);
|
||||
this.setResizable(true);
|
||||
this.setReorderable(false);
|
||||
this.setMinWidth(minWidth);
|
||||
this.setMaxWidth(maxWidth);
|
||||
this.setStyle("-fx-alignment: CENTER; -fx-font-size: 16px;");
|
||||
}
|
||||
|
||||
public MaaraTableColumn(String columnLabel, int width) {
|
||||
this(columnLabel, width, width);
|
||||
this.setResizable(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user