Java Code Examples for javafx.scene.control.Alert#setResizable()

The following examples show how to use javafx.scene.control.Alert#setResizable() . 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: QueryListDialog.java    From constellation with Apache License 2.0 7 votes vote down vote up
static String getQueryName(final Object owner, final String[] queryNames) {
    final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);

    final ObservableList<String> q = FXCollections.observableArrayList(queryNames);
    final ListView<String> nameList = new ListView<>(q);
    nameList.setCellFactory(p -> new DraggableCell<>());
    nameList.setEditable(false);
    nameList.setOnMouseClicked(event -> {
        if (event.getClickCount() > 1) {
            dialog.setResult(ButtonType.OK);
        }
    });

    dialog.setResizable(false);
    dialog.setTitle("Query names");
    dialog.setHeaderText("Select a query to load.");
    dialog.getDialogPane().setContent(nameList);
    final Optional<ButtonType> option = dialog.showAndWait();
    if (option.isPresent() && option.get() == ButtonType.OK) {
        return nameList.getSelectionModel().getSelectedItem();
    }

    return null;
}
 
Example 2
Source File: QueryListDialog.java    From constellation with Apache License 2.0 6 votes vote down vote up
static String getQueryName(final Object owner, final String[] labels) {
    final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);
    dialog.setTitle("Saved JDBC parameters");

    final ObservableList<String> q = FXCollections.observableArrayList(labels);
    final ListView<String> labelList = new ListView<>(q);
    labelList.setEditable(false);
    labelList.setOnMouseClicked(event -> {
        if (event.getClickCount() > 1) {
            dialog.setResult(ButtonType.OK);
        }
    });

    dialog.setResizable(false);
    dialog.setHeaderText("Select a parameter set to load.");
    dialog.getDialogPane().setContent(labelList);
    final Optional<ButtonType> option = dialog.showAndWait();
    if (option.isPresent() && option.get() == ButtonType.OK) {
        return labelList.getSelectionModel().getSelectedItem();
    }

    return null;
}
 
Example 3
Source File: DisplayEditorApplication.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public DisplayEditorInstance create()
{
    if (!AuthorizationService.hasAuthorization("edit_display"))
    {
        // User does not have a permission to start editor
        final Alert alert = new Alert(Alert.AlertType.WARNING);
        DialogHelper.positionDialog(alert, DockPane.getActiveDockPane(), -200, -100);
        alert.initOwner(DockPane.getActiveDockPane().getScene().getWindow());
        alert.setResizable(true);
        alert.setTitle(DISPLAY_NAME);
        alert.setHeaderText(Messages.DisplayApplicationMissingRight);
        // Autohide in some seconds, also to handle the situation after
        // startup without edit_display rights but opening editor from memento
        PauseTransition wait = new PauseTransition(Duration.seconds(7));
        wait.setOnFinished((e) -> {
            Button btn = (Button)alert.getDialogPane().lookupButton(ButtonType.OK);
            btn.fire();
        });
        wait.play();
        
        alert.showAndWait();
        return null;
    }
    return new DisplayEditorInstance(this);
}
 
Example 4
Source File: AppUtils.java    From OEE-Designer with MIT License 6 votes vote down vote up
public static ButtonType showAlert(AlertType type, String title, String header, String errorMessage) {
	// Show the error message.
	Alert alert = new Alert(type);
	alert.setTitle(title);
	alert.setHeaderText(header);
	alert.setContentText(errorMessage);
	alert.setResizable(true);

	// modal
	Optional<ButtonType> result = alert.showAndWait();

	ButtonType buttonType = null;
	try {
		buttonType = result.get();
	} catch (NoSuchElementException e) {
	}
	return buttonType;
}
 
Example 5
Source File: DialogUtils.java    From PeerWasp with MIT License 6 votes vote down vote up
/**
 * Creates an Alert dialog of given alert type.
 * In addition, the dialog is decorated and configured (icons, ...).
 *
 * @param type of the alert
 * @return alert dialog
 */
