Replace the menu item that has a given parent with the one provided
@param subMenu the parent
@param toReplace the menu item to replace by ID
967534
public void replaceMenuById(SubMenuItem subMenu, MenuItem toReplace) {
        synchronized (subMenuItems) {
            ArrayList<MenuItem> list = subMenuItems.get(subMenu);
            int idx = -1;
            for (int i = 0; i < list.size(); ++i) {
                if (list.get(i).getId() == toReplace.getId()) {
                    idx = i;
                }
            }

            if (idx != -1) {
                MenuItem oldItem = list.set(idx, toReplace);
                if (toReplace.hasChildren()) {
                    ArrayList<MenuItem> items = subMenuItems.remove(oldItem);
                    subMenuItems.put(toReplace, items);
                }
            }

        }
    }
487549
public void addMenuItem(SubMenuItem parent, MenuItem item) {
        SubMenuItem subMenu = (parent != null) ? parent : ROOT;

        synchronized (subMenuItems) {
            ArrayList<MenuItem> subMenuChildren = subMenuItems.computeIfAbsent(subMenu, sm -> new ArrayList<>());
            subMenuChildren.add(item);

            if (item.hasChildren()) {
                subMenuItems.put(item, new ArrayList<>());
            }
        }
    }
133374
function SubmenuPlugin(selectivity, options) {
    /**
     * Optional parent dropdown menu from which this dropdown was opened.
     */
    this.parentMenu = options.parentMenu;

    Dropdown.call(this, selectivity, options);

    this._closeSubmenuTimeout = 0;

    this._openSubmenuTimeout = 0;
}
373673
@Override
    public void onPrepareSubMenu(SubMenu subMenu) {
        subMenu.clear();
        if (DEBUG) {
            Log.v(TAG, "onPrepareSubMenu() mDefaultLength=" + mDefaultLength + " mShareTargets.size()=" + mShareTargets.size());
        }
        int length = Math.min(mDefaultLength, mShareTargets.size());
        Resources res = mContext.getResources();
        for (int i = 0; i < length; i++) {
            ShareTarget target = mShareTargets.get(i);
            subMenu.add(0, i, i, target.title).setIcon(target.icon).setOnMenuItemClickListener(this);
        }

        if (mDefaultLength < mShareTargets.size()) {
            subMenu = subMenu.addSubMenu(Menu.NONE, mDefaultLength, mDefaultLength, mExpandLabel);

            for (int i = 0; i < mShareTargets.size(); i++) {
                ShareTarget target = mShareTargets.get(i);
                subMenu.add(0, i, i, target.title).setIcon(target.icon).setOnMenuItemClickListener(this);
            }
        }
    }
421865
public final void setParent(ElementBase parent) {
        ElementBase oldParent = this.parent;
        
        if (oldParent == parent) {
            return;
        }
        
        if (oldParent != null) {
            oldParent.removeChild(this, false);
        }
        
        if (parent != null) {
            parent.addChild(this);
        }
    }
847082
private void updateParent(ElementBase newParent) {
        ElementBase oldParent = this.parent;
        
        if (oldParent != newParent) {
            beforeParentChanged(newParent);
            this.parent = newParent;
            
            if (oldParent != null) {
                oldParent.updateState();
            }
            
            if (newParent != null) {
                afterParentChanged(oldParent);
                newParent.updateState();
            }
        }
    }
839686
@Override
  public final void setPickUpPlace(final PickUpPlace pPickUpPlace) {
    this.pickUpPlace = pPickUpPlace;
    if (this.itsId == null) {
      this.itsId = new SeServicePlaceId();
    }
    this.itsId.setPickUpPlace(this.pickUpPlace);
  }
339202
@Override
  public final void setPickUpPlace(final PickUpPlace pPickUpPlace) {
    this.pickUpPlace = pPickUpPlace;
    if (this.itsId == null) {
      this.itsId = new SeGoodsPlaceId();
    }
    this.itsId.setPickUpPlace(this.pickUpPlace);
  }
