javafx.scene.control.TextInputDialog Java Examples

The following examples show how to use javafx.scene.control.TextInputDialog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DownloadController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
protected void plusAction() {
    try {
        TextInputDialog dialog = new TextInputDialog("https://");
        dialog.setTitle(message("DownloadManage"));
        dialog.setHeaderText(message("InputAddress"));
        dialog.setContentText("");
        dialog.getEditor().setPrefWidth(500);
        Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();
        Optional<String> result = dialog.showAndWait();
        if (!result.isPresent()) {
            return;
        }
        String address = result.get();
        download(address);

    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example #2
Source File: MsSpectrumPlotWindowController.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
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 #3
Source File: FindWidgetAction.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** @param node Node to position dialog
 *  @param editor Editor in which to select widgets
 */
public FindWidgetAction(final Node node, final DisplayEditor editor)
{
    super(Messages.FindWidget, ImageCache.getImageView(DisplayEditor.class, "/icons/search.png"));
    setOnAction(event ->
    {
        // Prompt for widget name
        final TextInputDialog prompt = new TextInputDialog();
        prompt.setTitle(Messages.FindWidget);
        prompt.setHeaderText("Enter (partial) widget name");
        prompt.setResizable(true);
        DialogHelper.positionAndSize(prompt, node,
                PhoebusPreferenceService.userNodeForClass(FindWidgetAction.class));
        final String pattern = prompt.showAndWait().orElse(null);
        if (pattern != null  &&  !pattern.isEmpty())
            editor.selectWidgetsByName(pattern);
    });
}
 
Example #4
Source File: RenameAction.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** @param node Node used to position confirmation dialog
 *  @param item Item to rename
 */
public RenameAction(final Node node, final TreeItem<FileInfo> item)
{
    super(Messages.Rename, ImageCache.getImageView(ImageCache.class, "/icons/name.png"));

    setOnAction(event ->
    {
        final File file = item.getValue().file;
        final TextInputDialog prompt = new TextInputDialog(file.getName());
        prompt.setTitle(getText());
        prompt.setHeaderText(Messages.RenameHdr);
        DialogHelper.positionDialog(prompt, node, 0, 0);
        final String new_name = prompt.showAndWait().orElse(null);
        if (new_name == null)
            return;

        JobManager.schedule(Messages.RenameJobName + item.getValue(), monitor ->
        {
            Files.move(file.toPath(), (new File(file.getParentFile(), new_name)).toPath(), StandardCopyOption.REPLACE_EXISTING);

            final FileTreeItem parent = (FileTreeItem)item.getParent();
            Platform.runLater(() ->  parent.forceRefresh());
        });
    });
}
 
Example #5
Source File: NewAttributeCommand.java    From megan-ce with GNU General Public License v3.0 6 votes vote down vote up
public void actionPerformed(ActionEvent event) {
    final SamplesViewer viewer = ((SamplesViewer) getViewer());
    final int index;
    final String selectedAttribute = viewer.getSamplesTableView().getASelectedAttribute();
    if (selectedAttribute != null)
        index = viewer.getSamplesTableView().getAttributes().indexOf(selectedAttribute);
    else
        index = viewer.getSamplesTableView().getSampleCount();

    String name = null;
    if (Platform.isFxApplicationThread()) {
        TextInputDialog dialog = new TextInputDialog("Attribute");
        dialog.setTitle("New attribute");
        dialog.setHeaderText("Enter attribute name:");

        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            name = result.get().trim();
        }
    } else if (javax.swing.SwingUtilities.isEventDispatchThread()) {
        name = JOptionPane.showInputDialog(getViewer().getFrame(), "Enter new attribute name", "Untitled");
    }

    if (name != null)
        executeImmediately("new attribute='" + name + "' position=" + index + ";");
}
 
Example #6
Source File: Program.java    From jace with GNU General Public License v2.0 6 votes vote down vote up
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 #7
Source File: Dialogs.java    From megan-ce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * show an input dialog
 *
 * @param swingParent
 * @param title
 * @param message
 * @param initialValue
 * @return
 */
private static String showInput(final Component swingParent, final String title, final String message, final String initialValue) {
    final Single<String> input = new Single<>(null);

    if (Platform.isFxApplicationThread()) {
        final TextInputDialog dialog = new TextInputDialog(initialValue != null ? initialValue : "");
        dialog.setTitle(title);
        dialog.setHeaderText(message);

        final Optional<String> result = dialog.showAndWait();
        result.ifPresent(input::set);

    } else if (javax.swing.SwingUtilities.isEventDispatchThread()) {
        input.set(JOptionPane.showInputDialog(swingParent, message, initialValue));
    } else {
        try {
            SwingUtilities.invokeAndWait(() -> input.set(showInput(swingParent, title, message, initialValue)));
        } catch (Exception e) {
            Basic.caught(e);
        }
    }
    return input.get();
}
 
Example #8
Source File: MyBoxLanguagesController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
public void plusAction() {
    TextInputDialog dialog = new TextInputDialog("");
    dialog.setTitle(message("ManageLanguages"));
    dialog.setHeaderText(message("InputLangaugeName"));
    dialog.setContentText("");
    dialog.getEditor().setPrefWidth(200);
    Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();

    Optional<String> result = dialog.showAndWait();
    if (!result.isPresent() || result.get().trim().isBlank()) {
        return;
    }
    langName = result.get().trim();
    langLabel.setText(langName);
    loadLanguage(null);
}
 
Example #9
Source File: Network.java    From PeerWasp with MIT License 6 votes vote down vote up
@FXML
public void editAction(ActionEvent event) {
	// load current selection and allow user to change value
	int index = lwBootstrappingNodes.getSelectionModel().getSelectedIndex();
	String nodeAddress = lwBootstrappingNodes.getSelectionModel().getSelectedItem();

	TextInputDialog input = new TextInputDialog();
	DialogUtils.decorateDialogWithIcon(input);
	input.getEditor().setText(nodeAddress);
	input.setTitle("Edit Node Address");
	input.setHeaderText("Enter node address");
	Optional<String> result = input.showAndWait();

	if(result.isPresent()) {
		String newNodeAddress = result.get().trim();
		if (!newNodeAddress.isEmpty() && !containsAddress(newNodeAddress)) {
			addresses.add(index, newNodeAddress);
			addresses.remove(nodeAddress);
		}
	}
}
 
Example #10
Source File: MediaTableController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
public void addLinkAction() {
    try {
        // http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8
        TextInputDialog dialog = new TextInputDialog("http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8");
        dialog.setTitle(message("HTTPLiveStreaming"));
        dialog.setHeaderText(message("InputAddress"));
        dialog.setContentText("HLS(.m3u8)");
        dialog.getEditor().setPrefWidth(500);
        Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();

        Optional<String> result = dialog.showAndWait();
        if (!result.isPresent()) {
            return;
        }
        String address = result.get();
        addLink(address);

    } catch (Exception e) {
        logger.error(e.toString());
    }

}
 
Example #11
Source File: AddWebActionHandler.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handle(ActionEvent t) {
    TextInputDialog dialog = new TextInputDialog("http://");
    dialog.setTitle(LabelGrabber.INSTANCE.getLabel("website.dialog.title"));
    dialog.setHeaderText(LabelGrabber.INSTANCE.getLabel("website.dialog.header"));
    dialog.setContentText(LabelGrabber.INSTANCE.getLabel("website.dialog.content"));
    dialog.setGraphic(new ImageView(new Image("file:icons/website.png")));
    Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
    stage.getIcons().add(new Image("file:icons/web-small.png"));

    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        String url = result.get();
        if (!url.startsWith("http")) {
            url = "http://" + url;
        }
        WebDisplayable displayable = new WebDisplayable(url);
        QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList().add(displayable);
    }
}
 
