@Override public void saveChanges() { node.setCase(caseSelectionPane.nodeProperty().getValue()); node.setScript(scriptSelectionPane.nodeProperty().getValue()); } }
protected AbstractSecurityAnalysisRunnerPane(T node, Scene scene, GseContext context) { this.node = Objects.requireNonNull(node); Project project = node.getProject(); caseSelectionPane = new ProjectNodeSelectionPane<>(project, RESOURCE_BUNDLE.getString("Case"), true, scene.getWindow(), context, ProjectFile.class, ProjectCase.class); contingencyStoreSelectionPane = new ProjectNodeSelectionPane<>(project, RESOURCE_BUNDLE.getString("ContingencyStore"), true, scene.getWindow(), context, ProjectFile.class, ContingenciesProvider.class); setVgap(5); setHgap(5); setPrefWidth(450); setPrefHeight(150); ColumnConstraints column0 = new ColumnConstraints(); ColumnConstraints column1 = new ColumnConstraints(); column1.setHgrow(Priority.ALWAYS); getColumnConstraints().addAll(column0, column1); add(new Label(RESOURCE_BUNDLE.getString("Name") + ":"), 0, 0); add(nameTextField, 1, 0, 2, 1); add(caseSelectionPane.getLabel(), 0, 1); add(caseSelectionPane.getTextField(), 1, 1); add(caseSelectionPane.getButton(), 2, 1); add(contingencyStoreSelectionPane.getLabel(), 0, 2); add(contingencyStoreSelectionPane.getTextField(), 1, 2); add(contingencyStoreSelectionPane.getButton(), 2, 2); new ValidationSupport().registerValidator(nameTextField, Validator.createEmptyValidator(RESOURCE_BUNDLE.getString("MandatoryName"))); }
protected AbstractVirtualCasePane(T node, Scene scene, GseContext context) { this.node = Objects.requireNonNull(node); Objects.requireNonNull(scene); Objects.requireNonNull(context); Project project = node.getProject(); nameTextField = NameTextField.create(node); caseSelectionPane = new ProjectNodeSelectionPane<>(project, RESOURCE_BUNDLE.getString("Case"), true, scene.getWindow(), context, ProjectFile.class, ProjectCase.class); scriptSelectionPane = new ProjectNodeSelectionPane<>(project, RESOURCE_BUNDLE.getString("ModificationScript"), true, scene.getWindow(), context, ModificationScript.class); setVgap(5); setHgap(5); ColumnConstraints column0 = new ColumnConstraints(); ColumnConstraints column1 = new ColumnConstraints(); column1.setHgrow(Priority.ALWAYS); getColumnConstraints().addAll(column0, column1); add(nameTextField.getNameLabel(), 0, 0); add(nameTextField.getInputField(), 1, 0, 2, 1); Platform.runLater(nameTextField.getInputField()::requestFocus); add(caseSelectionPane.getLabel(), 0, 1); add(caseSelectionPane.getTextField(), 1, 1); add(caseSelectionPane.getButton(), 2, 1); add(scriptSelectionPane.getLabel(), 0, 2); add(scriptSelectionPane.getTextField(), 1, 2); add(scriptSelectionPane.getButton(), 2, 2); add(NewScriptButton.create(node, scriptSelectionPane.nodeProperty(), context), 3, 2); add(nameTextField.getFileAlreadyExistsLabel(), 0, 3, 4, 1); }
folderSelectionPane = new ProjectNodeSelectionPane<>(project, RESOURCE_BUNDLE.getString("Folder"), true, window, context, ProjectFolder.class); folderSelectionPane.nodeProperty().addListener((observable, oldName, newName) -> nameTextField.changeFolder(newName)); folderSelectionPane.nodeProperty().setValue(folder); pane.add(nameTextField.getNameLabel(), 0, 0); pane.add(nameTextField.getInputField(), 1, 0, 2, 1); pane.add(folderSelectionPane.getLabel(), 0, 1); pane.add(folderSelectionPane.getTextField(), 1, 1, 2, 1); pane.add(folderSelectionPane.getButton(), 3, 1); pane.add(nameTextField.getFileAlreadyExistsLabel(), 0, 2, 4, 1); dialog.getDialogPane().setContent(pane); BooleanBinding okProperty = folderSelectionPane.nodeProperty().isNotNull() .and(nameTextField.okProperty()); button.disableProperty().bind(okProperty.not());
@Override public void saveChanges() { node.setCase(caseSelectionPane.nodeProperty().getValue()); node.setContingencyStore(contingencyStoreSelectionPane.nodeProperty().getValue()); } }
@Override public ProjectCreationTask createTask() { String name = nameTextField.getText(); ProjectFile aCase = caseSelectionPane.nodeProperty().getValue(); ProjectFile contingencyStore = contingencyStoreSelectionPane.nodeProperty().getValue(); return new ProjectCreationTask() { @Override
public BooleanBinding okProperty() { return caseSelectionPane.nodeProperty().isNotNull() .and(scriptSelectionPane.nodeProperty().isNotNull()) .and(nameTextField.okProperty()); }
@Override public ProjectCreationTask createTask() { String name = nameTextField.getText(); ProjectFile aCase = caseSelectionPane.nodeProperty().getValue(); ModificationScript script = scriptSelectionPane.nodeProperty().getValue(); return new ProjectCreationTask() { @Override
@Override public void edit() { nameTextField.setText(node.getName()); nameTextField.setDisable(true); node.getCase().ifPresent(aCase -> caseSelectionPane.nodeProperty().setValue(aCase)); node.getContingencyStore().ifPresent(contingencyStore -> contingencyStoreSelectionPane.nodeProperty().setValue(contingencyStore)); }
@Override public void edit() { nameTextField.setText(node.getName()); nameTextField.getInputField().setDisable(true); node.getCase().ifPresent(aCase -> caseSelectionPane.nodeProperty().setValue(aCase)); node.getScript().ifPresent(aScript -> scriptSelectionPane.nodeProperty().setValue(aScript)); }
public BooleanBinding okProperty() { return nameTextField.textProperty().isNotEmpty() .and(caseSelectionPane.nodeProperty().isNotNull()) .and(contingencyStoreSelectionPane.nodeProperty().isNotNull()); }
private void showAndWaitDialog(ProjectFolder folder, Project project, Window window, GseContext context) { Dialog<Boolean> dialog = createDialog(folder, project, window, context); dialog.showAndWait().filter(response -> response) .ifPresent(response -> { ProjectFolder targetFolder = folderSelectionPane.nodeProperty().getValue(); ModificationScript newScript = targetFolder.fileBuilder(ModificationScriptBuilder.class) .withName(nameTextField.getText()) .withType(ScriptType.GROOVY) .withContent("") .build(); if (scriptProperty != null) { scriptProperty.setValue(newScript); } }); dialog.close(); } }