下面列出了javafx.scene.control.Alert#getDialogPane ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@FXML
private void adminLoginAction(){
String userName = txtAdminUserName.getText();
String password = txtAdminPassword.getText();
if (!userName.isEmpty() && !password.isEmpty()){
for (AdminDTO adminDTO: adminDTOList
) {
if (adminDTO.getAdminName().equals(userName) && adminDTO.getPassword().equals(password)){
loadDashBoardUI();
}else {
Alert adminLoginFailedAlert = new Alert(Alert.AlertType.ERROR);
DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
dialogPane
.getStylesheets().add(getClass()
.getResource("/css/dialog-pane-styles.css")
.toExternalForm());
dialogPane.getStyleClass().add("myDialog");
adminLoginFailedAlert.setTitle("Admin Login");
adminLoginFailedAlert.setHeaderText("Admin Login failed");
adminLoginFailedAlert.setContentText("Please check your user name or password again.");
adminLoginFailedAlert.showAndWait();
}
}
}
}
public static void showDuplicateWarning(List<String> duplicatePaths, Path lib) {
Alert alert = new WindowModalAlert(Alert.AlertType.WARNING);
DialogPane dialogPane = alert.getDialogPane();
ListView listView = new ListView();
listView.getStyleClass().clear();
ObservableList items = listView.getItems();
items.addAll(duplicatePaths);
listView.setEditable(false);
dialogPane.setContent(listView);
alert.setTitle("Duplicate JARs found");
alert.setHeaderText(String.format("Duplicate JARs found, it may cause unexpected behaviours.\n\n" +
"Please remove the older versions from these pair(s) manually. \n" +
"JAR files are located at %s directory.", lib));
alert.getButtonTypes().clear();
alert.getButtonTypes().addAll(ButtonType.OK);
alert.showAndWait();
}
@Override
public void showConfigEntriesInfoDialog(String title,
String header,
ConfigEntriesView entriesView) {
final Alert alert = getConfigEntriesViewDialog(header);
alert.setTitle(title);
final DialogPane dialogPane = alert.getDialogPane();
dialogPane.setContent(entriesView);
alert.setResizable(true);
alert.showAndWait();
}
private void errorAlert(){
Alert adminLoginFailedAlert = new Alert(Alert.AlertType.ERROR);
DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
dialogPane.getStylesheets().add(
getClass().getResource("/css/dialog-pane-styles.css")
.toExternalForm());
dialogPane.getStyleClass().add("myDialog");
adminLoginFailedAlert.setTitle(title);
adminLoginFailedAlert.setHeaderText(headerText);
adminLoginFailedAlert.setContentText(contentText);
adminLoginFailedAlert.showAndWait();
}
private void infoAlert(){
Alert adminLoginFailedAlert = new Alert(Alert.AlertType.INFORMATION);
DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
dialogPane.getStylesheets().add(
getClass().getResource("/css/dialog-pane-styles.css")
.toExternalForm());
dialogPane.getStyleClass().add("myDialog");
adminLoginFailedAlert.setTitle(title);
adminLoginFailedAlert.setHeaderText(headerText);
adminLoginFailedAlert.setContentText(contentText);
adminLoginFailedAlert.showAndWait();
}
private void warnAlert(){
Alert adminLoginFailedAlert = new Alert(Alert.AlertType.WARNING);
DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
dialogPane.getStylesheets().add(
getClass().getResource("/css/dialog-pane-styles.css")
.toExternalForm());
dialogPane.getStyleClass().add("myDialog");
adminLoginFailedAlert.setTitle(title);
adminLoginFailedAlert.setHeaderText(headerText);
adminLoginFailedAlert.setContentText(contentText);
adminLoginFailedAlert.showAndWait();
}
public void showInformationEraseAlert() {
Alert aboutInfo = new Alert(Alert.AlertType.CONFIRMATION);
aboutInfo.setTitle("Operação de remoção");
aboutInfo.setHeaderText("Remoção bem sucedida!");
aboutInfo.setContentText("Operação de remoção concluída!");
DialogPane diagPanel = aboutInfo.getDialogPane();
diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
aboutInfo.showAndWait();
}
public void showAboutInformationAlert() {
Alert aboutInfo = new Alert(Alert.AlertType.INFORMATION);
aboutInfo.setTitle("Sobre o Software");
aboutInfo.setHeaderText("Sistema de Gerênciamento para Lojas de Informática.");
aboutInfo.setContentText("Software desenvolvido como trabalho prático para a \ndiscíplina de Programação Desktop.\n");
DialogPane diagPanel = aboutInfo.getDialogPane();
diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
aboutInfo.showAndWait();
}
public void showInformationEraseAlert() {
Alert aboutInfo = new Alert(Alert.AlertType.CONFIRMATION);
aboutInfo.setTitle("Operação de remoção");
aboutInfo.setHeaderText("Remoção bem sucedida!");
aboutInfo.setContentText("Operação de remoção concluída!");
DialogPane diagPanel = aboutInfo.getDialogPane();
diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
aboutInfo.showAndWait();
}
public void showAboutInformationAlert() {
Alert aboutInfo = new Alert(Alert.AlertType.INFORMATION);
aboutInfo.setTitle("Sobre o Software");
aboutInfo.setHeaderText("Sistema de Gerênciamento para Lojas de Informática.");
aboutInfo.setContentText("Software desenvolvido como trabalho prático para a \ndiscíplina de Programação Desktop.\n");
DialogPane diagPanel = aboutInfo.getDialogPane();
diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
aboutInfo.showAndWait();
}
public void showInformationEraseAlert() {
Alert aboutInfo = new Alert(Alert.AlertType.CONFIRMATION);
aboutInfo.setTitle("Operação de remoção");
aboutInfo.setHeaderText("Remoção bem sucedida!");
aboutInfo.setContentText("Operação de remoção concluída!");
DialogPane diagPanel = aboutInfo.getDialogPane();
diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
aboutInfo.showAndWait();
}
public void showAboutInformationAlert() {
Alert aboutInfo = new Alert(Alert.AlertType.INFORMATION);
aboutInfo.setTitle("Sobre o Software");
aboutInfo.setHeaderText("Sistema de Gerênciamento para Lojas de Informática.");
aboutInfo.setContentText("Software desenvolvido como trabalho prático para a \ndiscíplina de Programação Desktop.\n");
DialogPane diagPanel = aboutInfo.getDialogPane();
diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
aboutInfo.showAndWait();
}
private static void styleAlert(Alert alert) {
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
LibraryAssistantUtil.setStageIcon(stage);
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(AlertMaker.class.getResource("/resources/dark-theme.css").toExternalForm());
dialogPane.getStyleClass().add("custom-alert");
}
public ErrorDialogue(final I18nManager i18nManager, final I18nKey titleKey, final Throwable e, final String... messages) {
alert = new Alert(AlertType.ERROR);
alert.setTitle(i18nManager.text(titleKey));
alert.setHeaderText(headerText(messages));
TextArea textArea = new TextArea(exceptionText(e));
VBox expContent = new VBox();
DialogPane dialoguePane = alert.getDialogPane();
expContent.getChildren().setAll(new Label(i18nManager.text(ERROR_DETAILS)), textArea);
dialoguePane.setExpandableContent(expContent);
dialoguePane.expandedProperty().addListener(p -> Platform.runLater(this::resizeAlert));
dialoguePane.setId("errorDialogue");
}
public static Optional<String> showOldConfiguration(List<String> paths) {
Alert alert = new WindowModalAlert(AlertType.INFORMATION);
DialogPane dialogPane = alert.getDialogPane();
ListView listView = new ListView();
listView.getStyleClass().clear();
ObservableList items = listView.getItems();
items.addAll(paths);
listView.setEditable(false);
dialogPane.setContent(listView);
alert.setTitle("Load previous configuration?");
alert.setHeaderText(String.format("You have configuration files from previous AsciidocFX versions\n\n" +
"Select the configuration which you want to load configuration \n" +
"or continue with fresh configuration"));
alert.getButtonTypes().clear();
alert.getButtonTypes().addAll(ButtonType.APPLY);
alert.getButtonTypes().addAll(ButtonType.CANCEL);
ButtonType buttonType = alert.showAndWait().orElse(ButtonType.CANCEL);
Object selectedItem = listView.getSelectionModel().getSelectedItem();
return (buttonType == ButtonType.APPLY) ?
Optional.ofNullable((String) selectedItem) :
Optional.empty();
}
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();
}
/**
* Show a modal dialog to select a {@link CoordinateReferenceSystem}.
*
* @param parent parent frame of widget.
* @param crs {@link CoordinateReferenceSystem} to edit.
* @return modified {@link CoordinateReferenceSystem}.
*/
public static CoordinateReferenceSystem showDialog(Object parent, CoordinateReferenceSystem crs) {
final CRSChooser chooser = new CRSChooser();
chooser.crsProperty.set(crs);
final Alert alert = new Alert(Alert.AlertType.NONE);
final DialogPane pane = alert.getDialogPane();
pane.setContent(chooser);
alert.getButtonTypes().setAll(ButtonType.OK,ButtonType.CANCEL);
alert.setResizable(true);
final ButtonType res = alert.showAndWait().orElse(ButtonType.CANCEL);
return res == ButtonType.CANCEL ? null : chooser.crsProperty.get();
}
static Alert buildDeleteAlertDialog(List<Path> pathsLabel) {
Alert deleteAlert = new WindowModalAlert(Alert.AlertType.WARNING, null, ButtonType.YES, ButtonType.CANCEL);
deleteAlert.setHeaderText("Do you want to delete selected path(s)?");
DialogPane dialogPane = deleteAlert.getDialogPane();
ObservableList<Path> paths = Optional.ofNullable(pathsLabel)
.map(FXCollections::observableList)
.orElse(FXCollections.emptyObservableList());
if (paths.isEmpty()) {
dialogPane.setContentText("There are no files selected.");
deleteAlert.getButtonTypes().clear();
deleteAlert.getButtonTypes().add(ButtonType.CANCEL);
return deleteAlert;
}
ListView<Path> listView = new ListView<>(paths);
listView.setId("listOfPaths");
GridPane gridPane = new GridPane();
gridPane.addRow(0, listView);
GridPane.setHgrow(listView, Priority.ALWAYS);
double minWidth = 200.0;
double maxWidth = Screen.getScreens().stream()
.mapToDouble(s -> s.getBounds().getWidth() / 3)
.min().orElse(minWidth);
double prefWidth = paths.stream()
.map(String::valueOf)
.mapToDouble(s -> s.length() * 7)
.max()
.orElse(maxWidth);
double minHeight = IntStream.of(paths.size())
.map(e -> e * 70)
.filter(e -> e <= 300 && e >= 70)
.findFirst()
.orElse(200);
gridPane.setMinWidth(minWidth);
gridPane.setPrefWidth(prefWidth);
gridPane.setPrefHeight(minHeight);
dialogPane.setContent(gridPane);
return deleteAlert;
}