| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213 |
- MWF.xDesktop.requireApp("process.ProcessDesigner", "Property", null, false);
- MWF.xApplication.process.ProcessDesigner.Activity = new Class({
- initialize: function(data, process){
- this.data = data;
- this.process = process;
- this.paper = this.process.paper;
- if (!this.data.edition) this.data.edition = (new o2.widget.UUID()).toString();
- this.routes = [];
- this.fromRoutes = [];
- // this.decisions = [];
- // this.fromDecisions = [];
- // this.fromRoutes = [];
- this.setType();
- this.setStyle();
- this.setSize();
- this.getPoint();
- this.selectedMultiStatus = false;
- this.positionLoaded = false;
- },
- setType: function(){
- this.type = "activity";
- this.data.type = "activity";
- },
- setStyle: function(){
- this.style = this.process.css.activity["default"];
- },
- setSize: function(){
- var size = MWF.getTextSize(this.data.name, this.style.text);
- this.width = size.x+38;
- this.width = this.width<100 ? 100: this.width;
- this.height = 40;
- },
- getPoint: function(){
- this.paperSize = $(this.paper.canvas).getParent().getSize();
- this.paperOriginalSize = {x: this.paperSize.x*0.99, y: this.paperSize.y*0.99};
- var height = this.paperSize.y;
- var width = this.paperSize.x;
- this.top = height/2;
- this.left = width/2;
- this.center = {x: this.left, y: this.top};
- this.point = {x: this.left-(this.width/2), y: this.top-(this.height/2)};
- },
- resetPoint: function(){
- this.center = {x: this.point.x + this.width/2, y: this.point.y + this.height/2};
- },
- checkUUID: function(){
- for (var i=0; i<this.routes.length; i++){
- delete this.process.routes[this.routes[i].data.id];
- delete this.process.routeDatas[this.routes[i].data.id];
- this.routes[i].data.id = this.process.checkUUIDs.pop().id;
- this.routes[i].data.process = this.process.process.id;
- this.setRouteData(this.routes[i].data.id, i);
- //this.data.routeList[i] = this.routes[i].data.id;
- this.routes[i].data.activity = this.routes[i].toActivity.data.id;
- this.process.routes[this.routes[i].data.id] = this.routes[i];
- this.process.routeDatas[this.routes[i].data.id] = this.routes[i].data;
- }
- },
- loaded: function(callback){
- if (this.positionLoaded){
- if (callback) callback();
- }
- },
- load : function(callback){
- if (this.process.isNewProcess){
- this.data.createTime = new Date().format('db');
- this.data.updateTime = new Date().format('db');
- }
- this.draw();
- this.setActivityPosition(function(){
- this.positionLoaded = true;
- this.loaded(callback);
- }.bind(this));
- this.setEvent();
- if (this.process.activityListNode) this.addToActivityList();
- // this.setPosition(100,100);
- },
- addToActivityList: function(){
- this.listItem = new MWF.APPPD.Activity.List(this);
- this.listItem.load();
- },
- create: function(point){
- this.point = point || {x: 100, y: 100};
- this.center = {"x": this.point.x+(this.width/2), "y": this.point.y+(this.height/2)};
- //this.center = center || {x: 100, y: 100};
- //this.point = {x: this.center.x-(this.width/2), y: this.center.y-(this.height/2)};
- this.draw();
- this.setEvent();
- if (this.process.activityListNode) this.addToActivityList();
- },
- setEvent: function(){
- if (!this.process.options.isView){
- this.set.drag(
- function(dx, dy, x, y, e){
- if (!e.rightClick){
- if (this.process.selectedActivitys.length){
- this.noselected = true;
- this.process.selectedActivitys.each(function(activity){
- activity.activityMove(dx, dy, x, y);
- });
- }else{
- this.activityMove(dx, dy, x, y);
- }
- }
- }.bind(this),
- function(x, y, e){
- if (!e.rightClick){
- if (this.process.selectedActivitys.length){
- this.process.selectedActivitys.each(function(activity){
- activity.activityMoveStart();
- });
- }else{
- this.activityMoveStart();
- }
- }
- }.bind(this),
- function(e){
- if (!e.rightClick){
- if (this.process.selectedActivitys.length){
- this.process.selectedActivitys.each(function(activity){
- activity.activityMoveEnd();
- });
- }else{
- this.activityMoveEnd();
- }
- }
- }.bind(this)
- );
- //this.set.drag(
- // function(dx, dy, x, y, e){}.bind(this),
- // function(x, y, e){}.bind(this),
- // function(e){}.bind(this)
- //);
- this.set.click(function(e){
- if (this.process.isCreateRoute){
- this.checkCreateRoute();
- }else{
- if (this.process.selectedActivitys.length){
- if (!this.noselected){
- if (this.process.currentSelected != this){
- this.selected();
- }
- }
- this.noselected = false;
- }
- }
- e.stopPropagation();
- }.bind(this));
- this.set.dblclick(function(){
- this.quickCreateRoute();
- }.bind(this));
- // this.set.mouseup(function(e){
- // }.bind(this));
- this.set.mousedown(function(e){
- if (this.process.isCreateRoute){
- this.checkCreateRoute();
- }else{
- if (!this.process.selectedActivitys.length){
- if (this.process.currentSelected != this){
- this.selected();
- }
- }
- }
- //this.checkCreateRoute();
- e.stopPropagation();
- }.bind(this));
- // this.shap.node.mousedown(function(e){
- // e.stop();
- // });
- // this.text.node.mousedown(function(e){
- // e.stop();
- // });
- // this.icon.node.mousedown(function(e){
- // e.stop();
- // });
- this.set.hover(this.mouseHover.bind(this), function(){
- if (this.process.isCreateRoute || this.process.isCopyRoute || this.process.isChangeRouteTo || this.process.isChangeRouteFrom){
- this.shap.attr(this.style.shap);
- }
- }.bind(this));
- this.set.mouseup(function(){
- this.mouseUp();
- }.bind(this));
- }
- },
- mouseHover: function(){
- if (this.process.isCreateRoute || this.process.isCopyRoute || this.process.isChangeRouteTo || this.process.isChangeRouteFrom){
- this.shap.attr({"stroke-width": "2"});
- }
- },
- mouseUp: function(){
- if (this.process.isChangeRouteTo){
- this.process.currentChangeRoute.setActivity(this, null);
- this.process.currentChangeRoute.isBack = false;
- this.process.currentChangeRoute.positionPoints = this.process.currentChangeRoute.getRoutePoint();
- this.process.currentChangeRoute.reload();
- this.process.isChangeRouteTo = false;
- this.process.currentChangeRoute = null;
- }
- if (this.process.isChangeRouteFrom){
- this.process.currentChangeRoute.setActivity(null, this);
- this.process.currentChangeRoute.isBack = false;
- this.process.currentChangeRoute.positionPoints = this.process.currentChangeRoute.getRoutePoint();
- this.process.currentChangeRoute.reload();
- this.process.isChangeRouteFrom = false;
- this.process.currentChangeRoute = null;
- }
- this.shap.attr(this.style.shap);
- },
- quickCreateRoute: function(){
- this.process.createRoute();
- this.process.routeCreateFromActivity(this);
- },
- checkCreateRoute: function(){
- if (this.process.isCreateRoute){
- var route = this.process.currentCreateRoute;
- if (!route.fromActivity){
- this.process.routeCreateFromActivity(this);
- }else{
- this.process.routeCreateToActivity(this);
- }
- }
- if (this.process.isCopyRoute){
- this.process.routeAddFromActivity(this);
- }
- },
- draw: function(){
- this.set = this.paper.set();
- this.shap = this.createShap();
- // this.shadow = this.careteShadow();
- this.text = this.createText();
- this.icon = this.createIcon();
- this.set.push(this.shadow, this.shap, this.text, this.icon);
- },
- redraw: function(){
- this.setSize();
- this.resetPoint();
- if (this.shap) this.redrawShap();
- if (this.text) this.redrawText();
- if (this.icon) this.redrawIcon();
- if (this.bBox) this.redrawBox();
- if (this.listItem) this.redrawListItem();
- this.redrawRoute();
- },
- careteShadow: function(){
- var shadow;
- shadow = this.shap.glow({
- "width": 10,
- "fill": true,
- "opacity": 0.2,
- "offsetx": 0,
- "offsety": 0,
- "color": "#aaa"
- });
- shadow.data("bind", this);
- return shadow;
- },
- createShap: function(){
- var shap;
- shap = this.paper.rectPath(this.point.x, this.point.y, this.width, this.height, this.style.shap.radius);
- shap.attr(this.style.shap);
- shap.data("bind", this);
- return shap;
- },
- createText: function(){
- var atts = this.getTextIconPoint();
- text = this.paper.text(atts.tatt.x, atts.tatt.y, this.data.name);
- text.attr(this.style.text);
- if (this.style.text.display=="none"){
- text.hide();
- }
- return text;
- },
- createIcon: function(){
- var atts = this.getTextIconPoint();
- var icon = this.paper.image(this.style.icon.src, atts.iatt.x, atts.iatt.y, 16, 16);
- icon.attr(this.style.icon.attr);
- return icon;
- },
- redrawShap: function(){
- var shapPath = MWFRaphael.getRectPath(this.point.x, this.point.y, this.width, this.height, this.style.shap.radius);
- this.shap.attr("path", shapPath);
- },
- redrawText: function(){
- var atts = this.getTextIconPoint();
- this.text.attr({
- "x": atts.tatt.x,
- "y": atts.tatt.y,
- "text": this.data.name
- });
- },
- redrawIcon: function(){
- var atts = this.getTextIconPoint();
- this.icon.attr({
- "x": atts.iatt.x,
- "y": atts.iatt.y
- });
- },
- redrawBox: function(){
- this.set.exclude(this.bBox);
- this.bBox.remove();
- this.bBox = null;
- var bBox = this.set.getBBox();
- this.bBox = this.paper.rectPath(bBox.x-3, bBox.y-3, bBox.width+6, bBox.height+6, 0);
- this.bBox.attr(this.process.css.activity.box);
- this.set.push(this.bBox);
- // var bBox = this.set.getBBox();
- // var boxPath = MWFRaphael.getRectPath(bBox.x-3, bBox.y-3, bBox.width+6, bBox.height+6, 0);
- // this.bBox.attr("path", boxPath);
- },
- redrawListItem: function(){
- var nameTd = this.listItem.row.tds[1];
- nameTd.set("text", this.data.name);
- },
- loadRoutes: function(){
- var routeIds = this.getRoutedata();
- routeIds.each(function(id){
- if (this.process.routes[id]){
- this.routes.push(this.process.routes[id]);
- this.process.routes[id].setActivity(null, this);
- this.process.routes[id].load();
- }
- }.bind(this));
- },
- getRoutedata: function(){
- if (!this.data.routeList) this.data.routeList = [];
- this.data.routeList = this.data.routeList.clean();
- return this.data.routeList;
- },
- setRouteData: function(id, i){
- var index = (i || i==0) ? i : null;
- if (!this.data.routeList) this.data.routeList = [];
- if (index!=null && index<=this.data.routeList.length){
- var idx = this.data.routeList.indexOf(id);
- if (idx==-1) this.data.routeList[index] = id;
- }else{
- if (this.data.routeList.indexOf(id)==-1) this.data.routeList.push(id);
- }
- },
- removeRouteData: function(id){
- if (!this.data.routeList) this.data.routeList = [];
- this.data.routeList.erase(id);
- },
- // loadDecisions: function(){
- // if (this.data.decisionIdList){
- // if (typeOf(this.data.decisionIdList).toLowerCase() == "array"){
- // this.data.decisionIdList.each(function(id){
- // var item = this.process.decisionDatas[id];
- // var decision = new MWF.PCDecision(item, this.process, this);
- // this.decisions.push(decision);
- // decision.load();
- // }.bind(this));
- // }else{
- // var item = this.process.decisionDatas[this.data.decisionIdList];
- // var decision = new MWF.PCDecision(item, this.process, this);
- // this.decisions.push(decision);
- // decision.load();
- // }
- // };
- // },
- redrawRoute: function(path){
- this.routes.each(function(route){
- route.reload(path,null);
- });
- this.fromRoutes.each(function(route){
- route.reload(null,path);
- });
- },
- activityMove: function(dx, dy, tox, toy){
- //var moveSet = this.set.clone();
- if (!this.set.isFront){
- this.set.toFront();
- this.set.isFront = true;
- }
- //this.paperSize = $(this.paper.canvas).getParent().getSize();
- if ((this.set.ox+dx)<0) dx = 0 - this.set.ox;
- if ((this.set.ox+dx+this.width)>this.paperSize.x){
- this.paperSize.x = this.set.ox+dx+this.width;
- this.paper.setSize(this.paperSize.x, this.paperSize.y);
- //alert("set width");
- $(this.paper.canvas).getParent().setStyle("width", ""+this.paperSize.x+"px");
- }
- //if ((this.set.ox+dx+this.width)<this.paperOriginalSize.x){
- // if (this.paperSize.x > this.paperOriginalSize.x){
- // this.paperSize.x = this.paperOriginalSize.x;
- // this.paper.setSize(this.paperOriginalSize.x, this.paperSize.y);
- // //alert("set width");
- // $(this.paper.canvas).getParent().setStyle("width", ""+this.paperSize.x+"px");
- // }
- //}
- if ((this.set.oy + dy)<0) dy = 0 - this.set.oy;
- if ((this.set.oy + dy+this.height)>this.paperSize.y){
- this.paperSize.y = this.set.oy + dy+this.height;
- this.paper.setSize(this.paperSize.x, this.paperSize.y);
- //alert("set height");
- $(this.paper.canvas).getParent().setStyle("height", ""+this.paperSize.y+"px");
- }
- //if ((this.set.oy + dy+this.height)<this.paperOriginalSize.y){
- // if (this.paperSize.y > this.paperOriginalSize.y){
- // this.paperSize.y = this.paperOriginalSize.y;
- // this.paper.setSize(this.paperSize.x, this.paperSize.y);
- // $(this.paper.canvas).getParent().setStyle("height", ""+this.paperSize.y+"px");
- // }
- //}
- // if (this.process.isGrid){
- var toX = Raphael.snapTo(10, this.set.ox + dx + this.width/2, 10);
- var toY = Raphael.snapTo(10, this.set.oy + dy + this.height/2, 10);
- dx = toX - this.set.ox - this.width/2;
- dy = toY - this.set.oy - this.height/2;
- // }
- // this.shap.transform("t"+dx+","+dy);
- // if (this.bBox) this.bBox.transform("t"+dx+","+dy);
- // var path = this.shap.attr("path");
- path = Raphael.transformPath(this.set.shapPath, "t"+dx+","+dy);
- this.shap.attr("path", path);
- //this.cloneMoveShap.attr("path", path);
- //
- //return ;
- // this.shap.transform("t0,0");
- if (this.bBox){
- // var boxPath = this.bBox.attr("path");
- var bBox = this.shap.getBBox();
- boxPath = MWFRaphael.getRectPath(bBox.x-3, bBox.y-3, bBox.width+6, bBox.height+6, 0);
- //boxPath = Raphael.transformPath(this.set.boxPath, "t"+dx+","+dy);
- this.bBox.attr("path", boxPath);
- // this.bBox.transform("t0,0");
- }
- this.point = {x: this.set.ox + dx, y: this.set.oy + dy};
- this.center = {x: this.set.ox + dx + this.width/2, y: this.set.oy + dy + this.height/2};
- var atts = this.getMoveTextIconPoint();
- this.text.attr(atts.tatt);
- this.icon.attr(atts.iatt);
- this.routes.each(function(route){
- if (this.process.selectedActivitys.indexOf(route.toActivity) != -1){
- route.corners.each(function(corner, idx){
- // var p = this.positionPoints[idx];
- var p = corner.data("point");
- var cx = p.x.toFloat()+dx.toFloat();
- var cy = p.y.toFloat()+dy.toFloat();
- var cornerPath = MWFRaphael.getRectPath(cx-2.5,cy-2.5, 5, 5, 0);
- corner.attr("path", cornerPath);
- route.positionPoints[idx] = {"x": cx, "y": cy};
- }.bind(this));
- }
- }.bind(this));
- this.set.movex = dx;
- this.set.movey = dy;
- // var path = this.shap.attr("path");
- // path = Raphael.transformPath(path, "t"+this.set.movex+","+this.set.movey);
- // this.redrawRoute(path);
- this.redrawRoute();
- this.paper.safari();
- },
- activityMoveStart: function(){
- this.set.isFront = false;
- var box = this.shap.getBBox();
- this.set.ox = box.x;
- this.set.oy = box.y;
- this.set.movex = 0;
- this.set.movey = 0;
- this.set.animate({
- "fill-opacity": .5
- },
- 500
- );
- this.set.shapPath = this.shap.attr("path");
- if (this.bBox) this.set.boxPath = this.bBox.attr("path")
- //this.cloneMoveShap = this.shap.clone();
- //
- //this.cloneMoveShap.animate({
- // "fill-opacity": .3
- // },
- // 200
- //);
- this.routes.each(function(route){
- if (this.process.selectedActivitys.indexOf(route.toActivity) != -1){
- route.corners.each(function(corner, idx){
- var p = route.positionPoints[idx];
- corner.data("point", p);
- }.bind(this));
- }
- }.bind(this));
- },
- activityMoveEnd: function(){
- this.center.x = this.center.x.toInt();
- this.center.y = this.center.y.toInt();
- this.data.position = this.center.x+","+this.center.y;
- this.set.animate({"fill-opacity": 1}, 500);
- // this.reSizePaper(this.center.x, this.center.y);
- // this.cloneMoveShap.remove();
- },
- setActivityPosition: function(callback){
- var x;
- var y;
- if (this.data.position){
- var tmp = this.data.position.split(/(?:,\s*){1}|(?:;\s*){1}/g);
- x = tmp[0];
- y = tmp[1];
- }else{
- // this.paperSize.x;
- // this.paperSize.y;
- var xi = Math.random();
- x = ((this.paperSize.x-300) * xi).toInt();
- var yi = Math.random();
- y = ((this.paperSize.y-300) * yi).toInt();
- this.data.position = x+","+y;
- }
- this.reSizePaper(x, y);
- this.setPosition(x.toFloat(), y.toFloat(), null, callback);
- },
- reSizePaper: function(x, y){
- //this.paperSize = $(this.paper.canvas).getParent().getSize();
- // if (x>this.paperSize.x) this.process.designer.paperNode.setStyle("height", x);
- // if (y>this.paperSize.y) this.process.designer.paperNode.setStyle("width", y);
- y = y.toFloat()+this.height.toFloat();
- x = x.toFloat()+this.width.toFloat();
- if (x>this.paperSize.x){
- this.paper.setSize(x*0.99, this.paperSize.y);
- $(this.paper.canvas).getParent().setStyle("width", ""+x+"px");
- this.paperSize.x = x;
- }
- if (y>this.paperSize.y){
- this.paper.setSize(this.paperSize.x*0.99, y);
- $(this.paper.canvas).getParent().setStyle("height", ""+y+"px");
- this.paperSize.y = y;
- }
- },
- setPosition: function(x, y, time, callback){
- x = x.toFloat();
- y = y.toFloat();
- if (!time) time = 300;
- var mx = x-(this.center.x.toFloat());
- var my = y-(this.center.y.toFloat());
- this.center = {x: x, y: y};
- this.point = {x: x-(this.width/2), y: y-(this.height/2)};
- var path = this.shap.attr("path");
- var path = Raphael.transformPath(path, "t"+mx+","+my);
- var atts = this.getTextIconPoint();
- this.shap.animate({"path": path}, time, "<>", callback);
- this.text.animate(atts.tatt, time, "<>");
- this.icon.animate(atts.iatt, time, "<>");
- // this.animateLine(time);
- },
- getTextIconPoint: function(){
- var t_att = {x: this.center.x+10, y: this.center.y};
- var i_att = {x: this.center.x-(this.width/2)+8, y: this.center.y-8};
- return {"tatt": t_att, "iatt": i_att};
- },
- getMoveTextIconPoint: function(){
- return this.getTextIconPoint();
- },
- showProperty: function(){
- if (!this.property){
- this.property = new MWF.APPPD.Activity.Property(this, {
- "onPostLoad": function(){
- this.property.show();
- }.bind(this)
- });
- this.property.load();
- }else{
- this.property.show();
- }
- },
- selectedMulti: function(){
- if (!this.bBox){
- var bBox = this.shap.getBBox();
- this.bBox = this.paper.rectPath(bBox.x-3, bBox.y-3, bBox.width+6, bBox.height+6, 0);
- this.bBox.attr(this.process.css.activity.box);
- this.set.push(this.bBox);
- }
- this.process.selectedActivitys.push(this);
- this.process.selectedActivityDatas.push(this.data);
- if (this.listItem) this.listItem.listUnSelected();
- if (this.property) this.property.hide();
- this.selectedMultiStatus = true;
- },
- unSelectedMulti: function(){
- if (this.bBox){
- this.set.exclude(this.bBox);
- this.bBox.remove();
- this.bBox = null;
- }
- this.selectedMultiStatus = false;
- },
- selected: function(){
- // if (this.process.jsonParse) {
- // window.setTimeout(function(){this.process.jsonParse.stopParseJson = true;}.bind(this), 1);
- // }
- this.activitySelected();
- if (this.listItem) this.listItem.listSelected();
- // if (this.process.property) this.process.property.hide();
- window.setTimeout(function(){this.showProperty()}.bind(this), 10);
- // this.showQuickAction();
- },
- unSelected: function(){
- this.activityUnSelected();
- if (this.listItem) this.listItem.listUnSelected();
- if (this.property) this.property.hide();
- },
- showQuickAction: function(){
- this.getQuickActionJson(function(){
- this.quickActionJson.each(function(action, idx){
- var y = this.point.y-20;
- var x = this.point.x + (20*idx);
- var actionNode = this.paper.image(this.process.path+this.process.options.style+"/quickAction/"+action.icon, x, y, 16, 16);
- actionNode.toFront();
- //var actionNode = new Element("div", {
- // "styles": {
- // "top":this.center.y,
- // "left": this.center.x,
- // "height": "24px",
- // "width": "24px",
- // "position": "absolute",
- // "background-color": "red",
- // "z-index": "50000"
- // }
- //}).inject(this.process.designer.paperNode)
- }.bind(this));
- }.bind(this));
- },
- getQuickActionJson: function(callback){
- if (!this.quickActionJson){
- MWF.getJSON(this.process.path+"action.json", {
- "onSuccess": function(obj){
- var defaultActions = obj["default"];
- var myActions = obj[this.type];
- this.quickActionJson = defaultActions.concat(myActions);
- if (callback) callback();
- }.bind(this),
- "onerror": function(text){
- this.notice(text, "error");
- }.bind(this),
- "onRequestFailure": function(xhr){
- this.notice(xhr.responseText, "error");
- }.bind(this)
- });
- }else{
- if (callback) callback();
- }
- },
- activitySelected: function(){
- //if (this.process.currentSelected) this.process.currentSelected.unSelected();
- this.process.unSelectedAll();
- if (!this.bBox){
- var bBox = this.shap.getBBox();
- this.bBox = this.paper.rectPath(bBox.x-3, bBox.y-3, bBox.width+6, bBox.height+6, 0);
- this.bBox.attr(this.process.css.activity.box);
- this.set.push(this.bBox);
- }
- this.process.currentSelected = this;
- },
- activityUnSelected: function(){
- this.process.currentSelected = null;
- if (this.bBox){
- this.set.exclude(this.bBox);
- this.bBox.remove();
- this.bBox = null;
- }
- },
- addRouteData: function(id){
- if (this.data.routeList.indexOf(id)==-1) this.data.routeList.push(id);
- },
- destroy: function(){
- if (this.type=="begin"){
- this.process.begin = null;
- this.process.process.begin = null;
- }
- this.routes.each(function(r){
- r.destroy();
- });
- this.fromRoutes.each(function(r){
- r.destroy();
- });
- if (this.listItem){
- this.listItem.row.tr.destroy();
- }
- var activitys = {};
- for (aid in this.process[this.type+"s"]){
- if (aid!=this.data.id){
- activitys[aid] = this.process[this.type+"s"][aid];
- }else{
- this.process[this.type+"s"][aid] = null;
- }
- }
- this.process[this.type+"s"] = null;
- this.process[this.type+"s"] = activitys;
- this.process.activitys.erase(this);
- if (this.process.process[this.type+"List"]) this.process.process[this.type+"List"].erase(this.data);
- this.set.remove();
- }
- });
- MWF.APPPD.Activity.SingleRouter = new Class({
- Extends: MWF.APPPD.Activity,
- getRoutedata: function(){
- if (!this.data.route) this.data.route = "";
- return [this.data.route];
- },
- setRouteData: function(id){
- if (!this.data.route) this.data.route = "";
- this.data.route = id;
- },
- removeRouteData: function(id){
- this.data.route = "";
- },
- quickCreateRoute: function(){
- if (!this.routes.length){
- this.process.createRoute();
- this.process.routeCreateFromActivity(this);
- }
- },
- checkCreateRoute: function(){
- if (this.process.isCreateRoute){
- var route = this.process.currentCreateRoute;
- if (!route.fromActivity){
- if (!this.routes.length) this.process.routeCreateFromActivity(this);
- }else{
- this.process.routeCreateToActivity(this);
- }
- }
- if (this.process.isCopyRoute){
- if (!this.routes.length) this.process.routeAddFromActivity(this);
- }
- },
- mouseHover: function(){
- if (this.process.isCreateRoute){
- var route = this.process.currentCreateRoute;
- if (!route.fromActivity){
- if (!this.routes.length) this.shap.attr({"stroke-width": "2"});
- }else{
- this.shap.attr({"stroke-width": "2"});
- }
- }
- if (this.process.isChangeRouteTo){
- this.shap.attr({"stroke-width": "2"});
- }
- if (this.process.isChangeRouteFrom || this.process.isCopyRoute){
- if (!this.routes.length) this.shap.attr({"stroke-width": "2"});
- }
- },
- mouseUp: function(){
- if (this.process.isChangeRouteTo){
- this.process.currentChangeRoute.setActivity(this, null);
- this.process.currentChangeRoute.isBack = false;
- this.process.currentChangeRoute.positionPoints = this.process.currentChangeRoute.getRoutePoint();
- this.process.currentChangeRoute.reload();
- this.process.isChangeRouteTo = false;
- this.process.currentChangeRoute = null;
- }
- if (this.process.isChangeRouteFrom){
- if (!this.routes.length){
- this.process.currentChangeRoute.setActivity(null, this);
- this.process.currentChangeRoute.isBack = false;
- this.process.currentChangeRoute.positionPoints = this.process.currentChangeRoute.getRoutePoint();
- this.process.currentChangeRoute.reload();
- this.process.isChangeRouteFrom = false;
- this.process.currentChangeRoute = null;
- }
- }
- this.shap.attr(this.style.shap);
- },
- addRouteData: function(id){
- if (!this.data.route) this.data.route = id;
- }
- });
- MWF.APPPD.Activity.Circle = new Class({
- Extends: MWF.APPPD.Activity,
- setSize: function(){
- if (this.style.text.display=="none"){
- this.width = this.style.shap.width;
- this.height = this.style.shap.height;
- this.radius = this.style.shap.radius;
- }else{
- var size = MWF.getTextSize(this.data.name, this.style.text);
- this.radius = size.x/2+10;
- this.radius = this.radius<20 ? 20 : this.radius;
- this.width = this.height = this.radius*2;
- }
- },
- reSizePaper: function(x, y){
- //this.paperSize = $(this.paper.canvas).getParent().getSize();
- // if (x>this.paperSize.x) this.process.designer.paperNode.setStyle("height", x);
- // if (y>this.paperSize.y) this.process.designer.paperNode.setStyle("width", y);
- y = y.toFloat()+this.height.toFloat()/2;
- x = x.toFloat()+this.width.toFloat()/2;
- if (x>this.paperSize.x){
- this.paper.setSize(x*0.99, this.paperSize.y);
- $(this.paper.canvas).getParent().setStyle("width", ""+x+"px");
- this.paperSize.x = x;
- }
- if (y>this.paperSize.y){
- this.paper.setSize(this.paperSize.x*0.99, y);
- $(this.paper.canvas).getParent().setStyle("height", ""+y+"px");
- this.paperSize.y = y;
- }
- },
- resetPoint: function(){
- this.point = {x: this.center.x-this.width/2, y: this.center.y-this.height/2};
- },
- createShap: function(){
- var shap;
- shap = this.paper.circlePath(this.center.x, this.center.y, this.radius);
- shap.attr(this.style.shap);
- shap.data("bind", this);
- return shap;
- },
- redrawText: function(){
- return true;
- },
- redrawShap: function(){
- var shapPath = MWFRaphael.getCirclePath(this.center.x, this.center.y, this.radius);
- this.shap.attr("path", shapPath);
- },
- getOffset: function(){
- return {"tx": 6, "ty": 0, "ix": -8, "iy": -8};
- },
- getTextIconPoint: function(){
- var off = this.getOffset();
- if (this.style.text.display=="none"){
- var t_att = {x: this.center.x+off.tx, y: this.center.y+off.ty};
- var i_att = {x: this.center.x+off.ix, y: this.center.y+off.iy};
- return {"tatt": t_att, "iatt": i_att};
- }else{
- var t_att = {x: this.center.x+6, y: this.center.y};
- var i_att = {x: this.center.x-(this.width/2), y: this.center.y-8};
- return {"tatt": t_att, "iatt": i_att};
- }
- },
- getMoveOffset: function(){
- return {"tx": 6, "ty": 0, "ix": -9, "iy": -9};
- },
- getMoveTextIconPoint: function(){
- var off = this.getMoveOffset();
- if (this.style.text.display=="none"){
- var t_att = {x: this.center.x+off.tx, y: this.center.y+off.ty};
- var i_att = {x: this.center.x+off.ix, y: this.center.y+off.iy};
- return {"tatt": t_att, "iatt": i_att};
- }else{
- var t_att = {x: this.center.x+6, y: this.center.y};
- var i_att = {x: this.center.x-(this.width/2), y: this.center.y-8};
- return {"tatt": t_att, "iatt": i_att};
- }
- }
- });
- MWF.APPPD.Activity.Circle.SingleRouter = new Class({
- Extends: MWF.APPPD.Activity.Circle,
- getRoutedata: function(){
- if (!this.data.route) this.data.route = "";
- return [this.data.route];
- },
- setRouteData: function(id){
- if (!this.data.route) this.data.route = "";
- this.data.route = id;
- },
- removeRouteData: function(id){
- this.data.route = "";
- },
- quickCreateRoute: function(){
- if (!this.routes.length){
- this.process.createRoute();
- this.process.routeCreateFromActivity(this);
- }
- },
- checkCreateRoute: function(){
- if (this.process.isCreateRoute){
- var route = this.process.currentCreateRoute;
- if (!route.fromActivity){
- if (!this.routes.length) this.process.routeCreateFromActivity(this);
- }else{
- this.process.routeCreateToActivity(this);
- }
- }
- if (this.process.isCopyRoute){
- if (!this.routes.length) this.process.routeAddFromActivity(this);
- }
- },
- mouseHover: function(){
- if (this.process.isCreateRoute){
- var route = this.process.currentCreateRoute;
- if (!route.fromActivity){
- if (!this.routes.length) this.shap.attr({"stroke-width": "2"});
- }else{
- this.shap.attr({"stroke-width": "2"});
- }
- }
- if (this.process.isChangeRouteTo){
- this.shap.attr({"stroke-width": "2"});
- }
- if (this.process.isChangeRouteFrom || this.process.isCopyRoute){
- if (!this.routes.length) this.shap.attr({"stroke-width": "2"});
- }
- },
- mouseUp: function(){
- if (this.process.isChangeRouteTo){
- this.process.currentChangeRoute.setActivity(this, null);
- this.process.currentChangeRoute.isBack = false;
- this.process.currentChangeRoute.positionPoints = this.process.currentChangeRoute.getRoutePoint();
- this.process.currentChangeRoute.reload();
- this.process.isChangeRouteTo = false;
- this.process.currentChangeRoute = null;
- }
- if (this.process.isChangeRouteFrom){
- if (!this.routes.length){
- this.process.currentChangeRoute.setActivity(null, this);
- this.process.currentChangeRoute.isBack = false;
- this.process.currentChangeRoute.positionPoints = this.process.currentChangeRoute.getRoutePoint();
- this.process.currentChangeRoute.reload();
- this.process.isChangeRouteFrom = false;
- this.process.currentChangeRoute = null;
- }
- }
- this.shap.attr(this.style.shap);
- },
- addRouteData: function(id){
- if (!this.data.route) this.data.route = id;
- }
- });
- MWF.APPPD.Activity.Circle.NoRouter = new Class({
- Extends: MWF.APPPD.Activity.Circle,
- quickCreateRoute: function(){
- return false;
- },
- checkCreateRoute: function(){
- if (this.process.isCreateRoute){
- var route = this.process.currentCreateRoute;
- if (route.fromActivity){
- this.process.routeCreateToActivity(this);
- }
- }
- },
- mouseHover: function(){
- if (this.process.isCreateRoute){
- var route = this.process.currentCreateRoute;
- if (route.fromActivity){
- this.shap.attr({"stroke-width": "2"});
- }
- }
- if (this.process.isChangeRouteTo){
- this.shap.attr({"stroke-width": "2"});
- }
- },
- mouseUp: function(){
- if (this.process.isChangeRouteTo){
- this.process.currentChangeRoute.setActivity(this, null);
- this.process.currentChangeRoute.isBack = false;
- this.process.currentChangeRoute.positionPoints = this.process.currentChangeRoute.getRoutePoint();
- this.process.currentChangeRoute.reload();
- this.process.isChangeRouteTo = false;
- this.process.currentChangeRoute = null;
- }
- this.shap.attr(this.style.shap);
- },
- addRouteData: function(id){}
- });
- MWF.APPPD.Activity.Diamond = new Class({
- Extends: MWF.APPPD.Activity,
- setSize: function(){
- var size = MWF.getTextSize(this.data.name, this.style.text);
- this.width = size.x + 80;
- this.width = this.width<120 ? 120: this.width;
- this.height = this.width*0.4;
- },
- createShap: function(){
- var shap;
- shap = this.paper.diamond(this.point.x, this.point.y, this.width, this.height, this.style.shap.radiusX, this.style.shap.radiusY);
- shap.attr(this.style.shap);
- shap.data("bind", this);
- return shap;
- },
- redrawShap: function(){
- var shapPath = MWFRaphael.getDiamondPath(this.point.x, this.point.y, this.width, this.height, this.style.shap.radiusX, this.style.shap.radiusY);
- this.shap.attr("path", shapPath);
- },
- getTextIconPoint: function(){
- var t_att = {x: this.center.x+6, y: this.center.y+1};
- var i_att = {x: this.center.x-(this.width/2)+28, y: this.center.y-9};
- return {"tatt": t_att, "iatt": i_att};
- }
- });
- (function (){
- var Activity = function(extendClass, name){
- return new Class({
- Extends: extendClass,
- setType: function(){
- this.type = name;
- this.data.type = name;
- },
- setStyle: function(){
- this.style = this.process.css.activity[name];
- }
- });
- };
- MWF.APPPD.Activity.Begin = new Activity(MWF.APPPD.Activity.Circle.SingleRouter, "begin");
- MWF.APPPD.Activity.End = new Activity(MWF.APPPD.Activity.Circle.NoRouter, "end");
- MWF.APPPD.Activity.Cancel = new Activity(MWF.APPPD.Activity.Circle.NoRouter, "cancel");
- MWF.APPPD.Activity.Manual = new Activity(MWF.APPPD.Activity, "manual");
- MWF.APPPD.Activity.Condition = new Activity(MWF.APPPD.Activity.Diamond, "condition");
- MWF.APPPD.Activity.Choice = new Activity(MWF.APPPD.Activity.Diamond, "choice");
- MWF.APPPD.Activity.Split = new Activity(MWF.APPPD.Activity.Circle.SingleRouter, "split");
- MWF.APPPD.Activity.Parallel = new Activity(MWF.APPPD.Activity.Circle, "parallel");
- MWF.APPPD.Activity.Merge = new Activity(MWF.APPPD.Activity.Circle.SingleRouter, "merge");
- MWF.APPPD.Activity.Embed = new Activity(MWF.APPPD.Activity.SingleRouter, "embed");
- MWF.APPPD.Activity.Delay = new Activity(MWF.APPPD.Activity.Circle.SingleRouter, "delay");
- MWF.APPPD.Activity.Invoke = new Activity(MWF.APPPD.Activity.SingleRouter, "invoke");
- MWF.APPPD.Activity.Service = new Activity(MWF.APPPD.Activity.SingleRouter, "service");
- MWF.APPPD.Activity.Agent = new Activity(MWF.APPPD.Activity.SingleRouter, "agent");
- MWF.APPPD.Activity.Message = new Activity(MWF.APPPD.Activity.SingleRouter, "message");
- })();
- MWF.xApplication.process.ProcessDesigner.Activity.List = new Class({
- initialize: function(activity){
- this.activity = activity;
- this.process = activity.process;
- this.paper = this.activity.process.paper;
- },
- load: function(){
- //this.activity.process.activityListNode
- // this.listActivityNode = new Element("div",{
- // "styles": this.process.css.listActivityNode
- // });
- // this.activityTable = new HtmlTable({
- // "properties": {
- // "width": "100%"
- // }
- // }).inject(this.listActivityNode);
- var actionIcon = (this.activity.type=="begin") ? " " : "<img src=\""+"/x_component_process_ProcessDesigner/$Process/default/icon/copy.png"+"\" />";
- this.row = this.process.activityTable.push([
- {
- "content": " ",
- "properties": {
- "styles": this.activity.style.listIcon
- }
- },
- {
- "content": this.activity.data.name,
- "properties": {
- "styles": this.process.css.list.listText
- }
- },
- {
- "content": actionIcon,
- "properties": {
- "styles": this.process.css.list.listIcon,
- "events": {
- "click": this.copyActivity.bind(this)
- }
- }
- },
- {
- "content": "<img src=\""+"/x_component_process_ProcessDesigner/$Process/default/icon/delete.png"+"\" />",
- "properties": {
- "styles": this.process.css.list.listIcon,
- "events": {
- "click": this.deleteActivity.bind(this)
- }
- }
- }
- ]
- );
- this.row.tr.addEvent("click", function(){
- this.activity.selected();
- }.bind(this));
- //this.listActivityNode.inject(this.activity.process.activityListNode);
- //var activityTable = new Element("table").inject(this.listActivityNode);
- },
- copyActivity: function(){
- this.process.copyActivity(this.activity);
- },
- deleteActivity: function(e){
- this.process.deleteActivity(e, this.activity);
- },
- listSelected: function(){
- if (this.process.currentListSelected) this.process.currentListSelected.listUnSelected();
- this.row.tr.setStyles(this.process.css.list.listRowSelected);
- this.process.currentListSelected = this;
- //alert(this.process.currentSelected!=this.activity)
- //if (this.process.currentSelected!=this.activity) this.activity.selected();
- },
- listUnSelected: function(){
- this.process.currentListSelected = null;
- this.row.tr.setStyles(this.process.css.list.listRow);
- //if (this.process.currentSelected==this.activity) this.activity.unSelected();
- }
- });
- MWF.xApplication.process.ProcessDesigner.Activity.Property = new Class({
- Implements: [Options, Events],
- Extends: MWF.APPPD.Property,
- initialize: function(activity, options){
- this.setOptions(options);
- this.activity = activity;
- this.process = activity.process;
- this.paper = this.activity.process.paper;
- this.data = activity.data;
- this.htmlPath = "/x_component_process_ProcessDesigner/$Process/"+this.activity.type+".html";
- },
- setValue: function(name, value){
- this.data[name] = value;
- if (name=="name"){
- if (!value) this.data[name] = MWF.APPPD.LP.unnamed;
- this.activity.redraw();
- }
- }
- });
|