Displays this grouped flydown

Displays this flydown as a XHTML select. Level 1 tree nodes are
displayed as optgroups if their value is null, they have children and
they are not dividers.
336452
public function display()
    {
        if (!$this->visible) {
            return;
        }

        SwatWidget::display();

        // tree is copied for display so we can add a blank node if show_blank
        // is true
        $display_tree = $this->getDisplayTree();
        $count = count($display_tree) - 1;

        // only show a select if there is more than one option
        if ($count > 1) {
            $select_tag = new SwatHtmlTag('select');
            $select_tag->name = $this->id;
            $select_tag->id = $this->id;
            $select_tag->class = $this->getCSSClassString();

            if (!$this->isSensitive()) {
                $select_tag->disabled = 'disabled';
            }

            $select_tag->open();

            foreach ($display_tree->getChildren() as $child) {
                $this->displayNode($child, 1);
            }

            $select_tag->close();
        } elseif ($count === 1) {
            // get first and only element
            $children = $display_tree->getChildren();
            $option = reset($children)->getOption();
            $this->displaySingle($option);
        }
    }
1028678
public function display()
    {
        if (!$this->visible) {
            return;
        }

        parent::display();

        $wrapper_classes = array_merge(
            array_diff($this->getCSSClassNames(), array('swat-flydown')),
            array('swat-flydown-wrapper')
        );
        $wrapper = new SwatHtmlTag('span');
        $wrapper->class = implode(' ', $wrapper_classes);
        $wrapper->open();

        $options = $this->getOptions();
        $selected = false;

        if ($this->show_blank) {
            $options = array_merge(array($this->getBlankOption()), $options);
        }

        // only show a select if there is more than one option
        if (count($options) > 1) {
            $flydown_value = $this->serialize_values
                ? $this->value
                : (string) $this->value;

            if ($this->serialize_values) {
                $salt = $this->getForm()->getSalt();
            }

            $select_tag = new SwatHtmlTag('select');
            $select_tag->name = $this->id;
            $select_tag->id = $this->id;
            $select_tag->class = $this->getCSSClassString();

            if (!$this->isSensitive()) {
                $select_tag->disabled = 'disabled';
            }

            $option_tag = new SwatHtmlTag('option');

            $select_tag->open();

            foreach ($options as $flydown_option) {
                if ($this->serialize_values) {
                    $option_tag->value = SwatString::signedSerialize(
                        $flydown_option->value,
                        $salt
                    );
                } else {
                    $option_tag->value = (string) $flydown_option->value;
                }

                if ($flydown_option instanceof SwatFlydownDivider) {
                    $option_tag->disabled = 'disabled';
                    $option_tag->class = 'swat-flydown-option-divider';
                } elseif ($flydown_option instanceof SwatFlydownBlankOption) {
                    $option_tag->removeAttribute('disabled');
                    $option_tag->class = 'swat-blank-option';
                } else {
                    $option_tag->removeAttribute('disabled');
                    $option_tag->removeAttribute('class');

                    // add option-specific CSS classes from option metadata
                    $classes = $this->getOptionMetadata(
                        $flydown_option,
                        'classes'
                    );

                    if (is_array($classes)) {
                        $option_tag->class = implode(' ', $classes);
                    } elseif ($classes) {
                        $option_tag->class = strval($classes);
                    }
                }

                $value = $this->serialize_values
                    ? $flydown_option->value
                    : (string) $flydown_option->value;

                if (
                    $flydown_value === $value &&
                    !$selected &&
                    !($flydown_option instanceof SwatFlydownDivider)
                ) {
                    $option_tag->selected = 'selected';
                    $selected = true;
                } else {
                    $option_tag->removeAttribute('selected');
                }

                $option_tag->setContent(
                    $flydown_option->title,
                    $flydown_option->content_type
                );

                $option_tag->display();
            }

            $select_tag->close();
        } elseif (count($options) === 1) {
            // get first and only element
            $this->displaySingle(current($options));
        }

        $wrapper->close();
    }
189480
def nested_dropdown(items, text = 'post_title')
      result = []
      items.map do |item, sub_items|
        name = text == 'post_title' && !item.parent.blank? && item.parent.disabled == 'Y' ? item[text.to_sym] + " (parent: #{item.parent.post_title})" : item[text.to_sym]
        result << [('- ' * item.depth) + name.html_safe, item[:id]]
        result += nested_dropdown(sub_items, text) unless sub_items.blank?
      end
      result
    end