Example #12
Source File: ArduinoLibraryInstaller.java    From tcMenu with Apache License 2.0 6 votes vote down vote up
/**
 * This method will be called internally by the above method when a non standard layout is detected.
 *
 * @return the arduino path wrapped in an optional, or nothing if cancel is pressed.
 */
private Optional<String> getArduinoPathWithDialog() {
    String savedPath = Preferences.userNodeForPackage(ArduinoLibraryInstaller.class)
            .get(ARDUINO_CUSTOM_PATH, homeDirectory);

    Path libsPath = Paths.get(savedPath, "libraries");
    if (Files.exists(libsPath)) return Optional.of(savedPath);

    TextInputDialog dialog = new TextInputDialog(savedPath);
    dialog.setTitle("Manually enter Arduino Path");
    dialog.setHeaderText("Please manually enter the full path to the Arduino folder");
    dialog.setContentText("Arduino Path");
    Optional<String> path = dialog.showAndWait();
    path.ifPresent((p) -> Preferences.userNodeForPackage(ArduinoLibraryInstaller.class).put(ARDUINO_CUSTOM_PATH, p));
    return path;
}
 
Example #13
Source File: GuiController.java    From BlockMap with MIT License 6 votes vote down vote up
@FXML
public void showUrlDialog() {
	TextInputDialog dialog = new TextInputDialog();
	dialog.setTitle("Load remote world");
	dialog.setHeaderText("Enter the URL to the remote world you want to load");
	dialog.setGraphic(null);
	dialog.setResult(serverSettingsController.lastBrowsedURL);
	dialog.showAndWait().ifPresent(s -> {
		try {
			loadRemote(new URI(s));
			serverSettingsController.lastBrowsedURL = s;
			worldInput.setText(s);
		} catch (URISyntaxException | IllegalArgumentException e) {
			log.warn("Malformed input uri", e);
			ExceptionDialog d = new ExceptionDialog(e);
			d.setTitle("Malformed input");
			d.showAndWait();
		}
	});
}
 
