Java 类javafx.scene.control.TextInputDialog 实例源码

项目:CSS-Editor-FX    文件:StatusBarManager.java   
private void showLineJumpDialog() {
  TextInputDialog dialog = new TextInputDialog();
  dialog.setTitle("Goto Line");
  dialog.getDialogPane().setContentText("Input Line Number: ");
  dialog.initOwner(area.getValue().getScene().getWindow());
  TextField tf = dialog.getEditor();

  int lines = StringUtil.countLine(area.getValue().getText());
  ValidationSupport vs = new ValidationSupport();
  vs.registerValidator(tf, Validator.<String> createPredicateValidator(
      s -> TaskUtil.uncatch(() -> MathUtil.inRange(Integer.valueOf(s), 1, lines)) == Boolean.TRUE,
      String.format("Line number must be in [%d,%d]", 1, lines)));

  dialog.showAndWait().ifPresent(s -> {
    if (vs.isInvalid() == false) {
      area.getValue().moveTo(Integer.valueOf(s) - 1, 0);
    }
  });
}
项目:Virtual-Game-Shelf    文件:MainMenuBar.java   
/** Test importing games into gamelist from Steam library (.xml file). */
public static void onTestImportSteamLibraryXML() {
    // TODO: ID field should be empty by default in final code.
    //       Leaving 'Stevoisiak' as default ID for testing.

    // TODO: Accept multiple formats for Steam ID.
    //       (ie: gabelogannewell, 76561197960287930, STEAM_0:0:11101,
    //            [U:1:22202], http://steamcommunity.com/id/gabelogannewell/,
    //            http://steamcommunity.com/profiles/76561197960287930/,
    //            http://steamcommunity.com/profiles/[U:1:22202]/)
    //       Convert types with (https://github.com/xPaw/SteamID.php)?
    TextInputDialog steamIdDialog = new TextInputDialog("Stevoisiak");
    steamIdDialog.setTitle("Import library from Steam");
    steamIdDialog.setHeaderText(null);
    steamIdDialog.setContentText("Please enter your steam ID.");

    Optional<String> steamID = steamIdDialog.showAndWait();
    if (steamID.isPresent()) {
        SteamCommunityGameImporter importer = new SteamCommunityGameImporter();
        importer.steamCommunityAddGames(steamID.get());
    }
}
项目:titanium    文件:PlayerView.java   
private void kickPlayerAction(ActionEvent e) {
    TextInputDialog dial = new TextInputDialog("No reason indicated");
    dial.setTitle("Kick player");
    dial.setHeaderText("Do you really want to kick " + player.getName() + " ?");
    dial.setContentText("Reason ");
    Optional<String> result = dial.showAndWait();

    if (result.isPresent()) {
        try {
            server.kickPlayer(player, result.orElse("No reason indicated"));
        } catch (RCONServerException e1) {
            server.logError(e1);
        }
    }



}
项目:Orsum-occulendi    文件:Controller.java   
@FXML
public void presentNewGameProposalWindow(Event e) {
    TextInputDialog dialog = new TextInputDialog();
    dialog.setHeaderText("Neuer Spielvorschalg");
    dialog.setContentText("Wie soll das Spiel heissen?");

    Optional<String> gameNameResult = dialog.showAndWait();
    gameNameResult.ifPresent(result -> {
        if (!gameNameResult.get().isEmpty()) {
            this.client.enqueueTask(new CommunicationTask(new ClientMessage("server", "newgame", gameNameResult.get()), (success, response) -> {
                Platform.runLater(() -> {
                    if (success && response.getDomain().equals("success") && response.getCommand().equals("created")) {
                        refreshGameList(e);
                        System.out.println("Game erstellt");
                    } else {
                        Alert alert = new Alert(AlertType.ERROR);
                        alert.setHeaderText("Das Spiel konnte nicht erstellt werden");
                        alert.setContentText(response.toString());
                        alert.show();
                    }
                });
            }));
        }
    });
}
项目:textmd    文件:EditorOpenUrlItem.java   
@Override
public void getClickAction(final Dictionary dictionary, final Stage stage, final TabFactory tabFactory, final DialogFactory dialogFactory) {
    TextInputDialog input = dialogFactory.buildEnterUrlDialogBox(
            dictionary.DIALOG_OPEN_URL_TITLE,
            dictionary.DIALOG_OPEN_URL_CONTENT
    );
    Optional<String> result = input.showAndWait();
    result.ifPresent(url -> {
        try {
            tabFactory.createAndAddNewEditorTab(
                    new File(Utils.getDefaultFileName()),
                    Http.request(url + "", null, null, null, "GET")
            );
        } catch (IOException e1) {
            dialogFactory.buildExceptionDialogBox(
                    dictionary.DIALOG_EXCEPTION_TITLE,
                    dictionary.DIALOG_EXCEPTION_OPENING_MARKDOWN_URL_CONTENT,
                    e1.getMessage(),
                    e1
            ).showAndWait();
        }
    });
}
项目:textmd    文件:EditorImportUrlItem.java   
@Override
public void getClickAction(final Dictionary dictionary, final TabFactory tabFactory, final DialogFactory dialogFactory) {
    TextInputDialog input = dialogFactory.buildEnterUrlDialogBox(
            dictionary.DIALOG_IMPORT_URL_TITLE,
            dictionary.DIALOG_IMPORT_URL_CONTENT
    );
    Optional<String> result = input.showAndWait();
    result.ifPresent(url -> {
        try {
            EditorTab tab = ((EditorTab)tabFactory.getSelectedTab());
            tab.getEditorPane().setContent(tab.getEditorPane().getContent() + "\n" + Http.request(url + "", null, null, null, "GET"));
        } catch (IOException e1) {
            dialogFactory.buildExceptionDialogBox(
                    dictionary.DIALOG_EXCEPTION_TITLE,
                    dictionary.DIALOG_EXCEPTION_IMPORT_CONTENT,
                    e1.getMessage(),
                    e1
            ).showAndWait();
        }
    });
}
项目:fx-media-tags    文件:FxMediaTags.java   
private MenuItem createMenuAdd() {
    final MenuItem menuAdd = new MenuItem("Add");
    menuAdd.setOnAction(event -> {
        final TextInputDialog dialog = new TextInputDialog();
        dialog.setTitle("Custom Tag Input Dialog");
        dialog.setHeaderText("New Custom Tag");
        dialog.setContentText("Name:");
        final Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            final String tagName = StringType.nvl(result.get());
            if (!tagName.isEmpty()) {
                if (MODEL.tagsProperty().filtered(t -> tagName.equals(t.getName())).isEmpty()) {
                    final MetaTagModel metaTagModel = new MetaTagModel(tagName);
                    if (null != MODEL.getOnAddTag()) {
                        MODEL.getOnAddTag().accept(metaTagModel);
                    }
                    MODEL.tagsProperty().add(metaTagModel);
                }
            }
        }
    });
    return menuAdd;
}
项目:joanne    文件:ImageManager.java   
public void renameImage(String path,String file_to_rename) {
     TextInputDialog input = new TextInputDialog(file_to_rename.substring(0, file_to_rename.length()-4)+"1"+file_to_rename.substring(file_to_rename.length()-4));
        Optional<String> change = input.showAndWait();

        change.ifPresent((String change_event) -> {
            try {
                Files.move(new File(path).toPath(),new File(new File(path).getParent()+File.separator+change_event).toPath());
            } catch (IOException ex) {
               Alert a = new Alert(AlertType.ERROR);
               a.setTitle("Rename");
               a.setHeaderText("Error while renaming the file.");
               a.setContentText("Error code: "+e.getErrorInfo(ex)+"\n"+e.getErrorMessage(ex));
               a.showAndWait();
            }
     });
        System.gc();
}
项目:WebPLP    文件:Main.java   
private boolean renameProject(Project project)
{
    TextInputDialog dialog = new TextInputDialog(project.getName());
    dialog.setTitle("Rename Project");
    dialog.setHeaderText(null);
    dialog.setGraphic(null);
    dialog.setContentText("Enter a new name for the project:");

    Optional<String> result = dialog.showAndWait();
    if (result.isPresent())
    {
        String newName = result.get();
        if (newName.equals(project.getName()))
        {
            showInfoDialogue("The new name must be different from the old name");
            return renameProject(project);
        }
        else
        {
            project.setName(newName);
        }
    }

    return false;
}
项目:CSS-Editor-FX    文件:StatusBarManager.java   
private void showLineJumpDialog() {
  TextInputDialog dialog = new TextInputDialog();
  dialog.setTitle("Goto Line");
  dialog.getDialogPane().setContentText("Input Line Number: ");
  dialog.initOwner(area.getValue().getScene().getWindow());
  TextField tf = dialog.getEditor();

  int lines = StringUtil.countLine(area.getValue().getText());
  ValidationSupport vs = new ValidationSupport();
  vs.registerValidator(tf, Validator.<String> createPredicateValidator(
      s -> TaskUtil.uncatch(() -> MathUtil.inRange(Integer.valueOf(s), 1, lines)) == Boolean.TRUE,
      String.format("Line number must be in [%d,%d]", 1, lines)));

  dialog.showAndWait().ifPresent(s -> {
    if (vs.isInvalid() == false) {
      area.getValue().moveTo(Integer.valueOf(s) - 1, 0);
    }
  });
}
项目:ServerBrowser    文件:GTAController.java   
/**
 * Connects to a server, depending on if it is passworded, the user will be
 * asked to enter a
 * password. If the server is not reachable the user can not connect.
 *
 * @param address
 *            server address
 * @param port
 *            server port
 */
