use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class FoldOutgoingActionsRefactoring method removeFirstActions.
private void removeFirstActions(EList<Transition> transitions, int number) {
for (Transition transition : transitions) {
List<Expression> actionsToRemove = getFirstActions(transition, number);
Effect effect = transition.getEffect();
if (effect instanceof ReactionEffect && actionsToRemove.size() == ((ReactionEffect) effect).getActions().size()) {
// we need to remove all actions, so just remove the effect recursively which avoids serializer exceptions
EcoreUtil.delete(effect, true);
} else {
for (Expression action : actionsToRemove) {
EcoreUtil.delete(action);
}
}
}
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class AddOutgoingStateModification method execute.
@Override
protected void execute(EObject semanticElement, View view) {
State state = (State) semanticElement;
State newState = SGraphFactory.eINSTANCE.createState();
Transition transition = SGraphFactory.eINSTANCE.createTransition();
state.getParentRegion().getVertices().add(newState);
transition.setSource(state);
transition.setTarget(newState);
if (transitionSpecification != null)
transition.setSpecification(transitionSpecification);
if (stateName != null)
newState.setName(stateName);
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class NotationClipboardOperationHelper method getSemanticPasteTarget.
// PATCH START
/**
* Customized Method to find the semantic target which should contain the
* copied elements.
*
* @param view
* @param container
* @return the semantic target.
*/
public static EObject getSemanticPasteTarget(View view, View container) {
EObject copiedSemanticObject = view.getElement();
EObject semanticTarget = container.getElement();
if (copiedSemanticObject instanceof Transition) {
semanticTarget = copiedSemanticObject.eContainer();
}
EList<EReference> eAllReferences = semanticTarget.eClass().getEAllReferences();
for (EReference eReference : eAllReferences) {
EClass eReferenceType = eReference.getEReferenceType();
if (eReference.isContainment() && eReferenceType.isSuperTypeOf(copiedSemanticObject.eClass())) {
return semanticTarget;
}
}
return null;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class VertexEditHelper method getDestroyDependentsCommand.
@Override
protected ICommand getDestroyDependentsCommand(DestroyDependentsRequest req) {
Vertex elementToDestroy = (Vertex) req.getElementToDestroy();
EList<Transition> incomingTransitions = elementToDestroy.getIncomingTransitions();
if (incomingTransitions.size() != 0) {
CompositeCommand compoundCommand = new CompositeCommand("Delete vertex");
for (Transition transition : incomingTransitions) {
DestroyElementCommand destroyCommand = new DestroyElementCommand(new DestroyElementRequest(transition, false));
compoundCommand.add(destroyCommand);
}
return compoundCommand;
}
return super.getDestroyDependentsCommand(req);
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class STextJavaValidator method checkUnboundEntryPoints.
@Check(CheckType.NORMAL)
public void checkUnboundEntryPoints(final org.yakindu.sct.model.sgraph.State state) {
if (state.isComposite()) {
final List<Transition>[] transitions = STextValidationModelUtils.getEntrySpecSortedTransitions(state.getIncomingTransitions());
Map<Region, List<Entry>> regions = null;
// first list contains Transitions without entry spec
if (!transitions[0].isEmpty()) {
regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
if (!regions.isEmpty()) {
for (Transition transition : transitions[0]) {
error(TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT, transition, null, -1);
}
for (Region region : regions.keySet()) {
error(REGION_UNBOUND_DEFAULT_ENTRY_POINT, region, null, -1);
}
}
}
// second list contains Transitions with entry spec
if (!transitions[1].isEmpty()) {
if (regions == null) {
regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
}
for (Transition transition : transitions[1]) {
boolean hasTargetEntry = true;
for (ReactionProperty property : transition.getProperties()) {
if (property instanceof EntryPointSpec) {
EntryPointSpec spec = (EntryPointSpec) property;
String specName = "'" + spec.getEntrypoint() + "'";
for (Region region : regions.keySet()) {
boolean hasEntry = false;
for (Entry entry : regions.get(region)) {
if (entry.getName().equals(spec.getEntrypoint())) {
hasEntry = true;
break;
}
}
if (!hasEntry) {
error(REGION_UNBOUND_NAMED_ENTRY_POINT + specName, region, null, -1);
hasTargetEntry = false;
}
}
if (!hasTargetEntry) {
error(TRANSITION_UNBOUND_NAMED_ENTRY_POINT + specName, transition, null, -1);
}
}
}
}
}
}
}
Aggregations