blob: a75d33edfbb98e1d72bde4ff51038c2b0e445fe8 [file] [log] [blame]
package org.eclipse.papyrus.robotml.diagram.common.advices;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import org.eclipse.papyrus.RobotML.ServiceFlowKind;
import org.eclipse.papyrus.RobotML.ServicePort;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.util.UMLUtil;
public class ProvidedServicePortCreationHelperAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
final Port robotMLPort = (Port) request.getElementToConfigure();
return new ConfigureElementCommand(request) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info)
throws ExecutionException {
ServicePort sp = UMLUtil.getStereotypeApplication(robotMLPort, ServicePort.class);
if (sp != null) {
sp.setKind(ServiceFlowKind.PROVIDED);
}
return CommandResult.newOKCommandResult(robotMLPort);
}
};
}
}