| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 |
- 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
- },
- 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');
- if(node.dom && node.dom.tagName=='custom' && !formCondition){
-
- var arr=new Array();
- for(var i=0;i<node.dom.elements.length;i++){
- arr.push({
- text:node.dom.elements[i].attributes.name,
- url:node.dom.elements[i].attributes.type,
- handler:this.openCard,
- sysid:node.dom.elements[i].attributes.id,
- selectlistener:this,
- currentEditPart: editPart
-
- });
- }
- var contextMenu = new Ext.menu.Menu({
- items: arr
- });
- contextMenu.showAt([
- node.x+20,
- node.y+40
- ]);
- }
- this.model = node;
- },
- 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 : '<iframe id="iframe_ext-window" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
- 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);
- }
- }
- });
|