Puts widget at first free index

@param widget Widget to put
@return index of element in container
169954
public int put(Widget widget) {
		attach(widget);
		for (int i = 0; i < content.length; ++i)
			for (int j = 0; j < content[i].length; ++j)
				if (content[i][j] == null) {
					content[i][j] = widget;
					this.sendElement();
					return i;
				}
		throw new IndexOutOfBoundsException();
		//return -1;
	}
156588
@Override
    public Object set(int index, Object element) {
        if (cleared) {
            throw new JeppettoException("set() after clear() not supported");
        }

        return updates.put(String.format(indexFormat, index), element);
    }
1289504
public void consumeContainerElements(I_CmsDropContainer container) {

        boolean containsElements = false;
        // the drag element widgets are created from the existing DOM elements,
        Element child = container.getElement().getFirstChildElement();
        List<CmsContainerPageElementPanel> children = Lists.newArrayList();
        while (child != null) {
            boolean isContainerElement = CmsDomUtil.hasClass(
                CmsContainerElement.CLASS_CONTAINER_ELEMENT_START_MARKER,
                child);
            boolean isGroupcontainerElement = CmsDomUtil.hasClass(
                CmsContainerElement.CLASS_GROUP_CONTAINER_ELEMENT_MARKER,
                child);
            if (isContainerElement || isGroupcontainerElement) {
                containsElements = true;
                String serializedData = child.getAttribute(CmsGwtConstants.ATTR_DATA_ELEMENT);
                child.removeAttribute(CmsGwtConstants.ATTR_DATA_ELEMENT);
                CmsContainerElement elementData = null;
                try {
                    elementData = m_controller.getSerializedElement(serializedData);
                } catch (Exception e) {
                    CmsErrorDialog.handleException(
                        new Exception(
                            "Deserialization of element data failed. This may be caused by expired java-script resources, please clear your browser cache and try again.",
                            e));
                }
                if (isContainerElement) {

                    // searching for content element root
                    Element elementRoot = (Element)child.getNextSibling();
                    while ((elementRoot != null) && (elementRoot.getNodeType() != Node.ELEMENT_NODE)) {
                        Element temp = elementRoot;
                        elementRoot = (Element)elementRoot.getNextSibling();
                        temp.removeFromParent();
                    }
                    if (elementRoot == null) {
                        child.removeFromParent();
                        child = null;
                        continue;
                    }
                    if (CmsDomUtil.hasClass(CmsContainerElement.CLASS_CONTAINER_ELEMENT_START_MARKER, elementRoot)) {
                        // broken element, already at next start marker
                        if (elementData != null) {
                            alertParsingError(elementData.getSitePath());
                        }
                        child.removeFromParent();
                        child = elementRoot;
                        continue;
                    }
                    if (CmsDomUtil.hasClass(CmsContainerElement.CLASS_CONTAINER_ELEMENT_END_MARKER, elementRoot)) {
                        // broken element, no content element root
                        if (elementData != null) {
                            alertParsingError(elementData.getSitePath());
                        }
                        child.removeFromParent();
                        child = elementRoot.getNextSiblingElement();
                        elementRoot.removeFromParent();
                        continue;
                    } else {
                        // looking for the next marker that wraps the current element
                        Element endMarker = (Element)elementRoot.getNextSibling();
                        // only if the end marker node is not null and has neither the end-marker class or start-marker class
                        // remove the current node and check the next sibling
                        while (!((endMarker == null)
                            || ((endMarker.getNodeType() == Node.ELEMENT_NODE)
                                && (CmsDomUtil.hasClass(
                                    CmsContainerElement.CLASS_CONTAINER_ELEMENT_END_MARKER,
                                    endMarker)
                                    || CmsDomUtil.hasClass(
                                        CmsContainerElement.CLASS_CONTAINER_ELEMENT_START_MARKER,
                                        endMarker))))) {
                            Element temp = endMarker;
                            endMarker = (Element)endMarker.getNextSibling();
                            temp.removeFromParent();
                        }
                        if (endMarker == null) {
                            if (elementData != null) {
                                alertParsingError(elementData.getSitePath());
                            }
                            // broken element, end marker missing
                            elementRoot.removeFromParent();
                            child.removeFromParent();
                            child = null;
                            continue;
                        }
                        if (CmsDomUtil.hasClass(CmsContainerElement.CLASS_CONTAINER_ELEMENT_START_MARKER, endMarker)) {
                            if (elementData != null) {
                                alertParsingError(elementData.getSitePath());
                            }
                            // broken element, end marker missing
                            elementRoot.removeFromParent();
                            child.removeFromParent();
                            child = endMarker;
                        }
                        if (elementData == null) {
                            // deserialization failed, remove whole element
                            child.removeFromParent();
                            elementRoot.removeFromParent();
                            child = endMarker.getNextSiblingElement();
                            endMarker.removeFromParent();
                            continue;
                        }
                        CmsDomUtil.removeScriptTags(elementRoot);
                        CmsContainerPageElementPanel containerElement = createElement(
                            elementRoot,
                            container,
                            elementData);
                        children.add(containerElement);
                        if (elementData.isNew()) {
                            containerElement.setNewType(elementData.getResourceType());
                        }
                        container.adoptElement(containerElement);
                        child.removeFromParent();
                        child = endMarker.getNextSiblingElement();
                        endMarker.removeFromParent();
                    }
                } else if (isGroupcontainerElement && (container instanceof CmsContainerPageContainer)) {
                    if (elementData == null) {
                        Element sibling = child.getNextSiblingElement();
                        container.getElement().removeChild(child);
                        child = sibling;
                        continue;
                    }
                    CmsDomUtil.removeScriptTags(child);
                    CmsGroupContainerElementPanel groupContainer = createGroupcontainer(child, container, elementData);
                    groupContainer.setContainerId(container.getContainerId());
                    container.adoptElement(groupContainer);
                    consumeContainerElements(groupContainer);
                    if (groupContainer.getWidgetCount() == 0) {
                        groupContainer.addStyleName(
                            I_CmsLayoutBundle.INSTANCE.containerpageCss().emptyGroupContainer());
                    }
                    children.add(groupContainer);
                    // important: adding the option-bar only after the group-containers have been consumed
                    if (container.isEditable()
                        && (!m_controller.isDetailPage() || container.isDetailView() || container.isDetailOnly())) {
                        //only allow editing if either element of detail only container or not in detail view
                        if (m_controller.requiresOptionBar(groupContainer, container)) {
                            addOptionBar(groupContainer);
                        }
                    }
                    child = child.getNextSiblingElement();
                }
            } else {
                Element sibling = child.getNextSiblingElement();
                if (!containsElements && (sibling == null) && (container instanceof CmsContainerPageContainer)) {
                    // this element is no container element and is the container only child, assume it is an empty container marker
                    ((CmsContainerPageContainer)container).setEmptyContainerElement(child);
                } else {
                    // e.g. option bar
                    if (!CmsContainerPageElementPanel.isOverlay(child)) {
                        container.getElement().removeChild(child);
                    }
                }
                child = sibling;
                continue;
            }
        }
        container.onConsumeChildren(children);
    }
