Search in sources :

Example 41 with TextInput

use of org.apache.pivot.wtk.TextInput in project pivot by apache.

the class ComponentInspectorSkin method addInsetsControl.

private static Component addInsetsControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
    Insets insets = (Insets) 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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(insets.top));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                Insets insetsLocal = (Insets) dictionary.get(key);
                try {
                    int top = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new Insets(top, insetsLocal.left, insetsLocal.bottom, insetsLocal.right));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(insetsLocal.top));
                }
            }
        }
    });
    Label label = new Label("top");
    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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(insets.left));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                Insets insetsLocal = (Insets) dictionary.get(key);
                try {
                    int left = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new Insets(insetsLocal.top, left, insetsLocal.bottom, insetsLocal.right));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(insetsLocal.left));
                }
            }
        }
    });
    label = new Label("left");
    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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(insets.bottom));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                Insets insetsLocal = (Insets) dictionary.get(key);
                try {
                    int bottom = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new Insets(insetsLocal.top, insetsLocal.left, bottom, insetsLocal.right));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(insetsLocal.bottom));
                }
            }
        }
    });
    label = new Label("bottom");
    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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(insets.right));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                Insets insetsLocal = (Insets) dictionary.get(key);
                try {
                    int right = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new Insets(insetsLocal.top, insetsLocal.left, insetsLocal.bottom, right));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(insetsLocal.right));
                }
            }
        }
    });
    label = new Label("right");
    label.getStyles().put(Style.font, "{italic:true}");
    flowPane.add(label);
    return boxPane;
}
Also used : Insets(org.apache.pivot.wtk.Insets) IntValidator(org.apache.pivot.wtk.validation.IntValidator) BoxPane(org.apache.pivot.wtk.BoxPane) Label(org.apache.pivot.wtk.Label) FlowPane(org.apache.pivot.wtk.FlowPane) TextInput(org.apache.pivot.wtk.TextInput) Component(org.apache.pivot.wtk.Component) ComponentStateListener(org.apache.pivot.wtk.ComponentStateListener)

Example 42 with TextInput

use of org.apache.pivot.wtk.TextInput in project pivot by apache.

the class ComponentInspectorSkin method addPointControl.

private static Component addPointControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
    Point point = (Point) 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(3);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(point.x));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                Point pointLocal = (Point) dictionary.get(key);
                try {
                    int x = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new Point(x, pointLocal.y));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(pointLocal.x));
                }
            }
        }
    });
    Label label = new Label("x");
    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(3);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(point.y));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                Point pointLocal = (Point) dictionary.get(key);
                try {
                    int y = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new Point(pointLocal.x, y));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(pointLocal.y));
                }
            }
        }
    });
    label = new Label("y");
    label.getStyles().put(Style.font, "{italic:true}");
    flowPane.add(label);
    return boxPane;
}
Also used : IntValidator(org.apache.pivot.wtk.validation.IntValidator) BoxPane(org.apache.pivot.wtk.BoxPane) Label(org.apache.pivot.wtk.Label) FlowPane(org.apache.pivot.wtk.FlowPane) Point(org.apache.pivot.wtk.Point) TextInput(org.apache.pivot.wtk.TextInput) Component(org.apache.pivot.wtk.Component) ComponentStateListener(org.apache.pivot.wtk.ComponentStateListener)

Example 43 with TextInput

use of org.apache.pivot.wtk.TextInput 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));
    }
}
Also used : Scope(org.apache.pivot.wtk.ScrollBar.Scope) BoxPane(org.apache.pivot.wtk.BoxPane) TextInput(org.apache.pivot.wtk.TextInput)

Example 44 with TextInput

use of org.apache.pivot.wtk.TextInput in project pivot by apache.

the class ComponentInspectorSkin method addCornerRadiiControl.

