OW2 Consortium orchestra

Compare Revisions

Ignore whitespace Rev 6546 → Rev 6547

/trunk/OrchestraPVM/designer/bpmnviews/src/main/flex/org/ow2/orchestra/designer/bpmn/views/TaskView.as
1,231 → 1,235
/*
* Bull SAS / OW2 Orchestra
* Copyright (C) 2011 Bull S.A.S, and individual contributors as indicated
* by the @authors tag.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
 
package org.ow2.orchestra.designer.bpmn.views {
import flash.display.DisplayObject;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
 
import mx.binding.utils.BindingUtils;
import mx.binding.utils.ChangeWatcher;
import mx.containers.Canvas;
import mx.containers.HBox;
import mx.containers.VBox;
import mx.controls.Image;
import mx.controls.Label;
import mx.controls.Spacer;
import mx.events.FlexEvent;
 
import org.ow2.orchestra.designer.bpmn.model.AbstractElement;
import org.ow2.orchestra.designer.bpmn.model.TaskModel;
import org.ow2.orchestra.designer.bpmn.model.TaskType;
import org.ow2.orchestra.designer.bpmn.views.utils.ArrowStyle;
import org.ow2.orchestra.designer.bpmn.views.utils.ArrowUtil;
import org.ow2.orchestra.designer.bpmn.views.utils.GraphicUtils;
 
public class TaskView extends AbstractElementView implements IFlowNodeView {
[Bindable]
private var _taskModel:TaskModel;
 
private var _processView:ProcessView;
/**
* The source for "event" image data binding.
*/
[Bindable]
[Embed(source="/../assets/task.svg")]
public var taskBackgroundImage:Class;
/**
* The source for "event" image data binding.
*/
[Bindable]
[Embed(source="/../assets/serviceTask.svg")]
public var serviceTaskImage:Class;
 
private var imageTaskBackground:Image = new Image();
private var imageTask:Image = new Image();
private var messageFlowCanvas:Canvas = new Canvas();
private var messageFlowLabel:Label = new Label();
 
 
function TaskView(taskModel:TaskModel, processView:ProcessView) {
_processView = processView;
_taskModel = taskModel;
this.setStyle("horizontalAlign", "center");
imageTaskBackground.percentWidth = 100;
imageTaskBackground.minWidth = 60;
imageTaskBackground.percentHeight = 100;
 
imageTaskBackground.maintainAspectRatio = false;
imageTaskBackground.automationName = "TaskImage" + _taskModel.id;
imageTaskBackground.source = taskBackgroundImage;
 
watchers.addItem(BindingUtils.bindProperty(this, "x", _taskModel, "x"));
watchers.addItem(BindingUtils.bindProperty(this, "y", _taskModel, "y"));
 
var label:Label = new Label();
watchers.addItem(BindingUtils.bindProperty(label, "text", _taskModel, "name"));
watchers.addItem(ChangeWatcher.watch(_taskModel, "taskType", updateImage));
watchers.addItem(ChangeWatcher.watch(_taskModel, "operation", redraw));
watchers.addItem(ChangeWatcher.watch(this, "x", redraw));
watchers.addItem(ChangeWatcher.watch(this, "y", redraw));
 
var canvas:Canvas = new Canvas();
 
 
canvas.addChild(imageTaskBackground);
 
imageTask.x = 3;
imageTask.y = 3;
imageTask.height = 16;
imageTask.width = 16;
canvas.addChild(imageTask);
 
var hbox:HBox = new HBox();
hbox.percentWidth = 100;
hbox.percentHeight = 100;
var s1:Spacer = new Spacer();
s1.percentWidth = 100;
var s2:Spacer = new Spacer();
s2.percentWidth = 100;
var vbox:VBox = new VBox();
vbox.percentHeight = 100;
vbox.percentWidth = 100;
var s3:Spacer = new Spacer();
s3.height = 10;
var s4:Spacer = new Spacer();
s4.height = 5;
 
vbox.addChild(s3);
vbox.addChild(label);
vbox.addChild(s4);
hbox.addChild(s1);
hbox.addChild(vbox);
hbox.addChild(s2);
 
canvas.addChild(hbox);
this.addChild(canvas);
messageFlowCanvas.clipContent = false;
messageFlowCanvas.autoLayout = false;
messageFlowCanvas.width = 0;
messageFlowCanvas.height = 0;
this.addChild(messageFlowCanvas);
messageFlowCanvas.addChild(messageFlowLabel);
 
this.addEventListener(FlexEvent.CREATION_COMPLETE, updateImage);
}
 
 
override public function get model():AbstractElement {
return _taskModel;
}
 