32159
public function addWidget($widget)
    {
        $this->widgets->add($widget); 
        $this->layoutWidget($widget);
        return $this;
    }
119164
public I_CmsWidget getWidget(String name) {

        // first look up by class name
        I_CmsWidget result = m_registeredWidgets.get(name);
        if (result == null) {
            // not found by class name, look up an alias
            String className = m_widgetAliases.get(name);
            if (className != null) {
                result = m_registeredWidgets.get(className);
            }
        }
        if (result != null) {
            result = result.newInstance();
        }
        return result;
    }
682972
public Element put(int index, Element newValue) {

		Element oldValue = null;

        int size = list.size();

		if (index < 0) {
            if (index < -size) {
                // negative indices do not auto-prepend
                // (asopposed to positive ones that grow the list by appending undef)
                throw new EvaluationException(MessageUtils.format(
                    MSG_INVALID_NEGATIVE_LIST_INDEX, Integer.toString(index), size));
            } else {
                index += size;
            }
		}

		try {
			if ((newValue != null) && !(newValue instanceof Null)) {
				if (index >= size) {
					for (int i = 0; i < index - size; i++) {
						list.add(Undef.VALUE);
					}
					list.add(newValue);
				} else {
					oldValue = list.set(index, newValue);
					if (oldValue != null) {
						oldValue.checkValidReplacement(newValue);
					}
				}
			} else {
				try {
					oldValue = list.remove(index);
				} catch (IndexOutOfBoundsException ioobe) {
					// Ignore this error; removing non-existant element is OK.
				}
			}
		} catch (IndexOutOfBoundsException ioobe) {
			throw new EvaluationException(MessageUtils.format(
					MSG_NONEXISTANT_LIST_ELEMENT, Integer.toString(index)));
		}
		return oldValue;
	}