public static Alert createAlert(AlertType type) {
	Alert dlg = new Alert(type);
	decorateDialogWithIcon(dlg);

	if (OsUtils.isLinux()) {
		/*
		 * FIXME: Due to a bug in JavaFX and Java for linux (glass), the dialogs are not
		 * represented correctly. The size does not increase with the text length and is
		 * cut off if the text is too long (no wrapping).
		 * see the following links:
		 * - https://stackoverflow.com/questions/28937392/javafx-alerts-and-their-size
		 * - https://javafx-jira.kenai.com/browse/RT-40230
		 * Temporary solution: we make dialogs resizable and set a preferred size on Linux.
		 */
		dlg.setResizable(true);
		dlg.getDialogPane().setPrefSize(420, 280);
	}

	return dlg;
}
 
Example 6
Source File: DockItem.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Show info dialog */
private void showInfo()
{
    final Alert dlg = new Alert(AlertType.INFORMATION);
    dlg.setTitle(Messages.DockInfo);

    // No DialogPane 'header', all info is in the 'content'
    dlg.setHeaderText("");

    final StringBuilder info = new StringBuilder();
    fillInformation(info);
    final TextArea content = new TextArea(info.toString());
    content.setEditable(false);
    content.setPrefSize(300, 100);
    content.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    dlg.getDialogPane().setContent(content);

    DialogHelper.positionDialog(dlg, name_tab, 0, 0);
    dlg.setResizable(true);
    dlg.showAndWait();
}
 
Example 7
Source File: TargetDistancePane.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
private boolean validateDistanceData() {
	boolean isValid = validateDistanceField(shooterDistance);
	isValid = validateDistanceField(targetDistance) && isValid;
	isValid = validateDistanceField(cameraDistance) && isValid;
	isValid = validateDistanceField(targetWidth) && isValid;
	isValid = validateDistanceField(targetHeight) && isValid;

	if (!isValid) return isValid;

	if ("0".equals(targetDistance.getText())) {
		final Alert invalidDataAlert = new Alert(AlertType.ERROR);

		final String message = "Target Distance cannot be 0, please set a value greater than 0.";

		invalidDataAlert.setTitle("Invalid Target Distance");
		invalidDataAlert.setHeaderText("Target Distance Cannot Be Zero");
		invalidDataAlert.setResizable(true);
		invalidDataAlert.setContentText(message);
		invalidDataAlert.initOwner(getScene().getWindow());
		invalidDataAlert.showAndWait();

		isValid = false;
	}

	return isValid;
}
 
Example 8
Source File: JsonIODialog.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * *
 * Present a dialog allowing user to select an entry from a list of
 * available files.
 *
 * @param names list of filenames to choose from
 * @return the selected element text or null if nothing was selected
 */
public static String getSelection(final String[] names) {
    final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);
    final ObservableList<String> q = FXCollections.observableArrayList(names);
    final ListView<String> nameList = new ListView<>(q);

    nameList.setCellFactory(p -> new DraggableCell<>());
    nameList.setEditable(false);
    nameList.setOnMouseClicked(event -> {
        if (event.getClickCount() > 1) {
            dialog.setResult(ButtonType.OK);
        }
    });
    ButtonType removeButton = new ButtonType("Remove");
    dialog.getDialogPane().setContent(nameList);
    dialog.getButtonTypes().add(removeButton);
    dialog.setResizable(false);
    dialog.setTitle("Preferences");
    dialog.setHeaderText("Select a preference to load.");

    // The remove button has been wrapped inside the btOk, this has been done because any ButtonTypes added
    // to an alert window will automatically close the window when pressed. 
    // Wrapping it in another button can allow us to consume the closing event and keep the window open.
    final Button btOk = (Button) dialog.getDialogPane().lookupButton(removeButton);
    btOk.addEventFilter(ActionEvent.ACTION, event -> {
        JsonIO.deleteJsonPreference(nameList.getSelectionModel().getSelectedItem());
        q.remove(nameList.getSelectionModel().getSelectedItem());
        nameList.setCellFactory(p -> new DraggableCell<>());
        dialog.getDialogPane().setContent(nameList);
        event.consume();
    });
    final Optional<ButtonType> option = dialog.showAndWait();
    if (option.isPresent() && option.get() == ButtonType.OK) {
        return nameList.getSelectionModel().getSelectedItem();
    }

    return null;
}
 
Example 9
Source File: QualityControlViewPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Display a dialog containing all Rule objects registered with the Quality
 * Control View and which matched for a given identifier.
 *
 * @param owner The owner Node
 * @param identifier The identifier of the graph node being displayed.
 * @param rules The list of rules measured against this graph node.
 */
