Search in sources :

Example 1 with ButtonStateListener

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

the class ComponentInspectorSkin method addBooleanControl.

private Component addBooleanControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
    boolean value = dictionary.getBoolean(key);
    Checkbox checkbox = new Checkbox();
    checkbox.setSelected(value);
    section.add(checkbox);
    Form.setLabel(checkbox, key);
    checkbox.getButtonStateListeners().add(new ButtonStateListener() {

        private boolean updating = false;

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            if (!updating) {
                updating = true;
                try {
                    dictionary.put(key, button.isSelected());
                } catch (Exception exception) {
                    displayErrorMessage(exception, button.getWindow());
                    button.setState(previousState);
                } finally {
                    updating = false;
                }
            }
        }
    });
    return checkbox;
}
Also used : CalendarButton(org.apache.pivot.wtk.CalendarButton) ColorChooserButton(org.apache.pivot.wtk.ColorChooserButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) Checkbox(org.apache.pivot.wtk.Checkbox) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener)

Example 2 with ButtonStateListener

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

the class FillPanes method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    fillPane = (FillPane) namespace.get("fillPane");
    horizontalOrientationButton = (RadioButton) namespace.get("horizontalOrientationButton");
    verticalOrientationButton = (RadioButton) namespace.get("verticalOrientationButton");
    ButtonStateListener buttonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            updateFillPaneState();
        }
    };
    horizontalOrientationButton.getButtonStateListeners().add(buttonStateListener);
    verticalOrientationButton.getButtonStateListeners().add(buttonStateListener);
    updateFillPaneState();
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener)

Example 3 with ButtonStateListener

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

the class TabPanes method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    confirmCloseTabPrompt = (Prompt) namespace.get("confirmCloseTabPrompt");
    tabPane = (TabPane) namespace.get("tabPane");
    closeableCheckbox = (Checkbox) namespace.get("closeableCheckbox");
    collapsibleCheckbox = (Checkbox) namespace.get("collapsibleCheckbox");
    horizontalRadioButton = (RadioButton) namespace.get("horizontalRadioButton");
    verticalRadioButton = (RadioButton) namespace.get("verticalRadioButton");
    cornerBoxPane = (BoxPane) namespace.get("cornerBoxPane");
    tabPane.getTabPaneListeners().add(new TabPaneListener() {

        @Override
        public Vote previewRemoveTabs(final TabPane tabPaneArgument, final int index, final int count) {
            Vote vote;
            if (confirmCloseTab) {
                confirmCloseTabPrompt.open(TabPanes.this, new SheetCloseListener() {

                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (confirmCloseTabPrompt.getResult() && confirmCloseTabPrompt.getSelectedOptionIndex() == 1) {
                            confirmCloseTab = false;
                            int n = tabPaneArgument.getTabs().getLength();
                            if (index < n - 1) {
                                tabPaneArgument.setSelectedIndex(index + 1);
                            } else {
                                tabPaneArgument.setSelectedIndex(index - 1);
                            }
                            tabPaneArgument.getTabs().remove(index, count);
                            confirmCloseTab = true;
                        }
                    }
                });
                vote = Vote.DENY;
            } else {
                vote = Vote.APPROVE;
            }
            return vote;
        }
    });
    ButtonStateListener checkboxStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            updateTabPane();
        }
    };
    closeableCheckbox.getButtonStateListeners().add(checkboxStateListener);
    collapsibleCheckbox.getButtonStateListeners().add(checkboxStateListener);
    ButtonStateListener radioButtonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            if (button.isSelected()) {
                updateTabPane();
            }
        }
    };
    horizontalRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    verticalRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    updateTabPane();
}
Also used : TabPaneListener(org.apache.pivot.wtk.TabPaneListener) TabPane(org.apache.pivot.wtk.TabPane) Vote(org.apache.pivot.util.Vote) RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener) SheetCloseListener(org.apache.pivot.wtk.SheetCloseListener) Sheet(org.apache.pivot.wtk.Sheet)