private static Component addCornerRadiiControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
    CornerRadii cornerRadii = (CornerRadii) 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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(cornerRadii.topLeft));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                CornerRadii cornerRadiiLocal = (CornerRadii) dictionary.get(key);
                try {
                    int topLeft = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new CornerRadii(topLeft, cornerRadiiLocal.topRight, cornerRadiiLocal.bottomLeft, cornerRadiiLocal.bottomRight));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(cornerRadiiLocal.topLeft));
                }
            }
        }
    });
    Label label = new Label("topLeft");
    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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(cornerRadii.topRight));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                CornerRadii cornerRadiiLocal = (CornerRadii) dictionary.get(key);
                try {
                    int topRight = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new CornerRadii(cornerRadiiLocal.topLeft, topRight, cornerRadiiLocal.bottomLeft, cornerRadiiLocal.bottomRight));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(cornerRadiiLocal.topRight));
                }
            }
        }
    });
    label = new Label("topRight");
    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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(cornerRadii.bottomLeft));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                CornerRadii cornerRadiiLocal = (CornerRadii) dictionary.get(key);
                try {
                    int bottomLeft = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new CornerRadii(cornerRadiiLocal.topLeft, cornerRadiiLocal.topRight, bottomLeft, cornerRadiiLocal.bottomRight));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(cornerRadiiLocal.bottomLeft));
                }
            }
        }
    });
    label = new Label("bottomLeft");
    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(4);
    textInput.setMaximumLength(4);
    textInput.setValidator(new IntValidator());
    textInput.setText(String.valueOf(cornerRadii.bottomRight));
    flowPane.add(textInput);
    textInput.getComponentStateListeners().add(new ComponentStateListener() {

        @Override
        public void focusedChanged(Component component, Component obverseComponent) {
            if (!component.isFocused()) {
                TextInput textInputLocal = (TextInput) component;
                CornerRadii cornerRadiiLocal = (CornerRadii) dictionary.get(key);
                try {
                    int bottomRight = Integer.parseInt(textInputLocal.getText());
                    dictionary.put(key, new CornerRadii(cornerRadiiLocal.topLeft, cornerRadiiLocal.topRight, cornerRadiiLocal.bottomLeft, bottomRight));
                } catch (Exception exception) {
                    displayErrorMessage(exception, component.getWindow());
                    textInputLocal.setText(String.valueOf(cornerRadiiLocal.bottomRight));
                }
            }
        }
    });
    label = new Label("bottomRight");
    label.getStyles().put(Style.font, "{italic:true}");
    flowPane.add(label);
    return boxPane;
}
Also used : IntValidator(org.apache.pivot.wtk.validation.IntValidator) BoxPane(org.apache.pivot.wtk.BoxPane) Label(org.apache.pivot.wtk.Label) FlowPane(org.apache.pivot.wtk.FlowPane) CornerRadii(org.apache.pivot.wtk.CornerRadii) TextInput(org.apache.pivot.wtk.TextInput) Component(org.apache.pivot.wtk.Component) ComponentStateListener(org.apache.pivot.wtk.ComponentStateListener)

Example 45 with TextInput

use of org.apache.pivot.wtk.TextInput in project pivot by apache.

the class ComponentInspectorSkin method updatePointControl.

private void updatePointControl(Dictionary<String, Object> dictionary, String key) {
    BoxPane boxPane = (BoxPane) controls.get(key);
    if (boxPane != null) {
        Point point = (Point) dictionary.get(key);
        TextInput xTextInput = (TextInput) ((FlowPane) boxPane.get(0)).get(0);
        TextInput yTextInput = (TextInput) ((FlowPane) boxPane.get(1)).get(0);
        xTextInput.setText(String.valueOf(point.x));
        yTextInput.setText(String.valueOf(point.y));
    }
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Point(org.apache.pivot.wtk.Point) TextInput(org.apache.pivot.wtk.TextInput)

Aggregations

TextInput (org.apache.pivot.wtk.TextInput)51 Component (org.apache.pivot.wtk.Component)21 BoxPane (org.apache.pivot.wtk.BoxPane)15 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)11 TextInputContentListener (org.apache.pivot.wtk.TextInputContentListener)9 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)8 Label (org.apache.pivot.wtk.Label)8 Point (org.apache.pivot.wtk.Point)8 IntValidator (org.apache.pivot.wtk.validation.IntValidator)8 FlowPane (org.apache.pivot.wtk.FlowPane)7 ArrayList (org.apache.pivot.collections.ArrayList)6 IOException (java.io.IOException)5 Button (org.apache.pivot.wtk.Button)5 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)5 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)5 Keyboard (org.apache.pivot.wtk.Keyboard)5 Mouse (org.apache.pivot.wtk.Mouse)5 Sequence (org.apache.pivot.collections.Sequence)4 SerializationException (org.apache.pivot.serialization.SerializationException)4 ComponentKeyListener (org.apache.pivot.wtk.ComponentKeyListener)4