private static void showRuleDialog(final Node owner, final String identifier, final List<Pair<Integer, String>> rules) {
    final ScrollPane sp = new ScrollPane();
    sp.setPrefHeight(512);
    sp.setPrefWidth(512);
    sp.setFitToWidth(true);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);

    final VBox vbox = new VBox();
    vbox.prefWidthProperty().bind(sp.widthProperty());
    vbox.setPadding(Insets.EMPTY);
    for (final Pair<Integer, String> rule : rules) {
        final String[] t = rule.getValue().split("ยง");

        final String quality = rule.getKey() == 0 ? Bundle.MSG_NotApplicable() : "" + rule.getKey();
        final String title = String.format("%s - %s", quality, t[0]);

        final Text content = new Text(t[1]);
        content.wrappingWidthProperty().bind(sp.widthProperty().subtract(16)); // Subtract a random number to avoid the vertical scrollbar.

        final TitledPane tp = new TitledPane(title, content);
        tp.prefWidthProperty().bind(vbox.widthProperty());
        tp.setExpanded(false);
        tp.setWrapText(true);

        vbox.getChildren().add(tp);
    }
    sp.setContent(vbox);

    final Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setHeaderText(String.format(Bundle.MSG_QualtyControlRules(), identifier));
    alert.getDialogPane().setContent(sp);
    alert.setResizable(true);
    alert.show();
}
 
Example 10
Source File: DockItemWithInput.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Called when user tries to close the tab
 *
 *  <p>Derived class may override.
 *
 *  @return Should the tab close? Otherwise it stays open.
 */
protected boolean okToClose()
{
    if (! isDirty())
        return true;

    final String text = MessageFormat.format(Messages.DockAlertMsg, getLabel());
    final Alert prompt = new Alert(AlertType.NONE,
                                   text,
                                   ButtonType.NO, ButtonType.CANCEL, ButtonType.YES);
    prompt.setTitle(Messages.DockAlertTitle);
    prompt.getDialogPane().setMinSize(300, 100);
    prompt.setResizable(true);
    DialogHelper.positionDialog(prompt, getTabPane(), -200, -100);
    final ButtonType result = prompt.showAndWait().orElse(ButtonType.CANCEL);

    // Cancel the close request
    if (result == ButtonType.CANCEL)
        return false;

    // Close without saving?
    if (result == ButtonType.NO)
        return true;

    // Save in background job ...
    JobManager.schedule(Messages.Save, monitor -> save(monitor));
    // .. and leave the tab open, so user can then try to close again
    return false;
}
 
Example 11
Source File: DesignerApplication.java    From OEE-Designer with MIT License 5 votes vote down vote up
void showAboutDialog() throws Exception {
	Alert alert = new Alert(AlertType.INFORMATION);
	alert.setTitle(DesignerLocalizer.instance().getLangString("about"));
	alert.setHeaderText(DesignerLocalizer.instance().getLangString("about.header"));
	alert.setContentText(DomainUtils.getVersionInfo());
	alert.setResizable(true);

	alert.showAndWait();
}
 
Example 12
Source File: LauncherUpdater.java    From TerasologyLauncher with Apache License 2.0 5 votes vote down vote up
private FutureTask<Boolean> getUpdateDialog(Stage parentStage, GHRelease release) {
    final String infoText = "  " +
            BundleUtils.getLabel("message_update_current") +
            "  " +
            currentVersion.getValue() +
            "  \n" +
            "  " +
            BundleUtils.getLabel("message_update_latest") +
            "  " +
            versionOf(release).getValue() +
            "  ";

    return new FutureTask<>(() -> {
        Parent root = BundleUtils.getFXMLLoader("update_dialog").load();
        ((TextArea) root.lookup("#infoTextArea")).setText(infoText);
        ((TextArea) root.lookup("#changelogTextArea")).setText(release.getBody());

        final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle(BundleUtils.getLabel("message_update_launcher_title"));
        alert.setHeaderText(BundleUtils.getLabel("message_update_launcher"));
        alert.getDialogPane().setContent(root);
        alert.initOwner(parentStage);
        alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO);
        alert.initModality(Modality.APPLICATION_MODAL);
        alert.setResizable(true);

        return alert.showAndWait()
                .filter(response -> response == ButtonType.YES)
                .isPresent();
    });
}
 
