下面列出了javafx.scene.control.TextField#setPromptText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public SearchBox() {
String searchBoxCss = SearchBox.class.getResource("/common/css/searchbox.css").toExternalForm();
getStylesheets().add(searchBoxCss);
setId("SearchBox");
getStyleClass().add("search-box");
setMinHeight(24);
// setPrefSize(200, 24);
setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
textField = new TextField();
textField.setPromptText("查找");
clearButton = new Button();
clearButton.setVisible(false);
getChildren().addAll(textField, clearButton);
clearButton.setOnAction((ActionEvent actionEvent) -> {
textField.setText("");
textField.requestFocus();
});
textField.textProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
clearButton.setVisible(textField.getText().length() != 0);
});
}
private void addCol() {
TableColumn tc = new TableColumn();
tc.setEditable(true);
tc.setCellValueFactory(param -> {
CellDataFeatures<ZRow, String> dtf = (CellDataFeatures<ZRow, String>) param;
return new SimpleStringProperty(dtf.getValue().getRow().get(0));
});
tc.setCellFactory(TextFieldTableCell.forTableColumn());
tc.setOnEditCommit(t -> {
CellEditEvent<ZRow, String> evt = (CellEditEvent<ZRow, String>) t;
List<String> row = evt.getTableView().getItems().get(evt.getTablePosition().getRow()).getRow();
row.set(evt.getTablePosition().getColumn(), evt.getNewValue());
});
tc.setPrefWidth(150);
TextField txf = new TextField();
txf.setPrefWidth(150);
txf.setPromptText(Configuration.getBundle().getString("ui.dialog.table_editor.colon") +
(tableView.getColumns().size()+1));
tc.setGraphic(txf);
tableView.getColumns().addAll(tc);
postAddColumn();
}
public LocationInput(boolean emptyIsZero) {
this.emptyIsZero = emptyIsZero;
if (emptyIsZero) {
x = z = 0;
value = new Point2i(0, 0);
}
getStyleClass().add("location-input");
xValue = new TextField();
xValue.setPromptText("X");
xValue.textProperty().addListener((a, o, n) -> onXInput(o, n));
zValue = new TextField();
zValue.setPromptText("Z");
zValue.textProperty().addListener((a, o, n) -> onZInput(o, n));
getChildren().addAll(xValue, zValue);
}
public SearchBox() {
setId("SearchBox");
getStyleClass().add("search-box");
setMinHeight(24);
setPrefSize(200, 24);
setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
textBox = new TextField();
textBox.setPromptText("Search");
clearButton = new Button();
clearButton.setVisible(false);
getChildren().addAll(textBox, clearButton);
clearButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
textBox.setText("");
textBox.requestFocus();
}
});
textBox.textProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
clearButton.setVisible(textBox.getText().length() != 0);
}
});
}
final public void collectDataUI(){
GridPane gridLEFT = new GridPane();
Label queryLabel = new Label("Query");
UIUtils.setSize(queryLabel,Main.columnWidthLEFT/2, 24);
TextField queryField = new TextField();
queryField.setPromptText("formatted query");
UIUtils.setSize(queryField,Main.columnWidthLEFT/2, 24);
Label durationLabel = new Label("Duration");
UIUtils.setSize(durationLabel,Main.columnWidthLEFT/2, 24);
TextField durationField = new TextField();
durationField.setPromptText("duration in days (e.g. 2)");
UIUtils.setSize(durationField,Main.columnWidthLEFT/2, 24);
Label datasetIDLabel = new Label("Dataset ID");
UIUtils.setSize(datasetIDLabel,Main.columnWidthLEFT/2, 24);
TextField datasetIDField = new TextField();
datasetIDField.setPromptText("unique identifier");
UIUtils.setSize(datasetIDField,Main.columnWidthLEFT/2, 24);
gridLEFT.add(queryLabel,0,0);
gridLEFT.add(queryField,1,0);
gridLEFT.add(new Rectangle(0,3),0,1);
gridLEFT.add(durationLabel,0,2);
gridLEFT.add(durationField,1,2);
gridLEFT.add(new Rectangle(0,3),0,3);
gridLEFT.add(datasetIDLabel,0,4);
gridLEFT.add(datasetIDField,1,4);
Button button = new Button("Collect");
UIUtils.setSize(button,Main.columnWidthRIGHT, 24);
button.setAlignment(Pos.CENTER);
VBox buttonBox = new VBox();
buttonBox.setAlignment(Pos.CENTER);
buttonBox.getChildren().add(button);
HBox collectDataBOTH = new HBox(5);
collectDataBOTH.getChildren().addAll(gridLEFT,buttonBox);
grid.add(collectDataBOTH,0,8);
}
@Override
public void setContent(final Tab tab) {
GraphManager.getDefault().addGraphManagerListener(this);
newActiveGraph(GraphManager.getDefault().getActiveGraph());
final TextField filterText = new TextField();
filterText.setPromptText("Filter attribute names");
final ToggleGroup tg = new ToggleGroup();
final RadioButton startsWithRb = new RadioButton("Starts with");
startsWithRb.setToggleGroup(tg);
startsWithRb.setPadding(new Insets(0, 0, 0, 5));
startsWithRb.setSelected(true);
final RadioButton containsRb = new RadioButton("Contains");
containsRb.setToggleGroup(tg);
containsRb.setPadding(new Insets(0, 0, 0, 5));
tg.selectedToggleProperty().addListener((ov, oldValue, newValue) -> {
filter(table, filterText.getText(), startsWithRb.isSelected());
});
filterText.textProperty().addListener((ov, oldValue, newValue) -> {
filter(table, newValue, startsWithRb.isSelected());
});
final HBox headerBox = new HBox(new Label("Filter: "), filterText, startsWithRb, containsRb);
headerBox.setAlignment(Pos.CENTER_LEFT);
headerBox.setPadding(new Insets(5));
final VBox box = new VBox(schemaLabel, headerBox, table);
VBox.setVgrow(table, Priority.ALWAYS);
Platform.runLater(() -> {
tab.setContent(box);
});
}
/**
* {@inheritDoc}
*/
@Override
public void initializeParts() {
super.initializeParts();
node = new StackPane();
node.getStyleClass().add("simple-text-control");
editableField = new TextField(field.getValue());
DirectoryChooser directoryChooser = new DirectoryChooser();
if (initialDirectory != null) {
directoryChooser.setInitialDirectory(initialDirectory);
}
directoryChooserButton.setOnAction(event -> {
File dir = directoryChooser.showDialog(getNode().getScene().getWindow());
if (dir != null) {
editableField.setText(dir.getAbsolutePath());
}
});
directoryChooserButton.setText(buttonText);
editableField.setPromptText(field.placeholderProperty().getValue());
hBox.getChildren().addAll(editableField, directoryChooserButton);
}
public Node createNode()
{
final TextField groupField = new TextField(group.getValue());
groupField.setMinWidth(0);
groupField.setMaxWidth(Double.POSITIVE_INFINITY);
groupField.setPromptText(groupPromptText);
groupField.textProperty().bindBidirectional(group);
final ComboBox<String> datasetDropDown = new ComboBox<>(datasetChoices);
datasetDropDown.setPromptText(datasetPromptText);
datasetDropDown.setEditable(false);
datasetDropDown.valueProperty().bindBidirectional(dataset);
datasetDropDown.setMinWidth(groupField.getMinWidth());
datasetDropDown.setPrefWidth(groupField.getPrefWidth());
datasetDropDown.setMaxWidth(groupField.getMaxWidth());
datasetDropDown.disableProperty().bind(this.isDropDownReady);
final GridPane grid = new GridPane();
grid.add(groupField, 0, 0);
grid.add(datasetDropDown, 0, 1);
GridPane.setHgrow(groupField, Priority.ALWAYS);
GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
final Button button = new Button("Browse");
button.setOnAction(event -> {
Optional.ofNullable(onBrowseClicked.apply(group.getValue(), grid.getScene())).ifPresent(group::setValue);
});
grid.add(button, 1, 0);
groupField.effectProperty().bind(
Bindings.createObjectBinding(
() -> groupField.isFocused() ? this.textFieldNoErrorEffect : groupErrorEffect.get(),
groupErrorEffect,
groupField.focusedProperty()
));
return grid;
}
public StringBindingSample() {
final SimpleDateFormat format = new SimpleDateFormat("mm/dd/yyyy");
final TextField dateField = new TextField();
dateField.setPromptText("Enter a birth date");
dateField.setMaxHeight(TextField.USE_PREF_SIZE);
dateField.setMaxWidth(TextField.USE_PREF_SIZE);
Label label = new Label();
label.textProperty().bind(new StringBinding() {
{
bind(dateField.textProperty());
}
@Override protected String computeValue() {
try {
Date date = format.parse(dateField.getText());
Calendar c = Calendar.getInstance();
c.setTime(date);
Date today = new Date();
Calendar c2 = Calendar.getInstance();
c2.setTime(today);
if (c.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR) - 1
&& c.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
return "You were born yesterday";
} else {
return "You were born " + format.format(date);
}
} catch (Exception e) {
return "Please enter a valid birth date (mm/dd/yyyy)";
}
}
});
VBox vBox = new VBox(7);
vBox.setPadding(new Insets(12));
vBox.getChildren().addAll(label, dateField);
getChildren().add(vBox);
}
public final void importUI(){
GridPane gridLEFT = new GridPane();
// Labels
Label messagesLabel = new Label("Messages file");
UIUtils.setSize(messagesLabel, Main.columnWidthLEFT/2, 24);
Label networkLabel = new Label("Network file");
UIUtils.setSize(networkLabel, Main.columnWidthLEFT/2, 24);
Label datasetIdentificatorLabel = new Label("Dataset ID");
UIUtils.setSize(datasetIdentificatorLabel, Main.columnWidthLEFT/2, 24);
Label datasetDescriptionLabel = new Label("Dataset description");
UIUtils.setSize(datasetDescriptionLabel, Main.columnWidthLEFT/2, 24);
gridLEFT.add(messagesLabel,0,0);
gridLEFT.add(new Rectangle(0,3),0,1);
gridLEFT.add(networkLabel,0,2);
gridLEFT.add(new Rectangle(0,3),0,3);
gridLEFT.add(datasetIdentificatorLabel,0,4);
gridLEFT.add(new Rectangle(0,3),0,5);
gridLEFT.add(datasetDescriptionLabel,0,6);
// Values
messagesFileButton = createChooseFileButton("messagesFile");
UIUtils.setSize(messagesFileButton,Main.columnWidthLEFT/2, 24);
networkFileButton = createChooseFileButton("networkFile");
UIUtils.setSize(networkFileButton,Main.columnWidthLEFT/2, 24);
newDatasetIdentifierField = new TextField();
newDatasetIdentifierField.setPromptText("unique identifier");
UIUtils.setSize(newDatasetIdentifierField,Main.columnWidthLEFT/2, 24);
newDatasetDescriptionField = new TextField();
newDatasetDescriptionField.setPromptText("short dataset description");
UIUtils.setSize(newDatasetDescriptionField,Main.columnWidthLEFT/2, 24);
gridLEFT.add(messagesFileButton,1,0);
gridLEFT.add(networkFileButton,1,2);
gridLEFT.add(newDatasetIdentifierField,1,4);
gridLEFT.add(newDatasetDescriptionField,1,6);
HBox importDatasetBOTH = new HBox(5);
importDatasetBOTH.getChildren().addAll(gridLEFT,createImportButton());
grid.add(importDatasetBOTH,0,5);
}
private HBox createRubyHomeField() {
HBox rubyHomeBox = new HBox(5);
rubyHomeField = new TextField();
rubyHomeField.setId("RubyHomeField");
rubyHomeField.setPromptText("(Bundled JRuby)");
Label label = createLabel("Ruby Home: ");
label.setId("RubyLabel");
label.setMinWidth(Region.USE_PREF_SIZE);
rubyHomeBox.getChildren().addAll(label, rubyHomeField);
HBox.setHgrow(rubyHomeField, Priority.ALWAYS);
return rubyHomeBox;
}
public final void detectedEventsUI(){
// Detected events
HBox detectedEventsBOTH = new HBox(0);
initializeEventTable();
initializeFrequencyChart();
VBox detectedEventsRIGHT = new VBox(3);
filterEventsField = new TextField();
filterEventsField.setPromptText("Filter events");
UIUtils.setSize(filterEventsField, Main.columnWidthRIGHT, 24);
final EventHandler<KeyEvent> enterPressed =
new EventHandler<KeyEvent>() {
@Override
public void handle(final KeyEvent keyEvent) {
if(keyEvent.getCode()==KeyCode.ENTER){
eventTable.getItems().clear();
selectedMethod.events.filterList(filterEventsField.getText());
eventTable.setItems(selectedMethod.events.observableList);
}
}
};
filterEventsField.setOnKeyReleased(enterPressed);
detectedEventsRIGHT.getChildren().addAll(filterEventsField,eventTable,createTimelineButton());
detectedEventsBOTH.getChildren().addAll(frequencyChart,detectedEventsRIGHT);
grid.add(detectedEventsBOTH,0,5);
rectangleSelection = new Rectangle(0,240);
rectangleSelection.setOpacity(0.22);
rectangleSelection.setTranslateY(-28);
grid.add(rectangleSelection,0,5);
}
@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;
}
@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;
}
@Override
@SneakyThrows
public Tab getRoot(RequestContainer request) {
GrpcOperationAspect aspect = request.getAspect(GrpcOperationAspect.class).get();
TextField textField = new JFXTextField();
GenericBinding<GrpcOperationAspect, String> binding = GenericBinding.of(
GrpcOperationAspect::getOperation,
run(GrpcOperationAspect::setOperation)
.andThen(() -> aspect.setDirty(true)), //mark aspect as dirty propagates to the request itself and shows up in UI
aspect);
textField.setPromptText("<package>.<service>/<method>");
textField.textProperty().bindBidirectional(binding);
textField.setUserData(binding); //need to add a strong reference to keep the binding from being GC-collected.
HBox.setHgrow(textField, Priority.ALWAYS);
completer.attachVariableCompletionTo(textField);
ContentEditor contentView = new ContentEditor();
contentView.setEditable(true);
contentView.setContentTypePlugins(Collections.singletonList(new GrpcContentType()));
contentView.setContentType("application/vnd.wrm.protoschema");
contentView.setHeaderVisibility(false);
contentView.setContent(aspect::getProtoSchema, run(aspect::setProtoSchema).andThen(v -> aspect.setDirty(true)));
VBox.setVgrow(contentView, Priority.ALWAYS);
CheckBox useReflection = new JFXCheckBox("Use Reflection");
GenericBinding<GrpcOperationAspect, Boolean> reflBinding = GenericBinding.of(
GrpcOperationAspect::isUseReflection,
run(GrpcOperationAspect::setUseReflection)
.andThen(() -> aspect.setDirty(true)), //mark aspect as dirty propagates to the request itself and shows up in UI
aspect);
useReflection.selectedProperty().addListener((observable, oldValue, newValue) -> {
contentView.setDisableContent(newValue);
});
useReflection.selectedProperty().bindBidirectional(reflBinding);
useReflection.setUserData(reflBinding); //need to add a strong reference to keep the binding from being GC-collected.
return new Tab("Operation", new VBox(new HBox(10, new Label("Operation:"), textField, useReflection), new Label("Protobuf Schema:"), contentView));
}
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();
}
public GenericBackendDialogN5 backendDialog(ExecutorService propagationExecutor) throws IOException {
final ObjectField<String, StringProperty> containerField = ObjectField.stringField(container.get(), ObjectField.SubmitOn.ENTER_PRESSED, ObjectField.SubmitOn.ENTER_PRESSED);
final TextField containerTextField = containerField.textField();
containerField.valueProperty().bindBidirectional(container);
containerTextField.setMinWidth(0);
containerTextField.setMaxWidth(Double.POSITIVE_INFINITY);
containerTextField.setPromptText("N5 container");
final EventHandler<ActionEvent> onBrowseButtonClicked = event -> {
final File initialDirectory = Optional
.ofNullable(container.get())
.map(File::new)
.filter(File::exists)
.filter(File::isDirectory)
.orElse(new File(DEFAULT_DIRECTORY));
updateFromDirectoryChooser(initialDirectory, containerTextField.getScene().getWindow());
};
final Consumer<String> processSelection = ThrowingConsumer.unchecked(selection -> {
LOG.info("Got selection {}", selection);
if (selection == null)
return;
if (isN5Container(selection)) {
container.set(null);
container.set(selection);
return;
}
updateFromDirectoryChooser(Paths.get(selection).toFile(), containerTextField.getScene().getWindow());
});
final MenuButton menuButton = BrowseRecentFavorites.menuButton("_Find", Lists.reverse(PainteraCache.readLines(this.getClass(), "recent")), FAVORITES, onBrowseButtonClicked, processSelection);
GenericBackendDialogN5 d = new GenericBackendDialogN5(containerTextField, menuButton, "N5", writerSupplier, propagationExecutor);
final String path = container.get();
updateWriterSupplier(path);
return d;
}
private void collectIpCamInfo() {
final Stage ipcamStage = new Stage();
final GridPane ipcamPane = new GridPane();
final ColumnConstraints cc = new ColumnConstraints(400);
cc.setHalignment(HPos.CENTER);
ipcamPane.getColumnConstraints().addAll(new ColumnConstraints(), cc);
final TextField nameTextField = new TextField();
ipcamPane.add(new Label("IPCam Name:"), 0, 0);
ipcamPane.add(nameTextField, 1, 0);
final TextField userTextField = new TextField();
userTextField.setPromptText("Optional Username");
ipcamPane.add(new Label("Username:"), 0, 1);
ipcamPane.add(userTextField, 1, 1);
final PasswordField passwordField = new PasswordField();
passwordField.setPromptText("Optional Password");
ipcamPane.add(new Label("Password:"), 0, 2);
ipcamPane.add(passwordField, 1, 2);
final TextField urlTextField = new TextField("http://");
ipcamPane.add(new Label("IPCam URL:"), 0, 3);
ipcamPane.add(urlTextField, 1, 3);
final Button okButton = new Button("OK");
okButton.setDefaultButton(true);
ipcamPane.add(okButton, 1, 4);
okButton.setOnAction((e) -> {
if (nameTextField.getText().isEmpty() || urlTextField.getText().isEmpty()) {
final Alert ipcamInfoAlert = new Alert(AlertType.ERROR);
ipcamInfoAlert.setTitle("Missing Information");
ipcamInfoAlert.setHeaderText("Missing Required IPCam Information!");
ipcamInfoAlert.setResizable(true);
ipcamInfoAlert.setContentText("Please fill in both the IPCam name and the URL.");
ipcamInfoAlert.showAndWait();
return;
}
Optional<String> username = Optional.empty();
Optional<String> password = Optional.empty();
if (!userTextField.getText().isEmpty() || !passwordField.getText().isEmpty()) {
username = Optional.of(userTextField.getText());
password = Optional.of(passwordField.getText());
}
final Optional<Camera> cam = config.registerIpCam(nameTextField.getText(), urlTextField.getText(), username,
password);
if (cam.isPresent()) {
CheckableImageListCell.cacheCamera(cam.get(), PreferencesController.this);
if (!configuredCameras.contains(cam.get())) {
Platform.runLater(() -> {
webcamListView.setItems(null);
cameras.add(cam.get().getName());
webcamListView.setItems(cameras);
});
}
}
ipcamStage.close();
});
final Scene scene = new Scene(ipcamPane);
ipcamStage.initOwner(preferencesPane.getScene().getWindow());
ipcamStage.initModality(Modality.WINDOW_MODAL);
ipcamStage.setTitle("Register IPCam");
ipcamStage.setScene(scene);
ipcamStage.showAndWait();
}
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();
}
public final void preprocessUI(){
GridPane gridLEFT = new GridPane();
// Labels
Label stemmingLabel = new Label("Stemming");
UIUtils.setSize(stemmingLabel, Main.columnWidthLEFT/2, 24);
Label LemmatizationLabel = new Label("Lemmatization");
UIUtils.setSize(LemmatizationLabel, Main.columnWidthLEFT/2, 24);
Label TokenizationLabel = new Label("Tokenization");
UIUtils.setSize(TokenizationLabel, Main.columnWidthLEFT/2, 24);
Label partitionLabel = new Label("Partition and index messages");
UIUtils.setSize(partitionLabel, Main.columnWidthLEFT/2, 24);
gridLEFT.add(stemmingLabel,0,0);
gridLEFT.add(new Rectangle(0,3),0,1);
gridLEFT.add(LemmatizationLabel,0,2);
gridLEFT.add(new Rectangle(0,3),0,3);
gridLEFT.add(TokenizationLabel,0,4);
gridLEFT.add(new Rectangle(0,3),0,5);
gridLEFT.add(partitionLabel,0,6);
// Values
stemmingChoiceBox = new ChoiceBox();
stemmingChoiceBox.getItems().addAll("disabled","French","English","Arabic","Persian");
UIUtils.setSize(stemmingChoiceBox,Main.columnWidthLEFT/2, 24);
lemmatizationChoiceBox = new ChoiceBox();
lemmatizationChoiceBox.getItems().addAll("disabled","French","English");
UIUtils.setSize(lemmatizationChoiceBox,Main.columnWidthLEFT/2, 24);
tokenizationChoiceBox = new ChoiceBox();
tokenizationChoiceBox.getItems().addAll("1-gram","2-gram","3-gram");
UIUtils.setSize(tokenizationChoiceBox,Main.columnWidthLEFT/2, 24);
timeSliceLengthField = new TextField();
timeSliceLengthField.setPromptText("time-slice length in minutes (e.g. 30)");
UIUtils.setSize(timeSliceLengthField,Main.columnWidthLEFT/2, 24);
gridLEFT.add(stemmingChoiceBox,1,0);
gridLEFT.add(lemmatizationChoiceBox,1,2);
gridLEFT.add(tokenizationChoiceBox,1,4);
gridLEFT.add(timeSliceLengthField,1,6);
HBox preprocessDatasetBOTH = new HBox(5);
preprocessDatasetBOTH.getChildren().addAll(gridLEFT,createPreprocessButton());
grid.add(preprocessDatasetBOTH,0,8);
}