Skip to content

Commit

Permalink
[FIX] ObeoNetwork#94 tool for stateMachine
Browse files Browse the repository at this point in the history
Add a feature tool for stateMachine creation
Display owned StateMachine in block
  • Loading branch information
fbats committed Feb 9, 2018
1 parent ce958b5 commit 20fb40a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
20 changes: 18 additions & 2 deletions plugins/org.obeonetwork.dsl.sysml.design/description/sysml.odesign
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
<color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
</style>
</subNodeMappings>
<subNodeMappings name="BDD_StateMachine" detailDescriptions="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Block%20Definition%20Diagram']/@defaultLayer/@toolSections.6/@ownedTools[name='Function%20description%20creation']" deletionDescription="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Block%20Definition%20Diagram']/@defaultLayer/@toolSections.5/@subSections[name='BDD%20Delete%20Objects']/@ownedTools[name='Delete%20Function']" labelDirectEdit="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Block%20Definition%20Diagram']/@defaultLayer/@toolSections.4/@ownedTools[name='Edit%20Function%20Name']" semanticCandidatesExpression="feature:ownedBehavior" domainClass="uml.StateMachine">
<style xsi:type="style:SquareDescription" labelExpression="service:computeUmlLabel" labelAlignment="LEFT">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_blue']"/>
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_blue']"/>
</style>
</subNodeMappings>
<reusedNodeMappings href="../../org.obeonetwork.dsl.uml2.design/description/uml2.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Class%20Diagram']/@defaultLayer/@containerMappings[name='CD_ReusedMappingForFeatures']/@subNodeMappings[name='CD_Operation']"/>
<style xsi:type="style:FlatContainerStyleDescription" arcWidth="1" arcHeight="1" borderSizeComputationExpression="1" labelExpression="service:computeUmlLabel" tooltipExpression="feature:name" backgroundStyle="GradientTopToBottom" foregroundColor="//@userColorsPalettes[name='SysML%20Color%20Palette']/@entries[name='BlueBlock']">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
Expand Down Expand Up @@ -528,6 +535,15 @@
</initialOperation>
</tools>
</ownedTools>
<ownedTools xsi:type="tool:NodeCreationDescription" name="BDD_Create_StateMachine" label="State Machine" nodeMappings="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Block%20Definition%20Diagram']/@defaultLayer/@containerMappings[name='BDD_Block']/@subNodeMappings[name='BDD_StateMachine']">
<variable name="container"/>
<viewVariable name="containerView"/>
<initialOperation>
<firstModelOperations xsi:type="tool_1:CreateInstance" typeName="uml.StateMachine" referenceName="ownedBehavior">
<subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="service:computeSysmlLabel"/>
</firstModelOperations>
</initialOperation>
</ownedTools>
<reusedTools xsi:type="tool:NodeCreationDescription" href="../../org.obeonetwork.dsl.uml2.design/description/uml2.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Class%20Diagram']/@defaultLayer/@toolSections.2/@ownedTools[name='Literal']"/>
</toolSections>
<toolSections name="Relationships" label="Relationships">
Expand Down Expand Up @@ -1303,7 +1319,7 @@
<firstModelOperation xsi:type="tool_1:ChangeContext" browseExpression="aql:self.deleteRequirement()"/>
</delete>
</ownedSubLines>
<create name="RT Create SubRequirement" label="Create SubRequirement" forceRefresh="true" elementsToSelect="service:stdEmptyCollection" mapping="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Requirement%20Table']/@ownedLineMappings[name='RT_Requirements']/@ownedSubLines[name='RT_SubRequirements']">
<create name="RT Create SubRequirement" label="Create SubRequirement" forceRefresh="true" mapping="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Requirement%20Table']/@ownedLineMappings[name='RT_Requirements']/@ownedSubLines[name='RT_SubRequirements']" elementsToSelect="service:stdEmptyCollection">
<variables name="root" documentation="The semantic element of the table."/>
<variables name="element" documentation="The semantic currently edited element."/>
<variables name="container" documentation="The semantic element corresponding to the view container."/>
Expand All @@ -1320,7 +1336,7 @@
<firstModelOperation xsi:type="tool_1:ChangeContext" browseExpression="aql:self.deleteRequirement()"/>
</delete>
</ownedLineMappings>
<ownedCreateLine name="RT Create Requirement" label="Create Requirement" forceRefresh="true" elementsToSelect="service:stdEmptyCollection" mapping="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Requirement%20Table']/@ownedLineMappings[name='RT_Requirements']">
<ownedCreateLine name="RT Create Requirement" label="Create Requirement" forceRefresh="true" mapping="//@ownedViewpoints[name='SysML']/@ownedRepresentations[name='Requirement%20Table']/@ownedLineMappings[name='RT_Requirements']" elementsToSelect="service:stdEmptyCollection">
<variables name="root" documentation="The semantic element of the table."/>
<variables name="element" documentation="The semantic currently edited element."/>
<variables name="container" documentation="The semantic element corresponding to the view container."/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.util.UMLSwitch;

import com.google.common.base.Predicate;
Expand Down Expand Up @@ -160,6 +161,16 @@ public boolean apply(EObject input) {
return computeLabel(element, getUmlTypeName(element), predicate);
}

@Override
public String caseStateMachine(StateMachine element) {
final Predicate<EObject> predicate = new Predicate<EObject>() {
public boolean apply(EObject input) {
return input instanceof StateMachine;
}
};
return computeLabel(element, "stateMachine", predicate); //$NON-NLS-1$
}

/**
* Compute default label : name + number of existing element.
*
Expand All @@ -174,8 +185,8 @@ public boolean apply(EObject input) {
@SuppressWarnings("unchecked")
private String computeLabel(EObject element, String name,
@SuppressWarnings("rawtypes") Predicate predicate) {
final List<EObject> existingElements = Lists.newArrayList(Iterables.filter(element.eContainer()
.eContents(), predicate));
final List<EObject> existingElements = Lists
.newArrayList(Iterables.filter(element.eContainer().eContents(), predicate));

return name + existingElements.size();
}
Expand Down

0 comments on commit 20fb40a

Please sign in to comment.