Example #14
Source File: JsonIODialog.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Displays a small window allowing the user to enter a name for the new
 * preference
 *
 * @author formalhaut69
 * @return A tuple, the first item is a Boolean indicating whether the user
 * selected to proceed with the operation or not, the second is the name of
 * the file requested by the user.
 */
public static Tuple<Boolean, String> getName() {
    String returnedName = "";

    // opens up a slightly different dialog window to allow the user to name the
    // preference when it is being saved
    // create a text input dialog 
    TextInputDialog td = new TextInputDialog();
    td.setTitle("Preference name");
    // setHeaderText 
    td.setHeaderText("Enter a name for the preference");
    Optional<String> result = td.showAndWait();
    if (result.isPresent()) {
        returnedName = td.getEditor().getText();
    }
    return new Tuple<>(result.isPresent(), returnedName);
}
 
Example #15
Source File: ClientDisplay.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param title      null if user pressed cancel, or the text entered if pressed
 *                   OK (if pressed OK with no text entered, empty string is
 *                   brought back
 * @param textlength the maximum length of text to enter
 * @return
 */
public String showModalTextEntry(String title, int textlength) {
	logger.fine("NormalTextEntry " + title + " - " + textlength);

	logger.fine(" prepare to launch dialog");
	TextInputDialog dialog = new TextInputDialog();

	dialog.setHeaderText("Enter Update Note below");
	dialog.setContentText("");

	Optional<String> result = dialog.showAndWait();
	logger.fine(" dialog is displayed");

	if (!result.isPresent())
		return null;
	return result.get();

}
 
Example #16
Source File: DialogUtils.java    From qiniu with MIT License 5 votes vote down vote up
public static String showInputDialog(String header, String content, String defaultValue) {
    TextInputDialog dialog = new TextInputDialog(defaultValue);
    dialog.setTitle(QiniuValueConsts.MAIN_TITLE);
    dialog.setHeaderText(header);
    dialog.setContentText(content);
    Optional<String> result = dialog.showAndWait();
    return result.orElse(null);
}
 
Example #17
Source File: ExportTemplateTest.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void commonCanDoFixture() {
	final SystemUtils utils = Mockito.mock(SystemUtils.class);
	Mockito.when(utils.getPathTemplatesDirUser()).thenReturn("");
	SystemUtils.setSingleton(utils);
	svgGen = Mockito.mock(SVGDocumentGenerator.class);
	ui = Mockito.mock(JfxUI.class);
	statusWidget = Mockito.mock(Label.class);
	progressBar = Mockito.mock(ProgressBar.class);
	templatesPane = Mockito.mock(Pane.class);
	alertName = Mockito.mock(Alert.class);
	inputName = Mockito.mock(TextInputDialog.class);
	cmd = new ExportTemplate(templatesPane, svgGen, ui, progressBar, statusWidget, alertName, inputName);
}
 
Example #18
Source File: RenameSampleCommand.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
public void actionPerformed(ActionEvent event) {
    SamplesViewer viewer = (SamplesViewer) getViewer();
    String sampleName = viewer.getSamplesTableView().getASelectedSample();
    String newName = null;
    if (Platform.isFxApplicationThread()) {
        TextInputDialog dialog = new TextInputDialog(sampleName);
        dialog.setTitle("Rename sample");
        dialog.setHeaderText("Enter new sample name:");

        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            newName = result.get().trim();
        }
    } else if (javax.swing.SwingUtilities.isEventDispatchThread()) {
        newName = JOptionPane.showInputDialog(getViewer().getFrame(), "Enter new sample name", sampleName);
    }

    if (newName != null && !newName.equals(sampleName)) {
        if (viewer.getSampleAttributeTable().getSampleOrder().contains(newName)) {
            int count = 1;
            while (viewer.getSampleAttributeTable().getSampleOrder().contains(newName + "." + count))
                count++;
            newName += "." + count;
        }
        execute("rename sample='" + sampleName + "' newName='" + newName + "';" +
                "labelBy attribute='" + SampleAttributeTable.SAMPLE_ID + "'  samples=all;");
    }
}
 
