code: protected void setDesignContextMenu(BaseUIComponent component, Menupopup contextMenu) {
          component.setAttribute(CONTEXT_MENU, contextMenu);
          
          if (contextMenu == null) {
              SavedState.restore(component);
              applyHint();
          } else {
              new SavedState(component);
              component.setContext(contextMenu);
              component.setHint(getDefinition().getName());
          }
      }
docs: Apply/remove the design context menu to/from the specified component. If applying the design
  context menu, any existing context menu is saved. When removing the context menu, any saved
  context menu is restored.
  
  @param component Component to which to apply/remove the design context menu.
  @param contextMenu The design menu if design mode is activated, or null if it is not.