945174
public static function forWidget(Widget $widget): self
    {
        $values = StringUtil::deserialize($widget->bs_inputGroup, true);
        $helper = new static();

        foreach ($values as $entry) {
            if (!strlen($entry['addon'])) {
                continue;
            }

            if ($entry['position'] === 'after') {
                $helper->addAfter($entry['addon']);
            } else {
                $helper->addBefore($entry['addon']);
            }
        }

        return $helper;
    }
651032
def add_widget(self, wclass):
        """"""

        tree = self.treeview
        #  get the selected item:
        selected_item = ''
        tsel = tree.selection()
        if tsel:
            selected_item = tsel[0]

        #  Need to remove filter if set
        self.filter_remove()

        root = selected_item
        #  check if the widget can be added at selected point
        if not self._validate_add(root, wclass, False):
            #  if not try to add at item parent level
            parent = tree.parent(root)
            if parent != root:
                if self._validate_add(parent, wclass):
                    root = parent
                else:
                    return
            else:
                return

        #  root item should be set at this point
        #  setup properties
        widget_id = self.get_unique_id(wclass)

        data = WidgetDescr(wclass, widget_id)

        # setup default values for properties
        for pname in builder.CLASS_MAP[wclass].builder.properties:
            pdescription = {}
            if pname in properties.WIDGET_PROPERTIES:
                pdescription = properties.WIDGET_PROPERTIES[pname]
            if wclass in pdescription:
                pdescription = dict(pdescription, **pdescription[wclass])
            default_value = str(pdescription.get('default', ''))
            data.set_property(pname, default_value)
            # default text for widgets with text prop:
            if pname in ('text', 'label'):
                data.set_property(pname, widget_id)

        #
        #  default grid properties
        #
        # is_container = builder.CLASS_MAP[wclass].builder.container
        for prop_name in properties.GRID_PROPERTIES:
            pdescription = properties.LAYOUT_OPTIONS[prop_name]
            if wclass in pdescription:
                pdescription = dict(pdescription, **pdescription[wclass])
            default_value = str(pdescription.get('default', ''))
            data.set_layout_property(prop_name, default_value)

        rownum = '0'
        if root:
            rownum = str(self.get_max_row(root)+1)
        data.set_layout_property('row', rownum)
        data.set_layout_property('column', '0')

        item = self._insert_item(root, data)

        # Do redraw
        self.draw_widget(item)

        # Select and show the item created
        tree.after_idle(lambda: tree.selection_set(item))
        tree.after_idle(lambda: tree.focus(item))
        tree.after_idle(lambda: tree.see(item))
