OW2 Consortium orchestra

Rev

Rev 5841 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5841 Rev 6547
Line 24... Line 24...
24
 * NOTE: this file is only generated if it does not exist. You may safely put
24
 * NOTE: this file is only generated if it does not exist. You may safely put
25
 * your custom code here.
25
 * your custom code here.
26
 */
26
 */
27

27

28
package org.ow2.orchestra.designer.bpmn.model {
28
package org.ow2.orchestra.designer.bpmn.model {
29
  import flash.utils.IDataInput;
-
 
-
 
29
import flash.utils.IDataInput;
30

30

31
  import mx.collections.ArrayCollection;
-
 
32
  import mx.events.CollectionEvent;
-
 
33
  import mx.events.CollectionEventKind;
-
 
-
 
31
import mx.collections.ArrayCollection;
-
 
32
import mx.events.CollectionEvent;
-
 
33
import mx.events.CollectionEventKind;
34

34

35
  [Bindable]
-
 
36
  [RemoteClass(alias="org.ow2.orchestra.designer.bpmn.model.ProcessModel")]
-
 
37
  public class ProcessModel extends ProcessModelBase {
-
 
38
    public function ProcessModel() {
-
 
39
      super();
-
 
40
      elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
-
 
41
    }
-
 
-
 
35
[Bindable]
-
 
36
[RemoteClass(alias="org.ow2.orchestra.designer.bpmn.model.ProcessModel")]
-
 
37
public class ProcessModel extends ProcessModelBase {
-
 
38
  public function ProcessModel() {
-
 
39
    super();
-
 
40
    elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
-
 
41
  }
42

42

43
    // Add event listener for elements changes
-
 
44
    public override function readExternal(input:IDataInput):void {
-
 
45
      super.readExternal(input);
-
 
46
      elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
-
 
47
      for each (var element:AbstractElement in elements) {
-
 
48
        element.onDeserializationComplete();
-
 
49
      }
-
 
-
 
43
  // Add event listener for elements changes
-
 
44
  public override function readExternal(input:IDataInput):void {
-
 
45
    super.readExternal(input);
-
 
46
    elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
-
 
47
    for each (var element:AbstractElement in elements) {
-
 
48
      element.onDeserializationComplete();
50
    }
49
    }
-
 
50
  }
51

51

52
    /**
-
 
53
     * Listener for process element changes.
-
 
54
     * Deletes sequence flow when the source or target element is removed.
-
 
55
     * @param collectionEvent
-
 
56
     */
-
 
57
    public function elementsModified(collectionEvent:CollectionEvent):void {
-
 
58
      // model elements changed.
-
 
59
      var changedElements:Array = collectionEvent.items;
-
 
60
      if (collectionEvent.kind == CollectionEventKind.REMOVE) {
-
 
61
        for each (var removedElement:Object in changedElements) {
-
 
62
          if (removedElement is AbstractElementWithPosition) {
-
 
63
            // remove sequenceFlow elements attached to the element to delete
-
 
64
            // iterate on a copy of the elements list to avoid concurrent modifications
-
 
65
            // (sequenceFlow are removed from the elements list)
-
 
66
            var elementsCopy:ArrayCollection = new ArrayCollection();
-
 
67
            elementsCopy.addAll(elements);
-
 
68
            for each (var element:Object in elementsCopy) {
-
 
69
              if (element is SequenceFlowModel) {
-
 
70
                var sequenceFlowModel:SequenceFlowModel = element as SequenceFlowModel;
-
 
71
                if (sequenceFlowModel.sourceElement == removedElement || sequenceFlowModel.targetElement == removedElement) {
-
 
72
                  // remove sequence flow
-
 
73
                  elements.removeItemAt(elements.getItemIndex(sequenceFlowModel));
-
 
74
                }
-
 
-
 
52
  /**
-
 
53
   * Listener for process element changes.
-
 
54
   * Deletes sequence flow when the source or target element is removed.
-
 
55
   * @param collectionEvent
-
 
56
   */
-
 
57
  public function elementsModified(collectionEvent:CollectionEvent):void {
-
 
58
    // model elements changed.
-
 
59
    var changedElements:Array = collectionEvent.items;
-
 
60
    if (collectionEvent.kind == CollectionEventKind.REMOVE) {
-
 
61
      for each (var removedElement:Object in changedElements) {
-
 
62
        if (removedElement is AbstractElementWithPosition) {
-
 
63
          // remove sequenceFlow elements attached to the element to delete
-
 
64
          // iterate on a copy of the elements list to avoid concurrent modifications
-
 
65
          // (sequenceFlow are removed from the elements list)
-
 
66
          var elementsCopy:ArrayCollection = new ArrayCollection();
-
 
67
          elementsCopy.addAll(elements);
-
 
68
          for each (var element:Object in elementsCopy) {
-
 
69
            if (element is SequenceFlowModel) {
-
 
70
              var sequenceFlowModel:SequenceFlowModel = element as SequenceFlowModel;
-
 
71
              if (sequenceFlowModel.sourceElement == removedElement || sequenceFlowModel.targetElement == removedElement) {
-
 
72
                // remove sequence flow
-
 
73
                elements.removeItemAt(elements.getItemIndex(sequenceFlowModel));
75
              }
74
              }
76
            }
75
            }
77
            if (removedElement is EventModel) {
-
 
78
              // remove operation if element is deleted
-
 
79
              EventModel(removedElement).operation = null;
-
 
80
            }
-
 
81
          } else if (removedElement is SequenceFlowModel) {
-
 
82
            var removedSequenceFlowModel:SequenceFlowModel = removedElement as SequenceFlowModel;
-
 
83
            // Remove from old source outgoing sequence flows list
-
 
84
            var oldSource:AbstractElementWithPosition = removedSequenceFlowModel.sourceElement;
-
 
85
            if (oldSource != null) {
-
 
86
              var srcIndex:int = oldSource.outgoingSequenceFlows.getItemIndex(removedSequenceFlowModel);
-
 
87
              if (srcIndex != -1) {
-
 
88
                oldSource.outgoingSequenceFlows.removeItemAt(srcIndex);
-
 
-
 
76
          }
-
 
77
          if (removedElement is EventModel) {
-
 
78
            // remove operation if element is deleted
-
 
79
            EventModel(removedElement).operation = null;
-
 
80
          } else if (removedElement is PoolModel) {
-
 
81
            for each (var abstractElement:AbstractElement in this.elements) {
-
 
82
              //Check tasks related to this pool
-
 
83
              if ((abstractElement is TaskModel) &&
-
 
84
                      TaskModel(abstractElement).operation != null &&
-
 
85
                      TaskModel(abstractElement).operation.interfaceModel != null &&
-
 
86
                      PoolModel(removedElement).interfaces.containsValue(
-
 
87
                              TaskModel(abstractElement).operation.interfaceModel)) {
-
 
88
                TaskModel(abstractElement).operation = null;
89
              }
89
              }
90
            }
90
            }
91
            // Remove from old target incoming sequence flows list
-
 
92
            var oldTarget:AbstractElementWithPosition = removedSequenceFlowModel.targetElement;
-
 
93
            if (oldTarget != null) {
-
 
94
              var targetIndex:int = oldTarget.incomingSequenceFlows.getItemIndex(removedSequenceFlowModel);
-
 
95
              if (targetIndex != -1) {
-
 
96
                oldTarget.incomingSequenceFlows.removeItemAt(targetIndex);
-
 
97
              }
-
 
-
 
91
          }
-
 
92
        } else if (removedElement is SequenceFlowModel) {
-
 
93
          var removedSequenceFlowModel:SequenceFlowModel = removedElement as SequenceFlowModel;
-
 
94
          // Remove from old source outgoing sequence flows list
-
 
95
          var oldSource:AbstractElementWithPosition = removedSequenceFlowModel.sourceElement;
-
 
96
          if (oldSource != null) {
-
 
97
            var srcIndex:int = oldSource.outgoingSequenceFlows.getItemIndex(removedSequenceFlowModel);
-
 
98
            if (srcIndex != -1) {
-
 
99
              oldSource.outgoingSequenceFlows.removeItemAt(srcIndex);
-
 
100
            }
-
 
101
          }
-
 
102
          // Remove from old target incoming sequence flows list
-
 
103
          var oldTarget:AbstractElementWithPosition = removedSequenceFlowModel.targetElement;
-
 
104
          if (oldTarget != null) {
-
 
105
            var targetIndex:int = oldTarget.incomingSequenceFlows.getItemIndex(removedSequenceFlowModel);
-
 
106
            if (targetIndex != -1) {
-
 
107
              oldTarget.incomingSequenceFlows.removeItemAt(targetIndex);
98
            }
108
            }
99
          }
109
          }
100
        }
110
        }
101
      }
111
      }
102
    }
112
    }
103

-
 
104
  }
113
  }
-
 
114

-
 
115
}
105
}
116
}