下面列出了javafx.scene.control.TextField#setDisable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Update the current selected class.
*
* @param c
* The newly selected class.
*/
private void updateSelection(CDec c) {
selectedDec = c;
info.getChildren().clear();
info.add(new Label("Class name"), 0, 0);
TextField name = new TextField();
if (c.hasMappings()) {
name.setText(c.map().getCurrentName());
} else {
name.setText(c.getFullName());
name.setEditable(false);
}
if (c.isLocked())
name.setDisable(true);
info.add(name, 1, 0);
name.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
if (KeyCode.ENTER == e.getCode()) {
pass = -2;
c.map().setCurrentName(name.getText());
refreshCode();
resetSelection();
updateStyleAndRegions();
}
});
}
/**
* Update the current selected variable.
*
* @param v
* The newly selected variable.
*/
private void updateSelection(VDec v) {
selectedDec = v;
info.getChildren().clear();
// Member
TextField name = new TextField(v.map().getCurrentName());
TextField desc = new TextField(v.getDesc());
desc.setDisable(true);
info.add(new Label("Variable name"), 0, 1);
info.add(name, 1, 1);
info.add(new Label("Variable desc"), 0, 2);
info.add(desc, 1, 2);
name.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
if (KeyCode.ENTER == e.getCode()) {
v.map().setCurrentName(name.getText());
refreshCode();
resetSelection();
updateStyleAndRegions();
}
});
}
/**
* Creates the header for the Axis Editor popup, allowing to configure axis label and unit
*
* @param axis The axis to be edited
* @return pane containing label, label editor and unit editor
*/
private Node getLabelEditor(final Axis axis, final boolean isHorizontal) {
final GridPane header = new GridPane();
header.setAlignment(Pos.BASELINE_LEFT);
final TextField axisLabelTextField = new TextField(axis.getName());
axisLabelTextField.textProperty().bindBidirectional(axis.nameProperty());
header.addRow(0, new Label(" axis label: "), axisLabelTextField);
final TextField axisUnitTextField = new TextField(axis.getUnit());
axisUnitTextField.setPrefWidth(50.0);
axisUnitTextField.textProperty().bindBidirectional(axis.unitProperty());
header.addRow(isHorizontal ? 0 : 1, new Label(" unit: "), axisUnitTextField);
final TextField unitScaling = new TextField();
unitScaling.setPrefWidth(80.0);
final CheckBox autoUnitScaling = new CheckBox(" auto");
if (axis instanceof DefaultNumericAxis) {
autoUnitScaling.selectedProperty()
.bindBidirectional(((DefaultNumericAxis) axis).autoUnitScalingProperty());
unitScaling.textProperty().bindBidirectional(((DefaultNumericAxis) axis).unitScalingProperty(),
new NumberStringConverter(new DecimalFormat("0.0####E0")));
unitScaling.disableProperty().bind(autoUnitScaling.selectedProperty());
} else {
// TODO: consider adding an interface on whether
// autoUnitScaling is editable
autoUnitScaling.setDisable(true);
unitScaling.setDisable(true);
}
final HBox unitScalingBox = new HBox(unitScaling, autoUnitScaling);
unitScalingBox.setAlignment(Pos.BASELINE_LEFT);
header.addRow(isHorizontal ? 0 : 2, new Label(" unit scale:"), unitScalingBox);
return header;
}
FileSelector(
final ClientSetting<Path> clientSetting,
final BiFunction<Window, /* @Nullable */ Path, /* @Nullable */ Path> chooseFile) {
this.clientSetting = clientSetting;
final @Nullable Path initialValue = clientSetting.getValue().orElse(null);
final HBox wrapper = new HBox();
textField = new TextField(SelectionComponentUiUtils.toString(clientSetting.getValue()));
textField
.prefColumnCountProperty()
.bind(Bindings.add(1, Bindings.length(textField.textProperty())));
textField.setMaxWidth(Double.MAX_VALUE);
textField.setMinWidth(100);
textField.setDisable(true);
final Button chooseFileButton = new Button("...");
selectedPath = initialValue;
chooseFileButton.setOnAction(
e -> {
final @Nullable Path path =
chooseFile.apply(chooseFileButton.getScene().getWindow(), selectedPath);
if (path != null) {
selectedPath = path;
textField.setText(path.toString());
}
});
wrapper.getChildren().addAll(textField, chooseFileButton);
getChildren().add(wrapper);
}
public static Tuple3<HBox, TextField, Label> getNonEditableValueBox() {
final Tuple3<HBox, InputTextField, Label> editableValueBox = getEditableValueBox("");
final TextField textField = editableValueBox.second;
textField.setDisable(true);
return new Tuple3<>(editableValueBox.first, editableValueBox.second, editableValueBox.third);
}
protected void addBrowserName() {
nameField = new TextField();
nameField.setText(getBrowserName());
nameField.setDisable(true);
basicPane.addFormField("Browser Name:", nameField, 2, 1);
}
private Node createContent(final Model model, final int count)
{
final GridPane layout = new GridPane();
// layout.setGridLinesVisible(true);
layout.setHgap(5);
layout.setVgap(5);
final ColumnConstraints stay = new ColumnConstraints();
final ColumnConstraints fill = new ColumnConstraints();
fill.setHgrow(Priority.ALWAYS);
layout.getColumnConstraints().addAll(stay, stay, fill);
axis_options = FXCollections.observableArrayList(model.getAxes().stream().map(AxisConfig::getName).collect(Collectors.toList()));
axis_options.add(0, Messages.AddPV_NewOrEmptyAxis);
int row = -1;
for (int i=0; i<count; ++i)
{
final String nm = count == 1 ? Messages.Name : Messages.Name + " " + (i+1);
layout.add(new Label(nm), 0, ++row);
final TextField name = new TextField();
name.textProperty().addListener(event -> checkDuplicateName(name));
name.setTooltip(new Tooltip(formula ? Messages.AddFormula_NameTT : Messages.AddPV_NameTT));
if (! formula)
PVAutocompleteMenu.INSTANCE.attachField(name);
names.add(name);
layout.add(name, 1, row, 2, 1);
if (! formula)
{
layout.add(new Label(Messages.AddPV_Period), 0, ++row);
final TextField period = new TextField(Double.toString(Preferences.scan_period));
period.setTooltip(new Tooltip(Messages.AddPV_PeriodTT));
periods.add(period);
period.setDisable(true);
layout.add(period, 1, row);
final CheckBox monitor = new CheckBox(Messages.AddPV_OnChange);
monitor.setTooltip(new Tooltip(Messages.AddPV_OnChangeTT));
monitor.setSelected(true);
monitors.add(monitor);
monitor.setOnAction(event -> period.setDisable(monitor.isSelected()));
layout.add(monitors.get(i), 2, row);
}
layout.add(new Label(Messages.AddPV_Axis), 0, ++row);
final ChoiceBox<String> axis = new ChoiceBox<>(axis_options);
axis.setTooltip(new Tooltip(Messages.AddPV_AxisTT));
axis.getSelectionModel().select(0);
axes.add(axis);
layout.add(axes.get(i), 1, row);
layout.add(new Separator(), 0, ++row, 3, 1);
}
return layout;
}
UiEPXSubmitGrid( String name, String pHexPatch ) {
setId( "epx-submit-grid" );
hexPatch = pHexPatch;
Label hdrLabel = new Label( "Please complete the fields below so your patch can be catalogued correctly..." );
hdrLabel.setWrapText( true );
GridPane.setColumnSpan( hdrLabel, 3 );
add( hdrLabel, 0, 0);
add( new Label( "Name" ), 0, 1 );
nameField = new TextField( name );
nameField.setDisable( true );
GridPane.setColumnSpan( nameField, 2 );
add( nameField, 1, 1 );
add( new Label( "Origin" ), 0, 2 );
originField = new TextField();
GridPane.setColumnSpan( originField, 2 );
add( originField, 1, 2 );
add( new Label( "Type" ), 0, 3 );
typeChoice = new ChoiceBox<String>();
typeChoice.getItems().addAll( "[None]" );
typeChoice.getSelectionModel().select( 0 );
add( typeChoice, 1, 3 );
privacyCheckBox = new CheckBox( "Private" );
add( privacyCheckBox, 2, 3 );
add( new Label( "Description" ), 0, 4 );
descriptionArea = new TextArea();
descriptionArea.setWrapText( true );
descriptionArea.setTooltip( new Tooltip( "(Optional - max. 255 characters)" ) );
GridPane.setColumnSpan( descriptionArea, 2 );
add( descriptionArea, 1, 4 );
add( new Label( "Tags" ), 0, 5 );
tagsField = new TextField();
GridPane.setColumnSpan( tagsField, 2 );
add( tagsField, 1, 5 );
okButton = new Button( "OK" );
add( okButton, 1, 6 );
cancelButton = new Button( "Cancel" );
add( cancelButton, 2, 6 );
}
/** Initializes the components. */
private void initializeComponents() {
final Settings settings = Settings.getInstance();
button_undo = JFXHelper.createIconButton(VIconType.UNDO.getFilePath(), 16, 16);
button_redo = JFXHelper.createIconButton(VIconType.REDO.getFilePath(), 16, 16);
button_selectFfmpegExecutablePath = new Button("Select FFMPEG Executable Path");
button_selectDefaultEncodingFolder = new Button("Select Default Encoding Folder");
button_selectDefaultDecodingFolder = new Button("Select Default Decoding Folder");
button_accept = JFXHelper.createIconButton(VIconType.BUTTON_ACCEPT.getFilePath(), 16, 16);
button_cancel = JFXHelper.createIconButton(VIconType.BUTTON_CANCEL.getFilePath(), 16, 16);
textField_ffmpegExecutablePath = new TextField(settings.getStringSetting("FFMPEG Executable Path"));
textField_ffmpegExecutablePath.setPromptText("FFMPEG Executable Path");
textField_ffmpegExecutablePath.setDisable(true);
textField_defaultEncodingFolder = new TextField(settings.getStringSetting("Default Encoding Output Directory"));
textField_defaultEncodingFolder.setPromptText("Default Encoding Folder");
textField_defaultEncodingFolder.setDisable(true);
textField_defaultDecodingFolder = new TextField(settings.getStringSetting("Default Decoding Output Directory"));
textField_defaultDecodingFolder.setPromptText("Default Decoding Folder");
textField_defaultDecodingFolder.setDisable(true);
textField_codec = new TextField(settings.getStringSetting("Encoding Codec"));
textField_codec.setPromptText("Encoding Codec");
// Setup Frame Dimensions Combo Box:
final List<String> frameDimensions = new ArrayList<>();
for (final FrameDimension dimension : FrameDimension.values()) {
frameDimensions.add(dimension.name());
}
comboBox_frameDimensions = JFXHelper.createComboBox(frameDimensions);
comboBox_frameDimensions.getSelectionModel().select(settings.getStringSetting("Encoding Frame Dimensions"));
// Setup Frame Rate Combo Box:
final List<String> frameRates = new ArrayList<>();
for (final FrameRate rate : FrameRate.values()) {
frameRates.add(rate.name());
}
comboBox_frameRate = JFXHelper.createComboBox(frameRates);
comboBox_frameRate.getSelectionModel().select(settings.getStringSetting("Encoding Frame Rate"));
// Setup Block Size Combo Box:
final List<String> blockSizes = new ArrayList<>();
for (final BlockSize size : BlockSize.values()) {
blockSizes.add(size.name());
}
comboBox_blockSize = JFXHelper.createComboBox(blockSizes);
comboBox_blockSize.getSelectionModel().select(settings.getStringSetting("Encoding Block Size"));
}
/**
* Creates and returns the control for loading maps
* @return the control for loading stored maps
*/
public GridPane getRouteControl() {
GridPane gp = new GridPane();
gp.setPadding(new Insets(5, 5, 5, 5));
gp.setHgap(5);
gp.setVgap(5);
newRouteField = new TextField();
newRouteField.setDisable(true);
newRouteField.setOnAction(e -> {
newRouteField.setDisable(true);
String text = newRouteField.getText();
newRouteField.clear();
if(routeCombo.getItems().contains(text)) return;
routeCombo.getItems().add(text);
routeCombo.getCheckModel().check(text);
Route newRoute = new Route(text);
map.addRoute(newRoute);
map.selectRoute(newRoute);
});
Button addNew = new Button("New");
addNew.setOnAction(e -> {
newRouteField.requestFocus();
newRouteField.setDisable(false);
});
HBox rsMode = new HBox();
addWaypointBox = new CheckBox("Add Waypoints");
addWaypointBox.setTextFill(Color.WHITE);
addWaypointBox.setOnAction(e -> {
map.setMode(addWaypointBox.isSelected() ? Mode.ADD_WAYPOINTS : Mode.NORMAL);
if(map.getCurrentRoute() != null) {
MarkerType.reset(map.getCurrentRoute());
}
});
rsMode.getChildren().add(addWaypointBox);
Label l = new Label("Select or enter route name:");
l.setFont(Font.font(l.getFont().getFamily(), 12));
l.setTextFill(Color.WHITE);
routeCombo.getCheckModel().getCheckedItems().addListener((Change<? extends String> c) -> {
// Set the current Route pointer in the map
alterSelection(c);
map.eraseMap();
List<String> items = routeCombo.getCheckModel().getCheckedItems();
List<Route> routes = null;
PersistentMap selectedMap = map.getMapStore().getMap(map.getMapStore().getSelectedMapName());
if(items != null && items.size() > 0) {
routes = items.stream().map(s -> selectedMap.getRoute(s)).collect(Collectors.toList());
}else{
return;
}
map.displayRoutes(routes);
});
Button clr = new Button("Clear route");
clr.setOnAction(e -> routeCombo.getCheckModel()
.getCheckedItems().stream().forEach(s -> map.clearRoute(map.getRoute(s))));
Button del = new Button("Delete route");
del.setOnAction(e -> routeCombo.getCheckModel()
.getCheckedItems().stream().forEach(s -> {
Route r = map.getRoute(s);
map.eraseRoute(r);
map.removeRoute(r);
}));
gp.add(l, 0, 0, 2, 1);
gp.add(newRouteField, 0, 1, 2, 1);
gp.add(addNew, 2, 1, 1, 1);
gp.add(new Separator(), 0, 2, 5, 1);
gp.add(rsMode, 2, 0, 2, 1);
gp.add(routeCombo, 0, 3, 2, 1);
gp.add(clr, 2, 3);
gp.add(del, 3, 3);
return gp;
}
public static Tuple3<HBox, InfoInputTextField, Label> getNonEditableValueBoxWithInfo() {
final Tuple3<HBox, InfoInputTextField, Label> editableValueBoxWithInfo = getEditableValueBoxWithInfo("");
TextField textField = editableValueBoxWithInfo.second.getInputTextField();
textField.setDisable(true);
return editableValueBoxWithInfo;
}