当前位置: 首页>>代码示例>>Java>>正文


Java Dialog.setResultConverter方法代码示例

本文整理汇总了Java中javafx.scene.control.Dialog.setResultConverter方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setResultConverter方法的具体用法?Java Dialog.setResultConverter怎么用?Java Dialog.setResultConverter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.Dialog的用法示例。


在下文中一共展示了Dialog.setResultConverter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
private void setup() {
	ProjectConfig config = ProjectConfig.getLast();

	Dialog<ProjectConfig> dialog = new Dialog<>();
	//dialog.initModality(Modality.APPLICATION_MODAL);
	dialog.setResizable(true);
	dialog.setTitle("UID Setup");
	dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

	Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);

	UidSetupPane setupPane = new UidSetupPane(config, dialog.getOwner(), okButton);
	dialog.getDialogPane().setContent(setupPane);
	dialog.setResultConverter(button -> button == ButtonType.OK ? config : null);

	dialog.showAndWait().ifPresent(newConfig -> {
		setupPane.updateConfig();

		if (!newConfig.isValid()) return;

		newConfig.saveAsLast();
	});
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:24,代码来源:UidMenu.java

示例2: showOptions

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public void showOptions() {
    Dialog<String> dialog = new Dialog<>();
    dialog.setTitle("Perception-Action Configuration");
    dialog.setHeaderText("You can define next action in function of agent perception (up, left, right and down)");
    dialog.getDialogPane().setPrefSize(500, 600);

    FontIcon icon = new FontIcon(FontAwesome.COGS);
    icon.setIconSize(64);
    dialog.setGraphic(icon);
    ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);

    try {
        FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("PerceptionActionAgent.fxml"));
        Parent root = fxmlLoader.load();
        dialog.getDialogPane().setContent(root);
        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == applyChanges) {
                PerceptionActionAgentController configurationController = fxmlLoader.getController();
                for (PerceptionActionAgentController.PerceptionRule rule : configurationController.tableContent) {
                    ((PerceptionAction) getAlgorithm()).addRule(rule.getLeft(), rule.getRight(), rule.getUp(), rule.getDown(), Directions.valueOf(rule.getAction()));
                }
                return null;
            }
            return null;
        });

    } catch (IOException e) {
        new ErrorView("No possible load agent configuration");
        e.printStackTrace();
    }

    Optional<String> s = dialog.showAndWait();
}
 
开发者ID:AdrianBZG,项目名称:IEMLS,代码行数:36,代码来源:PerceptionActionAgent.java

示例3: editDocument

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public Optional<String> editDocument(String formattedJson, int cursorPosition) {
  Dialog<String> dialog = new Dialog<>();
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
  dialog.setTitle("MongoFX - edit document");
  dialog.setResizable(true);
  dialog.getDialogPane().getStylesheets().add(getClass().getResource("/ui/editor.css").toExternalForm());

  CodeArea codeArea = setupEditorArea(formattedJson, dialog, cursorPosition);

  dialog.setResultConverter(bt -> {
    if (ButtonData.OK_DONE == bt.getButtonData()) {
      return codeArea.getText();
    }
    return null;
  });
  return dialog.showAndWait();
}
 
开发者ID:daa84,项目名称:mongofx,代码行数:18,代码来源:UIBuilder.java

示例4: colorInput

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public Optional<Color> colorInput(String action, String question, Color _default) {
    Dialog<Color> dialog = new Dialog<>();
    dialog.setTitle(action);
    dialog.setHeaderText(question);
    ColorPicker picker = new ColorPicker(_default);
    Button randomiser = new Button("Mix");
    randomiser.setOnAction(e -> {
        Color current = picker.getValue();
        Color shifted = Item.shiftColor(current);
        picker.setValue(shifted);
    });
    HBox box = new HBox();
    box.getChildren().addAll(picker, randomiser);
    dialog.getDialogPane().setContent(box);

    dialog.getDialogPane().getButtonTypes().addAll(
            ButtonType.OK, ButtonType.CANCEL);

    dialog.setResultConverter(buttonType -> {
        if (buttonType.equals(ButtonType.OK)) {
            return picker.getValue();
        } else {
            return null;
        }
    });
    return dialog.showAndWait();
}
 
开发者ID:fuzzyBSc,项目名称:systemdesign,代码行数:29,代码来源:Interactions.java

