private void constructContextMenuMap() {
    if (contextMenuMap == null) {
      contextMenuMap = new LinkedHashMap<>();

      // Build the ContextMenu item from the library builtin items
      final String contextMenuFxmlPath = "builtin/ContextMenu.fxml"; // NOI18N
      final URL contextMenuFxmlURL = BuiltinLibrary.class.getResource(contextMenuFxmlPath);
      assert contextMenuFxmlURL != null;

      final AbstractSelectionGroup asg = getEditorController().getSelection().getGroup();
      assert asg instanceof ObjectSelectionGroup; // Because of (1)
      final ObjectSelectionGroup osg = (ObjectSelectionGroup) asg;

      try {
        final String contextMenuFxmlText = FXOMDocument.readContentFromURL(contextMenuFxmlURL);

        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
        final Library library = getEditorController().getLibrary();
        for (FXOMObject fxomObject : osg.getItems()) {
          final FXOMDocument contextMenuDocument =
              new FXOMDocument(
                  contextMenuFxmlText, contextMenuFxmlURL, library.getClassLoader(), null);

          assert contextMenuDocument != null;
          final FXOMObject contextMenuObject = contextMenuDocument.getFxomRoot();
          assert contextMenuObject != null;
          contextMenuObject.moveToFxomDocument(fxomDocument);
          assert contextMenuDocument.getFxomRoot() == null;

          contextMenuMap.put(fxomObject, contextMenuObject);
        }
      } catch (IOException x) {
        throw new IllegalStateException("Bug in " + getClass().getSimpleName(), x); // NOI18N
      }
    }
  }