public static void tryToConnect(final String address, final Integer port) {
    try (final SampQuery query = new SampQuery(address, port)) {
        final Optional<String[]> serverInfo = query.getBasicServerInfo();

        if (serverInfo.isPresent() && StringUtility.stringToBoolean(serverInfo.get()[0])) {
            final TextInputDialog dialog = new TextInputDialog();
            dialog.setTitle("Connect to Server");
            dialog.setHeaderText("Enter the servers password (Leave empty if u think there is none).");

            final Optional<String> result = dialog.showAndWait();
            result.ifPresent(password -> GTAController.connectToServer(address, port, password));
        }
        else {
            GTAController.connectToServer(address, port, "");
        }
    }
    catch (final IOException exception) {
        Logging.warn("Couldn't connect to server.", exception);
        showCantConnectToServerError();
    }
}
项目:Incubator    文件:AudioClipBoxPresenter.java   
private void onMouseClickedChangeTitle() {
    LoggerFacade.getDefault().debug(this.getClass(), "On mouse clicked change Title"); // NOI18N

    final TextInputDialog dialog = new TextInputDialog(lTitle.getText());
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setHeaderText("Change title"); // NOI18N
    dialog.setResizable(Boolean.FALSE);
    dialog.setTitle("AudioClip"); // NOI18N

    final Optional<String> result = dialog.showAndWait();
    if (result.isPresent() && !result.get().isEmpty()) {
        lTitle.setText(result.get());
    }

    // TODO save to db
}
项目:Incubator    文件:TopicPresenter.java   
private void onMouseClickedChangeTitle() {
    LoggerFacade.getDefault().debug(this.getClass(), "On mouse clicked change Title"); // NOI18N

    final TextInputDialog dialog = new TextInputDialog(lTitle.getText());
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setHeaderText("Change title"); // NOI18N
    dialog.setResizable(Boolean.FALSE);
    dialog.setTitle("Topic"); // NOI18N

    final Optional<String> result = dialog.showAndWait();
    if (result.isPresent() && !result.get().isEmpty()) {
        lTitle.setText(result.get());
    }

    // TODO save to db
}
项目:megan-ce    文件:NewAttributeCommand.java   
public void actionPerformed(ActionEvent event) {
    final SamplesViewer viewer = ((SamplesViewer) getViewer());
    int position = viewer.getSamplesTable().getASelectedColumnIndex();
    String name = null;
    if (position != -1) {
        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)
        execute("new attribute='" + name + "' position=" + position + ";");
}
项目:Simulizer    文件:UIUtils.java   
/**
 * show a dialog box to input an integer
 */
