blob: 372822c23987cf1a79828a892fa412dd5cb27772 [file] [log] [blame]
/**
* Copyright (c)2020 CEA LIST, Committer Name, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* CEA LIST - Initial API and implementation
* Gabriel Pedroza (CEA LIST) gabriel.pedroza@cea.fr
*
*/
package org.eclipse.papyrus.pdp4eng.designer.controller.internal;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.pdp4eng.designer.profile.pdp4engDesign.pdp4engDesignPackage;
import org.eclipse.uml2.uml.AggregationKind;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
/**
* Creates an abstraction from Data.
*
*/
public class AbstractDataCreateCommand extends RecordingCommand {
protected NamedElement selectedElement;
private static int no = 0;
public AbstractDataCreateCommand(TransactionalEditingDomain domain, NamedElement selectedElements) {
super(domain, "AbstractDataCreateCommand");
this.selectedElement = selectedElements;
}
protected void createCompositeData(org.eclipse.uml2.uml.Package owner, String text) {
org.eclipse.uml2.uml.Class abstractData = owner.createOwnedClass(this.selectedElement.getName()+"_"+no, false);
StereotypeApplicationHelper stereotypeApplicationHelper = StereotypeApplicationHelper.getInstance(null);
stereotypeApplicationHelper.applyStereotype(abstractData, pdp4engDesignPackage.eINSTANCE.getCompositeData(),null);
((Classifier)selectedElement).createAssociation(true, AggregationKind.get(2),"data_target", 0, 1, abstractData, false, AggregationKind.get(0), "data_source", 1, 1);
no++;
}
@Override
protected void doExecute() {
createCompositeData(selectedElement.getNearestPackage(), "");
}
}