示例5: newProject

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
private void newProject() {
	ProjectConfig config = ProjectConfig.getLast();

	Dialog<ProjectConfig> dialog = new Dialog<>();
	//dialog.initModality(Modality.APPLICATION_MODAL);
	dialog.setResizable(true);
	dialog.setTitle("Project configuration");
	dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

	Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);

	dialog.getDialogPane().setContent(new NewProjectPane(config, dialog.getOwner(), okButton));
	dialog.setResultConverter(button -> button == ButtonType.OK ? config : null);

	dialog.showAndWait().ifPresent(newConfig -> {
		if (!newConfig.isValid()) return;

		newConfig.saveAsLast();

		gui.getMatcher().reset();
		gui.onProjectChange();

		gui.runProgressTask("Initializing files...",
				progressReceiver -> gui.getMatcher().init(newConfig, progressReceiver),
				() -> gui.onProjectChange(),
				Throwable::printStackTrace);
	});
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:29,代码来源:FileMenu.java

示例6: loadProject

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
private void loadProject() {
	Path file = Gui.requestFile("Select matches file", gui.getScene().getWindow(), getMatchesLoadExtensionFilters(), true);
	if (file == null) return;

	List<Path> paths = new ArrayList<>();

	Dialog<List<Path>> dialog = new Dialog<>();
	//dialog.initModality(Modality.APPLICATION_MODAL);
	dialog.setResizable(true);
	dialog.setTitle("Project paths");
	dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

	Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);

	dialog.getDialogPane().setContent(new LoadProjectPane(paths, dialog.getOwner(), okButton));
	dialog.setResultConverter(button -> button == ButtonType.OK ? paths : null);

	dialog.showAndWait().ifPresent(newConfig -> {
		if (paths.isEmpty()) return;

		gui.getMatcher().reset();
		gui.onProjectChange();

		gui.runProgressTask("Initializing files...",
				progressReceiver -> gui.getMatcher().readMatches(file, paths, progressReceiver),
				() -> gui.onProjectChange(),
				Throwable::printStackTrace);
	});
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:30,代码来源:FileMenu.java

示例7: entitySearchDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static <T extends Entity<T>> Optional<List<T>> entitySearchDialog(Query<T> query, boolean multiSelect) {
    try {
        FXMLLoader loader = new FXMLLoader(EntityGuiController.class.getResource("/fxml/Collection.fxml"));
        AnchorPane content = (AnchorPane) loader.load();
        final ControllerCollection<T> controller = loader.<ControllerCollection<T>>getController();
        controller.setQuery(query, false, false, false, multiSelect);

        Dialog<List<T>> dialog = new Dialog<>();
        dialog.setHeight(800);
        if (multiSelect) {
            dialog.setTitle("Choose one or more " + EntityType.singleForClass(query.getEntityType().getType()).getName());
        } else {
            dialog.setTitle("Choose a " + EntityType.singleForClass(query.getEntityType().getType()).getName());
        }
        dialog.setResizable(true);
        dialog.getDialogPane().setContent(content);
        ButtonType buttonTypeOk = new ButtonType("Set", ButtonBar.ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
        ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
        dialog.getDialogPane().getButtonTypes().add(buttonTypeCancel);
        dialog.setResultConverter((ButtonType button) -> {
            if (button == buttonTypeOk) {
                if (multiSelect) {
                    return controller.getSelectedEntities();
                }
                List<T> list = new ArrayList<>();
                list.add(controller.getSelectedEntity());
                return list;
            }
            return null;
        });
        return dialog.showAndWait();

    } catch (IOException ex) {
        LoggerFactory.getLogger(EntityGuiController.class).error("Failed to load Tab.", ex);
        return Optional.empty();
    }
}
 
开发者ID:hylkevds,项目名称:SensorThingsManager,代码行数:39,代码来源:EntityGuiController.java

示例8: showDailySectionChooserDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static final DailySectionModel showDailySectionChooserDialog() {
       LoggerFacade.INSTANCE.debug(DialogProvider.class, "Show DailySection chooser dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO add size to the dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO use properties"); // NOI18N
       
       final Dialog<DailySectionModel> dialog = new Dialog<>();
       dialog.setTitle("Daily Section Chooser"); // NOI18N
       dialog.setHeaderText("Select the Daily Section to which the Project should be added!"); // NOI18N
       dialog.setResizable(false);
       
       final DailySectionChooserDialogView view = new DailySectionChooserDialogView();
       dialog.getDialogPane().setContent(view.getView());
       
       final ButtonType buttonTypeOk = new ButtonType("Okay", ButtonData.OK_DONE); // NOI18N
       final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); // NOI18N
dialog.getDialogPane().getButtonTypes().addAll(buttonTypeOk, buttonTypeCancel);
       
dialog.setResultConverter((ButtonType buttonType) -> {
           if (
                   buttonType != null
                   && buttonType.equals(buttonTypeOk)
           ) {
               return view.getRealPresenter().getDailySection();
           }
           
           return null;
       });
       
       final Optional<DailySectionModel> result = dialog.showAndWait();
       if (!result.isPresent()) {
           return null;
       }
       
       return result.get();
   }
 
