Search in sources :

Example 26 with Vote

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);
        }
    }
}
Also used : Vote(org.apache.pivot.util.Vote)

Example 27 with 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);
        }
    }
}
Also used : Vote(org.apache.pivot.util.Vote)

Example 28 with 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;
}
Also used : Vote(org.apache.pivot.util.Vote) Transition(org.apache.pivot.wtk.effects.Transition) TransitionListener(org.apache.pivot.wtk.effects.TransitionListener) Component(org.apache.pivot.wtk.Component) GradientPaint(java.awt.GradientPaint)

Aggregations

Vote (org.apache.pivot.util.Vote)28 ArrayList (org.apache.pivot.collections.ArrayList)4 Transition (org.apache.pivot.wtk.effects.Transition)4 TransitionListener (org.apache.pivot.wtk.effects.TransitionListener)4 IOException (java.io.IOException)2 Button (org.apache.pivot.wtk.Button)2 Component (org.apache.pivot.wtk.Component)2 Form (org.apache.pivot.wtk.Form)2 Window (org.apache.pivot.wtk.Window)2 Validator (org.apache.pivot.wtk.validation.Validator)2 GradientPaint (java.awt.GradientPaint)1 File (java.io.File)1 FileName (org.apache.commons.vfs2.FileName)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 FileSystemManager (org.apache.commons.vfs2.FileSystemManager)1 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 ImmutablePath (org.apache.pivot.collections.Sequence.Tree.ImmutablePath)1 VoteResult (org.apache.pivot.util.VoteResult)1 Accordion (org.apache.pivot.wtk.Accordion)1