943155
public void replaceChildren(List<T> list, String parentId) {
		for (T item : list) {
			item.setParentId(parentId);
		}
		@SuppressWarnings("resource")
		SQLiteDatabase db = dbHelper.getWritableDatabase();
		boolean endTransaction = beginTransaction(db);
		try {
			db.delete(getTableName(), getParentIdColumnName() + "=?", new String[] { parentId });
			addAll(list);
			LOGGER.trace("Replaced children of parent " + parentId + " and type " + getTableName());
			successTransaction(db, endTransaction);
		} finally {
			endTransaction(db, endTransaction);
		}
	}
233834
function replaceNode(replacementNode, node) {
  remove(replacementNode)
  node.parentNode.insertBefore(replacementNode, node)
  remove(node)
}
479885
void updateReplace() {

        boolean replace = m_replace.getValue().booleanValue();

        m_replaceResource.setVisible(replace ? SearchType.resourcetype.equals(m_searchType.getValue()) : replace);
        m_replacePattern.setVisible(
            replace
            ? !SearchType.resourcetype.equals(m_searchType.getValue())
                & !SearchType.renameContainer.equals(m_searchType.getValue())
            : replace);

        m_newName.setVisible(replace ? SearchType.renameContainer.equals(m_searchType.getValue()) : replace);
        m_oldName.setVisible(replace ? SearchType.renameContainer.equals(m_searchType.getValue()) : replace);

        m_workProject.setVisible(replace);

        m_search.setCaption(
            replace
            ? CmsVaadinUtils.getMessageText(Messages.GUI_SOURCESEARCH_REPLACE_0)
            : CmsVaadinUtils.getMessageText(Messages.GUI_SOURCESEARCH_SEARCH_0));

    }
1164706
public static SubMenuItem asSubMenu(MenuItem item) {
        return visitWithResult(item, new AbstractMenuItemVisitor<SubMenuItem>() {
            @Override
            public void visit(SubMenuItem item) {
                setResult(item);
            }

            @Override
            public void anyItem(MenuItem item) { /* ignored */ }
        }).orElse(null);
    }
403421
function addLinkToParent(idNode, idParentNode){
    g.addLink(idParentNode, idNode, nodesToBeLinked[idNode].name);
    delete nodesToBeLinked[idNode];

    //we remove the node from childrenNodes
    var index = childrenNodes.indexOf(idNode);
    if (index > -1) {
        childrenNodes.splice(index, 1);
    }
}
1059164
private void relink(DOMOutputElement parent, Element element)
    {
        super.relink(parent);
        mParent = parent;
        mElement = element;
        parent.appendNode(element);
        mDefaultNsSet = false;
    }
8429
function replace(oldNode, newNode){
    return oldNode[PARENT_NODE] ? oldNode[PARENT_NODE].replaceChild(newNode, oldNode) : oldNode;
  }
429027
public void removeItem(ContextMenuItem contextMenuItem) {

        if (!hasMenuItem(contextMenuItem)) {
            return;
        }

        if (contextMenuItem.isRootItem()) {
            getState().getRootItems().remove(contextMenuItem.m_state);
        } else {
            ContextMenuItem parent = contextMenuItem.getParent();
            parent.m_state.getChildren().remove(contextMenuItem.m_state);
        }

        Set<ContextMenuItem> children = contextMenuItem.getAllChildren();

        m_items.remove(contextMenuItem.m_state.getId());

        for (ContextMenuItem child : children) {
            m_items.remove(child.m_state.getId());
        }

        markAsDirty();
    }
294630
public void setProperty(String strProperty, String strValue)
    {
        if (DBParams.MENU.equalsIgnoreCase(strProperty))
            this.setMenuProperty(strValue);     // Special case
        else
            super.setProperty(strProperty, strValue);
    }