Improve input field of export file name

This commit is contained in:
0xb00bface 2021-12-20 17:29:57 +01:00
parent f04eb5310e
commit a111d12969
4 changed files with 40 additions and 9 deletions

View File

@ -70,7 +70,7 @@ public abstract class AbstractFileSelectionBox extends HBox {
fileInput.setText(initialValue);
}
private ChangeListener<? super String> textListener() {
protected ChangeListener<String> textListener() {
return (obs, o, n) -> {
var input = fileInput.getText();
if (StringUtil.isBlank(input)) {

View File

@ -0,0 +1,28 @@
package ctbrec.ui.controls;
import javafx.beans.value.ChangeListener;
import java.io.File;
public class SaveFileSelectionBox extends FileSelectionBox {
public SaveFileSelectionBox() {
disableValidation();
useSaveDialog();
}
@Override
protected void setFile(File file) {
// nothing to do
}
@Override
protected ChangeListener<String> textListener() {
return (obs, o, n) -> {};
}
@Override
protected String validate(File file) {
return null;
}
}

View File

@ -60,12 +60,9 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import static ctbrec.ui.tabs.recorded.ModelImportExport.ExportIncludes.*;
public abstract class AbstractRecordedModelsTab extends Tab implements TabSelectionListener {
private static final Logger LOG = LoggerFactory.getLogger(AbstractRecordedModelsTab.class);
private static final Image SILHOUETTE = new Image(AbstractRecordedModelsTab.class.getResourceAsStream("/silhouette_256.png"));
@ -258,6 +255,7 @@ public abstract class AbstractRecordedModelsTab extends Tab implements TabSelect
@Override
protected void done() {
getContent().setCursor(Cursor.DEFAULT);
reload();
}
};
GlobalThreadPool.submit(task);

View File

@ -1,7 +1,7 @@
package ctbrec.ui.tabs.recorded;
import ctbrec.ui.controls.Dialogs;
import ctbrec.ui.controls.FileSelectionBox;
import ctbrec.ui.controls.SaveFileSelectionBox;
import ctbrec.ui.tabs.recorded.ModelImportExport.ExportIncludes;
import ctbrec.ui.tabs.recorded.ModelImportExport.ExportOptions;
import javafx.geometry.Insets;
@ -11,6 +11,7 @@ import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import java.io.File;
@ -27,7 +28,7 @@ public class ModelExportDialog {
private CheckBox notesButton;
private CheckBox groupsButton;
private CheckBox portraisButton;
private FileSelectionBox fileSelectionBox;
private SaveFileSelectionBox fileSelectionBox;
public ModelExportDialog(Node source) {
this.source = source;
@ -41,11 +42,11 @@ public class ModelExportDialog {
gridPane.setPadding(new Insets(20, 150, 10, 10));
Label l = new Label("Export to file");
gridPane.add(l, 0, 0);
fileSelectionBox = new FileSelectionBox();
fileSelectionBox.useSaveDialog();
fileSelectionBox.disableValidation();
fileSelectionBox = new SaveFileSelectionBox();
gridPane.add(fileSelectionBox, 1, 0);
GridPane.setValignment(l, VPos.TOP);
GridPane.setMargin(l, new Insets(5, 0, 0, 0));
GridPane.setHgrow(fileSelectionBox, Priority.ALWAYS);
notesButton = new CheckBox("notes");
notesButton.setSelected(true);
groupsButton = new CheckBox("groups");
@ -57,6 +58,10 @@ public class ModelExportDialog {
VBox.setMargin(notesButton, new Insets(5));
VBox.setMargin(groupsButton, new Insets(5));
VBox.setMargin(portraisButton, new Insets(5));
l = new Label("Include");
GridPane.setMargin(l, new Insets(5, 0, 0, 0));
GridPane.setValignment(l, VPos.TOP);
gridPane.add(l, 0, 1);
gridPane.add(row, 1, 1);
}