public static void openIntInputDialog(String title, String header, String message, int defaultVal, Consumer<Integer> callback) {
    TextInputDialog dialog = new TextInputDialog(""+defaultVal);
    Stage parent = GuiMode.getPrimaryStage(); // owner is null if JavaFX not fully loaded yet
    if(parent != null && parent.getOwner() != null) {
        dialog.initOwner(parent.getOwner());
    }
    dialog.setTitle(title);
    dialog.setHeaderText(header);
    dialog.setContentText(message);

    dialog.showAndWait().ifPresent((text) -> {
        int val = defaultVal;
        try {
            val = Integer.parseInt(text);
        } catch(NumberFormatException ignored) {
        }

        callback.accept(val);
    });
}
项目:Simulizer    文件:UIUtils.java   
/**
 * show a dialog box to input a double
 */
public static void openDoubleInputDialog(String title, String header, String message, double defaultVal, Consumer<Double> callback) {
    TextInputDialog dialog = new TextInputDialog(""+defaultVal);
    Stage parent = GuiMode.getPrimaryStage(); // owner is null if JavaFX not fully loaded yet
    if(parent != null && parent.getOwner() != null) {
        dialog.initOwner(parent.getOwner());
    }
    dialog.setTitle(title);
    dialog.setHeaderText(header);
    dialog.setContentText(message);

    dialog.showAndWait().ifPresent((text) -> {
        double val = defaultVal;
        try {
            val = Double.parseDouble(text);
        } catch(NumberFormatException ignored) {
        }

        callback.accept(val);
    });
}
项目:corona-ide    文件:MainController.java   
@FXML
private void handleFileNewProject(ActionEvent event) {
    TextInputDialog newProjectDialog = new TextInputDialog();
    newProjectDialog.setTitle("Create Project");
    newProjectDialog.setHeaderText("Create new project");
    newProjectDialog.setContentText("Project name:");

    newProjectDialog.showAndWait()
            .ifPresent(r -> {
                Path projectPath = workspaceService.getActiveWorkspace().getWorkingDirectory().resolve(r);
                try {
                    listViewProjects.getItems().add(projectService.create(new ProjectRequest(projectPath)));
                } catch (IOException e) {
                    Alert alert = new Alert(AlertType.ERROR);
                    alert.setTitle("Create project failed");
                    alert.setHeaderText("Failed to create new project.");
                    alert.showAndWait();
                    // TODO nickavv: create custom "stack trace dialog" to show the actual error
                }
            });
}
项目:TG-BUYME    文件:AtenderEncomendaController.java   
/**
 * M�TODO QUE ABRE A TELA PARA INSERIR A QUANTIDADE DE PRODUTOS PARA ATENDER A ENCOMENDA
 * @return Quantidade de produtos para atender a encomenda
 */