Example 13
Source File: ExceptionDetailsErrorDialog.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private static void doOpenError(final Node node, final String title, final String message, final Exception exception)
{
    final Alert dialog = new Alert(AlertType.ERROR);
    dialog.setTitle(title);
    dialog.setHeaderText(message);

    if (exception != null)
    {
        // Show the simple exception name,
        // e.g. "Exception" or "FileAlreadyExistsException" without package name,
        // followed by message
        dialog.setContentText(exception.getClass().getSimpleName() + ": " + exception.getMessage());

        // Show exception stack trace in expandable section of dialog
        final ByteArrayOutputStream buf = new ByteArrayOutputStream();
        exception.printStackTrace(new PrintStream(buf));

        // User can copy trace out of read-only text area
        final TextArea trace = new TextArea(buf.toString());
        trace.setEditable(false);
        dialog.getDialogPane().setExpandableContent(trace);
    }

    dialog.setResizable(true);
    dialog.getDialogPane().setPrefWidth(800);

    if (node != null)
        DialogHelper.positionDialog(dialog, node, -400, -200);

    dialog.showAndWait();
}
 
Example 14
Source File: AppUtils.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
public static void showErrorDialog(String title, String content) {
	Alert dialog = new Alert(Alert.AlertType.ERROR);
	dialog.setTitle(title);
	dialog.setHeaderText(null);
	dialog.setResizable(true);
	dialog.setContentText(content);
	dialog.showAndWait();
}
 
Example 15
Source File: WKTPane.java    From sis with Apache License 2.0 5 votes vote down vote up
public static void showDialog(Object parent, FormattableObject candidate){
    final WKTPane chooser = new WKTPane(candidate);

    final Alert alert = new Alert(Alert.AlertType.NONE);
    final DialogPane pane = alert.getDialogPane();
    pane.setContent(chooser);
    alert.getButtonTypes().setAll(ButtonType.OK);
    alert.setResizable(true);
    alert.showAndWait();
}
 
Example 16
Source File: OpenAbout.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Void call()
{
    dialog = new Alert(AlertType.INFORMATION);
    dialog.setTitle(Messages.HelpAboutTitle);
    dialog.setHeaderText(Messages.HelpAboutHdr);

    // Table with Name, Value columns
    final ObservableList<List<String>> infos = FXCollections.observableArrayList();
    // Start with most user-specific to most generic: User location, install, JDK, ...
    // Note that OpenFileBrowserCell is hard-coded to add a "..." button for the first few rows.
    infos.add(Arrays.asList(Messages.HelpAboutUser, Locations.user().toString()));
    infos.add(Arrays.asList(Messages.HelpAboutInst, Locations.install().toString()));
    infos.add(Arrays.asList(Messages.HelpAboutUserDir, System.getProperty("user.dir")));
    infos.add(Arrays.asList(Messages.HelpJavaHome, System.getProperty("java.home")));
    infos.add(Arrays.asList(Messages.AppVersionHeader, Messages.AppVersion));
    infos.add(Arrays.asList(Messages.HelpAboutJava, System.getProperty("java.specification.vendor") + " " + System.getProperty("java.runtime.version")));
    infos.add(Arrays.asList(Messages.HelpAboutJfx, System.getProperty("javafx.runtime.version")));
    infos.add(Arrays.asList(Messages.HelpAboutPID, Long.toString(ProcessHandle.current().pid())));

    // Display in TableView
    final TableView<List<String>> info_table = new TableView<>(infos);
    info_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    info_table.setPrefHeight(290.0);

    final TableColumn<List<String>, String> name_col = new TableColumn<>(Messages.HelpAboutColName);
    name_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(0)));
    info_table.getColumns().add(name_col);

    final TableColumn<List<String>, String> value_col = new TableColumn<>(Messages.HelpAboutColValue);
    value_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1)));
    value_col.setCellFactory(col -> new ReadOnlyTextCell<>());
    info_table.getColumns().add(value_col);

    final TableColumn<List<String>, String> link_col = new TableColumn<>();
    link_col.setMinWidth(50);
    link_col.setMaxWidth(50);
    link_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1)));
    link_col.setCellFactory(col ->  new OpenFileBrowserCell());
    info_table.getColumns().add(link_col);

    dialog.getDialogPane().setContent(info_table);

    // Info for expandable "Show Details" section
    dialog.getDialogPane().setExpandableContent(createDetailSection());

    dialog.setResizable(true);
    dialog.getDialogPane().setPrefWidth(800);
    DialogHelper.positionDialog(dialog, DockPane.getActiveDockPane(), -400, -300);

    dialog.showAndWait();
    // Indicate that dialog is closed; allow GC
    dialog = null;

    return null;
}
 