Example #19
Source File: NewVitaminWizardController.java    From BowlerStudio with GNU General Public License v3.0 5 votes vote down vote up
@FXML
  void onNewMeasurment(ActionEvent event) {
newMeasurmentButton.setDisable(true);
TextInputDialog dialog = new TextInputDialog("lengthOfThing");
dialog.setTitle("Add new measurment to "+typeOfVitaminString);
dialog.setHeaderText("This measurment will be added to all instances of the vitamin");
dialog.setContentText("New measurment name:");

// Traditional way to get the response value.
Optional<String> result = dialog.showAndWait();
// The Java 8 way to get the response value (with lambda expression).
result.ifPresent(name -> { 
	TextInputDialog dialog2 = new TextInputDialog("0.0");
	dialog2.setTitle("Set value of "+name);
	dialog2.setHeaderText("This value will be added to all instances of the vitamin");
	dialog2.setContentText(name+" = ");

	// Traditional way to get the response value.
	Optional<String> result2 = dialog2.showAndWait();
	result2.ifPresent(name2 -> { 
		setupKeyValueToTable(name,name2,sizeOfVitaminString);
		for(String size:Vitamins.listVitaminSizes(typeOfVitaminString)) {
			Vitamins.getConfiguration(typeOfVitaminString, size).put(name,name2);
		}
	});
	newMeasurmentButton.setDisable(false);
	
});


  }
 
