added missing corefx config files due to gitignore

This commit is contained in:
Blake J. Harnden 2019-05-28 09:36:18 -07:00
parent 01fc5be82f
commit 7da09a0dd9
7 changed files with 202 additions and 0 deletions

View file

@ -0,0 +1,19 @@
package com.core.ui.config;
import com.core.data.ConfigOption;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import lombok.Data;
@Data
public abstract class BaseConfigItem implements IConfigItem {
private final Stage stage;
private final Label label;
private final ConfigOption option;
public BaseConfigItem(Stage stage, ConfigOption option) {
this.stage = stage;
this.option = option;
this.label = new Label(option.getLabel());
}
}

View file

@ -0,0 +1,32 @@
package com.core.ui.config;
import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXToggleButton;
import javafx.scene.Node;
import javafx.stage.Stage;
public class BooleanConfigItem extends BaseConfigItem {
private JFXToggleButton button = new JFXToggleButton();
public BooleanConfigItem(Stage stage, ConfigOption option) {
super(stage, option);
button.setMaxWidth(Double.MAX_VALUE);
if ("1".equals(option.getValue())) {
button.setSelected(true);
}
button.selectedProperty().addListener(((observable, oldValue, newValue) -> {
String value;
if (newValue) {
value = "1";
} else {
value = "0";
}
getOption().setValue(value);
}));
}
@Override
public Node getNode() {
return button;
}
}

View file

@ -0,0 +1,29 @@
package com.core.ui.config;
import com.core.data.ConfigOption;
import com.core.data.ConfigDataType;
import javafx.stage.Stage;
public final class ConfigItemUtils {
private ConfigItemUtils() {
}
public static IConfigItem get(Stage stage, ConfigOption option) {
IConfigItem configItem;
ConfigDataType dataType = ConfigDataType.get(option.getType());
if (dataType == ConfigDataType.BOOL) {
configItem = new BooleanConfigItem(stage, option);
} else {
if (!option.getSelect().isEmpty()) {
configItem = new SelectConfigItem(stage, option);
} else if (option.getLabel().endsWith(" file")) {
configItem = new FileConfigItem(stage, option);
} else {
configItem = new DefaultConfigItem(stage, option);
}
}
return configItem;
}
}

View file

@ -0,0 +1,24 @@
package com.core.ui.config;
import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXTextField;
import javafx.scene.Node;
import javafx.stage.Stage;
public class DefaultConfigItem extends BaseConfigItem {
private JFXTextField textField;
public DefaultConfigItem(Stage stage, ConfigOption option) {
super(stage, option);
textField = new JFXTextField(option.getValue());
textField.setMaxWidth(Double.MAX_VALUE);
textField.textProperty().addListener(((observable, oldValue, newValue) -> {
getOption().setValue(newValue);
}));
}
@Override
public Node getNode() {
return textField;
}
}

View file

@ -0,0 +1,56 @@
package com.core.ui.config;
import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTextField;
import javafx.scene.Node;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import java.io.File;
public class FileConfigItem extends BaseConfigItem {
private GridPane gridPane;
public FileConfigItem(Stage stage, ConfigOption option) {
super(stage, option);
gridPane = new GridPane();
gridPane.setHgap(5);
gridPane.setMaxWidth(Double.MAX_VALUE);
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setVgrow(Priority.SOMETIMES);
ColumnConstraints textFieldConstraints = new ColumnConstraints();
textFieldConstraints.setHgrow(Priority.SOMETIMES);
textFieldConstraints.setPercentWidth(60);
ColumnConstraints buttonConstraints = new ColumnConstraints();
buttonConstraints.setHgrow(Priority.SOMETIMES);
buttonConstraints.setPercentWidth(40);
gridPane.getColumnConstraints().addAll(textFieldConstraints, buttonConstraints);
JFXTextField textField = new JFXTextField();
textField.setMaxWidth(Double.MAX_VALUE);
textField.textProperty().addListener(((observable, oldValue, newValue) -> getOption().setValue(newValue)));
JFXButton button = new JFXButton("Select File");
button.getStyleClass().add("core-button");
button.setMaxWidth(Double.MAX_VALUE);
button.setOnAction(event -> {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select File");
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
File file = fileChooser.showOpenDialog(stage);
if (file != null) {
textField.setText(file.getPath());
}
});
gridPane.addRow(0, textField, button);
}
@Override
public Node getNode() {
return gridPane;
}
}

View file

@ -0,0 +1,13 @@
package com.core.ui.config;
import com.core.data.ConfigOption;
import javafx.scene.Node;
import javafx.scene.control.Label;
public interface IConfigItem {
Label getLabel();
Node getNode();
ConfigOption getOption();
}

View file

@ -0,0 +1,29 @@
package com.core.ui.config;
import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXComboBox;
import javafx.scene.Node;
import javafx.stage.Stage;
public class SelectConfigItem extends BaseConfigItem {
private JFXComboBox<String> comboBox = new JFXComboBox<>();
public SelectConfigItem(Stage stage, ConfigOption option) {
super(stage, option);
comboBox.setMaxWidth(Double.MAX_VALUE);
comboBox.getItems().addAll(option.getSelect());
comboBox.getSelectionModel().select(option.getValue());
comboBox.getSelectionModel().selectedItemProperty().addListener(((observable, oldValue, newValue) -> {
if (newValue == null) {
return;
}
getOption().setValue(newValue);
}));
}
@Override
public Node getNode() {
return comboBox;
}
}