Example 17
Source File: DisplayEditorApplication.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private URI getFileResource(final URI original_resource)
{
    try
    {
        // Strip query from resource, because macros etc.
        // are only relevant to runtime, not to editor
        final URI resource = new URI(original_resource.getScheme(), original_resource.getUserInfo(),
                                     original_resource.getHost(), original_resource.getPort(),
                                     original_resource.getPath(), null, null);

        // Does the resource already point to a local file?
        File file = ModelResourceUtil.getFile(resource);
        if (file != null)
        {
            last_local_file = file;
            return file.toURI();
        }

        // Does user want to download into local file?
        final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        DialogHelper.positionDialog(alert, DockPane.getActiveDockPane(), -200, -100);
        alert.initOwner(DockPane.getActiveDockPane().getScene().getWindow());
        alert.setResizable(true);
        alert.setTitle(Messages.DownloadTitle);
        alert.setHeaderText(MessageFormat.format(Messages.DownloadPromptFMT,
                                                 resource.toString()));
        // Setting "Yes", "No" buttons
        alert.getButtonTypes().clear();
        alert.getButtonTypes().add(ButtonType.YES);
        alert.getButtonTypes().add(ButtonType.NO);
        if (alert.showAndWait().orElse(ButtonType.NO) == ButtonType.NO)
            return null;

        // Prompt for local file
        final File local_file = promptForFilename(Messages.DownloadTitle);
        if (local_file == null)
            return null;

        // In background thread, ..
        JobManager.schedule(Messages.DownloadTitle, monitor ->
        {
            monitor.beginTask("Download " + resource);
            // .. download resource into local file ..
            try
            (
                final InputStream read = ModelResourceUtil.openResourceStream(resource.toString());
            )
            {
                Files.copy(read, local_file.toPath(), StandardCopyOption.REPLACE_EXISTING);
            }
            // .. and then, back on UI thread, open editor for the local file
            Platform.runLater(() -> create(ResourceParser.getURI(local_file)));
        });

        // For now, return null, no editor is opened right away.
    }
    catch (Exception ex)
    {
        ExceptionDetailsErrorDialog.openError("Error", "Cannot load " + original_resource, ex);
    }
    return null;
}
 
Example 18
Source File: UpdateApplication.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private void promptForUpdate(final Node node, final Instant new_version)
{
    final File install_location = Locations.install();
    // Want to  update install_location, but that's locked on Windows,
    // and replacing the jars of a running application might be bad.
    // So download into a stage area.
    // The start script needs to be aware of this stage area
    // and move it to the install location on startup.
    final File stage_area = new File(install_location, "update");
    final StringBuilder buf = new StringBuilder();
    buf.append("You are running version  ")
       .append(TimestampFormats.DATETIME_FORMAT.format(Update.current_version))
       .append("\n")
       .append("The new version is dated ")
       .append(TimestampFormats.DATETIME_FORMAT.format(new_version))
       .append("\n\n")
       .append("The update will replace the installation in\n")
       .append(install_location)
       .append("\n(").append(stage_area).append(")")
       .append("\nwith the content of ")
       .append(Update.update_url)
       .append("\n\n")
       .append("Do you want to update?\n");

    final Alert prompt = new Alert(AlertType.INFORMATION,
                                   buf.toString(),
                                   ButtonType.OK, ButtonType.CANCEL);
    prompt.setTitle(NAME);
    prompt.setHeaderText("A new version of this software is available");
    prompt.setResizable(true);
    DialogHelper.positionDialog(prompt, node, -600, -350);
    prompt.getDialogPane().setPrefSize(600, 300);
    if (prompt.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK)
    {
        // Show job manager to display progress
        ApplicationService.findApplication(JobViewerApplication.NAME).create();
        // Perform update
        JobManager.schedule(NAME, monitor ->
        {
            Update.downloadAndUpdate(monitor, stage_area);
            Update.adjustCurrentVersion();
            if (! monitor.isCanceled())
                Platform.runLater(() -> restart(node));
        });
    }
    else
    {
        // Remove the update button
        StatusBar.getInstance().removeItem(start_update);
        start_update = null;
    }
}
 