Example #20
Source File: FeatureTableColumnsEditor.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public FeatureTableColumnsEditor(PropertySheet.Item parameter) {

    // HBox properties
    setSpacing(10);
    setAlignment(Pos.CENTER_LEFT);

    namePatternList = new ListView<>();
    namePatternList.setEditable(true);
    namePatternList.setPrefHeight(150);
    namePatternList.setCellFactory(TextFieldListCell.forListView());

    Button addButton = new Button("Add");
    addButton.setOnAction(e -> {
      TextInputDialog dialog = new TextInputDialog();
      dialog.setTitle("Add name pattern");
      dialog.setHeaderText("New name pattern");
      Optional<String> result = dialog.showAndWait();
      result.ifPresent(value -> namePatternList.getItems().add(value));
    });

    Button removeButton = new Button("Remove");
    removeButton.setOnAction(e -> {
      List<String> selectedItems = namePatternList.getSelectionModel().getSelectedItems();
      namePatternList.getItems().removeAll(selectedItems);
    });

    VBox buttons = new VBox(addButton, removeButton);
    buttons.setSpacing(10);

    getChildren().addAll(namePatternList, buttons);
  }
 
Example #21
Source File: PCGenFrame.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Optional<String> showInputDialog(String title, String message, String initialValue)
{
	GuiAssertions.assertIsNotJavaFXThread();
	TextInputDialog dialog = GuiUtility.runOnJavaFXThreadNow(() -> new TextInputDialog(initialValue));
	dialog.setTitle(title);
	dialog.setContentText(message);
	return GuiUtility.runOnJavaFXThreadNow(dialog::showAndWait);
}
 
Example #22
Source File: Controller.java    From uip-pc2 with MIT License 5 votes vote down vote up
public void solicitar(ActionEvent actionEvent) {
    TextInputDialog dialogo = new TextInputDialog("0");
    dialogo.setTitle("Solicitud de Datos");
    dialogo.setContentText("Ingrese un numero:");
    Optional<String> resultado = dialogo.showAndWait();
    if (resultado.isPresent()) {
        System.out.println("Numero: " + resultado.get());
        numero = Integer.parseInt(resultado.get());
    }
}
 
Example #23
Source File: FxHelper.java    From TerminalFX with MIT License 5 votes vote down vote up
public static String askInput(String message) {
    CompletableFuture<String> completableFuture = new CompletableFuture<String>();
    completableFuture.runAsync(() -> {
        ThreadHelper.runActionLater(() -> {
            TextInputDialog inputDialog = new TextInputDialog();
            inputDialog.setContentText(message);
            Optional<String> optional = inputDialog.showAndWait();
            completableFuture.complete(optional.orElseGet(() -> null));
        });
    });

    return completableFuture.join();
}
 
Example #24
Source File: FleetTabPane.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * 分岐点係数を変更する
 *
 * @param event ActionEvent
 */
@FXML
void changeBranchCoefficient(ActionEvent event) {
    TextInputDialog dialog = new TextInputDialog(Double.toString(this.branchCoefficient));
    dialog.getDialogPane().getStylesheets().add("logbook/gui/application.css");
    InternalFXMLLoader.setGlobal(dialog.getDialogPane());
    dialog.initOwner(this.getScene().getWindow());
    dialog.setTitle("分岐点係数を変更");
    dialog.setHeaderText("分岐点係数を数値で入力してください 例)\n"
            + "沖ノ島沖 G,I,Jマス 係数: 1.0\n"
            + "北方AL海域 Gマス 係数: 4.0\n"
            + "中部海域哨戒線 G,Hマス 係数: 4.0\n"
            + "MS諸島沖 E,Iマス 係数: 3.0\n"
            + "グアノ環礁沖海域 Hマス 係数: 3.0");

    val result = dialog.showAndWait();
    if (result.isPresent()) {
        String value = result.get();
        if (!value.isEmpty()) {
            try {
                this.branchCoefficient = Double.parseDouble(value);
                this.setDecision33();
            } catch (NumberFormatException e) {
            }
        }
    }
}
 
Example #25
Source File: PCGenFrame.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Optional<String> showInputDialog(String title, String message, String initialValue)
{
	GuiAssertions.assertIsNotJavaFXThread();
	TextInputDialog dialog = GuiUtility.runOnJavaFXThreadNow(() -> new TextInputDialog(initialValue));
	dialog.setTitle(title);
	dialog.setContentText(message);
	return GuiUtility.runOnJavaFXThreadNow(dialog::showAndWait);
}
 
