Comments (6)
i'll take a few days to test this bug report and possibly commit a bug fix.
feel free to send a patch if you fix the problem before me.
thanks
Original comment by fmorbini
on 3 Dec 2011 at 9:32
from scxmlgui.
Hi,
I'm implementing SCXML, not the GUI, but I can give you my code where I do
this validation so you can use it on yours.
For each state in parallel states check the LCA from transitions and, if
the LCA is the parallel state itself then... validation error...
private void validateNoTransitionBetweenParallelSiblings(ParallelState
parallelState)throws ParallelSiblingTransactionException {
List<State> stateList=stateToList(parallelState);
for(State state:stateList){
for(Transition transition:state.getTransitions()){
if(searchLCA(transition).equals(parallelState)){
throw new ParallelSiblingTransactionException();
}
}
}
}
To calculate the LCA I calculate first the breadcrumb of each state and
compare until one state is different... the last common state in the
breadcrumb is the LCA.
In my case null is the scxml itself (it depends on how you calculate the
breadcrumb).
protected State searchLCA(Transition transition) {
State[] states = new State[] { transition.getSourceState(),
transition.getTargetState() };
return searchLCA(states);
}
protected State searchLCA(State[] states) {
State LCA= ROOT_STATE;
Iterator<State>[] breadcrumbs = new Iterator[states.length];
// get all the breadcrumbs
for (int i = 0; i < states.length; i++) {
breadcrumbs[i] = states[i].getBreadCrumb().iterator();
i++;
}
State candidate;
State other;
boolean foundLCA = false;
while (!foundLCA) {
//take the first state from breadcrumbs
candidate=breadcrumbs[0].hasNext()?breadcrumbs[0].next():null;
if(candidate!=null){
//and compare with all the other states
for (int i = 1; i < states.length&&!foundLCA; i++) {
other=breadcrumbs[i].hasNext()?breadcrumbs[0].next():null;
if(other==null||other.equals(candidate)){
foundLCA=true;
}
}
//if no other states is different from candidate
if(!foundLCA){
//put candidate to LCA
LCA=candidate;
}
}else{
//there is no candidate so... LCA has been found
foundLCA=true;
}
}
return LCA;
}
And last, to calculate the breadcrumb (this could be cached to improve
performance):
@Override
public List<State> getBreadCrumb() {
List<State> breadcrumb = new ArrayList<State>();
calculateBreadCrumb(breadcrumb);
return breadcrumb;
}
protected void calculateBreadCrumb(List<State> breadcrumb) {
BasicState aux = (BasicState) parent;
if (aux != null) {
aux.calculateBreadCrumb(breadcrumb);
breadcrumb.add(aux);
}
}
I hope this code could help you!!
Regards.
Original comment by [email protected]
on 5 Dec 2011 at 10:47
from scxmlgui.
Have you found this useful?
Original comment by [email protected]
on 9 Dec 2011 at 10:14
from scxmlgui.
sorry, haven't looked at this yet. I may take an additional couple of weeks
before i'll be able to check this out.
Original comment by fmorbini
on 10 Dec 2011 at 2:17
from scxmlgui.
fixed in revision 140.
Original comment by fmorbini
on 3 Jan 2012 at 6:34
- Changed state: Fixed
from scxmlgui.
Thanks!
Original comment by [email protected]
on 25 Jan 2012 at 3:42
from scxmlgui.
Related Issues (20)
- Disable grid snapping for transition event labels HOT 1
- Diagram-level color customization
- Visually differentiate conditional transitions
- Option for multiline transition events
- Keyboard nudge HOT 2
- Serialized location information subtly changing floating point value HOT 2
- History States marked as Initial don't visually indicate history type HOT 2
- Datamodel attribute to scxml root node HOT 2
- "target" transition attribute not being added HOT 3
- CDATA info is not saved HOT 1
- apostrophes showing as ' in an Executable content tab of an element editor window HOT 1
- Error while opening edge editor. when rename a source node ID HOT 4
- not graphically contained in its parent
- Building issue HOT 2
- Cannot find Symbol Type.OUTGOING_EDGE_ORDER
- Request to add version="1.0" HOT 1
- History support? HOT 1
- Outsourcing using xi:include is a one-way operation HOT 1
- Specify license of the code HOT 2
- Crashes on start HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scxmlgui.