Пример #1
0
  @Nonnull
  public CanvasObjectItem duplicate(@Nonnull CanvasObjectItem obj) {
    if (!(obj instanceof ComponentItemImpl))
      throw new IllegalArgumentException(
          obj + " needs to be an instance of: " + ComponentItemImpl.class.getName());

    ComponentItemConfig config = getConfig().addNewComponent();
    config.set(((ComponentItemImpl) obj).getConfig());
    if (obj.getCanvas().equals(this)) config.setLabel("Copy of " + config.getLabel());
    config.setId(addressableRegistry.generateId());
    try {
      return loadComponent(config);
    } catch (ComponentCreationException e) {
      // Shouldn't happen...
      throw new RuntimeException(e);
    }
  }