Example #26
Source File: Network.java    From PeerWasp with MIT License 5 votes vote down vote up
@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 #27
Source File: ExportTemplate.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
public ExportTemplate(final @NotNull Pane templatesPane, final @NotNull SVGDocumentGenerator svgGen, final @NotNull JfxUI ui,
		final @NotNull ProgressBar progressBar, final @NotNull Label statusWidget, final @NotNull Alert alertName,
		final @NotNull TextInputDialog nameInput) {
	super(null, svgGen, progressBar, statusWidget, ui);
	this.templatesPane = templatesPane;
	this.svgGen = svgGen;
	this.nameInput = nameInput;
	this.alertName = alertName;
}
 
Example #28
Source File: SaveLayoutMenuItem.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Save the layout. Prompt for a new filename, validate, possibly confirm an overwrite, and then save.
 *  @return <code>true</code> if layout save has been initiated (may take some time to complete)
 */
private boolean saveLayout()
{
    final TextInputDialog prompt = new TextInputDialog();
    prompt.setTitle(getText());
    prompt.setHeaderText(Messages.SaveDlgHdr);
    positionDialog(prompt);

    while (true)
    {
        final String filename = prompt.showAndWait().orElse(null);

        // Canceled?
        if (filename == null)
            return false;
        // OK to save?
        if (! validateFilename(filename))
        {
            // Ask again
            prompt.setHeaderText(Messages.SaveDlgErrHdr);
            continue;
        }
        else
            prompt.setHeaderText(Messages.SaveDlgHdr);

        // Done if save succeeded.
        if (saveState(filename))
            return true;
    }
}
 
Example #29
Source File: NamePaneMenuItem.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Edit name of dock pane */
private void editName(final DockPane pane)
{
    final TextInputDialog dialog = new TextInputDialog(pane.getName());
    dialog.setTitle(Messages.NamePane);
    dialog.setHeaderText(Messages.NamePaneHdr);
    DialogHelper.positionDialog(dialog, pane, -200, -100);
    dialog.showAndWait().ifPresent(pane::setName);
}
 
Example #30
Source File: DuplicatePVAction.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** @param node Node to position dialog
 *  @param model Model where new component is added
 *  @param parent Parent item in alarm tree
 */
public DuplicatePVAction(final Node node, final AlarmClient model, final AlarmClientLeaf original)
{
    super("Duplicate PV", ImageCache.getImageView(AlarmSystem.class, "/icons/move.png"));
    setOnAction(event ->
    {
        // Prompt for new PV name
        final TextInputDialog dialog = new TextInputDialog();
        dialog.setTitle(getText());
        dialog.setHeaderText("Enter name for duplicate of\n" + original.getPathName());
        DialogHelper.positionDialog(dialog, node, -100, -50);
        final String new_name = dialog.showAndWait().orElse(null);
        if (new_name == null  ||  new_name.isEmpty())
            return;

        // Create near copy of original PV, but with new name
        final AlarmClientLeaf template = new AlarmClientLeaf(null, new_name);
        template.setDescription(original.getDescription());
        template.setEnabled(original.isEnabled());
        template.setLatching(original.isLatching());
        template.setAnnunciating(original.isAnnunciating());
        template.setDelay(original.getDelay());
        template.setCount(original.getCount());
        template.setFilter(original.getFilter());
        template.setGuidance(original.getGuidance());
        template.setDisplays(original.getDisplays());
        template.setCommands(original.getCommands());
        template.setActions(original.getActions());

        // Request adding new PV
        final String new_path = AlarmTreePath.makePath(original.getParent().getPathName(), new_name);
        JobManager.schedule(getText(), monitor -> model.sendItemConfigurationUpdate(new_path, template));
    });
}