Java Examples for javafx.scene.control.TextInputDialog
The following java examples will help you to understand the usage of javafx.scene.control.TextInputDialog. These source code samples are taken from different open source projects.
Example 1
| Project: idnadrev-master File: CopyAllToDirAndScaleDown.java View source code |
@Override
public void before(Scene scene) {
super.before(scene);
int scaleDownSize = Options.get(GallerySettings.class).getScaleDownSize();
TextInputDialog dialog = new TextInputDialog(String.valueOf(scaleDownSize));
dialog.setTitle(Localized.get("enter.targetResolution"));
dialog.setHeaderText(null);
dialog.setContentText(Localized.get("targetResolution:"));
Optional<String> s = dialog.showAndWait();
if (s.isPresent()) {
try {
int i = Integer.parseInt(s.get());
targetWidth = i;
} catch (NumberFormatException e) {
targetWidth = 0;
}
} else {
targetWidth = 0;
}
}Example 2
| Project: latexdraw-master File: ExportTemplate.java View source code |
@Override
protected void doActionBody() {
final TextInputDialog dialog = new TextInputDialog("templateFileName");
dialog.setHeaderText(LangTool.INSTANCE.getBundle().getString("DrawContainer.nameTemplate"));
dialog.showAndWait().ifPresent( name -> {
String path = LPath.PATH_TEMPLATES_DIR_USER + File.separator + name + ".svg";
if (Files.exists(Paths.get(path))) {
final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setHeaderText(LangTool.INSTANCE.getBundle().getString("DrawContainer.overwriteTemplate"));
alert.setTitle(LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.42"));
if (alert.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK) {
SVGDocumentGenerator.INSTANCE.saveTemplate(path, progressBar, statusWidget, templatesPane);
}
} else {
SVGDocumentGenerator.INSTANCE.saveTemplate(path, progressBar, statusWidget, templatesPane);
}
});
}Example 3
| Project: sportstracker-master File: STContextImpl.java View source code |
@Override
public Optional<String> showTextInputDialog(final Window parent, final String titleKey, final String messageKey, final String initialValue) {
final TextInputDialog inputDlg = new TextInputDialog(initialValue == null ? "" : initialValue);
inputDlg.initOwner(parent);
inputDlg.setTitle(getResources().getString(titleKey));
inputDlg.setContentText(getResources().getString(messageKey));
inputDlg.setHeaderText(null);
return inputDlg.showAndWait();
}Example 4
| Project: viskell-master File: LambdaBlock.java View source code |
public void editSignature() {
String input = this.definitionName.getText().isEmpty() ? "example" : this.definitionName.getText();
if (this.explicitSignature.isPresent()) {
input += " :: " + this.explicitSignature.get().prettyPrint();
}
TextInputDialog dialog = new TextInputDialog(input);
dialog.setTitle("Edit lambda signature");
dialog.setHeaderText("Set the name and optionally the type");
Optional<String> result = dialog.showAndWait();
result.ifPresent( signature -> {
if (!this.definitionName.isVisible()) {
this.definitionName.addEventHandler(MouseEvent.MOUSE_RELEASED, this::createFunctionUseBlock);
this.definitionName.addEventHandler(TouchEvent.TOUCH_RELEASED, this::createFunctionUseBlock);
}
List<String> parts = Splitter.on(" :: ").splitToList(signature);
if (parts.size() < 2) {
this.definitionName.setText(signature);
this.definitionName.setVisible(true);
} else {
this.definitionName.setText(parts.get(0));
this.definitionName.setVisible(true);
Type type = this.getToplevel().getEnvInstance().buildType(parts.get(1));
if (type.countArguments() >= this.body.argCount()) {
this.explicitSignature = Optional.of(type);
this.signature.setText(type.prettyPrint());
this.body.enforceExplicitType(type);
this.initiateConnectionChanges();
}
}
});
}Example 5
| Project: PeerWasp-master File: Network.java View source code |
@FXML
public void addAction(ActionEvent event) {
// request node address from user and add
TextInputDialog input = new TextInputDialog();
DialogUtils.decorateDialogWithIcon(input);
input.getEditor().setPromptText("Enter address");
input.setTitle("New Node Address");
input.setHeaderText("Enter new node address");
Optional<String> result = input.showAndWait();
if (result.isPresent()) {
String nodeAddress = result.get().trim();
addItemIgnoreDuplicate(nodeAddress);
}
}Example 6
| Project: itol-master File: AttachmentTableViewHandler.java View source code |
/**
* Add selected attachments to blacklist.
* This attachments should not be added to an issue anymore, e.g. company logos.
* For each attachment, a dialog queries for a name under which the properties of the attachment are stored in the configuration file.
*/
public static void addSelectedAttachmentsToBlacklist(Window owner, MailAttachmentHelper attachmentHelper, ProgressCallback cb, TableView<Attachment> tabAttachments) throws Exception {
try {
ArrayList<Attachment> allItems = new ArrayList<>(tabAttachments.getItems());
ResourceBundle resb = Globals.getResourceBundle();
for (Attachment att : tabAttachments.getSelectionModel().getSelectedItems()) {
TextInputDialog dialog = new TextInputDialog(att.getFileName());
dialog.initOwner(owner);
dialog.setTitle(resb.getString("menuAddToBlacklist"));
dialog.setHeaderText(resb.getString("menuAddToBlacklist.hint"));
Optional<String> selectedName = dialog.showAndWait();
if (!selectedName.isPresent())
break;
URI uri = attachmentHelper.downloadAttachment(att, cb);
File localFile = new File(uri);
MailAttachmentHelper.addBlacklistItem(selectedName.get(), localFile);
allItems.remove(att);
}
if (allItems.size() != tabAttachments.getItems().size()) {
tabAttachments.getItems().clear();
tabAttachments.getItems().addAll(allItems);
tabAttachments.refresh();
}
} finally {
cb.setFinished();
}
}Example 7
| Project: CaseTracker-master File: EditorController.java View source code |
@FXML
protected void handleEditEvidenceAction(ActionEvent e) {
logger.info("Editing evidence attached to new case");
Evidence evidence = lstAddEvidence.getSelectionModel().getSelectedItem();
Evidence oldEvidence = evidence;
if (evidence != null) {
TextInputDialog editDialog = new TextInputDialog(evidence.getDescription());
editDialog.setTitle("Edit Evidence");
editDialog.setContentText("Please enter the description:");
Optional<String> newDescription = editDialog.showAndWait();
if (newDescription.isPresent()) {
logger.debug("Setting new evidence description to {}", newDescription.get());
evidence.setDescription(newDescription.get());
int index = lstAddEvidence.getItems().indexOf(oldEvidence);
lstAddEvidence.getItems().set(index, evidence);
}
} else {
logger.debug("No evidence selected to edit");
Alert selectionWarning = new Alert(AlertType.WARNING);
selectionWarning.setTitle("No Evidence Selected");
selectionWarning.setContentText("No evidence selected to edit");
selectionWarning.showAndWait();
}
}Example 8
| Project: bgfinancas-master File: Janela.java View source code |
public static String showEntrada(String mensagem, String valorPadrao) {
TextInputDialog entrada = new TextInputDialog(valorPadrao);
entrada.setTitle(idioma.getMensagem("informe_dados"));
entrada.setHeaderText(null);
entrada.setContentText(mensagem);
ButtonType ok = new ButtonType(idioma.getMensagem("ok"), ButtonData.OK_DONE);
ButtonType cancelar = new ButtonType(idioma.getMensagem("cancelar"), ButtonData.CANCEL_CLOSE);
entrada.getDialogPane().getButtonTypes().setAll(ok, cancelar);
Optional<String> result = entrada.showAndWait();
if (result.isPresent()) {
return result.get();
} else {
return null;
}
}Example 9
| Project: jace-master File: Program.java View source code |
public void initEditor(WebView editor, File sourceFile, boolean isBlank) {
this.editor = editor;
targetFile = sourceFile;
if (targetFile != null) {
filename = targetFile.getName();
}
editor.getEngine().getLoadWorker().stateProperty().addListener(( value, old, newState) -> {
if (newState == Worker.State.SUCCEEDED) {
JSObject document = (JSObject) editor.getEngine().executeScript("window");
document.setMember("java", this);
Platform.runLater(() -> createEditor(isBlank));
}
});
editor.getEngine().setPromptHandler((PromptData prompt) -> {
TextInputDialog dialog = new TextInputDialog(prompt.getDefaultValue());
dialog.setTitle("Jace IDE");
dialog.setHeaderText("Respond and press OK, or Cancel to abort");
dialog.setContentText(prompt.getMessage());
return dialog.showAndWait().orElse(null);
});
editor.getEngine().load(getClass().getResource(CODEMIRROR_EDITOR).toExternalForm());
}Example 10
| Project: Matrixonator-Java-master File: MatrixOverviewController.java View source code |
/**
* Method is called when the "Edit" button is pressed. If a valid matrix is selected in the table
* on the left, then it is deleted from the matrixTable.
*/
@FXML
private void handleEditMatrix() {
int selectedIndex = matrixTable.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) {
// User has selected a valid matrix on the left.
TextInputDialog dialog = new TextInputDialog(matrixTable.getSelectionModel().getSelectedItem().getName());
dialog.setTitle("Editing Matrix");
dialog.setHeaderText("Leave blank, or click cancel for no changes.");
dialog.setContentText("Please enter new name:");
Optional<String> result = dialog.showAndWait();
result.ifPresent( name -> matrixTable.getSelectionModel().getSelectedItem().setName(name));
updateMatrixList();
} else {
// Nothing is selected
MatrixAlerts.noSelectionAlert();
}
}Example 11
| Project: chunky-master File: GradientEditor.java View source code |
@Override
public void initialize(URL location, ResourceBundle resources) {
for (String[] preset : presets) {
MenuItem menuItem = new MenuItem(preset[0]);
menuItem.setOnAction( e -> importGradient(preset[1]));
loadPreset.getItems().add(menuItem);
}
prevBtn.setTooltip(new Tooltip("Select the previous stop."));
prevBtn.setOnAction( e -> {
selectStop(Math.max(selected - 1, 0));
draw();
});
nextBtn.setTooltip(new Tooltip("Select the next stop."));
nextBtn.setOnAction( e -> {
selectStop(Math.min(selected + 1, gradient.size() - 1));
draw();
});
addBtn.setTooltip(new Tooltip("Add a new stop after the selected stop."));
addBtn.setOnAction( e -> {
selectStop(addStopAfter(selected));
gradientChanged();
});
removeBtn.setTooltip(new Tooltip("Delete the selected stop."));
removeBtn.setDisable(true);
removeBtn.setOnAction( e -> {
if (removeStop(selected)) {
selectStop(Math.min(selected, gradient.size() - 1));
nextBtn.setDisable(selected == gradient.size() - 1);
gradientChanged();
}
});
importBtn.setOnAction( e -> {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Import Gradient");
dialog.setHeaderText("Gradient Import");
dialog.setContentText("Graident JSON:");
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
importGradient(result.get());
}
});
exportBtn.setOnAction( e -> {
TextInputDialog dialog = new TextInputDialog(Sky.gradientJson(gradient).toCompactString());
dialog.setTitle("Gradient Export");
dialog.setHeaderText("Gradient Export");
dialog.setContentText("Gradient JSON:");
dialog.showAndWait();
});
canvas.setOnMouseDragged( e -> {
double pos = e.getX() / canvas.getWidth();
if (selected > 0 && selected + 1 < gradient.size()) {
pos = Math.max(gradient.get(selected - 1).w, pos);
pos = Math.min(gradient.get(selected + 1).w, pos);
gradient.get(selected).w = pos;
gradientChanged();
}
});
canvas.setOnMousePressed( e -> {
double pos = e.getX() / canvas.getWidth();
double closest = Double.MAX_VALUE;
int stop = 0;
int index = 0;
for (Vector4 m : gradient) {
double distance = Math.abs(m.w - pos);
if (distance < closest) {
stop = index;
closest = distance;
}
index += 1;
}
selectStop(stop);
draw();
});
canvas.setOnMouseClicked( e -> {
if (e.getClickCount() == 2) {
double pos = e.getX() / canvas.getWidth();
int stop = 0;
int index = 0;
for (Vector4 m : gradient) {
if (pos >= m.w) {
stop = index;
} else {
break;
}
index += 1;
}
int added = addStopAfter(stop, pos);
gradient.get(added).w = pos;
selectStop(added);
gradientChanged();
}
});
colorPicker.colorProperty().addListener(colorListener);
}Example 12
| Project: jBrowserDriver-master File: MonocleApplication.java View source code |
@Override
protected FileChooserResult staticCommonDialogs_showFileChooser(Window owner, String folder, String filename, String title, int type, boolean multipleMode, ExtensionFilter[] extensionFilters, int defaultFilterIndex) {
TextInputDialog dialog = new TextInputDialog();
dialog.showAndWait();
File[] files;
String filePaths = dialog.getEditor().getText();
if (filePaths != null && !filePaths.isEmpty()) {
String[] filePathParts = filePaths.split("\t");
files = new File[filePathParts.length];
for (int i = 0; i < filePathParts.length; i++) {
files[i] = new File(filePathParts[i]);
}
} else {
files = new File[0];
}
return new FileChooserResult(Arrays.asList(files), null);
}Example 13
| Project: nanobot-master File: MainController.java View source code |
private String prompt(final String msg, final String value) {
final String[] toReturn = new String[1];
platformRunNow(() -> {
final TextInputDialog dialog = new TextInputDialog(value == null ? "" : value);
dialog.initOwner(application.getPrimaryStage());
dialog.setHeaderText(msg);
final Optional<String> result = dialog.showAndWait();
toReturn[0] = result.isPresent() ? result.get() : null;
});
return toReturn[0];
}Example 14
| Project: geotoolkit-master File: FXStyleClassifSinglePane.java View source code |
@FXML
private void addValue(ActionEvent event) {
final TextInputDialog dialog = new TextInputDialog();
dialog.setHeaderText(GeotkFX.getString(FXStyleClassifSinglePane.class, "newvalue"));
final Optional<String> str = dialog.showAndWait();
if (str.get() == null)
return;
final String val = str.get();
final MutableRule r = createRule(uiProperty.getSelectionModel().getSelectedItem(), val, uiTable.getItems().size());
uiTable.getItems().add(r);
}Example 15
| Project: mqtt-spy-master File: LineChartPaneController.java View source code |
@FXML
private void updateSaveOnInterval() {
if (saveImageAtInterval.isSelected()) {
final TextInputDialog dialog = new TextInputDialog("60");
dialog.setTitle("Export interval");
dialog.setHeaderText(null);
dialog.setContentText("Please enter export interval (in seconds):");
final Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
try {
exportInterval = Integer.valueOf(result.get());
if (exportInterval > 0) {
new Thread(new Runnable() {
@Override
public void run() {
while (exportInterval != null && exportInterval > 0) {
Platform.runLater(new Runnable() {
@Override
public void run() {
exportAsImage(selectedImageFile);
}
});
try {
Thread.sleep(exportInterval * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
} else // else if (exportInterval == 0)
// {
// exportInterval = null;
// }
{
DialogFactory.createErrorDialog("Invalid number format", "The provided value is not a correct number (>0).");
exportInterval = null;
}
} catch (NumberFormatException e) {
DialogFactory.createErrorDialog("Invalid number format", "The provided value is not a correct number (>0).");
}
}
} else {
exportInterval = null;
}
}Example 16
| Project: mzmine3-master File: MsSpectrumPlotWindowController.java View source code |
public void handleSetMzShiftManually(Event event) {
DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
String newMzShiftString = "0.0";
Double newMzShift = (Double) setToMenuItem.getUserData();
if (newMzShift != null)
newMzShiftString = mzFormat.format(newMzShift);
TextInputDialog dialog = new TextInputDialog(newMzShiftString);
dialog.setTitle("m/z shift");
dialog.setHeaderText("Set m/z shift value");
Optional<String> result = dialog.showAndWait();
result.ifPresent( value -> {
try {
double newValue = Double.parseDouble(value);
mzShift.set(newValue);
} catch (Exception e) {
e.printStackTrace();
}
});
}Example 17
| Project: jvarkit-master File: JfxNgs.java View source code |
void openBamUrl(final Window owner) {
final String lastkey = "last.bam.url";
final TextInputDialog dialog = new TextInputDialog(this.preferences.get(lastkey, ""));
dialog.setContentText("URL:");
dialog.setTitle("Get BAM URL");
dialog.setHeaderText("Input BAM URL");
final Optional<String> choice = dialog.showAndWait();
if (!choice.isPresent())
return;
BamFile input = null;
try {
input = BamFile.newInstance(choice.get());
this.preferences.put(lastkey, choice.get());
final BamStage stage = new BamStage(JfxNgs.this, input);
stage.show();
} catch (final Exception err) {
CloserUtil.close(input);
showExceptionDialog(owner, err);
}
}Example 18
| Project: CloudTrailViewer-master File: DialogUtils.java View source code |
public static Optional<String> showTextInputDialog(String title, String message) {
TextInputDialog dialog = new TextInputDialog("");
dialog.setTitle(title);
dialog.setHeaderText(message);
return dialog.showAndWait();
}Example 19
| Project: jabref-master File: FXDialogService.java View source code |
@Override
public Optional<String> showInputDialogAndWait(String title, String content) {
TextInputDialog inputDialog = new TextInputDialog();
inputDialog.setHeaderText(title);
inputDialog.setContentText(content);
return inputDialog.showAndWait();
}Example 20
| Project: Turnierserver-master File: Dialog.java View source code |
public static String textInput(String text, String title, String defaultText) {
TextInputDialog dialog = new TextInputDialog(defaultText);
dialog.setTitle(title);
dialog.setHeaderText(null);
dialog.setContentText(text);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
return result.get();
}
return null;
}Example 21
| Project: JXTN-master File: JFX.java View source code |
/**
* 建立新的{@link javafx.scene.control.TextInputDialog}建構器。
*
* @return 新的{@link javafx.scene.control.TextInputDialogMaker}
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static javafx.scene.control.TextInputDialogMaker<javafx.scene.control.TextInputDialog, ?> textInputDialog() {
return new javafx.scene.control.TextInputDialogMaker();
}