public function display()
    {
        if (!$this->visible) {
            return;
        }

        parent::display();

        $flydown = $this->getCompositeWidget('action_flydown');
        foreach ($this->action_items as $item) {
            if ($item->visible) {
                if ($item instanceof SwatActionItemDivider) {
                    $flydown->addDivider();
                } else {
                    $flydown->addOption($item->id, $item->title);
                }
            }
        }

        // set the flydown back to its initial state (no persistence). The
        // flydown is never reset if there is a selected item and the selected
        // items has a widget with one or more messages.
        if (
            $this->auto_reset &&
            ($this->selected === null ||
                $this->selected->widget === null ||
                !$this->selected->widget->hasMessage())
        ) {
            $flydown->reset();
        }

        // select the current action item based upon the flydown value
        if (isset($this->action_items_by_id[$flydown->value])) {
            $this->selected = $this->action_items_by_id[$flydown->value];
        } else {
            $this->selected = null;
        }

        $div_tag = new SwatHtmlTag('div');
        $div_tag->id = $this->id;
        $div_tag->class = $this->getCSSClassString();
        $div_tag->open();

        echo '<div class="swat-actions-controls">';

        $label = new SwatHtmlTag('label');
        $label->for = $flydown->getFocusableHtmlId();
        $label->setContent(Swat::_('Action: '));
        $label->display();

        $flydown->display();
        echo ' ';
        $this->displayButton();

        echo '</div>';

        foreach ($this->action_items as $item) {
            if ($item->widget !== null) {
                $div = new SwatHtmlTag('div');

                $div->class =
                    $item == $this->selected ? 'swat-visible' : 'swat-hidden';

                $div->id = $this->id . '_' . $item->id;

                $div->open();
                $item->display();
                $div->close();
            }
        }

        echo '<div class="swat-actions-note">';
        echo Swat::_('Actions apply to checked items.');
        echo '</div>';

        $div_tag->close();

        Swat::displayInlineJavaScript($this->getInlineJavaScript());
    }