1178132
public function addWidget(WidgetPageWidget $widget)
    {
        if ($this->widgets->contains($widget) === false) {
            $widget->setWidgetPage($this);
            $this->widgets->add($widget);
        }

        return $this;
    }
1121241
def index_to_widget(self, idx):
        """"""
        nchild = self.mdi_w.get_nth_page(idx)
        return self._native_to_child(nchild)
647246
def itemAt( self, index ):
        
        layout = self.widget().layout()
        if ( 0 <= index and index < (layout.count() - 1) ):
            return layout.itemAt(index).widget()
        return None
359673
public TabbedPanel put(Widget widget, String name, int index) {
		if (index < 0 || index >= content.length) throw new IndexOutOfBoundsException();
		if (widget == null) return this;
		attach(widget);
		content[index] = new Tab(widget, name);
		this.sendElement();
		return this;
	}
686829
@Override
    protected void defineWidgets() {

        super.defineWidgets();

        // set default value if field is new
        if (m_field.getName() == null) {
            m_field.setStored(true);
            m_field.setIndexed(true);
            m_field.setDisplayed(true);
        }

        // widgets to display
        // new indexsource
        if (m_field.getName() == null) {
            addWidget(new CmsWidgetDialogParameter(m_field, "name", PAGES[0], new CmsInputWidget()));
        } else {
            addWidget(new CmsWidgetDialogParameter(m_field, "name", PAGES[0], new CmsDisplayWidget()));
        }
        addWidget(
            new CmsWidgetDialogParameter(
                this,
                "indexed",
                "true",
                PAGES[0],
                new CmsSelectWidget(getTokenizedWidgetConfiguration()),
                1,
                1));
        addWidget(new CmsWidgetDialogParameter(m_field, "stored", "true", PAGES[0], new CmsCheckboxWidget(), 1, 1));
        addWidget(new CmsWidgetDialogParameter(m_field, "inExcerpt", "", PAGES[0], new CmsCheckboxWidget(), 0, 1));
        addWidget(
            new CmsWidgetDialogParameter(
                m_field,
                "displayNameForConfiguration",
                "",
                PAGES[0],
                new CmsInputWidget(),
                0,
                1));
        addWidget(new CmsWidgetDialogParameter(m_field, "boostDisplay", "", PAGES[0], new CmsInputWidget(), 0, 1));
        addWidget(new CmsWidgetDialogParameter(m_field, "defaultValue", "", PAGES[0], new CmsInputWidget(), 0, 1));
    }
89195
public List<Widget> putFactories(Iterable<? extends IWidgetFactory> factories) throws IndexOutOfBoundsException {
		List<Widget> instances = new LinkedList<Widget>();
		for (IWidgetFactory factory : factories) {
			instances.add(put(factory));
		}
		return instances;
	}
1215101
@UiChild(limit = 1, tagname = "widget")
  public void setChildWidget(final TakesValue<T> pwidget) {
    widget = (Widget) pwidget;
    contents.add(widget);
    setEditor(new ExtendedValueBoxEditor<>(pwidget, this));
  }
1067181
def put_values(self):
        
        for value_name, widget in self.index.items():
            widget.set_value(self.value[value_name])
            widget.connect(self.set_modified)
531749
def add_widget(self, wid, index=0, canvas=None):
        
        super().add_widget(wid, index, canvas)
        if not hasattr(wid, 'group'):
            return
        wid._no_use_canvas = True
        mycanvas = (
            self.canvas.before if canvas == 'before' else
            self.canvas.after if canvas == 'after' else
            self.canvas
        )
        mycanvas.remove(wid.canvas)
        pawncanvas = (
            self.board.spotlayout.canvas.before if canvas == 'before' else
            self.board.spotlayout.canvas.after if canvas == 'after' else
            self.board.spotlayout.canvas
        )
        for child in self.children:
            if hasattr(child, 'group') and child.group in pawncanvas.children:
                pawncanvas.remove(child.group)
            pawncanvas.add(child.group)
        self.pospawn(wid)