override public function copy():AbstractElementView {
return new TaskView(_taskModel, _processView);
}
 
override public function get borderImage():DisplayObject {
return imageTaskBackground;
}
 
override public function get subtypeImage():DisplayObject {
return imageTask;
}
 
protected function updateImage(event:Event = null):void {
if (_taskModel.taskType == TaskType.SERVICE) {
imageTask.source = serviceTaskImage;
}
this.redraw();
}
 
protected function redraw(event:Event = null):void {
if (_taskModel.taskType == TaskType.SERVICE && _taskModel.operation != null) {
var targetView:AbstractElementView = this._processView.getElementViewByModel(_taskModel.operation.interfaceModel.poolModel);
// get source and target border image
var sourceImage:DisplayObject = this.borderImage;
 
// get image centers in y, and this view center in x
var sourceCenterPoint:Point = this.localToGlobal(new Point(sourceImage.x + (sourceImage.width / 2), sourceImage.y + (sourceImage.height / 2)));
var targetCenterPoint:Point = this._processView.localToGlobal(new Point(0, targetView.y + (targetView.height / 2)));
targetCenterPoint.x = sourceCenterPoint.x;
 
// update source and target points
var sourcePoint:Point = GraphicUtils.findIntersection(sourceImage, sourceCenterPoint, targetCenterPoint, _processView);
var targetPoint:Point = GraphicUtils.findIntersection(targetView.borderImage, targetCenterPoint, sourceCenterPoint, _processView);
 
// draw arrow
var style:ArrowStyle = new ArrowStyle();
style.headWidth = 11;
style.headLength = 17;
style.color = 0x000000;
style.headFill = false;
style.thickness = 0;
style.isDashed = true;
style.isMessage = true;
var localTarget:Point = messageFlowCanvas.globalToLocal(targetPoint);
messageFlowLabel.text = _taskModel.operation.name;
messageFlowLabel.width = messageFlowLabel.measureText(messageFlowLabel.text).width + 10;
messageFlowLabel.y = localTarget.y + 10;
if (_taskModel.operation.outMessageType == null) {
messageFlowLabel.x = localTarget.x + 10;
ArrowUtil.drawArrow(messageFlowCanvas.graphics, messageFlowCanvas.globalToLocal(sourcePoint), messageFlowCanvas.globalToLocal(targetPoint), style);
} else {
messageFlowLabel.x = localTarget.x + 20;
sourcePoint.x -= 10;
targetPoint.x -= 10;
ArrowUtil.drawArrow(messageFlowCanvas.graphics, messageFlowCanvas.globalToLocal(sourcePoint), messageFlowCanvas.globalToLocal(targetPoint), style);
sourcePoint.x += 20;
targetPoint.x += 20;
ArrowUtil.drawArrow(messageFlowCanvas.graphics, messageFlowCanvas.globalToLocal(targetPoint), messageFlowCanvas.globalToLocal(sourcePoint), style, false);
}
 
} else {
messageFlowCanvas.graphics.clear();
messageFlowLabel.text = "";
}
}
 
 
////////////////////////////////////////////////////////////////////////////////////////
// Override selection function: clicking on a message flow should not select the task //
////////////////////////////////////////////////////////////////////////////////////////
override public function includeInto(selection:Rectangle, targetCoordinateSpace:DisplayObject):Boolean {
var bounds:Rectangle = this.borderImage.getRect(targetCoordinateSpace);
if (selection.containsRect(bounds)) {
return true;
}
return false;
}
 