开发者ID:Naoghuman,项目名称:Incubator,代码行数:36,代码来源:DialogProvider.java

示例9: showDeleteProjectDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static final void showDeleteProjectDialog(long idToDelete, String projectTitle) {
       LoggerFacade.INSTANCE.debug(DialogProvider.class, "Show delete Project dialog"); // NOI18N

       final Dialog<Boolean> dialog = new Dialog<>();
       dialog.setTitle("Delete " + projectTitle); // NOI18N
       dialog.setHeaderText("Do you really want to delete this project?"); // NOI18N
       dialog.setResizable(false);
       
       final ButtonType buttonTypeOk = new ButtonType("Okay", ButtonData.OK_DONE); // NOI18N
       final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); // NOI18N
dialog.getDialogPane().getButtonTypes().addAll(buttonTypeOk, buttonTypeCancel);
       
       dialog.setResultConverter((ButtonType buttonType) -> {
           final boolean shouldProjectDelete = buttonType != null && buttonType.equals(buttonTypeOk);
           return shouldProjectDelete;
       });
       
       final Optional<Boolean> result = dialog.showAndWait();
       if (
               !result.isPresent()
               || !result.get()
       ) {
           return;
       }
       
       // Delete the project
       SqlFacade.INSTANCE.getProjectSqlProvider().delete(idToDelete);
       
       // Cleanup
       ActionFacade.INSTANCE.handle(INavigationOverviewConfiguration.ON_ACTION__UPDATE_PROJECTS);
   }
 
开发者ID:Naoghuman,项目名称:Incubator,代码行数:32,代码来源:DialogProvider.java

示例10: showNewDailySectionDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static final DailySectionModel showNewDailySectionDialog() {
       LoggerFacade.INSTANCE.debug(DialogProvider.class, "Show new DailySection dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO add size to the dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO use properties"); // NOI18N
       
       final Dialog<DailySectionModel> dialog = new Dialog<>();
       dialog.setTitle("New Daily Section"); // NOI18N
       dialog.setHeaderText("Creates a new Daily Section."); // NOI18N
       dialog.setResizable(false);
       
       final DailySectionDialogView view = new DailySectionDialogView();
       dialog.getDialogPane().setContent(view.getView());
       
       final ButtonType buttonTypeOk = new ButtonType("Create", ButtonData.OK_DONE); // NOI18N
       final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); // NOI18N
dialog.getDialogPane().getButtonTypes().addAll(buttonTypeOk, buttonTypeCancel);
       
dialog.setResultConverter((ButtonType buttonType) -> {
           if (
                   buttonType != null
                   && buttonType.equals(buttonTypeOk)
           ) {
               return view.getRealPresenter().getDailySection();
           }
           
           return null;
       });
       
       final Optional<DailySectionModel> result = dialog.showAndWait();
       if (!result.isPresent()) {
           return null;
       }
       
       return result.get();
   }
 
开发者ID:Naoghuman,项目名称:Incubator,代码行数:36,代码来源:DialogProvider.java

示例11: showYesOrNoDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static Optional<Pair<String, String>> showYesOrNoDialog(Stage stage, String title, String message,
		Consumer<? super Pair<String, String>> consumer, Consumer<Dialog<Pair<String, String>>> dialogHandler) {

	// Create the custom dialog.
	Dialog<Pair<String, String>> dialog = new Dialog<>();
	dialog.setTitle(title);
	dialog.setHeaderText(message);

	// Set the button types.
	ButtonType yesBtn = new ButtonType("Yes", ButtonData.YES);
	ButtonType noBtn = new ButtonType("No", ButtonData.NO);

	dialog.getDialogPane().getButtonTypes().addAll(yesBtn, noBtn);

	dialog.setResultConverter(dialogButton -> {
		if (dialogButton == yesBtn) {
			return new Pair<>("RESULT", "Y");
		} else if (dialogButton == noBtn) {
			return new Pair<>("RESULT", "N");
		}
		return null;
	});

	dialog.initOwner(stage);
	if (dialogHandler != null)
		dialogHandler.accept(dialog);

	Optional<Pair<String, String>> result = dialog.showAndWait();

	if (consumer != null)
		result.ifPresent(consumer);

	return result;

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:36,代码来源:DialogUtil.java

示例12: showDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
 * Show dialog
 *
 * @param selectedText
 * @return
 */
private String showDialog(String selectedText) {
    Dialog dialog = new Dialog();
    dialog.setTitle("Edit Hex");
    dialog.setResizable(false);
    TextField text1 = new TextField();
    text1.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(2));
    text1.setText(selectedText);
    StackPane dialogPane = new StackPane();
    dialogPane.setPrefSize(150, 50);
    dialogPane.getChildren().add(text1);
    dialog.getDialogPane().setContent(dialogPane);
    ButtonType buttonTypeOk = new ButtonType("Save", ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
    dialog.setResultConverter(new Callback<ButtonType, String>() {
        @Override
        public String call(ButtonType b) {
            
            if (b == buttonTypeOk) {
                switch (text1.getText().length()) {
                    case 0:
                        return null;
                    case 1:
                        return "0".concat(text1.getText());
                    default:
                        return text1.getText();
                }
            }
            return null;
        }
    });
    
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        return result.get();
    }
    return null;
}
 
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:44,代码来源:PacketHex.java