320240
protected function htmlOptionsGroup()
    {
        $class = !empty($this->defaults['groupClass']) ? $this->defaults['groupClass'] : '';
        $style = !empty($this->defaults['groupStyle']) ? $this->defaults['groupStyle'] : '';

        if (!empty($this->bootstrapDefaults['groupClass'])) {
            $class .= $this->bootstrapDefaults['groupClass'];
            if ($this->dropup) {
                $class .= ' dropup';
            }
        }
        if (!empty($this->bootstrapDefaults['groupStyle'])) {
            $style .= $this->bootstrapDefaults['groupStyle'];
        }
        if (!empty($this->groupClass) && is_string($this->groupClass)) {
            $class .= ' ' . $this->groupClass;
        }
        if (!empty($this->groupStyle) && is_string($this->groupStyle)) {
            $style .= ' ' . $this->groupStyle;
        }

        return [
            'class' => $class ?: null,
            'style' => $style ?: null,
        ];
    }
1231884
private void displayNode(JcrNode node) {
        this.node = node;
        this.path = node.getPath();

        pathLabel.display(node.getPath());

        //display childs, properties and ACLs
        childrenEditor.show(node);
        propertiesEditor.show(node);
        permissionsEditor.show(node);

        displayBinaryContent(node);

        //bring this page on top
//        console.display(Contents.this);
    }
349089
protected function displaySingle(SwatOption $flydown_option)
    {
        $title = $flydown_option->title;
        $value = $flydown_option->value;

        $hidden_tag = new SwatHtmlTag('input');
        $hidden_tag->type = 'hidden';
        $hidden_tag->name = $this->id;

        if ($this->serialize_values) {
            $salt = $this->getForm()->getSalt();
            $hidden_tag->value = SwatString::signedSerialize($value, $salt);
        } else {
            $hidden_tag->value = (string) $value;
        }

        $hidden_tag->display();

        $span_tag = new SwatHtmlTag('span');
        $span_tag->class = 'swat-flydown-single';
        $span_tag->setContent($title, $flydown_option->content_type);
        $span_tag->display();
    }
392066
public function display()
    {
        if (!$this->visible) {
            return;
        }

        SwatWidget::display();

        $this->getForm()->addHiddenField($this->id . '_submitted', 1);

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

        $this->label_tag = new SwatHtmlTag('label');
        $this->label_tag->class = 'swat-control';

        $this->input_tag = new SwatHtmlTag('input');
        $this->input_tag->type = 'checkbox';
        $this->input_tag->name = $this->id . '[]';

        if ($this->tree !== null) {
            $num_nodes = $this->displayNode($this->tree);
        } else {
            $num_nodes = 0;
        }

        // Only display the check-all widget if more than one checkable item is
        // displayed.
        $check_all = $this->getCompositeWidget('check_all');
        $check_all->visible = $num_nodes > 1 && $this->show_check_all;
        $check_all->display();

        $div_tag->close();

        Swat::displayInlineJavaScript($this->getInlineJavaScript());
    }
810578
void printDotNodesAtLevel(PrintStream os, int levelToPrint, boolean detail, PrintMojo.PrintTreeOptions treeOptions) {
    if (getDepth() == levelToPrint) {
      printDotNode(os, detail, treeOptions);
      return;
    }

    assert (getDepth() < levelToPrint);

    if (leftChild != null) {
      leftChild.printDotNodesAtLevel(os, levelToPrint, detail, treeOptions);
    }
    if (rightChild != null) {
      rightChild.printDotNodesAtLevel(os, levelToPrint, detail, treeOptions);
    }
  }
