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;
}
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();
}
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();
}
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();
}
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();
}
Aggregations