示例13: showSpeciesManager

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static void showSpeciesManager() {
    Dialog<String> dialog = new Dialog<>();
    dialog.setTitle("Species Manager");
    dialog.setHeaderText("You can manage environment species with the following options: \n - create specie, \n - delete specie");
    dialog.getDialogPane().setPrefSize(500, 600);

    FontIcon icon = new FontIcon(FontAwesome.COGS);
    icon.setIconSize(64);
    dialog.setGraphic(icon);
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);

    try {
        FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("SpeciesConfiguration.fxml"));
        Parent root = fxmlLoader.load();
        dialog.getDialogPane().setContent(root);
        dialog.setResultConverter(dialogButton -> {
            return null;
        });

    } catch (IOException e) {
        new ErrorView("No possible load agent configuration");
        e.printStackTrace();
    }


    Optional<String> result = dialog.showAndWait();
}
 
开发者ID:AdrianBZG,项目名称:IEMLS,代码行数:28,代码来源:Specie.java

示例14: showOptions

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
 *
 */
@Override
public void showOptions() {
    Dialog<String> dialog = new Dialog<>();
    dialog.setTitle("Agent Configuration");
    dialog.setHeaderText("You can edit: \n - appearance, \n - internal algorithm, \n - objectives, \n - and export and import agents");
    dialog.getDialogPane().setPrefSize(500, 600);

    FontIcon icon = new FontIcon(FontAwesome.COGS);
    icon.setIconSize(64);
    dialog.setGraphic(icon);
    ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);

    try {
        FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("CollectionAgentConfiguration.fxml"));
        Parent root = fxmlLoader.load();
        dialog.getDialogPane().setContent(root);
        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == applyChanges) {
                CollectorConfigurationController configurationController = fxmlLoader.getController();
                setAlgorithm(configurationController.getAlgorithm());
                return null;
            }
            return null;
        });

    } catch (IOException e) {
        new ErrorView("No possible load agent configuration");
        e.printStackTrace();
    }


    Optional<String> result = dialog.showAndWait();
}
 
开发者ID:AdrianBZG,项目名称:IEMLS,代码行数:38,代码来源:CollectorAgent.java

示例15: showOptions

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
 *
 */
@Override
public void showOptions() {
    Dialog<String> dialog = new Dialog<>();
    dialog.setTitle("Agent Configuration");
    dialog.setHeaderText("You can edit: \n - appearance, \n - internal algorithm, \n - objectives, \n - and export and import agents");
    dialog.getDialogPane().setPrefSize(500, 600);

    FontIcon icon = new FontIcon(FontAwesome.COGS);
    icon.setIconSize(64);
    dialog.setGraphic(icon);
    ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);

    try {
        FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("MachineLearningAgentConfiguration.fxml"));
        Parent root = fxmlLoader.load();
        dialog.getDialogPane().setContent(root);
        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == applyChanges) {
                MachineLearningAgentConfigurationController machineLearningConfigurationController = fxmlLoader.getController();
                setAlgorithm(machineLearningConfigurationController.getAlgorithm());
                return null;
            }
            return null;
        });

    } catch (IOException e) {
        new ErrorView("No possible load agent configuration");
        e.printStackTrace();
    }


    Optional<String> result = dialog.showAndWait();
}
 
开发者ID:AdrianBZG,项目名称:IEMLS,代码行数:38,代码来源:QLearningAgent.java


注:本文中的javafx.scene.control.Dialog.setResultConverter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。