public Integer telaQuantidade(){
    TextInputDialog dialog = new TextInputDialog();
    dialog.setTitle("BuyMe");
    dialog.setHeaderText("Atender encomenda");
    dialog.setContentText("Digite a quantidade que deseja atender com essa produ��o: ");

    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()){
        if(Utils.isNumber(result.get())){
            return Integer.parseInt(result.get());
        }else{
            popup.getError("A quantidade deve ser um n�mero!");

            return 0;
        }
    }else{
        return 0;
    }
}
项目:LuoYing    文件:RenameMenuItem.java   
private void doRename() {
    ObservableList<TreeItem<File>> selectedItems = fileTree.getSelectionModel().getSelectedItems();
    if (selectedItems.isEmpty())
        return;
    TreeItem<File> itemSelect = selectedItems.get(0);
    if (itemSelect == null || itemSelect.getValue() == null) {
        return;
    }
    TextInputDialog dialog = new TextInputDialog(itemSelect.getValue().getName());
    dialog.setTitle(Manager.getRes(ResConstants.ALERT_RENAME_TITLE));
    dialog.setHeaderText(Manager.getRes(ResConstants.ALERT_RENAME_HEADER
            , new Object[] {itemSelect.getValue().getName()}));
    Optional<String> result = dialog.showAndWait();
    result.ifPresent(name -> {
        if (name == null || name.trim().isEmpty()) {
            return;
        }
        File file = itemSelect.getValue();
        File newFile = new File(file.getParent(), name);
        file.renameTo(newFile);
        itemSelect.setValue(newFile);
    });
}
项目:programmierpraktikum-abschlussprojekt-nimmdochirgendeinennamen    文件:TDDTDialog.java   
/**
 * Shows a simple dialog that waits for the user to enter some text.
 * @param message The message is shown in the content text of the dialog.
 * @return The user input
    */
