use of org.yakindu.sct.model.sgraph.ReactionProperty in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method addEntryPointSpec.
private void addEntryPointSpec(Transition transition, Entry entryPoint) {
EList<ReactionProperty> properties = transition.getProperties();
EntryPointSpec entryPointSpec = StextFactory.eINSTANCE.createEntryPointSpec();
// A transition can only have one entry point so alter the existing
for (ReactionProperty reactionProperty : properties) {
if (reactionProperty instanceof EntryPointSpec) {
entryPointSpec = (EntryPointSpec) reactionProperty;
}
}
entryPointSpec.setEntrypoint(entryPoint.getName());
properties.add(entryPointSpec);
}
use of org.yakindu.sct.model.sgraph.ReactionProperty 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);
}
}
}
}
}
}
}
use of org.yakindu.sct.model.sgraph.ReactionProperty in project statecharts by Yakindu.
the class STextJavaValidator method checkUnusedEntry.
@Check(CheckType.FAST)
public void checkUnusedEntry(final Entry entry) {
if (entry.getParentRegion().getComposite() instanceof org.yakindu.sct.model.sgraph.State && entry.getIncomingTransitions().isEmpty()) {
org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) entry.getParentRegion().getComposite();
if (!STextValidationModelUtils.isDefault(entry)) {
boolean hasIncomingTransition = false;
Iterator<Transition> transitionIt = state.getIncomingTransitions().iterator();
while (transitionIt.hasNext() && !hasIncomingTransition) {
Iterator<ReactionProperty> propertyIt = transitionIt.next().getProperties().iterator();
while (propertyIt.hasNext() && !hasIncomingTransition) {
ReactionProperty property = propertyIt.next();
if (property instanceof EntryPointSpec) {
hasIncomingTransition = entry.getName().equals(((EntryPointSpec) property).getEntrypoint());
}
}
}
if (!hasIncomingTransition) {
warning(ENTRY_UNUSED, entry, null, -1);
}
}
}
}
use of org.yakindu.sct.model.sgraph.ReactionProperty in project statecharts by Yakindu.
the class STextValidationModelUtils method getExitSpecSortedTransitions.
/**
* Sorts the given elements in transition without and with
* {@link ExitPointSpec}s
*
* @param elements
* - list of transitions to sort
* @return an array with the sorted elements. The first index contains a
* list of the transitions without {@link ExitPointSpec}s. The
* second index contains a list of the transitions with
* {@link ExitPointSpec}s.
*/
public static List<Transition>[] getExitSpecSortedTransitions(List<Transition> elements) {
@SuppressWarnings("unchecked") final List<Transition>[] transitions = new ArrayList[2];
// first list contains Transitions without exit spec
transitions[0] = new ArrayList<Transition>();
// second list contains Transitions with exit spec
transitions[1] = new ArrayList<Transition>();
for (Transition transition : elements) {
boolean hasExitSpec = false;
for (ReactionProperty property : transition.getProperties()) {
if (property instanceof ExitPointSpec) {
transitions[1].add(transition);
hasExitSpec = true;
break;
}
}
if (!hasExitSpec) {
transitions[0].add(transition);
}
}
return transitions;
}
use of org.yakindu.sct.model.sgraph.ReactionProperty in project statecharts by Yakindu.
the class StextResource method serializeReaction.
private String serializeReaction(Reaction reaction) {
StringBuilder builder = new StringBuilder();
builder.append(serialize(reaction.getTrigger()));
if (reaction.getEffect() != null) {
builder.append(" / ");
builder.append(serialize(reaction.getEffect()));
}
if (reaction.getProperties().size() > 0) {
builder.append(" # ");
for (ReactionProperty property : reaction.getProperties()) {
builder.append(serialize(property));
}
}
return builder.toString();
}
Aggregations