override public function containsRectangle(selection:Rectangle, targetCoordinateSpace:DisplayObject):Boolean {
var objectRect:Rectangle = this.borderImage.getRect(targetCoordinateSpace);
if (objectRect.containsRect(selection)) {
return true;
}
return false;
}
 
public function getCollisionRectangle(targetCoordinateSpace:DisplayObject):Rectangle {
return this.borderImage.getRect(targetCoordinateSpace);
}
}
}
/*
* Bull SAS / OW2 Orchestra
* Copyright (C) 2011 Bull S.A.S, and individual contributors as indicated
* by the @authors tag.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
 
package org.ow2.orchestra.designer.bpmn.views {
import flash.display.DisplayObject;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
 
import mx.binding.utils.BindingUtils;
import mx.binding.utils.ChangeWatcher;
import mx.containers.Canvas;
import mx.containers.HBox;
import mx.containers.VBox;
import mx.controls.Image;
import mx.controls.Label;
import mx.controls.Spacer;
import mx.events.FlexEvent;
 
import org.ow2.orchestra.designer.bpmn.model.AbstractElement;
import org.ow2.orchestra.designer.bpmn.model.TaskModel;
import org.ow2.orchestra.designer.bpmn.model.TaskType;
import org.ow2.orchestra.designer.bpmn.views.utils.ArrowStyle;
import org.ow2.orchestra.designer.bpmn.views.utils.ArrowUtil;
import org.ow2.orchestra.designer.bpmn.views.utils.GraphicUtils;
 
public class TaskView extends AbstractElementView implements IFlowNodeView {
[Bindable]
private var _taskModel:TaskModel;
 
private var _processView:ProcessView;
/**
* The source for "event" image data binding.
*/
[Bindable]
[Embed(source="/../assets/task.svg")]
public var taskBackgroundImage:Class;
/**
* The source for "event" image data binding.
*/
[Bindable]
[Embed(source="/../assets/serviceTask.svg")]
public var serviceTaskImage:Class;
 
private var imageTaskBackground:Image = new Image();
private var imageTask:Image = new Image();
private var messageFlowCanvas:Canvas = new Canvas();
private var messageFlowLabel:Label = new Label();
 
 
function TaskView(taskModel:TaskModel, processView:ProcessView) {
_processView = processView;
_taskModel = taskModel;
this.setStyle("horizontalAlign", "center");
imageTaskBackground.percentWidth = 100;
imageTaskBackground.minWidth = 60;
imageTaskBackground.percentHeight = 100;
 
imageTaskBackground.maintainAspectRatio = false;
imageTaskBackground.automationName = "TaskImage" + _taskModel.id;
imageTaskBackground.source = taskBackgroundImage;
 
watchers.addItem(BindingUtils.bindProperty(this, "x", _taskModel, "x"));
watchers.addItem(BindingUtils.bindProperty(this, "y", _taskModel, "y"));
 
var label:Label = new Label();
watchers.addItem(BindingUtils.bindProperty(label, "text", _taskModel, "name"));
watchers.addItem(ChangeWatcher.watch(_taskModel, "taskType", updateImage));
watchers.addItem(ChangeWatcher.watch(_taskModel, "operation", redraw));
watchers.addItem(ChangeWatcher.watch(this, "x", redraw));
watchers.addItem(ChangeWatcher.watch(this, "y", redraw));
 
var canvas:Canvas = new Canvas();
 
 
canvas.addChild(imageTaskBackground);
 
imageTask.x = 3;
imageTask.y = 3;
imageTask.height = 16;
imageTask.width = 16;
canvas.addChild(imageTask);
 
var hbox:HBox = new HBox();
hbox.percentWidth = 100;
hbox.percentHeight = 100;
var s1:Spacer = new Spacer();
s1.percentWidth = 100;
var s2:Spacer = new Spacer();
s2.percentWidth = 100;
var vbox:VBox = new VBox();
vbox.percentHeight = 100;
vbox.percentWidth = 100;
var s3:Spacer = new Spacer();
s3.height = 10;
var s4:Spacer = new Spacer();
s4.height = 5;
 
vbox.addChild(s3);
vbox.addChild(label);
vbox.addChild(s4);
hbox.addChild(s1);
hbox.addChild(vbox);
hbox.addChild(s2);
 
canvas.addChild(hbox);
this.addChild(canvas);
messageFlowCanvas.clipContent = false;
messageFlowCanvas.autoLayout = false;
messageFlowCanvas.width = 0;
messageFlowCanvas.height = 0;
this.addChild(messageFlowCanvas);
messageFlowCanvas.addChild(messageFlowLabel);
 
this.addEventListener(FlexEvent.CREATION_COMPLETE, updateImage);
}
 
 
override public function get model():AbstractElement {
return _taskModel;
}
 
override public function copy():AbstractElementView {
return new TaskView(_taskModel, _processView);
}
 
override public function get borderImage():DisplayObject {
return imageTaskBackground;
}
 
override public function get subtypeImage():DisplayObject {
return imageTask;
}
 
protected function updateImage(event:Event = null):void {
if (_taskModel.taskType == TaskType.SERVICE) {
imageTask.source = serviceTaskImage;
}
this.redraw();
}
 
protected function redraw(event:Event = null):void {
var clearMsgFlow:Boolean = false;
if (_taskModel.taskType == TaskType.SERVICE
&& _taskModel.operation != null
&& _taskModel.operation.interfaceModel != null
&& _taskModel.operation.interfaceModel.poolModel != null) {
var targetView:AbstractElementView = this._processView.getElementViewByModel(_taskModel.operation.interfaceModel.poolModel);
if (targetView != null) {
// get source and target border image
var sourceImage:DisplayObject = this.borderImage;
 
// get image centers in y, and this view center in x
var sourceCenterPoint:Point = this.localToGlobal(new Point(sourceImage.x + (sourceImage.width / 2), sourceImage.y + (sourceImage.height / 2)));
var targetCenterPoint:Point = this._processView.localToGlobal(new Point(0, targetView.y + (targetView.height / 2)));
targetCenterPoint.x = sourceCenterPoint.x;
 
// update source and target points
var sourcePoint:Point = GraphicUtils.findIntersection(sourceImage, sourceCenterPoint, targetCenterPoint, _processView);
var targetPoint:Point = GraphicUtils.findIntersection(targetView.borderImage, targetCenterPoint, sourceCenterPoint, _processView);
 
// draw arrow
var style:ArrowStyle = new ArrowStyle();
style.headWidth = 11;
style.headLength = 17;
style.color = 0x000000;
style.headFill = false;
style.thickness = 0;
style.isDashed = true;
style.isMessage = true;
var localTarget:Point = messageFlowCanvas.globalToLocal(targetPoint);
messageFlowLabel.text = _taskModel.operation.name;
messageFlowLabel.width = messageFlowLabel.measureText(messageFlowLabel.text).width + 10;
messageFlowLabel.y = localTarget.y + 10;
if (_taskModel.operation.outMessageType == null) {
messageFlowLabel.x = localTarget.x + 10;
ArrowUtil.drawArrow(messageFlowCanvas.graphics, messageFlowCanvas.globalToLocal(sourcePoint), messageFlowCanvas.globalToLocal(targetPoint), style);
} else {
messageFlowLabel.x = localTarget.x + 20;
sourcePoint.x -= 10;
targetPoint.x -= 10;
ArrowUtil.drawArrow(messageFlowCanvas.graphics, messageFlowCanvas.globalToLocal(sourcePoint), messageFlowCanvas.globalToLocal(targetPoint), style);
sourcePoint.x += 20;
targetPoint.x += 20;
ArrowUtil.drawArrow(messageFlowCanvas.graphics, messageFlowCanvas.globalToLocal(targetPoint), messageFlowCanvas.globalToLocal(sourcePoint), style, false);
}
} else {
clearMsgFlow = true;
}
} else {
clearMsgFlow = true;
}
if (clearMsgFlow) {
messageFlowCanvas.graphics.clear();
messageFlowLabel.text = "";
}
}
 
 
////////////////////////////////////////////////////////////////////////////////////////
// Override selection function: clicking on a message flow should not select the task //
////////////////////////////////////////////////////////////////////////////////////////
override public function includeInto(selection:Rectangle, targetCoordinateSpace:DisplayObject):Boolean {
var bounds:Rectangle = this.borderImage.getRect(targetCoordinateSpace);
return selection.containsRect(bounds);
}
 
override public function containsRectangle(selection:Rectangle, targetCoordinateSpace:DisplayObject):Boolean {
var objectRect:Rectangle = this.borderImage.getRect(targetCoordinateSpace);
return objectRect.containsRect(selection);
}
 
public function getCollisionRectangle(targetCoordinateSpace:DisplayObject):Rectangle {
return this.borderImage.getRect(targetCoordinateSpace);
}
}
}
/trunk/OrchestraPVM/designer/designer-flex-model/src/main/flex/org/ow2/orchestra/designer/bpmn/model/ProcessModel.as
26,80 → 26,91
*/
 
package org.ow2.orchestra.designer.bpmn.model {
import flash.utils.IDataInput;
import flash.utils.IDataInput;
 
import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;
import mx.events.CollectionEventKind;
import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;
import mx.events.CollectionEventKind;
 
[Bindable]
[RemoteClass(alias="org.ow2.orchestra.designer.bpmn.model.ProcessModel")]
public class ProcessModel extends ProcessModelBase {
public function ProcessModel() {
super();
elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
}
[Bindable]
[RemoteClass(alias="org.ow2.orchestra.designer.bpmn.model.ProcessModel")]
public class ProcessModel extends ProcessModelBase {
public function ProcessModel() {
super();
elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
}
 
// Add event listener for elements changes
public override function readExternal(input:IDataInput):void {
super.readExternal(input);
elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
for each (var element:AbstractElement in elements) {
element.onDeserializationComplete();
}
// Add event listener for elements changes
public override function readExternal(input:IDataInput):void {
super.readExternal(input);
elements.addEventListener(CollectionEvent.COLLECTION_CHANGE, elementsModified);
for each (var element:AbstractElement in elements) {
element.onDeserializationComplete();
}
}
 
/**
* Listener for process element changes.
* Deletes sequence flow when the source or target element is removed.
* @param collectionEvent
*/
public function elementsModified(collectionEvent:CollectionEvent):void {
// model elements changed.
var changedElements:Array = collectionEvent.items;
if (collectionEvent.kind == CollectionEventKind.REMOVE) {
for each (var removedElement:Object in changedElements) {
if (removedElement is AbstractElementWithPosition) {
// remove sequenceFlow elements attached to the element to delete
// iterate on a copy of the elements list to avoid concurrent modifications
// (sequenceFlow are removed from the elements list)
var elementsCopy:ArrayCollection = new ArrayCollection();
elementsCopy.addAll(elements);
for each (var element:Object in elementsCopy) {
if (element is SequenceFlowModel) {
var sequenceFlowModel:SequenceFlowModel = element as SequenceFlowModel;
if (sequenceFlowModel.sourceElement == removedElement || sequenceFlowModel.targetElement == removedElement) {
// remove sequence flow
elements.removeItemAt(elements.getItemIndex(sequenceFlowModel));
}
/**
* Listener for process element changes.
* Deletes sequence flow when the source or target element is removed.
* @param collectionEvent
*/
public function elementsModified(collectionEvent:CollectionEvent):void {
// model elements changed.
var changedElements:Array = collectionEvent.items;
if (collectionEvent.kind == CollectionEventKind.REMOVE) {
for each (var removedElement:Object in changedElements) {
if (removedElement is AbstractElementWithPosition) {
// remove sequenceFlow elements attached to the element to delete
// iterate on a copy of the elements list to avoid concurrent modifications
// (sequenceFlow are removed from the elements list)
var elementsCopy:ArrayCollection = new ArrayCollection();
elementsCopy.addAll(elements);
for each (var element:Object in elementsCopy) {
if (element is SequenceFlowModel) {
var sequenceFlowModel:SequenceFlowModel = element as SequenceFlowModel;
if (sequenceFlowModel.sourceElement == removedElement || sequenceFlowModel.targetElement == removedElement) {
// remove sequence flow
elements.removeItemAt(elements.getItemIndex(sequenceFlowModel));
}
}
if (removedElement is EventModel) {
// remove operation if element is deleted
EventModel(removedElement).operation = null;
}
} else if (removedElement is SequenceFlowModel) {
var removedSequenceFlowModel:SequenceFlowModel = removedElement as SequenceFlowModel;
// Remove from old source outgoing sequence flows list
var oldSource:AbstractElementWithPosition = removedSequenceFlowModel.sourceElement;
if (oldSource != null) {
var srcIndex:int = oldSource.outgoingSequenceFlows.getItemIndex(removedSequenceFlowModel);
if (srcIndex != -1) {
oldSource.outgoingSequenceFlows.removeItemAt(srcIndex);
}
if (removedElement is EventModel) {
// remove operation if element is deleted
EventModel(removedElement).operation = null;
} else if (removedElement is PoolModel) {
for each (var abstractElement:AbstractElement in this.elements) {
//Check tasks related to this pool
if ((abstractElement is TaskModel) &&
TaskModel(abstractElement).operation != null &&
TaskModel(abstractElement).operation.interfaceModel != null &&
PoolModel(removedElement).interfaces.containsValue(
TaskModel(abstractElement).operation.interfaceModel)) {
TaskModel(abstractElement).operation = null;
}
}
// Remove from old target incoming sequence flows list
var oldTarget:AbstractElementWithPosition = removedSequenceFlowModel.targetElement;
if (oldTarget != null) {
var targetIndex:int = oldTarget.incomingSequenceFlows.getItemIndex(removedSequenceFlowModel);
if (targetIndex != -1) {
oldTarget.incomingSequenceFlows.removeItemAt(targetIndex);
}
}
} else if (removedElement is SequenceFlowModel) {
var removedSequenceFlowModel:SequenceFlowModel = removedElement as SequenceFlowModel;
// Remove from old source outgoing sequence flows list
var oldSource:AbstractElementWithPosition = removedSequenceFlowModel.sourceElement;
if (oldSource != null) {
var srcIndex:int = oldSource.outgoingSequenceFlows.getItemIndex(removedSequenceFlowModel);
if (srcIndex != -1) {
oldSource.outgoingSequenceFlows.removeItemAt(srcIndex);
}
}
// Remove from old target incoming sequence flows list
var oldTarget:AbstractElementWithPosition = removedSequenceFlowModel.targetElement;
if (oldTarget != null) {
var targetIndex:int = oldTarget.incomingSequenceFlows.getItemIndex(removedSequenceFlowModel);
if (targetIndex != -1) {
oldTarget.incomingSequenceFlows.removeItemAt(targetIndex);
}
}
}
}
}
}
 
}
}
}
/trunk/OrchestraPVM/designer/designer-component/src/main/flex/org/ow2/orchestra/designer/view/processEditor/ProcessEditorMovingStateHelper.as
96,23 → 96,29
elementsMove.addItem(new ElementCoordinatesUpdate((element as AbstractElementWithPosition)));
}
}
//Retrieve selection filter
var elementView:AbstractElementView =
processEditorView.processView.getElementViewByModel((elementsMove.getItemAt(0) as ElementCoordinatesUpdate).elementModel);
selectionFilter = elementView.borderImage.filters[0];
// elementsMove may be empty if only seqFlow are selected
if (elementsMove.length > 0) {
//Retrieve selection filter
var elementView:AbstractElementView =
processEditorView.processView.getElementViewByModel((elementsMove.getItemAt(0) as ElementCoordinatesUpdate).elementModel);
selectionFilter = elementView.borderImage.filters[0];
}
}
 
private function movingStateExit(event:FlexEvent):void {
for each (var abstractElementView:AbstractElementView in elementsInCollision) {
elementsInCollision.removeItemAt(elementsInCollision.getItemIndex(abstractElementView));
// elementsMove may be empty if only seqFlow are selected
if (elementsMove.length > 0) {
for each (var abstractElementView:AbstractElementView in elementsInCollision) {
elementsInCollision.removeItemAt(elementsInCollision.getItemIndex(abstractElementView));
}
elementsInCollision.removeEventListener(CollectionEvent.COLLECTION_CHANGE, elementsInCollisionChanged);
// selected element is moved, generate a process modification event.
new ProcessSelectionElementCoordinatesChangeEvent(
ProcessSelectionElementCoordinatesChangeEvent.COORDINATES_CHANGE,
processEditorView.processEditorModel,
elementsMove
).dispatch();
}
elementsInCollision.removeEventListener(CollectionEvent.COLLECTION_CHANGE, elementsInCollisionChanged);
// selected element is moved, generate a process modification event.
new ProcessSelectionElementCoordinatesChangeEvent(
ProcessSelectionElementCoordinatesChangeEvent.COORDINATES_CHANGE,
processEditorView.processEditorModel,
elementsMove
).dispatch();
}
 
private function elementsInCollisionChanged(event:CollectionEvent):void {
/trunk/OrchestraPVM/designer/designer-component/src/main/flex/org/ow2/orchestra/designer/model/ProcessEditorModel.as
1,113 → 1,113
/**
* Bull SAS / OW2 Orchestra
* Copyright (C) 2010 Bull S.A.S, and individual contributors as indicated
* by the @authors tag.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
package org.ow2.orchestra.designer.model {
import mx.collections.ArrayCollection;
 
import org.ow2.orchestra.designer.bpmn.model.ProcessModel;
import org.ow2.orchestra.designer.utils.DesignerUtil;
import org.ow2.orchestra.designer.vo.FileNavigatorProcess;
 
[Bindable]
public class ProcessEditorModel {
 
//Path of the file on the server to store the process
private var _fileNavigatorProcess:FileNavigatorProcess;
 
//indicate if the process is editing in writing or no, by default true;
private var _readWrite:Boolean;
 
// Elements currently selected
private var _selectedElements:ArrayCollection = new ArrayCollection();
 
private var _processModel:ProcessModel;
 
// For undo redo
// Number of undo/redo elements to keep in memory
private static const UNDO_REDO_QUEUE_LENGTH:int = 10;
private var _undoState:ArrayCollection = new ArrayCollection();
private var _redoState:ArrayCollection = new ArrayCollection();
 
 
public function ProcessEditorModel() {
_processModel = new ProcessModel();
_readWrite = true;
}
 
 
public function get selectedElements():ArrayCollection {
return _selectedElements;
}
 
public function set selectedElements(value:ArrayCollection):void {
_selectedElements = value;
}
 
public function get processModel():ProcessModel {
return _processModel;
}
 
public function set processModel(value:ProcessModel):void {
_processModel = value;
_selectedElements.removeAll();
}
 
public function get fileNavigatorProcess():FileNavigatorProcess {
return DesignerModelLocator.getInstance().fileNavigatorModel.getProcess(_fileNavigatorProcess);
}
 
public function set fileNavigatorProcess(value:FileNavigatorProcess):void {
_fileNavigatorProcess = value;
}
 
public function saveModelForUndo():void {
_undoState.addItem(ProcessModel(DesignerUtil.copy(processModel)));
if (_undoState.length > UNDO_REDO_QUEUE_LENGTH) {
// undo max length is reached, remove the oldest process state
_undoState.removeItemAt(0);
}
_redoState.removeAll();
}
 
public function undo():void {
trace("Undo..");
if (_undoState.length != 0) {
_redoState.addItem(ProcessModel(DesignerUtil.copy(processModel)));
processModel = ProcessModel(_undoState.removeItemAt(_undoState.length - 1));
trace("Undo done");
}
}
 
public function redo():void {
if (_redoState.length != 0) {
_undoState.addItem(ProcessModel(DesignerUtil.copy(processModel)));
processModel = ProcessModel(_redoState.removeItemAt(_redoState.length - 1));
}
}
 
public function set readWrite(readWrite:Boolean) {
_readWrite = readWrite;
}
 
public function get readWrite():Boolean {
return _readWrite;
}
}
}
/**
* Bull SAS / OW2 Orchestra
* Copyright (C) 2010 Bull S.A.S, and individual contributors as indicated
* by the @authors tag.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
package org.ow2.orchestra.designer.model {
import mx.collections.ArrayCollection;
 
import org.ow2.orchestra.designer.bpmn.model.ProcessModel;
import org.ow2.orchestra.designer.utils.DesignerUtil;
import org.ow2.orchestra.designer.vo.FileNavigatorProcess;
 
[Bindable]
public class ProcessEditorModel {
 
//Path of the file on the server to store the process
private var _fileNavigatorProcess:FileNavigatorProcess;
 
//indicate if the process is editing in writing or no, by default true;
private var _readWrite:Boolean;
 
// Elements currently selected
private var _selectedElements:ArrayCollection = new ArrayCollection();
 
private var _processModel:ProcessModel;
 
// For undo redo
// Number of undo/redo elements to keep in memory
private static const UNDO_REDO_QUEUE_LENGTH:int = 10;
private var _undoState:ArrayCollection = new ArrayCollection();
private var _redoState:ArrayCollection = new ArrayCollection();
 
 
public function ProcessEditorModel() {
_processModel = new ProcessModel();
_readWrite = true;
}
 
 
public function get selectedElements():ArrayCollection {
return _selectedElements;
}
 
public function set selectedElements(value:ArrayCollection):void {
_selectedElements = value;
}
 
public function get processModel():ProcessModel {
return _processModel;
}
 
public function set processModel(value:ProcessModel):void {
_processModel = value;
_selectedElements.removeAll();
}
 
public function get fileNavigatorProcess():FileNavigatorProcess {
return DesignerModelLocator.getInstance().fileNavigatorModel.getProcess(_fileNavigatorProcess);
}
 
public function set fileNavigatorProcess(value:FileNavigatorProcess):void {
_fileNavigatorProcess = value;
}
 
public function saveModelForUndo():void {
_undoState.addItem(ProcessModel(DesignerUtil.copy(processModel)));
if (_undoState.length > UNDO_REDO_QUEUE_LENGTH) {
// undo max length is reached, remove the oldest process state
_undoState.removeItemAt(0);
}
_redoState.removeAll();
}
 
public function undo():void {
trace("Undo..");
if (_undoState.length != 0) {
_redoState.addItem(ProcessModel(DesignerUtil.copy(processModel)));
processModel = ProcessModel(_undoState.removeItemAt(_undoState.length - 1));
trace("Undo done");
}
}
 
public function redo():void {
if (_redoState.length != 0) {
_undoState.addItem(ProcessModel(DesignerUtil.copy(processModel)));
processModel = ProcessModel(_redoState.removeItemAt(_redoState.length - 1));
}
}
 
public function set readWrite(readWrite:Boolean):void {
_readWrite = readWrite;
}
 
public function get readWrite():Boolean {
return _readWrite;
}
}
}