private String showTextInput(String message) {
    TextInputDialog dialog = new TextInputDialog();
    ((Stage)dialog.getDialogPane().getScene().getWindow()).getIcons().add(new Image("file:pictures/icon.png"));
    dialog.setTitle("Please input a value");
    dialog.setHeaderText(null);
    dialog.setContentText(message);

    Optional<String> input = dialog.showAndWait();
    if (input.isPresent()) {
        if (!input.get().isEmpty()) {
            return input.get();
        } else {
            new TDDTDialog("alert", "Missing input");
        }
    }
    return "-1";
}
项目:gseproject    文件:TrackManagerController.java   
private void dropOnSourcePallet(DragEvent event, int sourcePalletId) {
    event.setDropCompleted(true);
    TextInputDialog addBlocksDialog = new TextInputDialog();
    addBlocksDialog.setTitle("Add Blocks");
    addBlocksDialog.setHeaderText("Enter the amount of blocks you want to add");
    Optional<String> result = addBlocksDialog.showAndWait();
    result.ifPresent(count -> sourcePallets[sourcePalletId] += Integer.parseInt(count));

    String stateImagePath;
    if (sourcePallets[sourcePalletId] <= 5) {
        stateImagePath = "images/blocks-almost-empty.png";
    } else if (sourcePallets[sourcePalletId] > 5 && sourcePallets[sourcePalletId] <= 15) {
        stateImagePath = "images/blocks-normal.png";
    } else if (sourcePallets[sourcePalletId] > 15) {
        stateImagePath = "images/blocks-full.png";
    } else {
        stateImagePath = "";
    }
    Image stateImage = new Image(getClass().getResource(stateImagePath).toString());
    ((BorderPane) event.getSource()).setCenter(new ImageView(stateImage));

    System.out.println(Arrays.toString(sourcePallets));
    event.consume();
}
项目:mars-sim    文件:BuildingPanel.java   
/**
 * Ask for a new building name using TextInputDialog in JavaFX/8
 * @return new name
 */
public String askNameFX(String oldName) {
    String newName = null;
    TextInputDialog dialog = new TextInputDialog(oldName);
    dialog.setTitle(Msg.getString("BuildingPanel.renameBuilding.dialogTitle"));
    dialog.setHeaderText(Msg.getString("BuildingPanel.renameBuilding.dialog.header"));
    dialog.setContentText(Msg.getString("BuildingPanel.renameBuilding.dialog.content"));

    Optional<String> result = dialog.showAndWait();
    //result.ifPresent(name -> {});

    if (result.isPresent()){
        logger.info("The old building name has been changed to: " + result.get());
        newName = result.get();
    }

    return newName;
}
项目:mars-sim    文件:SettlementTransparentPanel.java   
/**
 * Ask for a new building name using TextInputDialog in JavaFX/8
 * @return new name
 */
public String askNameFX(String oldName) {
    String newName = null;
    TextInputDialog dialog = new TextInputDialog(oldName);
    dialog.initOwner(desktop.getMainScene().getStage());
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setTitle(Msg.getString("BuildingPanel.renameBuilding.dialogTitle"));
    dialog.setHeaderText(Msg.getString("BuildingPanel.renameBuilding.dialog.header"));
    dialog.setContentText(Msg.getString("BuildingPanel.renameBuilding.dialog.content"));

    Optional<String> result = dialog.showAndWait();
    //result.ifPresent(name -> {});

    if (result.isPresent()){
        //logger.info("The settlement name has been changed to : " + result.get());
        newName = result.get();
    }

    return newName;
}
项目:viskell    文件:ConstantBlock.java   
public void editValue(Optional<String> startValue) {
    TextInputDialog dialog = new TextInputDialog(startValue.orElse(this.getValue()));
    dialog.setTitle("Edit constant block");
    dialog.setHeaderText("Type a Haskell expression");

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

    result.ifPresent(value -> {
        this.setValue(value);
        GhciSession ghci = this.getToplevel().getGhciSession();

        try {
            Type type = ghci.pullType(value, this.getToplevel().getEnvInstance());
            this.output.setExactRequiredType(type);
            this.hasValidValue = true;
            this.outputSpace.setVisible(true);
        } catch (HaskellException e) {
            this.hasValidValue = false;
            this.outputSpace.setVisible(false);
        }

        this.initiateConnectionChanges();
    });
}
项目:SimpleTaskList    文件:NewEditDialogController.java   
/**
 * Handle a click on the "add context" button: open an input dialog
 * and add the inserted context to the list.
 */