Example 19
Source File: Configuration.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
public Optional<Camera> registerIpCam(String cameraName, String cameraURL, Optional<String> username,
		Optional<String> password) {
	try {
		final URL url = new URL(cameraURL);
		final Camera cam = IpCamera.registerIpCamera(cameraName, url, username, password);
		ipcams.put(cameraName, url);

		if (username.isPresent() && password.isPresent()) {
			ipcamCredentials.put(cameraName, username.get() + "|" + password.get());
		}

		return Optional.of(cam);
	} catch (MalformedURLException | URISyntaxException ue) {
		final Alert ipcamURLAlert = new Alert(AlertType.ERROR);
		ipcamURLAlert.setTitle("Malformed URL");
		ipcamURLAlert.setHeaderText("IPCam URL is Malformed!");
		ipcamURLAlert.setResizable(true);
		ipcamURLAlert.setContentText("IPCam URL is not valid: \n\n" + ue.getMessage());
		ipcamURLAlert.showAndWait();
	} catch (final UnknownHostException uhe) {
		final Alert ipcamHostAlert = new Alert(AlertType.ERROR);
		ipcamHostAlert.setTitle("Unknown Host");
		ipcamHostAlert.setHeaderText("IPCam URL Unknown!");
		ipcamHostAlert.setResizable(true);
		ipcamHostAlert.setContentText("The IPCam at " + cameraURL
				+ " cannot be resolved. Ensure the URL is correct "
				+ "and that you are either connected to the internet or on the same network as the camera.");
		ipcamHostAlert.showAndWait();
	} catch (final TimeoutException te) {
		final Alert ipcamTimeoutAlert = new Alert(AlertType.ERROR);
		ipcamTimeoutAlert.setTitle("IPCam Timeout");
		ipcamTimeoutAlert.setHeaderText("Connection to IPCam Reached Timeout!");
		ipcamTimeoutAlert.setResizable(true);
		ipcamTimeoutAlert.setContentText("Could not communicate with the IP at " + cameraURL
				+ ". Please check the following:\n\n" + "-The IPCam URL is correct\n"
				+ "-You are connected to the Internet (for external cameras)\n"
				+ "-You are connected to the same network as the camera (for local cameras)");
		ipcamTimeoutAlert.showAndWait();
	}

	return Optional.empty();
}
 
Example 20
Source File: TemplateListDialog.java    From constellation with Apache License 2.0 4 votes vote down vote up
String getName(final Object owner, final File delimIoDir) {
    final String[] templateLabels = getFileLabels(delimIoDir);

    final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);

    final TextField label = new TextField();
    label.setPromptText("Template label");

    final ObservableList<String> q = FXCollections.observableArrayList(templateLabels);
    final ListView<String> nameList = new ListView<>(q);
    nameList.setEditable(false);
    nameList.setOnMouseClicked(event -> {
        label.setText(nameList.getSelectionModel().getSelectedItem());
        if (event.getClickCount() > 1) {
            dialog.setResult(ButtonType.OK);
        }
    });

    final HBox prompt = new HBox(new Label("Name: "), label);
    prompt.setPadding(new Insets(10, 0, 0, 0));

    final VBox vbox = new VBox(nameList, prompt);

    dialog.setResizable(false);
    dialog.setTitle("Import template names");
    dialog.setHeaderText(String.format("Select an import template to %s.", isLoading ? "load" : "save"));
    dialog.getDialogPane().setContent(vbox);
    final Optional<ButtonType> option = dialog.showAndWait();
    if (option.isPresent() && option.get() == ButtonType.OK) {
        final String name = label.getText();
        final File f = new File(delimIoDir, FilenameEncoder.encode(name + ".json"));
        boolean go = true;
        if (!isLoading && f.exists()) {
            final String msg = String.format("'%s' already exists. Do you want to overwrite it?", name);
            final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
            alert.setHeaderText("Import template exists");
            alert.setContentText(msg);
            final Optional<ButtonType> confirm = alert.showAndWait();
            go = confirm.isPresent() && confirm.get() == ButtonType.OK;
        }

        if (go) {
            return name;
        }
    }

    return null;
}