return boxPane;
}
private Component addSpanControl(final Dictionary<String, Object> dictionary,
final String key, Form.Section section) {
Span span = (Span)dictionary.get(key);
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
section.add(boxPane);
Form.setLabel(boxPane, key);
FlowPane flowPane = new FlowPane();
flowPane.getStyles().put("alignToBaseline", true);
flowPane.getStyles().put("horizontalSpacing", 5);
boxPane.add(flowPane);
TextInput textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(span == null ? "" : String.valueOf(span.start));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Span span = (Span)dictionary.get(key);
try {
int start = Integer.parseInt(textInput.getText());
dictionary.put(key, new Span(start, span == null ? start : span.end));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(span == null ? "" : String.valueOf(span.start));
}
}
}
});
Label label = new Label("start");
label.getStyles().put("font", "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put("alignToBaseline", true);
flowPane.getStyles().put("horizontalSpacing", 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(span == null ? "" : String.valueOf(span.end));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Span span = (Span)dictionary.get(key);
try {
int end = Integer.parseInt(textInput.getText());
dictionary.put(key, new Span(span == null ? end : span.start, end));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(span == null ? "" : String.valueOf(span.end));
}
}