use of org.apache.pivot.util.Vote in project pivot by apache.
the class Accordion method setSelectedIndex.
public void setSelectedIndex(int selectedIndex) {
indexBoundsCheck("selectedIndex", selectedIndex, -1, panels.getLength() - 1);
int previousSelectedIndex = this.selectedIndex;
if (previousSelectedIndex != selectedIndex) {
Vote vote = accordionSelectionListeners.previewSelectedIndexChange(this, selectedIndex);
if (vote == Vote.APPROVE) {
this.selectedIndex = selectedIndex;
accordionSelectionListeners.selectedIndexChanged(this, previousSelectedIndex);
} else {
accordionSelectionListeners.selectedIndexChangeVetoed(this, vote);
}
}
}
use of org.apache.pivot.util.Vote in project pivot by apache.
the class CardPane method setSelectedIndex.
/**
* Sets the selected card index.
*
* @param selectedIndex The selected card index, or <tt>-1</tt> for no
* selection.
*/
public void setSelectedIndex(int selectedIndex) {
indexBoundsCheck("selectedIndex", selectedIndex, -1, getLength() - 1);
int previousSelectedIndex = this.selectedIndex;
if (previousSelectedIndex != selectedIndex) {
Vote vote = cardPaneListeners.previewSelectedIndexChange(this, selectedIndex);
if (vote == Vote.APPROVE) {
this.selectedIndex = selectedIndex;
cardPaneListeners.selectedIndexChanged(this, previousSelectedIndex);
} else {
cardPaneListeners.selectedIndexChangeVetoed(this, vote);
}
}
}
use of org.apache.pivot.util.Vote in project pivot by apache.
the class TerraAccordionSkin method previewSelectedIndexChange.
// Accordion selection events
@Override
public Vote previewSelectedIndexChange(final Accordion accordion, final int selectedIndex) {
Vote vote = Vote.APPROVE;
if (accordion.isShowing() && accordion.isValid()) {
if (selectionChangeTransition == null) {
int previousSelectedIndex = accordion.getSelectedIndex();
if (selectedIndex != -1 && previousSelectedIndex != -1) {
Component fromPanel = accordion.getPanels().get(previousSelectedIndex);
Component toPanel = accordion.getPanels().get(selectedIndex);
selectionChangeTransition = new SelectionChangeTransition(fromPanel, toPanel);
layout();
selectionChangeTransition.start(new TransitionListener() {
@Override
public void transitionCompleted(Transition transition) {
accordion.setSelectedIndex(selectedIndex);
selectionChangeTransition = null;
invalidateComponent();
}
});
vote = Vote.DEFER;
}
} else {
if (selectionChangeTransition.isRunning()) {
vote = Vote.DEFER;
}
}
}
return vote;
}
Aggregations