Example 4 with ButtonStateListener

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

the class BoxPanes method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    boxPane = (BoxPane) namespace.get("boxPane");
    horizontalOrientationButton = (RadioButton) namespace.get("horizontalOrientationButton");
    verticalOrientationButton = (RadioButton) namespace.get("verticalOrientationButton");
    horizontalAlignmentRightButton = (RadioButton) namespace.get("horizontalAlignmentRightButton");
    horizontalAlignmentLeftButton = (RadioButton) namespace.get("horizontalAlignmentLeftButton");
    horizontalAlignmentCenterButton = (RadioButton) namespace.get("horizontalAlignmentCenterButton");
    verticalAlignmentTopButton = (RadioButton) namespace.get("verticalAlignmentTopButton");
    verticalAlignmentBottomButton = (RadioButton) namespace.get("verticalAlignmentBottomButton");
    verticalAlignmentCenterButton = (RadioButton) namespace.get("verticalAlignmentCenterButton");
    fillCheckbox = (Checkbox) namespace.get("fillCheckbox");
    ButtonStateListener buttonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            updateBoxPaneState();
        }
    };
    horizontalOrientationButton.getButtonStateListeners().add(buttonStateListener);
    verticalOrientationButton.getButtonStateListeners().add(buttonStateListener);
    horizontalAlignmentLeftButton.getButtonStateListeners().add(buttonStateListener);
    horizontalAlignmentRightButton.getButtonStateListeners().add(buttonStateListener);
    horizontalAlignmentCenterButton.getButtonStateListeners().add(buttonStateListener);
    verticalAlignmentTopButton.getButtonStateListeners().add(buttonStateListener);
    verticalAlignmentBottomButton.getButtonStateListeners().add(buttonStateListener);
    verticalAlignmentCenterButton.getButtonStateListeners().add(buttonStateListener);
    fillCheckbox.getButtonStateListeners().add(buttonStateListener);
    updateBoxPaneState();
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener)

Example 5 with ButtonStateListener

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

the class FlowPanes method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    flowPane = (FlowPane) namespace.get("flowPane");
    leftRadioButton = (RadioButton) namespace.get("leftRadioButton");
    rightRadioButton = (RadioButton) namespace.get("rightRadioButton");
    centerRadioButton = (RadioButton) namespace.get("centerRadioButton");
    alignToBaselineCheckbox = (Checkbox) namespace.get("alignToBaselineCheckbox");
    ButtonStateListener buttonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            updateFlowPaneState();
        }
    };
    leftRadioButton.getButtonStateListeners().add(buttonStateListener);
    rightRadioButton.getButtonStateListeners().add(buttonStateListener);
    centerRadioButton.getButtonStateListeners().add(buttonStateListener);
    alignToBaselineCheckbox.getButtonStateListeners().add(buttonStateListener);
    updateFlowPaneState();
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener)

Aggregations

Button (org.apache.pivot.wtk.Button)7 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)7 RadioButton (org.apache.pivot.wtk.RadioButton)5 Checkbox (org.apache.pivot.wtk.Checkbox)2 ListButton (org.apache.pivot.wtk.ListButton)2 ArrayList (org.apache.pivot.collections.ArrayList)1 Vote (org.apache.pivot.util.Vote)1 State (org.apache.pivot.wtk.Button.State)1 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)1 CalendarButton (org.apache.pivot.wtk.CalendarButton)1 CardPane (org.apache.pivot.wtk.CardPane)1 CardPaneListener (org.apache.pivot.wtk.CardPaneListener)1 ColorChooserButton (org.apache.pivot.wtk.ColorChooserButton)1 LinkButton (org.apache.pivot.wtk.LinkButton)1 Sheet (org.apache.pivot.wtk.Sheet)1 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)1 TabPane (org.apache.pivot.wtk.TabPane)1 TabPaneListener (org.apache.pivot.wtk.TabPaneListener)1