use of org.apache.pivot.wtk.TabPaneListener 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();
}
Aggregations