Packing de dialogos
This commit is contained in:
1 parent
571f0b7102
commit
374d5d6157
6 files changed
+43
-10
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package com.molnarandrei.sopa;
|
||||
|
||||
import com.molnarandrei.sopa.ui.lib.Packing;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.control.Alert;
|
||||
|
||||
@@ -126,7 +127,7 @@ public class Utils {
|
||||
*/
|
||||
public static void alert(Alert.AlertType type, String title, String header, String content) {
|
||||
Platform.runLater(() -> {
|
||||
var alert = new Alert(type);
|
||||
var alert = Packing.pack(new Alert(type));
|
||||
alert.setTitle(title);
|
||||
alert.setHeaderText(header);
|
||||
alert.setContentText(content);
|
||||
|
||||
@@ -6,15 +6,12 @@ import com.molnarandrei.sopa.trash.TrashService;
|
||||
import com.molnarandrei.sopa.Utils;
|
||||
import com.molnarandrei.sopa.data.RepositoryException;
|
||||
import com.molnarandrei.sopa.data.yaml.Step;
|
||||
import com.molnarandrei.sopa.data.yaml.TestCase;
|
||||
import com.molnarandrei.sopa.step.StepRepository;
|
||||
import com.molnarandrei.sopa.testcase.TestCaseRepository;
|
||||
import com.molnarandrei.sopa.ui.lib.Packing;
|
||||
import javafx.scene.control.TextInputDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -41,7 +38,7 @@ public class StepService {
|
||||
}
|
||||
|
||||
public static void create(Path testCasePath) {
|
||||
var input = new TextInputDialog();
|
||||
var input = Packing.pack(new TextInputDialog());
|
||||
input.setTitle("Crear paso en prueba");
|
||||
input.setHeaderText("Nombre del paso");
|
||||
var name = input.showAndWait().orElse("");
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.molnarandrei.sopa.data.yaml.Kind;
|
||||
import com.molnarandrei.sopa.trash.TrashService;
|
||||
import com.molnarandrei.sopa.step.StepService;
|
||||
import com.molnarandrei.sopa.Utils;
|
||||
import com.molnarandrei.sopa.testcase.TestCaseRepository;
|
||||
import com.molnarandrei.sopa.data.RepositoryException;
|
||||
import com.molnarandrei.sopa.data.yaml.TestCase;
|
||||
import com.molnarandrei.sopa.ui.lib.Packing;
|
||||
import javafx.scene.control.TextInputDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -39,7 +39,7 @@ public class TestCaseService {
|
||||
}
|
||||
|
||||
public static void create(Path projectPath) {
|
||||
var input = new TextInputDialog();
|
||||
var input = Packing.pack(new TextInputDialog());
|
||||
input.setTitle("Crear caso de prueba");
|
||||
input.setHeaderText("Nombre del caso");
|
||||
var name = input.showAndWait().orElse("");
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.molnarandrei.sopa.soap.SoapVersion;
|
||||
import com.molnarandrei.sopa.wsdl.WsdlRemote;
|
||||
import com.molnarandrei.sopa.wsdl.WsdlService;
|
||||
import com.molnarandrei.sopa.ui.editor.HeadersPane;
|
||||
import com.molnarandrei.sopa.ui.lib.Packing;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
@@ -131,10 +132,12 @@ public class CreateProjectDialog extends Stage {
|
||||
form.setCenter(headersPane);
|
||||
form.setBottom(new VBox(8, new Separator(), status, actions));
|
||||
|
||||
var scene = new Scene(form, 600, 480);
|
||||
form.setPrefWidth(600);
|
||||
var scene = new Scene(form);
|
||||
if (owner != null && owner.getScene() != null)
|
||||
scene.getStylesheets().addAll(owner.getScene().getStylesheets());
|
||||
setScene(scene);
|
||||
Packing.pack(this, scene);
|
||||
}
|
||||
|
||||
private void choosePath() {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.molnarandrei.sopa.ui.lib;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public final class Packing {
|
||||
private Packing() {}
|
||||
|
||||
public static <D extends Dialog<?>> D pack(D dialog) {
|
||||
var pane = dialog.getDialogPane();
|
||||
pane.setMinHeight(Region.USE_PREF_SIZE);
|
||||
pane.setMinWidth(Region.USE_PREF_SIZE);
|
||||
dialog.setResizable(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void pack(Stage stage, Scene scene) {
|
||||
var lastNeeded = new double[] { -1 };
|
||||
scene.addPostLayoutPulseListener(() -> {
|
||||
if (! stage.isShowing()) return;
|
||||
var root = scene.getRoot();
|
||||
var needed = Math.ceil(root.prefHeight(scene.getWidth()));
|
||||
if (needed == lastNeeded[0]) return;
|
||||
lastNeeded[0] = needed;
|
||||
var missing = needed - scene.getHeight();
|
||||
if (missing > 0) stage.setHeight(stage.getHeight() + missing);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.molnarandrei.sopa.step.StepRepository;
|
||||
import com.molnarandrei.sopa.step.StepService;
|
||||
import com.molnarandrei.sopa.testcase.TestCaseRepository;
|
||||
import com.molnarandrei.sopa.testcase.TestCaseService;
|
||||
import com.molnarandrei.sopa.ui.lib.Packing;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonBar;
|
||||
import javafx.scene.control.ButtonType;
|
||||
@@ -16,7 +17,7 @@ public class DeleteDialog {
|
||||
private static final ButtonType CANCEL = new ButtonType("Cancelar", ButtonBar.ButtonData.CANCEL_CLOSE);
|
||||
|
||||
public static void confirmAndDelete(TreeIdentity identity) {
|
||||
var alert = new Alert(Alert.AlertType.CONFIRMATION, "", DELETE, CANCEL);
|
||||
var alert = Packing.pack(new Alert(Alert.AlertType.CONFIRMATION, "", DELETE, CANCEL));
|
||||
alert.setTitle("Eliminar");
|
||||
alert.setHeaderText("Seguro que desea eliminar el %s %s?".formatted(kindName(identity), nameOf(identity)));
|
||||
alert.setContentText(identity.path().getParent().toString());
|
||||
|
||||
Reference in new issue
Block a user