removed config from .gitignore, added files that were not added due to gitignore previously
This commit is contained in:
parent
c1f6e3711b
commit
9b8f2868fd
7 changed files with 141 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,7 +8,6 @@ Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
config
|
|
||||||
config.h
|
config.h
|
||||||
config.h.in
|
config.h.in
|
||||||
config.log
|
config.log
|
||||||
|
|
16
corefx/src/main/java/com/core/ui/config/BaseConfigItem.java
Normal file
16
corefx/src/main/java/com/core/ui/config/BaseConfigItem.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package com.core.ui.config;
|
||||||
|
|
||||||
|
import com.core.client.rest.ConfigOption;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public abstract class BaseConfigItem implements IConfigItem {
|
||||||
|
private final Label label;
|
||||||
|
private final ConfigOption option;
|
||||||
|
|
||||||
|
public BaseConfigItem(ConfigOption option) {
|
||||||
|
this.option = option;
|
||||||
|
this.label = new Label(option.getLabel());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.core.ui.config;
|
||||||
|
|
||||||
|
import com.core.client.rest.ConfigOption;
|
||||||
|
import com.jfoenix.controls.JFXToggleButton;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
|
||||||
|
public class BooleanConfigItem extends BaseConfigItem {
|
||||||
|
private JFXToggleButton button = new JFXToggleButton();
|
||||||
|
|
||||||
|
public BooleanConfigItem(ConfigOption option) {
|
||||||
|
super(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;
|
||||||
|
}
|
||||||
|
}
|
30
corefx/src/main/java/com/core/ui/config/ConfigItemUtils.java
Normal file
30
corefx/src/main/java/com/core/ui/config/ConfigItemUtils.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package com.core.ui.config;
|
||||||
|
|
||||||
|
import com.core.client.rest.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 = null;
|
||||||
|
ConfigDataType dataType = ConfigDataType.get(option.getType());
|
||||||
|
switch (dataType) {
|
||||||
|
case BOOL:
|
||||||
|
configItem = new BooleanConfigItem(option);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (!option.getSelect().isEmpty()) {
|
||||||
|
configItem = new SelectConfigItem(option);
|
||||||
|
} else {
|
||||||
|
configItem = new DefaultConfigItem(option);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return configItem;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.core.ui.config;
|
||||||
|
|
||||||
|
import com.core.client.rest.ConfigOption;
|
||||||
|
import com.jfoenix.controls.JFXTextField;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
|
||||||
|
public class DefaultConfigItem extends BaseConfigItem {
|
||||||
|
private JFXTextField textField;
|
||||||
|
|
||||||
|
public DefaultConfigItem(ConfigOption option) {
|
||||||
|
super(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;
|
||||||
|
}
|
||||||
|
}
|
13
corefx/src/main/java/com/core/ui/config/IConfigItem.java
Normal file
13
corefx/src/main/java/com/core/ui/config/IConfigItem.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package com.core.ui.config;
|
||||||
|
|
||||||
|
import com.core.client.rest.ConfigOption;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
|
||||||
|
public interface IConfigItem {
|
||||||
|
Label getLabel();
|
||||||
|
|
||||||
|
Node getNode();
|
||||||
|
|
||||||
|
ConfigOption getOption();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.core.ui.config;
|
||||||
|
|
||||||
|
import com.core.client.rest.ConfigOption;
|
||||||
|
import com.jfoenix.controls.JFXComboBox;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
|
||||||
|
public class SelectConfigItem extends BaseConfigItem {
|
||||||
|
private JFXComboBox<String> comboBox = new JFXComboBox<>();
|
||||||
|
|
||||||
|
public SelectConfigItem(ConfigOption option) {
|
||||||
|
super(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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue