Gef.ns('Gef.jbs'); Gef.jbs.ExtEditor = Gef.extend(Gef.jbs.JBSEditor, { constructor: function() { Gef.jbs.ExtEditor.superclass.constructor.call(this); this.modelFactory = new Gef.jbs.JBSModelFactory(); this.editPartFactory = new Gef.jbs.JBSEditPartFactory(); }, createGraphicalViewer: function() { return new Gef.jbs.ExtGraphicalViewer(this); }, getPaletteHelper: function() { if (!this.paletteHelper) { this.paletteHelper = new Gef.jbs.ExtPaletteHelper(this); } return this.paletteHelper; }, addSelectionListener: function(selectionListener) { this.getGraphicalViewer() .getBrowserListener() .selectionListenerTracker .addSelectionListener(selectionListener); }, enable: function() { this.getGraphicalViewer().getBrowserListener().enable(); }, disable: function() { this.getGraphicalViewer().getBrowserListener().disable(); } }); Gef.override(Gef.jbs.tool.ChangeTypeTool, { handleMenuClick: function(item, e) { var toolTracker = this.toolTracker; var type = item.changedType; var oldModel = this.node.editPart.model; var newModel = toolTracker.getModelFactory().createModel(type); var compoundCommand = new Gef.commands.CompoundCommand(); compoundCommand.addCommand(new Gef.gef.command.CreateNodeCommand(newModel, oldModel.getParent(), { x: oldModel.x, y: oldModel.y, w: oldModel.w, h: oldModel.h })); Gef.each(oldModel.getIncomingConnections(), function(connection) { var connectionType = connection.getType(); var newConnection = toolTracker.getModelFactory().createModel(connectionType); newConnection.text = connection.text; compoundCommand.addCommand(new Gef.gef.command.RemoveConnectionCommand( connection )); compoundCommand.addCommand(new Gef.gef.command.CreateConnectionCommand( newConnection, connection.getSource(), newModel )); compoundCommand.addCommand(new Gef.gef.command.ResizeConnectionCommand( newConnection, [], connection.innerPoints )); }); Gef.each(oldModel.getOutgoingConnections(), function(connection) { var connectionType = connection.getType(); var newConnection = toolTracker.getModelFactory().createModel(connectionType); newConnection.text = connection.text; compoundCommand.addCommand(new Gef.gef.command.RemoveConnectionCommand( connection )); compoundCommand.addCommand(new Gef.gef.command.CreateConnectionCommand( newConnection, newModel, connection.getTarget() )); compoundCommand.addCommand(new Gef.gef.command.ResizeConnectionCommand( newConnection, [], connection.innerPoints )); }); compoundCommand.addCommand(new Gef.gef.command.RemoveNodeCommand(oldModel)); toolTracker.getCommandStack().execute(compoundCommand); toolTracker.getSelectionManager().addSelectedNode(newModel.editPart); }, drag: function(toolTracker, request) { this.toolTracker = toolTracker; var items = []; Gef.each(this.allowedTypes, function(item) { if (item.type == this.node.editPart.model.getType()) { return true; } items.push({ text: item.name, changedType: item.type, handler: this.handleMenuClick, scope: this }); }, this); var contextMenu = new Ext.menu.Menu({ items: items }); contextMenu.showAt([ request.point.absoluteX, request.point.absoluteY ]); }, move: function(toolTracker, request) { }, drop: function(toolTracker, request) { } }); Gef.ns("Gef.jbs"); Gef.jbs.ExtGraphicalViewer = Gef.extend(Gef.gef.support.DefaultGraphicalViewer, { render: function() { this.canvasEl = Ext.getDom('__gef_jbs_center__'); this.rootEditPart.render(); this.rendered = true; }, getPaletteLocation: function() { if (!this.paletteLocation) { var paletteBox = Ext.get('__gef_jbs_palette__').getBox(); this.paletteLocation = { x: paletteBox.x, y: paletteBox.y, w: paletteBox.width, h: paletteBox.height }; } return this.paletteLocation; }, getCanvasLocation: function() { //if (!this.canvasLocation) { var box = Ext.get('__gef_jbs_center__').getBox(); var scroll = Ext.get('__gef_jbs_center__').getScroll(); this.canvasLocation = { x: box.x, y: box.y, w: box.width, h: box.height }; //} return this.canvasLocation; } }); Gef.jbs.ExtPaletteHelper = Gef.extend(Gef.jbs.JBSPaletteHelper, { createSource: function() { return { select: { text: 'select', creatable: false }, transition: { text: 'transition', creatable: false, isConnection: true }, start: { text: 'start', w: 48, h: 48 }, end: { text: 'end', w: 48, h: 48 }, cancel: { text: 'cancel', w: 48, h: 48 }, error: { text: 'error', w: 48, h: 48 }, state: { text: 'state', w: 90, h: 50 }, task: { text: 'task', w: 90, h: 50 }, decision: { text: 'decision', w: 48, h: 48 }, fork: { text: 'fork', w: 48, h: 48 }, join: { text: 'join', w: 48, h: 48 }, java: { text: 'java', w: 90, h: 50 }, script: { text: 'script', w: 90, h: 50 }, hql: { text: 'hql', w: 90, h: 50 }, sql: { text: 'sql', w: 90, h: 50 }, derive: { text: 'derive', w: 32, h: 32 }, mission: { text: 'mission', w: 64, h: 32 }, idea: { text: 'idea', w: 90, h: 32 }, custom: { text: 'custom', w: 90, h: 50 }, mail: { text: 'mail', w: 90, h: 50 }, subProcess: { text: 'subProcess', w: 90, h: 50 }, jms: { text: 'jms', w: 90, h: 50 }, ruleDecision: { text: 'ruleDecision', w: 48, h: 48 }, rules: { text: 'rules', w: 90, h: 50 }, auto: { text: 'auto', w: 90, h: 50 }, human: { text: 'human', w: 90, h: 50 }, 'counter-sign': { text: 'counter-sign', w: 90, h: 50 }, foreach: { text: 'foreach', w: 48, h: 48 } }; }, getSource: function() { if (!this.source) { this.source = this.createSource(); } return this.source; }, render: Gef.emptyFn, changeActivePalette: function(paletteConfig) { var el = null; if (this.getActivePalette()) { var oldActivePaletteId = this.getActivePalette().text; el = document.getElementById(oldActivePaletteId + '-img'); el.style.border = ''; } this.setActivePalette(paletteConfig); el = document.getElementById(paletteConfig.text + '-img'); el.style.border = '1px dotted black'; }, resetActivePalette: function() { this.changeActivePalette({ text: 'select' }); }, getPaletteConfig: function(p, t) { var id = t.parentNode.id; if (!id) { return null; } var source = this.getSource(); var paletteConfig = this.getSource()[id]; if (!paletteConfig) { return null; } this.changeActivePalette(paletteConfig); if (paletteConfig.creatable === false) { return null; } return paletteConfig; } }); Gef.ns('Gef.jbs'); //监听 2013-12-18 zhouy Gef.jbs.ExtSelectionListener = Gef.extend(Gef.gef.tracker.DefaultSelectionListener, { constructor: function(propertyGrid) { this.propertyGrid = propertyGrid; }, selectNode: function(editPart) { var node = editPart.getModel(); if (this.propertyGrid) { this.propertyGrid.updateForm(node); } var formCondition=getUrlParam('formCondition'); this.model = node; var model = this.model; //从工具栏拖动下来时 根据类型分辨 if(model.id.indexOf('derive')>=0){//派生流程 model.flowtype = 'derive'; } if(model.id.indexOf('mission')>=0){//派生任务 model.flowtype = 'mission'; } if(model.id.indexOf('idea')>=0){//派生意见 model.flowtype = 'idea'; } if(model.id.indexOf('task')>=0){//普通任务节点 model.flowtype = 'task'; } }, selectConnection: function(editPart) { var connection = editPart.getModel(); if (this.propertyGrid) { this.propertyGrid.updateForm(connection); } this.model = connection; }, selectDefault: function(editPart) { var process = editPart.getModel(); if (this.propertyGrid) { this.propertyGrid.updateForm(process); } this.model = process; }, setEditor: function(editor) { this.editor = editor; this.model = editor.getGraphicalViewer().getContents().getModel(); }, editText: function(model, text) { var command = new Gef.gef.command.EditTextCommand(model, text); this.editor.getEditDomain().getCommandStack().execute(command); }, getModel: function() { return this.model; }, parseUrl: function(url){ var id = url.substring(url.lastIndexOf('?')+1);//将作为新tab的id if (id == null) { id = url.substring(0,url.lastIndexOf('.')); } if(url.indexOf('session:em_uu')>-1){//对url中session值的处理 url = url.replace(/session:em_uu/,em_uu); } if(url.indexOf('session:em_code')>-1){//对url中em_code值的处理 url = url.replace(/session:em_code/, "'" + em_code + "'"); } if(url.indexOf('sysdate')>-1){//对url中系统时间sysdate的处理 url = url.replace(/sysdate/, "to_date('" + Ext.Date.toString(new Date()) + "','yyyy-mm-dd')"); } if(url.indexOf('session:em_name')>-1){ url = url.replace(/session:em_name/,"'"+em_name+"'" ); } return url; }, openCard: function(){ var me = this; var panel =Ext.getCmp(me.sysid); var url=me.selectlistener.parseUrl( me.url); if(!panel){ panel = { title : me.text, tag : 'iframe', id : me.sysid, tabConfig: {tooltip:me.text}, frame : true, border : false, layout : 'fit', bodyPadding: 0, html : '', closable : true, listeners : { close : function(){ var main = parent.Ext.getCmp("content-panel"); main.setActiveTab(Ext.getCmp("HomePage")); } } }; var o = (typeof panel == "string" ? panel : panel.id); var main = parent.Ext.getCmp("content-panel"); var tab = main.getComponent(o); if (tab) { main.setActiveTab(tab); } else if(typeof panel!="string"){ panel.id = o; var p = main.add(panel); main.setActiveTab(p); } } else{ var main = Ext.getCmp("content-panel"); main.setActiveTab(panel); } } });