@FXML
private void handleAddContext() {
    final TextInputDialog input = new TextInputDialog();
    AbstractDialogController.prepareDialog(input, "dialog.context.new.title",
            "dialog.context.new.header", "dialog.context.new.content", getCurrentWindowData());
    final Optional<String> text = input.showAndWait();
    if (text.isPresent()) {
        /* Remove whitespaces from String */
        final String preparedText = text.get().replaceAll("\\s+", "");

        /* Add item if not yet in list */
        if (!listviewContext.getItems().contains(preparedText)) {
            listviewContext.getItems().add(preparedText);
        }

        /* Add item if not yet in selection and keep list sorted */
        if (!contexts.contains(preparedText)) {
            contexts.add(preparedText);
            Collections.sort(contexts, String.CASE_INSENSITIVE_ORDER);
        }
    }
}
项目:SimpleTaskList    文件:NewEditDialogController.java   
/**
 * Handle a click on the "add project" button: open an input dialog and
 * add the inserted project to the list.
 */
@FXML
private void handleAddProject() {
    final TextInputDialog input = new TextInputDialog();
    AbstractDialogController.prepareDialog(input, "dialog.project.new.title",
            "dialog.project.new.header", "dialog.project.new.content", getCurrentWindowData());
    final Optional<String> text = input.showAndWait();
    if (text.isPresent()) {
        /* Remove whitespaces from String */
        final String preparedText = text.get().replaceAll("\\s+", "");

        /* Add item if not yet in list */
        if (!listviewProject.getItems().contains(preparedText)) {
            listviewProject.getItems().add(preparedText);
        }

        /* Add item if not yet in selection and keep list sorted */
        if (!projects.contains(preparedText)) {
            projects.add(preparedText);
            Collections.sort(projects, String.CASE_INSENSITIVE_ORDER);
        }
    }
}
项目:mzmine3    文件:MsSpectrumPlotWindowController.java   
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();
    }
  });

}
项目:UT4Converter    文件:ConversionSettingsController.java   
/**
 * Allow changing the default ut4 map name suggested by ut4 converter
 * 
 * @param event
 */
@FXML
private void changeMapName(ActionEvent event) {

    TextInputDialog dialog = new TextInputDialog(mapConverter.getOutMapName());

    dialog.setTitle("Text Input Dialog");
    dialog.setHeaderText("Map Name Change");
    dialog.setContentText("Enter UT4 map name:");

    // Traditional way to get the response value.
    Optional<String> result = dialog.showAndWait();

    if (result.isPresent()) {
        String newMapName = result.get();
        newMapName = T3DUtils.filterName(newMapName);

        if (newMapName.length() > 3) {
            mapConverter.setOutMapName(newMapName);
            outMapNameLbl.setText(mapConverter.getOutMapName());
            mapConverter.initConvertedResourcesFolder();
            ut4BaseReferencePath.setText(mapConverter.getUt4ReferenceBaseFolder());
        }
    }

}
项目:UT4Converter    文件:ConversionSettingsController.java   
@FXML
private void changeRelativeUtMapPath(ActionEvent event) {

    // TODO
    TextInputDialog dialog = new TextInputDialog(mapConverter.getOutMapName());

    dialog.setTitle("Text Input Dialog");
    dialog.setHeaderText("Map Name Change");
    dialog.setContentText("Enter UT4 map name:");

    // Traditional way to get the response value.
    Optional<String> result = dialog.showAndWait();

    if (result.isPresent()) {
        String newMapName = result.get();
        newMapName = T3DUtils.filterName(newMapName);

        if (newMapName.length() > 3) {
            mapConverter.setOutMapName(newMapName);
            outMapNameLbl.setText(mapConverter.getOutMapName());
        }
    }

}
项目:logbook-kai    文件:FleetTabPane.java   
/**
 * 分岐点係数を変更する
 *
 * @param event ActionEvent
 */
