blob: d8754109391141f45292f7b37b391b14ef595de7 [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2019 CEA LIST, 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:
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.sysml16.service.types.advice;
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.uml2.uml.AggregationKind;
import org.eclipse.uml2.uml.Property;
/**
* The EditHelperAdvice class used for ConnectorProperty
* [3]The aggregation of a property stereotyped by ConnectorProperty must be composite.
*/
public class ConnectorPropertyEditHelperAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
final Property property = (Property) request.getElementToConfigure();
return new ConfigureElementCommand(request) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
property.setAggregation(AggregationKind.COMPOSITE_LITERAL);
return CommandResult.newOKCommandResult(property);
}
};
}
}