* Handles a click on any arc in any state
*/
private void arcClicked(ArcModel arc) {
if (arc.isActivated()) {
AbstractPetriNetElementModel source = (AbstractPetriNetElementModel) getPetriNet().getElementContainer().getElementById(
arc.getSourceId());
AbstractPetriNetElementModel target = (AbstractPetriNetElementModel) getPetriNet().getElementContainer().getElementById(
arc.getTargetId());
OperatorTransitionModel tempOperator;
// As a reminder, an arc is generally going from a place to a
// transition or from a
// transition to a place.
// When pointing to a transition it is referencing a potential
// provider of a token.
// When pointing to a place that place is potential receiver for a
// token.
// First, we check if the origin of our clicked arc is a transition
// (Note that we check for the operator type only as ordinary
// transitions are not triggered
// by clicking the arrow but by clicking the transition itself which
// is handled in transitionClicked())
if (source.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
tempOperator = (OperatorTransitionModel) source;
if (tempOperator.isActivated()) {
if (tempOperator.getOperatorType() == OperatorTransitionModel.XOR_SPLIT_TYPE
|| tempOperator.getOperatorType() == OperatorTransitionModel.XOR_SPLITJOIN_TYPE
|| tempOperator.getOperatorType() == OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE) {
receiveTokens(arc);
if (tempOperator.getOperatorType() != OperatorTransitionModel.XOR_SPLITJOIN_TYPE) {
sendTokens(getPetriNet().getElementContainer().getIncomingArcs(tempOperator.getId()));
} else {
// Special code for splitjoin. We have to take the
// token from the center place
if (tempOperator.getCenterPlace() != null) {
// FIXME: Once implemented, this place will also
// have to remove weighted tokens
tempOperator.getCenterPlace().sendToken();
}
}
}
}
} else
if (target.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
tempOperator = (OperatorTransitionModel) target;
if (tempOperator.getOperatorType() == OperatorTransitionModel.XOR_JOIN_TYPE
|| tempOperator.getOperatorType() == OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE
|| tempOperator.getOperatorType() == OperatorTransitionModel.XOR_SPLITJOIN_TYPE) {
sendTokens(arc);