@FXML
void changeBranchCoefficient(ActionEvent event) {
    TextInputDialog dialog = new TextInputDialog(Double.toString(this.branchCoefficient));
    dialog.getDialogPane().getStylesheets().add("logbook/gui/application.css");
    dialog.initOwner(this.getScene().getWindow());
    dialog.setTitle("分岐点係数を変更");
    dialog.setHeaderText("分岐点係数を数値で入力してください 例)\n"
            + SeaArea.沖ノ島沖 + " H,Iマス 係数: 1.0\n"
            + SeaArea.北方AL海域 + " Gマス 係数: 4.0\n"
            + SeaArea.中部海域哨戒線 + " E,Fマス 係数: 4.0\n"
            + SeaArea.MS諸島沖 + " F,Hマス 係数: 3.0\n"
            + SeaArea.グアノ環礁沖海域 + " 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) {
            }
        }
    }
}
项目:RaspberryPiBeaconParser    文件:MainController.java   
@FXML
private void handleSCPAction() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open File for SCP");
    Stage mainStage = (Stage) consoleArea.getScene().getWindow();
    File selectedFile = fileChooser.showOpenDialog(mainStage);
    if (selectedFile != null) {
        TextInputDialog dialog = new TextInputDialog("");
        dialog.setTitle("Target Directory");
        dialog.setHeaderText("Specify target directory");
        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()){
            String targetPath = result.get();
            String hostIP = selectedInfo.getLastStatus().get(StatusProperties.HostIPAddress.name());
            consoleArea.setText(String.format("Beginning scp(%s) to: %s:%s\n", selectedFile, selectedInfo.getScannerID(), targetPath));
            Thread scpThread = new Thread(() -> doSCP(hostIP, selectedFile, targetPath), "handleSCPAction");
            scpThread.setDaemon(true);
            scpThread.start();
        }
    }
}
项目:rs-timer    文件:MainWindow.java   
/**
 * Third entry. This if it returns a value actually creates the tab
 */
void showNewTabColumnsDialog(String name, int rows) {
    logger.info("showNewTabColumnsDialog was called with the data: " + name + " & " + rows);
    if (rows > 0) {
        finishNewTabDialogs(rows, 0, name);
        return;
    }
    TextInputDialog inputDialog = new TextInputDialog();
    inputDialog.setContentText("Enter the number of columns to apply to the tab");
    inputDialog.getEditor().setTextFormatter(new TextFormatter<Integer>(new IntegerStringConverter()));
    inputDialog.getEditor().setText("0");
    inputDialog.setHeaderText(null);
    inputDialog.setTitle("New Tab Columns");
    inputDialog.showAndWait()
        .filter(response -> !"".equals(response))
        .ifPresent( response -> this.finishNewTabDialogs(rows, Integer.parseInt(response), name)); 
}
项目:jace    文件:Program.java   
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());
}
项目:PeerWasp    文件:Network.java   
@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);
        }
    }
}
项目:Matrixonator-Java    文件:MatrixOverviewController.java   
/**
 * 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();
  }

}
项目:lawless-legends    文件:Program.java   
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());
}
项目:jvarkit    文件:JfxNgs.java   
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);
    }

}
项目:jvarkit    文件:JfxNgs.java   
void openVcfUrl(final Window owner)
{
    final String lastkey="last.vcf.url";
final TextInputDialog dialog=new TextInputDialog(this.preferences.get(lastkey, ""));
dialog.setContentText("URL:");
dialog.setTitle("Get VCF URL");
dialog.setHeaderText("Input VCF URL");
final Optional<String> choice=dialog.showAndWait();
if(!choice.isPresent()) return;
    VcfFile input=null;
    try {
    input = VcfFile.newInstance(choice.get());
    this.preferences.put(lastkey, choice.get());
    VcfStage stage=new VcfStage(JfxNgs.this, input);
    stage.show();
} catch (final Exception err) {
    CloserUtil.close(input);
    showExceptionDialog(owner, err);
    }
}
项目:titanium    文件:Controls.java   
private void broadcastAction(Event e) {
    TextInputDialog dial = new TextInputDialog();
    dial.setTitle("Broadcast");

    Optional<String> result = dial.showAndWait();

    if (result.isPresent()) {
        try {
            tab.getServer().broadcast(result.get());
        } catch (RCONServerException e1) {
            logError(e1);
        }
    }

}
项目:titanium    文件:OrganizationManagerStage.java   
private void newAction(Event e) {
    TextInputDialog dialog = new TextInputDialog();
    dialog.setTitle("New organization");
    dialog.setHeaderText("Create a new organization");
    dialog.setContentText("Organization name");

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

    if (result.isPresent() && result.get().length() > 0) {
        System.out.println("present");
        if (result.get().length() <= 3) {
            new Alert(AlertType.ERROR, "The name is too short.").show();;
        } else {
            try {
                wsp.newOrganization(result.get());
                wsp.fecthAndSetOrganization();
                forceOrganizationListRefresh();
                App.getCurrentInstance().refreshWSPTabs();
            } catch (JSONException | IOException | HttpException | WebApiException e1) {
                ErrorUtils.getAlertFromException(e1).show();
            }
        }
    } else {
        System.out.println("not present");
    }

    System.out.println(result);

}