12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244 |
- 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(){
- var parentNode = $(this.paper.canvas).getParent() || this.process.designer.paperInNode;
- this.paperSize = parentNode.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{
- debugger;
- 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;
- }
- var paperSize = this.process.getPaperSize();
- if ((this.set.ox+dx)<0) dx = 0 - this.set.ox;
- if ((this.set.ox+dx+this.width)>paperSize.x){
- //this.paperSize.x = this.set.ox+dx+this.width;
- this.process.setPaperSizeX( this.set.ox+dx+this.width );
- this.paper.setSize(paperSize.x, paperSize.y);
- //alert("set width");
- $(this.paper.canvas).getParent().setStyle("width", ""+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)>paperSize.y){
- //this.paperSize.y = this.set.oy + dy+this.height;
- this.process.setPaperSizeY( this.set.oy + dy+this.height );
- this.paper.setSize(paperSize.x, paperSize.y);
- //alert("set height");
- $(this.paper.canvas).getParent().setStyle("height", ""+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};
- route.data.track = route.positionPointsToString();
- }.bind(this));
- }
- if (route.data.position){
- var t = route.getTextPoint();
- var tx = t.x.toFloat() + dx.toFloat() - this.set.movex;
- var ty = t.y.toFloat() + dy.toFloat() - this.set.movey;
- route.text.attr({
- "x": tx,
- "y": ty
- });
- route.data.position = tx + "," + ty;
- }
- }.bind(this));
- this.set.movex = dx;
- this.set.movey = dy;
- 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);
- // }
- try{
- this.process.designer.paperInNode.focus();
- }catch(e){};
- 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.Publish = new Activity(MWF.APPPD.Activity.SingleRouter, "publish");
- 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){
- var names = name.split(".");
- var o = this.data;
- while (names.length>1){
- var k = names.shift();
- if (!o.hasOwnProperty(k)){
- o[k] = {};
- }
- o=o[k];
- }
- var key = names.shift();
- o[key] = value;
- // this.data[name] = value;
- if (name=="name"){
- if (!value) this.data[name] = MWF.APPPD.LP.unnamed;
- this.activity.redraw();
- }
- }
- });
|