1087352
function (group, opts) {
			if (!group) {
				return;
			}

			if (!$.isPlainObject(opts)) {
				opts = {};
			}

			// Close if already active
			if (false === F.close(true)) {
				return;
			}

			// Normalize group
			if (!$.isArray(group)) {
				group = isQuery(group) ? $(group).get() : [group];
			}

			// Recheck if the type of each element is `object` and set content type (image, ajax, etc)
			$.each(group, function(i, element) {
				var obj = {},
					href,
					title,
					content,
					type,
					rez,
					hrefParts,
					selector;

				if ($.type(element) === "object") {
					// Check if is DOM element
					if (element.nodeType) {
						element = $(element);
					}

					if (isQuery(element)) {
						obj = {
							href    : element.data('fancybox-href') || element.attr('href'),
							title   : element.data('fancybox-title') || element.attr('title'),
							isDom   : true,
							element : element
						};

						if ($.metadata) {
							$.extend(true, obj, element.metadata());
						}

					} else {
						obj = element;
					}
				}

				href  = opts.href  || obj.href || (isString(element) ? element : null);
				title = opts.title !== undefined ? opts.title : obj.title || '';

				content = opts.content || obj.content;
				type    = content ? 'html' : (opts.type  || obj.type);

				if (!type && obj.isDom) {
					type = element.data('fancybox-type');

					if (!type) {
						rez  = element.prop('class').match(/fancybox\.(\w+)/);
						type = rez ? rez[1] : null;
					}
				}

				if (isString(href)) {
					// Try to guess the content type
					if (!type) {
						if (F.isImage(href)) {
							type = 'image';

						} else if (F.isSWF(href)) {
							type = 'swf';

						} else if (href.charAt(0) === '#') {
							type = 'inline';

						} else if (isString(element)) {
							type    = 'html';
							content = element;
						}
					}

					// Split url into two pieces with source url and content selector, e.g,
					// "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
					if (type === 'ajax') {
						hrefParts = href.split(/\s+/, 2);
						href      = hrefParts.shift();
						selector  = hrefParts.shift();
					}
				}

				if (!content) {
					if (type === 'inline') {
						if (href) {
							content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7

						} else if (obj.isDom) {
							content = element;
						}

					} else if (type === 'html') {
						content = href;

					} else if (!type && !href && obj.isDom) {
						type    = 'inline';
						content = element;
					}
				}

				$.extend(obj, {
					href     : href,
					type     : type,
					content  : content,
					title    : title,
					selector : selector
				});

				group[ i ] = obj;
			});

			// Extend the defaults
			F.opts = $.extend(true, {}, F.defaults, opts);

			// All options are merged recursive except keys
			if (opts.keys !== undefined) {
				F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
			}

			F.group = group;

			return F._start(F.opts.index);
		}
1101881
public function optgroup(Optgroup $optgroup)
    {
        $innerHtml = '';
        foreach ($optgroup->getOptions() as $option) {
            $innerHtml .= $this->render($option) . PHP_EOL;
        }

        $tag = new Tag('optgroup', $innerHtml);
        $tag->setAttribute('label', $optgroup->getLabel());

        return $this->parseTag($tag, $optgroup);
    }
666407
private static function select_optgroup($groupname, $options, array $selected) {
        if (empty($options)) {
            return '';
        }
        $attributes = array('label'=>$groupname);
        $output = '';
        foreach ($options as $value=>$label) {
            $output .= self::select_option($label, $value, $selected);
        }
        return self::tag('optgroup', $output, $attributes);
    }
1160851
function(dataprovider) {

            var groupCounter = 0;
            var $select = this.$select.empty();

            $.each(dataprovider, function (index, option) {
                var $tag;

                if ($.isArray(option.children)) { // create optiongroup tag
                    groupCounter++;

                    $tag = $('<optgroup/>').attr({
                        label: option.label || 'Group ' + groupCounter,
                        disabled: !!option.disabled
                    });

                    forEach(option.children, function(subOption) { // add children option tags
                        $tag.append($('<option/>').attr({
                            value: subOption.value,
                            label: subOption.label || subOption.value,
                            title: subOption.title,
                            selected: !!subOption.selected,
                            disabled: !!subOption.disabled
                        }));
                    });
                }
                else {
                    $tag = $('<option/>').attr({
                        value: option.value,
                        label: option.label || option.value,
                        title: option.title,
                        selected: !!option.selected,
                        disabled: !!option.disabled
                    });
                }

                $select.append($tag);
            });

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

        parent::display();

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

        echo '<span class="swat-time-entry-span">';

        if ($this->display_parts & self::HOUR) {
            $hour_flydown = $this->getCompositeWidget('hour_flydown');
            if ($hour_flydown->value === null && $this->value !== null) {
                // work around a bug in PEAR::Date that returns hour as a string
                $hour = intval($this->value->getHour());

                // convert 24-hour value to 12-hour display
                if ($this->twelve_hour) {
                    if ($hour > 12) {
                        $hour -= 12;
                    }

                    if ($hour === 0) {
                        $hour = 12;
                    }
                }

                $hour_flydown->value = $hour;
            }

            $hour_flydown->display();

            if ($this->display_parts & (self::MINUTE | self::SECOND)) {
                echo ':';
            }
        }

        if ($this->display_parts & self::MINUTE) {
            $minute_flydown = $this->getCompositeWidget('minute_flydown');
            if ($minute_flydown->value === null && $this->value !== null) {
                // work around a bug in PEAR::Date that returns minutes as a
                // 2-character string
                $minute = intval($this->value->getMinute());
                $minute_flydown->value = $minute;
            }

            $minute_flydown->display();
            if ($this->display_parts & self::SECOND) {
                echo ':';
            }
        }

        if ($this->display_parts & self::SECOND) {
            $second_flydown = $this->getCompositeWidget('second_flydown');
            if ($second_flydown->value === null && $this->value !== null) {
                $second_flydown->value = $this->value->getSecond();
            }

            $second_flydown->display();
        }

        if ($this->display_parts & self::HOUR && $this->twelve_hour) {
            $am_pm_flydown = $this->getCompositeWidget('am_pm_flydown');
            if ($am_pm_flydown->value === null && $this->value !== null) {
                $am_pm_flydown->value =
                    $this->value->getHour() < 12 ? 'am' : 'pm';
            }

            $am_pm_flydown->display();
        }

        echo '</span>';

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

        $div_tag->close();
    }
