
org.eclipse.emf.mapping.command.InitializeCopyOverrideCommand Maven / Gradle / Ivy
The newest version!
/**
* Copyright (c) 2002-2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* IBM - Initial API and implementation
*/
package org.eclipse.emf.mapping.command;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.CopyCommand;
import org.eclipse.emf.edit.command.InitializeCopyCommand;
import org.eclipse.emf.mapping.domain.MappingDomain;
/**
* This command overrides the InitializeCopyCommand for cross-domain copies.
* This implementation is a no-op unless the objects are suitable ECore classes,
* in which case it copies the name and possibly the eType.
* Application specific subclasses should override execute() to complete the initialization, if necessary.
*/
public class InitializeCopyOverrideCommand extends AbstractCommand
{
/**
* This keeps track of the mapping domain in which the command operates.
*/
protected MappingDomain mappingDomain;
/**
* This is command we're overriding
*/
protected InitializeCopyCommand initializeCommand;
/**
* This creates a command instance that initializes a copied object
*/
public InitializeCopyOverrideCommand(MappingDomain domain, InitializeCopyCommand initializeCommand)
{
super(initializeCommand.doGetLabel(), initializeCommand.doGetDescription());
this.mappingDomain = domain;
this.initializeCommand = initializeCommand;
}
@Override
protected boolean prepare()
{
return true;
}
public void execute()
{
EObject owner = initializeCommand.getOwner();
EObject copy = initializeCommand.getCopy();
CopyCommand.Helper copyHelper = initializeCommand.getCopyHelper();
/*
if (owner.refMetaObject() == copy.refMetaObject())
{
initializeCommand.doExecute();
return;
}
*/
// Copy the children references
//
Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy