use of org.apache.pivot.wtk.ScrollBar.Scope in project pivot by apache.
the class ComponentInspectorSkin method addScopeControl.
private static Component addScopeControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
Scope scope = (Scope) dictionary.get(key);
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
section.add(boxPane);
Form.setLabel(boxPane, key);
FlowPane flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
TextInput textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(scope == null ? "" : String.valueOf(scope.start));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Scope scopeLocal = (Scope) dictionary.get(key);
try {
int start = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Scope(start, scopeLocal == null ? start : scopeLocal.end, scopeLocal == null ? start : scopeLocal.extent));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(scopeLocal == null ? "" : String.valueOf(scopeLocal.start));
}
}
}
});
Label label = new Label("start");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(scope == null ? "" : String.valueOf(scope.end));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Scope scopeLocal = (Scope) dictionary.get(key);
try {
int end = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Scope(scopeLocal == null ? end : scopeLocal.start, end, scopeLocal == null ? end : scopeLocal.extent));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(scopeLocal == null ? "" : String.valueOf(scopeLocal.end));
}
}
}
});
label = new Label("end");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(scope == null ? "" : String.valueOf(scope.extent));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Scope scopeLocal = (Scope) dictionary.get(key);
try {
int extent = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Scope(scopeLocal == null ? extent : scopeLocal.start, scopeLocal == null ? extent : scopeLocal.end, extent));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(scopeLocal == null ? "" : String.valueOf(scopeLocal.extent));
}
}
}
});
label = new Label("extent");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
return boxPane;
}
use of org.apache.pivot.wtk.ScrollBar.Scope in project pivot by apache.
the class ComponentInspectorSkin method updateScopeControl.
private void updateScopeControl(Dictionary<String, Object> dictionary, String key) {
BoxPane boxPane = (BoxPane) controls.get(key);
if (boxPane != null) {
Scope scope = (Scope) dictionary.get(key);
TextInput startTextInput = (TextInput) ((FlowPane) boxPane.get(0)).get(0);
TextInput endTextInput = (TextInput) ((FlowPane) boxPane.get(1)).get(0);
TextInput extentTextInput = (TextInput) ((FlowPane) boxPane.get(2)).get(0);
startTextInput.setText(scope == null ? "" : String.valueOf(scope.start));
endTextInput.setText(scope == null ? "" : String.valueOf(scope.end));
extentTextInput.setText(scope == null ? "" : String.valueOf(scope.extent));
}
}
Aggregations