1231189
public Element drawGroup(Object parent, Object object, String tagName) {
		if (isAttached()) {
			return helper.drawGroup(parent, object, tagName);
		} else {
			return null;
		}
	}
1105244
function() {
			var self = this;
			var field_label = self.settings.labelField;
			var field_optgroup = self.settings.optgroupLabelField;
	
			var templates = {
				'optgroup': function(data) {
					return '<div class="optgroup">' + data.html + '</div>';
				},
				'optgroup_header': function(data, escape) {
					return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
				},
				'option': function(data, escape) {
					return '<div class="option">' + escape(data[field_label]) + '</div>';
				},
				'item': function(data, escape) {
					return '<div class="item">' + escape(data[field_label]) + '</div>';
				},
				'option_create': function(data, escape) {
					return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
				}
			};
	
			self.settings.render = $.extend({}, templates, self.settings.render);
		}
548108
private void buildGroupedRoot(Map<?,?> groupedItems, RecursiveTreeItem parent, int groupIndex) {
        boolean setRoot = false;
        if (parent == null) {
            parent = new RecursiveTreeItem<>(new RecursiveTreeObject(), RecursiveTreeObject::getChildren);
            setRoot = true;
        }

        for (Map.Entry<?, ?> entry : groupedItems.entrySet()) {
            Object key = entry.getKey();
            RecursiveTreeObject groupItem = new RecursiveTreeObject<>();
            groupItem.setGroupedValue(key);
            groupItem.setGroupedColumn(groupOrder.get(groupIndex));

            RecursiveTreeItem node = new RecursiveTreeItem<>(groupItem, RecursiveTreeObject::getChildren);
            // TODO: need to be removed once the selection issue is fixed
            node.expandedProperty().addListener((o, oldVal, newVal) -> {
                getSelectionModel().clearSelection();
            });

            parent.originalItems.add(node);
            parent.getChildren().add(node);

            Object children = entry.getValue();
            if (children instanceof List) {
                node.originalItems.addAll((List) children);
                node.getChildren().addAll((List) children);
            } else if (children instanceof Map) {
                buildGroupedRoot((Map) children, node, groupIndex + 1);
            }
        }

        // update ui
        if (setRoot) {
            final RecursiveTreeItem<S> newParent = parent;
            JFXUtilities.runInFX(() -> {
                ArrayList<TreeTableColumn<S, ?>> sortOrder = new ArrayList<>();
                sortOrder.addAll(getSortOrder());
                internalSetRoot = true;
                setRoot(newParent);
                internalSetRoot = false;
                getSortOrder().addAll(sortOrder);
                getSelectionModel().select(0);
            });
        }
    }
913997
def display_hierarchy_helper(root, parent_id_to_children, depth):
  
  print '%s%s (%s)' % ('%s+--' % ('|'.join(['  '] * depth)),
                       root['name'], root['id'])

  # Recurse for each child of this root that has children.
  for child in parent_id_to_children.get(root['id'], []):
    display_hierarchy_helper(child, parent_id_to_children, depth + 1)