Java Code Examples for javafx.scene.control.Dialog#setTitle()
The following examples show how to use
javafx.scene.control.Dialog#setTitle() .
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: DialogUtils.java From mapper-generator-javafx with Apache License 2.0 | 7 votes |
public static void closeDialog(Stage primaryStage) { Dialog<ButtonType> dialog = new Dialog<>(); dialog.setTitle("关闭"); dialog.setContentText("确认关闭吗?"); dialog.initOwner(primaryStage); dialog.getDialogPane().getButtonTypes().add(ButtonType.APPLY); dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE); dialog.getDialogPane().setPrefSize(350, 100); Optional<ButtonType> s = dialog.showAndWait(); s.ifPresent(s1 -> { if (s1.equals(ButtonType.APPLY)) { primaryStage.close(); } else if (s1.equals(ButtonType.CLOSE)) { dialog.close(); } }); }
Example 2
Source File: DesktopBrowserLauncher.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
/** * View a URI in a browser. * * @param uri URI to display in browser. * @throws IOException if browser can not be launched */ private static void viewInBrowser(URI uri) throws IOException { if (Desktop.isDesktopSupported() && DESKTOP.isSupported(Action.BROWSE)) { DESKTOP.browse(uri); } else { Dialog<ButtonType> alert = GuiUtility.runOnJavaFXThreadNow(() -> new Alert(Alert.AlertType.WARNING)); Logging.debugPrint("unable to browse to " + uri); alert.setTitle(LanguageBundle.getString("in_err_browser_err")); alert.setContentText(LanguageBundle.getFormattedString("in_err_browser_uri", uri)); GuiUtility.runOnJavaFXThreadNow(alert::showAndWait); } }
Example 3
Source File: RadioChooserDialog.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private void onOK(final ActionEvent ignored) { Toggle selectedToggle = toggleGroup.getSelectedToggle(); Logging.debugPrint("selected toggle is " + selectedToggle); if (selectedToggle != null) { Integer whichItemId = (Integer)selectedToggle.getUserData(); InfoFacade selectedItem = chooser.getAvailableList().getElementAt(whichItemId); chooser.addSelected(selectedItem); } if (chooser.isRequireCompleteSelection() && (chooser.getRemainingSelections().get() > 0)) { Dialog<ButtonType> alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(chooser.getName()); alert.setContentText(LanguageBundle.getFormattedString("in_chooserRequireComplete", chooser.getRemainingSelections().get())); alert.showAndWait(); return; } chooser.commit(); committed = true; this.dispose(); }
Example 4
Source File: PatchEditorTab.java From EWItool with GNU General Public License v3.0 | 6 votes |
public void mergePatchesUi() { List<String> patchNames = new ArrayList<>(); for (int p = 0; p < EWI4000sPatch.EWI_NUM_PATCHES; p++) patchNames.add( sharedData.ewiPatchList[p].getName() ); Dialog<Integer> mergeDialog = new Dialog<>(); mergeDialog.setTitle( "EWItool - Merge Patches" ); mergeDialog.setHeaderText( "Choose patch to merge with..." ); ListView<String> lv = new ListView<>(); lv.getItems().setAll( patchNames ); // don't need Observable here mergeDialog.getDialogPane().setContent( lv ); mergeDialog.setResultConverter( button -> { if (button == ButtonType.OK) return lv.getSelectionModel().getSelectedIndex(); else return null; } ); mergeDialog.getDialogPane().getButtonTypes().addAll( ButtonType.OK, ButtonType.CANCEL ); Optional<Integer> result = mergeDialog.showAndWait(); if (result.isPresent() && result.get() != -1) { mergeWith( result.get() ); } }
Example 5
Source File: DesktopBrowserLauncher.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
/** * View a URI in a browser. * * @param uri URI to display in browser. * @throws IOException if browser can not be launched */ private static void viewInBrowser(URI uri) throws IOException { if (Desktop.isDesktopSupported() && DESKTOP.isSupported(Action.BROWSE)) { DESKTOP.browse(uri); } else { Dialog<ButtonType> alert = GuiUtility.runOnJavaFXThreadNow(() -> new Alert(Alert.AlertType.WARNING)); Logging.debugPrint("unable to browse to " + uri); alert.setTitle(LanguageBundle.getString("in_err_browser_err")); alert.setContentText(LanguageBundle.getFormattedString("in_err_browser_uri", uri)); GuiUtility.runOnJavaFXThreadNow(alert::showAndWait); } }
Example 6
Source File: DialogFactory.java From Motion_Profile_Generator with MIT License | 6 votes |
public static Dialog<Boolean> createAboutDialog() { Dialog<Boolean> dialog = new Dialog<>(); try { FXMLLoader loader = new FXMLLoader( ResourceLoader.getResource("/com/mammen/ui/javafx/dialog/about/AboutDialog.fxml") ); dialog.setDialogPane( loader.load() ); dialog.setResultConverter( (ButtonType buttonType) -> buttonType.getButtonData() == ButtonBar.ButtonData.CANCEL_CLOSE ); } catch( Exception e ) { e.printStackTrace(); dialog.getDialogPane().getButtonTypes().add( ButtonType.CLOSE ); } dialog.setTitle( "About" ); return dialog; }
Example 7
Source File: DialogFactory.java From Motion_Profile_Generator with MIT License | 6 votes |
public static Dialog<Boolean> createSettingsDialog() { Dialog<Boolean> dialog = new Dialog<>(); try { FXMLLoader loader = new FXMLLoader( ResourceLoader.getResource("/com/mammen/ui/javafx/dialog/settings/SettingsDialog.fxml") ); dialog.setDialogPane( loader.load() ); ((Button) dialog.getDialogPane().lookupButton(ButtonType.APPLY)).setDefaultButton(true); ((Button) dialog.getDialogPane().lookupButton(ButtonType.CANCEL)).setDefaultButton(false); // Some header stuff dialog.setTitle("Settings"); dialog.setHeaderText("Manage settings"); dialog.setResultConverter( (ButtonType buttonType) -> buttonType.getButtonData() == ButtonBar.ButtonData.APPLY ); } catch( Exception e ) { e.printStackTrace(); } return dialog; }
Example 8
Source File: RadioChooserDialog.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private void onOK(final ActionEvent ignored) { Toggle selectedToggle = toggleGroup.getSelectedToggle(); Logging.debugPrint("selected toggle is " + selectedToggle); if (selectedToggle != null) { Integer whichItemId = (Integer)selectedToggle.getUserData(); InfoFacade selectedItem = chooser.getAvailableList().getElementAt(whichItemId); chooser.addSelected(selectedItem); } if (chooser.isRequireCompleteSelection() && (chooser.getRemainingSelections().get() > 0)) { Dialog<ButtonType> alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(chooser.getName()); alert.setContentText(LanguageBundle.getFormattedString("in_chooserRequireComplete", chooser.getRemainingSelections().get())); alert.showAndWait(); return; } chooser.commit(); committed = true; this.dispose(); }
Example 9
Source File: Dialogs.java From CPUSim with GNU General Public License v3.0 | 5 votes |
/** * Initialized a dialog with the given owner window, and String header and content * @param dialog dialog box to initialize * @param window owning window or null if there is none * @param header dialog header * @param content dialog content */ public static void initializeDialog(Dialog dialog, Window window, String header, String content){ if (window != null) dialog.initOwner(window); dialog.setTitle("CPU Sim"); dialog.setHeaderText(header); dialog.setContentText(content); // Allow dialogs to resize for Linux // https://bugs.openjdk.java.net/browse/JDK-8087981 dialog.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); }
Example 10
Source File: PacketHex.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
/** * 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; }
Example 11
Source File: MultiplayerClient.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void connectDialog() { // Create the custom dialog. Dialog<String> dialog = new Dialog<>(); // Get the Stage. Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); /* stage.setOnCloseRequest(e -> { boolean isExit = mainMenu.exitDialog(stage);//.getScreensSwitcher().exitDialog(stage); if (!isExit) { e.consume(); } else { Platform.exit(); } }); */ // Add corner icon. stage.getIcons().add(new Image(this.getClass().getResource("/icons/network/client48.png").toString())); // Add Stage icon dialog.setGraphic(new ImageView(this.getClass().getResource("/icons/network/network256.png").toString())); // dialog.initOwner(mainMenu.getStage()); dialog.setTitle("Mars Simulation Project"); dialog.setHeaderText("Multiplayer Client"); dialog.setContentText("Enter the host address : "); // Set the button types. ButtonType connectButtonType = new ButtonType("Connect", ButtonData.OK_DONE); // ButtonType localHostButton = new ButtonType("localhost"); // dialog.getDialogPane().getButtonTypes().addAll(localHostButton, // loginButtonType, ButtonType.CANCEL); dialog.getDialogPane().getButtonTypes().addAll(connectButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); // TextField tfUser = new TextField(); // tfUser.setPromptText("Username"); TextField tfServerAddress = new TextField(); // PasswordField password = new PasswordField(); tfServerAddress.setPromptText("192.168.xxx.xxx"); tfServerAddress.setText("192.168.xxx.xxx"); Button localhostB = new Button("Use localhost"); // grid.add(new Label("Username:"), 0, 0); // grid.add(tfUser, 1, 0); grid.add(new Label("Server Address:"), 0, 1); grid.add(tfServerAddress, 1, 1); grid.add(localhostB, 2, 1); // Enable/Disable connect button depending on whether the host address // was entered. Node connectButton = dialog.getDialogPane().lookupButton(connectButtonType); connectButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). tfServerAddress.textProperty().addListener((observable, oldValue, newValue) -> { connectButton.setDisable(newValue.trim().isEmpty()); } ); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> tfServerAddress.requestFocus()); // Convert the result to a username-password-pair when the login button // is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == connectButtonType) { return tfServerAddress.getText(); } return null; } ); localhostB.setOnAction(event -> { tfServerAddress.setText("127.0.0.1"); } ); // localhostB.setPadding(new Insets(1)); // localhostB.setPrefWidth(10); Optional<String> result = dialog.showAndWait(); result.ifPresent(input -> { String serverAddressStr = tfServerAddress.getText(); this.serverAddressStr = serverAddressStr; logger.info("Connecting to server at " + serverAddressStr); loginDialog(); } ); }
Example 12
Source File: PikaRFIDDirectReader.java From pikatimer with GNU General Public License v3.0 | 4 votes |
private void setClockDialog(){ Integer localTZ = TimeZone.getDefault().getOffset(System.currentTimeMillis())/3600000; Integer ultraTZ = Integer.parseInt(ultraSettings.get("23")); // open a dialog box Dialog<Boolean> dialog = new Dialog(); dialog.setTitle("Set Ultra Clock"); dialog.setHeaderText("Set the clock for " + ultraIP); ButtonType setButtonType = new ButtonType("Set", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(setButtonType, ButtonType.CANCEL); VBox clockVBox = new VBox(); clockVBox.setStyle("-fx-font-size: 16px;"); CheckBox useComputer = new CheckBox("Sync with the local computer"); VBox manualVBox = new VBox(); manualVBox.setSpacing(5.0); manualVBox.disableProperty().bind(useComputer.selectedProperty()); HBox dateHBox = new HBox(); dateHBox.setSpacing(5.0); Label dateLabel = new Label("Date:"); dateLabel.setMinWidth(40); DatePicker ultraDate = new DatePicker(); dateHBox.getChildren().addAll(dateLabel,ultraDate); HBox timeHBox = new HBox(); timeHBox.setSpacing(5.0); Label timeLabel = new Label("Time:"); timeLabel.setMinWidth(40); TextField ultraTime = new TextField(); timeHBox.getChildren().addAll(timeLabel,ultraTime); HBox tzHBox = new HBox(); tzHBox.setSpacing(5.0); Label tzLabel = new Label("TimeZone:"); tzLabel.setMinWidth(40); Spinner<Integer> tzSpinner = new Spinner<>(-23, 23, localTZ); tzHBox.getChildren().addAll(tzLabel,tzSpinner); manualVBox.getChildren().addAll(dateHBox,timeHBox,tzHBox); CheckBox autoGPS = new CheckBox("Use GPS to auto-set the clock"); autoGPS.setSelected(true); clockVBox.getChildren().addAll(useComputer,manualVBox,autoGPS); dialog.getDialogPane().setContent(clockVBox); BooleanProperty timeOK = new SimpleBooleanProperty(false); ultraTime.textProperty().addListener((observable, oldValue, newValue) -> { timeOK.setValue(false); if (DurationParser.parsable(newValue)) timeOK.setValue(Boolean.TRUE); if ( newValue.isEmpty() || newValue.matches("^[0-9]*(:?([0-5]?([0-9]?(:([0-5]?([0-9]?)?)?)?)?)?)?") ){ System.out.println("Possiblely good start Time (newValue: " + newValue + ")"); } else { Platform.runLater(() -> { int c = ultraTime.getCaretPosition(); if (oldValue.length() > newValue.length()) c++; else c--; ultraTime.setText(oldValue); ultraTime.positionCaret(c); }); System.out.println("Bad clock time (newValue: " + newValue + ")"); } }); ultraDate.setValue(LocalDate.now()); ultraTime.setText(LocalTime.ofSecondOfDay(LocalTime.now().toSecondOfDay()).toString()); Node createButton = dialog.getDialogPane().lookupButton(setButtonType); createButton.disableProperty().bind(timeOK.not()); dialog.setResultConverter(dialogButton -> { if (dialogButton == setButtonType) { return Boolean.TRUE; } return null; }); Optional<Boolean> result = dialog.showAndWait(); if (result.isPresent()) { if (useComputer.selectedProperty().get()) { System.out.println("Timezone check: Local :" + localTZ + " ultra: " + ultraTZ); if (localTZ.equals(ultraTZ)) setClock(LocalDateTime.now(),null,autoGPS.selectedProperty().get()); else setClock(LocalDateTime.now(),localTZ,autoGPS.selectedProperty().get()); } else { LocalTime time = LocalTime.MIDNIGHT.plusSeconds(DurationParser.parse(ultraTime.getText()).getSeconds()); Integer newTZ = tzSpinner.getValue(); if (newTZ.equals(ultraTZ)) setClock(LocalDateTime.of(ultraDate.getValue(), time),null,autoGPS.selectedProperty().get()); else { setClock(LocalDateTime.of(ultraDate.getValue(), time),newTZ,autoGPS.selectedProperty().get()); } } } }
Example 13
Source File: ViewUtil.java From ClusterDeviceControlPlatform with MIT License | 4 votes |
public static Optional<TcpMsgResponseRandomDeviceStatus> randomDeviceStatus() throws NumberFormatException { Dialog<TcpMsgResponseRandomDeviceStatus> dialog = new Dialog<>(); dialog.setTitle("随机状态信息"); dialog.setHeaderText("随机设备的状态信息"); ButtonType loginButtonType = new ButtonType("发送", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField textFieldGroupId = new TextField(); textFieldGroupId.setPromptText("1 - 120"); TextField textFieldLength = new TextField(); textFieldLength.setPromptText("1 - 60_0000"); TextField textFieldStatus = new TextField(); textFieldStatus.setPromptText("1 - 6"); grid.add(new Label("组号: "), 0, 0); grid.add(textFieldGroupId, 1, 0); grid.add(new Label("范围: "), 0, 1); grid.add(textFieldLength, 1, 1); grid.addRow(2, new Label("状态码: ")); // grid.add(, 0, 2); grid.add(textFieldStatus, 1, 2); // Enable/Disable login button depending on whether a username was entered. Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus))); textFieldLength.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus))); textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus))); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(textFieldGroupId::requestFocus); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { try { TcpMsgResponseRandomDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseRandomDeviceStatus(Integer.parseInt( textFieldGroupId.getText().trim()), Integer.parseInt(textFieldStatus.getText().trim()), Integer.parseInt(textFieldLength.getText().trim())); return tcpMsgResponseDeviceStatus; } catch (NumberFormatException e) { System.out.println("空"); return new TcpMsgResponseRandomDeviceStatus(-1, -1, -1); } } return null; }); return dialog.showAndWait(); }
Example 14
Source File: ViewUtil.java From ClusterDeviceControlPlatform with MIT License | 4 votes |
public static Optional<TcpMsgResponseDeviceStatus> ResponseDeviceStatusResult() throws NumberFormatException { Dialog<TcpMsgResponseDeviceStatus> dialog = new Dialog<>(); dialog.setTitle("发送状态信息"); dialog.setHeaderText("请设置单个设备的状态"); ButtonType loginButtonType = new ButtonType("发送", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField textFieldGroupId = new TextField(); textFieldGroupId.setPromptText("1 - 120"); TextField textFieldDeviceId = new TextField(); textFieldDeviceId.setPromptText("1 - 100"); TextField textFieldStatus = new TextField(); textFieldStatus.setPromptText("1 - 6"); grid.add(new Label("组号: "), 0, 0); grid.add(textFieldGroupId, 1, 0); grid.add(new Label("设备号: "), 0, 1); grid.add(textFieldDeviceId, 1, 1); grid.addRow(2, new Label("状态码: ")); // grid.add(, 0, 2); grid.add(textFieldStatus, 1, 2); // Enable/Disable login button depending on whether a username was entered. Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus))); textFieldDeviceId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus))); textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus))); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(textFieldGroupId::requestFocus); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { try { TcpMsgResponseDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseDeviceStatus(Integer.parseInt( textFieldGroupId.getText().trim()), Integer.parseInt(textFieldDeviceId.getText().trim()), Integer.parseInt(textFieldStatus.getText().trim())); return tcpMsgResponseDeviceStatus; } catch (NumberFormatException e) { System.out.println("空"); return new TcpMsgResponseDeviceStatus(-1, -1, -1); } } return null; }); return dialog.showAndWait(); }
Example 15
Source File: PortsItemEventHandler.java From EWItool with GNU General Public License v3.0 | 4 votes |
@Override public void handle( ActionEvent arg0 ) { Dialog<ButtonType> dialog = new Dialog<>(); dialog.setTitle( "EWItool - Select MIDI Ports" ); dialog.getDialogPane().getButtonTypes().addAll( ButtonType.CANCEL, ButtonType.OK ); GridPane gp = new GridPane(); gp.add( new Label( "MIDI In Ports" ), 0, 0 ); gp.add( new Label( "MIDI Out Ports" ), 1, 0 ); ListView<String> inView, outView; List<String> inPortList = new ArrayList<>(), outPortList = new ArrayList<>(); ObservableList<String> inPorts = FXCollections.observableArrayList( inPortList ), outPorts = FXCollections.observableArrayList( outPortList ); inView = new ListView<>( inPorts ); outView = new ListView<>( outPorts ); String lastInDevice = userPrefs.getMidiInPort(); String lastOutDevice = userPrefs.getMidiOutPort(); int ipIx = -1, opIx = -1; MidiDevice device; MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo(); for ( MidiDevice.Info info : infos ) { try { device = MidiSystem.getMidiDevice( info ); if (!( device instanceof Sequencer ) && !( device instanceof Synthesizer )) { if (device.getMaxReceivers() != 0) { opIx++; outPorts.add( info.getName() ); if (info.getName().equals( lastOutDevice )) { outView.getSelectionModel().clearAndSelect( opIx ); } Debugger.log( "DEBUG - Found OUT Port: " + info.getName() + " - " + info.getDescription() ); } else if (device.getMaxTransmitters() != 0) { ipIx++; inPorts.add( info.getName() ); if (info.getName().equals( lastInDevice )) { inView.getSelectionModel().clearAndSelect( ipIx ); } Debugger.log( "DEBUG - Found IN Port: " + info.getName() + " - " + info.getDescription() ); } } } catch (MidiUnavailableException ex) { ex.printStackTrace(); } } gp.add( inView, 0, 1 ); gp.add( outView, 1, 1 ); dialog.getDialogPane().setContent( gp ); Optional<ButtonType> rc = dialog.showAndWait(); if (rc.get() == ButtonType.OK) { if (outView.getSelectionModel().getSelectedIndex() != -1) { userPrefs.setMidiOutPort( outView.getSelectionModel().getSelectedItem() ); } if (inView.getSelectionModel().getSelectedIndex() != -1) { userPrefs.setMidiInPort( inView.getSelectionModel().getSelectedItem() ); } } }
Example 16
Source File: GitFxDialog.java From GitFx with Apache License 2.0 | 4 votes |
@Override public String gitOpenDialog(String title, String header, String content) { String repo; DirectoryChooser chooser = new DirectoryChooser(); Dialog<Pair<String, GitFxDialogResponse>> dialog = new Dialog<>(); //Dialog<Pair<String, GitFxDialogResponse>> dialog = getCostumeDialog(); dialog.setTitle(title); dialog.setHeaderText(header); dialog.setContentText(content); ButtonType okButton = new ButtonType("Ok"); ButtonType cancelButton = new ButtonType("Cancel"); dialog.getDialogPane().getButtonTypes().addAll(okButton, cancelButton); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField repository = new TextField(); repository.setPrefWidth(250.0); repository.setPromptText("Repo"); grid.add(new Label("Repository:"), 0, 0); grid.add(repository, 1, 0); /////////////////////Modification of choose Button//////////////////////// Button chooseButtonType = new Button("Choose"); grid.add(chooseButtonType, 2, 0); // Button btnCancel1 = new Button("Cancel"); // btnCancel1.setPrefWidth(90.0); // Button btnOk1 = new Button("Ok"); // btnOk1.setPrefWidth(90.0); // HBox hbox = new HBox(4); // hbox.getChildren().addAll(btnOk1,btnCancel1); // hbox.setPadding(new Insets(2)); // grid.add(hbox, 1, 1); chooseButtonType.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { // label.setText("Accepted"); File path = chooser.showDialog(dialog.getOwner()); getFileAndSeText(repository,path); chooser.setTitle(resourceBundle.getString("repo")); } }); // btnCancel1.setOnAction(new EventHandler<ActionEvent>(){ // @Override public void handle(ActionEvent e) { // System.out.println("Shyam : Testing"); // setResponse(GitFxDialogResponse.CANCEL); // } // }); ////////////////////////////////////////////////////////////////////// dialog.getDialogPane().setContent(grid); dialog.setResultConverter(dialogButton -> { if (dialogButton == okButton) { String filePath = repository.getText(); //filePath = filePath.concat("/.git"); //[LOG] logger.debug(filePath); if (!filePath.isEmpty() && new File(filePath).exists()) { setResponse(GitFxDialogResponse.OK); return new Pair<>(repository.getText(), GitFxDialogResponse.OK); } else { this.gitErrorDialog(resourceBundle.getString("errorOpen"), resourceBundle.getString("errorOpenTitle"), resourceBundle.getString("errorOpenDesc")); } } if (dialogButton == cancelButton) { //[LOG] logger.debug("Cancel clicked"); setResponse(GitFxDialogResponse.CANCEL); return new Pair<>(null, GitFxDialogResponse.CANCEL); } return null; }); Optional<Pair<String, GitFxDialogResponse>> result = dialog.showAndWait(); result.ifPresent(repoPath -> { //[LOG] logger.debug(repoPath.getKey() + " " + repoPath.getValue().toString()); }); Pair<String, GitFxDialogResponse> temp = null; if (result.isPresent()) { temp = result.get(); } if(temp != null){ return temp.getKey();// + "/.git"; } return EMPTY_STRING; }
Example 17
Source File: GitFxDialog.java From GitFx with Apache License 2.0 | 4 votes |
@Override public Pair<String, String> gitInitDialog(String title, String header, String content) { Pair<String, String> repo; Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle(title); dialog.setHeaderText(header); dialog.setContentText(content); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField localPath = new TextField(); localPath.setPromptText("Local Path"); localPath.setPrefWidth(250.0); grid.add(new Label("Local Path:"), 0, 0); grid.add(localPath, 1,0); ButtonType initRepo = new ButtonType("Initialize Repository"); ButtonType cancelButtonType = new ButtonType("Cancel"); dialog.getDialogPane().setContent(grid); dialog.getDialogPane().getButtonTypes().addAll( initRepo, cancelButtonType); /////////////////////Modification of choose Button//////////////////////// Button chooseButtonType = new Button("Choose"); grid.add(chooseButtonType, 2, 0); chooseButtonType.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { DirectoryChooser chooser = new DirectoryChooser(); chooser.setTitle(resourceBundle.getString("selectRepo")); File initialRepo = chooser.showDialog(dialog.getOwner()); getFileAndSeText(localPath, initialRepo); dialog.getDialogPane(); } }); ////////////////////////////////////////////////////////////////////// dialog.setResultConverter(dialogButton -> { if (dialogButton == initRepo) { setResponse(GitFxDialogResponse.INITIALIZE); String path = localPath.getText(); //[LOG] logger.debug( "path" + path + path.isEmpty()); if (new File(path).exists()) { //[LOG] logger.debug(path.substring(localPath.getText().lastIndexOf(File.separator))); String projectName= path.substring(localPath.getText().lastIndexOf(File.separator)+1); return new Pair<>(projectName, localPath.getText()); } else { this.gitErrorDialog(resourceBundle.getString("errorInit"), resourceBundle.getString("errorInitTitle"), resourceBundle.getString("errorInitDesc")); } } if (dialogButton == cancelButtonType) { setResponse(GitFxDialogResponse.CANCEL); return new Pair<>(null, null); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); Pair<String, String> temp = null; if (result.isPresent()) { temp = result.get(); } return temp; }
Example 18
Source File: GitFxDialog.java From GitFx with Apache License 2.0 | 4 votes |
@Override public Pair<String, String> gitCloneDialog(String title, String header, String content) { Dialog<Pair<String, String>> dialog = new Dialog<>(); DirectoryChooser chooser = new DirectoryChooser(); dialog.setTitle(title); dialog.setHeaderText(header); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField remoteRepo = new TextField(); remoteRepo.setPromptText("Remote Repo URL"); remoteRepo.setPrefWidth(250.0); TextField localPath = new TextField(); localPath.setPromptText("Local Path"); localPath.setPrefWidth(250.0); grid.add(new Label("Remote Repo URL:"), 0, 0); grid.add(remoteRepo, 1, 0); grid.add(new Label("Local Path:"), 0, 1); grid.add(localPath, 1, 1); //ButtonType chooseButtonType = new ButtonType("Choose"); ButtonType cloneButtonType = new ButtonType("Clone"); ButtonType cancelButtonType = new ButtonType("Cancel"); /////////////////////Modification of choose Button//////////////////////// Button chooseButtonType = new Button("Choose"); grid.add(chooseButtonType, 2, 1); chooseButtonType.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { chooser.setTitle(resourceBundle.getString("cloneRepo")); File cloneRepo = chooser.showDialog(dialog.getOwner()); getFileAndSeText(localPath, cloneRepo); } }); ////////////////////////////////////////////////////////////////////// dialog.getDialogPane().setContent(grid); dialog.getDialogPane().getButtonTypes().addAll( cloneButtonType, cancelButtonType); dialog.setResultConverter(dialogButton -> { if (dialogButton == cloneButtonType) { setResponse(GitFxDialogResponse.CLONE); String remoteRepoURL = remoteRepo.getText(); String localRepoPath = localPath.getText(); if (!remoteRepoURL.isEmpty() && !localRepoPath.isEmpty()) { return new Pair<>(remoteRepo.getText(), localPath.getText()); } else { this.gitErrorDialog(resourceBundle.getString("errorClone"), resourceBundle.getString("errorCloneTitle"), resourceBundle.getString("errorCloneDesc")); } } if (dialogButton == cancelButtonType) { //[LOG] logger.debug("Cancel clicked"); setResponse(GitFxDialogResponse.CANCEL); return new Pair<>(null, null); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); Pair<String, String> temp = null; if (result.isPresent()) { temp = result.get(); } return temp; }
Example 19
Source File: ViewUtil.java From ClusterDeviceControlPlatform with MIT License | 4 votes |
public static Optional<Pair<String, String>> ConnDialogResult() { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("建立连接"); dialog.setHeaderText("请输入服务器的连接信息"); ButtonType loginButtonType = new ButtonType("连接", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField hostName = new TextField(); hostName.setPromptText("localhost"); hostName.setText("localhost"); TextField port = new TextField(); port.setPromptText("30232"); port.setText("30232"); grid.add(new Label("主机名: "), 0, 0); grid.add(hostName, 1, 0); grid.add(new Label("端口号: "), 0, 1); grid.add(port, 1, 1); // Enable/Disable login button depending on whether a username was entered. // Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); // loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). // hostName.textProperty().addListener((observable, oldValue, newValue) -> { // loginButton.setDisable(newValue.trim().isEmpty()); // }); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> hostName.requestFocus()); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { return new Pair<>(hostName.getText(), port.getText()); } return null; }); return dialog.showAndWait(); }
Example 20
Source File: ProjectDirectoryNotSpecifiedDialog.java From paintera with GNU General Public License v2.0 | 4 votes |
public Optional<String> showDialog(final String contentText) throws ProjectDirectoryNotSpecified { if (this.defaultToTempDirectory) { return Optional.of(tmpDir()); } final StringProperty projectDirectory = new SimpleStringProperty(null); final ButtonType specifyProject = new ButtonType("Specify Project", ButtonData.OTHER); final ButtonType noProject = new ButtonType("No Project", ButtonData.OK_DONE); final Dialog<String> dialog = new Dialog<>(); dialog.setResultConverter(bt -> { return ButtonType.CANCEL.equals(bt) ? null : noProject.equals(bt) ? tmpDir() : projectDirectory.get(); }); dialog.getDialogPane().getButtonTypes().setAll(specifyProject, noProject, ButtonType.CANCEL); dialog.setTitle("Paintera"); dialog.setHeaderText("Specify Project Directory"); dialog.setContentText(contentText); final Node lookupProjectButton = dialog.getDialogPane().lookupButton(specifyProject); if (lookupProjectButton instanceof Button) { ((Button) lookupProjectButton).setTooltip(new Tooltip("Look up project directory.")); } Optional .ofNullable(dialog.getDialogPane().lookupButton(noProject)) .filter(b -> b instanceof Button) .map(b -> (Button) b) .ifPresent(b -> b.setTooltip(new Tooltip("Create temporary project in /tmp."))); Optional .ofNullable(dialog.getDialogPane().lookupButton(ButtonType.CANCEL)) .filter(b -> b instanceof Button) .map(b -> (Button) b) .ifPresent(b -> b.setTooltip(new Tooltip("Do not start Paintera."))); lookupProjectButton.addEventFilter(ActionEvent.ACTION, event -> { final DirectoryChooser chooser = new DirectoryChooser(); final Optional<String> d = Optional.ofNullable(chooser.showDialog(dialog.getDialogPane().getScene() .getWindow())).map( File::getAbsolutePath); if (d.isPresent()) { projectDirectory.set(d.get()); } else { // consume on cancel, so that parent dialog does not get closed. event.consume(); } }); dialog.setResizable(true); final Optional<String> returnVal = dialog.showAndWait(); if (!returnVal.isPresent()) { throw new ProjectDirectoryNotSpecified(); } return returnVal; }