| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- Ext.ns('App.property');
- App.property.AbstractPropertyPanel = Ext.extend(Ext.Panel, {
- title: '属性面板',
- iconCls: 'tb-prop',
- layout: 'fit',
- split: true,
- tools: [{
- id: 'maximize',
- handler: function(event, toolEl, panel) {
- panel.propertyManager.changePropertyStatus('max');
- }
- }],
- // ========================================================================
- initComponent: function() {
- var tabPanel = new Ext.TabPanel({
- enableTabScroll:true,
- layoutOnTabChange: true,
- defaults: {
- autoScroll: true
- }
- });
- this.tabPanel = tabPanel;
- this.items = [tabPanel];
- App.property.AbstractPropertyPanel.superclass.initComponent.call(this);
- },
- setPropertyManager: function(propertyManager) {
- this.propertyManager = propertyManager;
- },
- getTabPanel: function() {
- return this.tabPanel;
- },
- hide: function() {
- this.clearItem(this.tabPanel);
- App.property.AbstractPropertyPanel.superclass.hide.call(this);
- },
- clearItem: function(p) {
- if (typeof p.items != 'undefined') {
- var item = null;
- while ((item = p.items.last())) {
- p.remove(item, true);
- }
- }
- }
- });
- Ext.ns('App.property');
- App.property.BottomPanel = Ext.extend(App.property.AbstractPropertyPanel, {
- region: 'south',
- height: 200,
- draggable: {
- insertProxy: false,
- onDrag: function(e) {
- var pel = this.proxy.getEl();
- this.x = pel.getLeft(true);
- this.y = pel.getTop(true);
- },
- endDrag: function(e) {
- var x = this.x;
- var y = this.y;
- var propertyManager = this.panel.propertyManager;
- var size = Ext.getBody().getViewSize();
- if (y < size.height - 200) {
- if (x > size.width - 200) {
- propertyManager.changePropertyStatus('right');
- } else {
- propertyManager.changePropertyStatus('max');
- }
- }
- }
- },
- getStatusName: function() {
- return 'bottom';
- }
- });
- Ext.ns('App.property');
- App.property.MaxWindow = Ext.extend(Ext.Window, {
- title: '属性面板',
- iconCls: 'tb-prop',
- layout: 'fit',
- stateful: false,
- closable: false,
- width: 500,
- height: 400,
- // FIXME: 希望实现,不disable editor,编辑window中的元素时,不会选中editor中的元素
- modal: false,
- constrainHeader: true,
- autoScroll: true,
- tools: [{
- id: 'restore',
- handler: function(event, toolEl, panel) {
- panel.propertyManager.changePropertyStatus(panel.restore.getStatusName());
- }
- }],
- // ========================================================================
- initComponent: function() {
- var tabPanel = new Ext.TabPanel({
- enableTabScroll:true,
- layoutOnTabChange: true
- });
- this.tabPanel = tabPanel;
- this.items = [tabPanel];
- App.property.MaxWindow.superclass.initComponent.call(this);
- },
- afterRender: function() {
- App.property.MaxWindow.superclass.afterRender.call(this);
- this.dd.endDrag = function(e) {
- try {
- this.win.unghost();
- // this.win.saveState();
- var x = e.xy[0];
- var y = e.xy[1];
- var propertyManager = this.win.propertyManager;
- var size = Ext.getBody().getViewSize();
- if (y > size.height - 200) {
- propertyManager.changePropertyStatus('bottom');
- } else if (x > size.width - 200) {
- propertyManager.changePropertyStatus('right');
- }
- } catch(e) {
- Gef.error(e);
- }
- }.createDelegate(this.dd);
- },
- setPropertyManager: function(propertyManager) {
- this.propertyManager = propertyManager;
- },
- getTabPanel: function() {
- return this.tabPanel;
- },
- clearItem: function(p) {
- if (typeof p.items != 'undefined') {
- var item = null;
- while ((item = p.items.last())) {
- p.remove(item, true);
- }
- }
- },
- // ========================================================================
- hide: function() {
- this.clearItem(this.tabPanel);
- if (this.el) {
- if (Gef.activeEditor) {
- //Gef.activeEditor.enable();
- }
- App.property.MaxWindow.superclass.hide.call(this);
- }
- },
- show: function() {
- if (Gef.activeEditor) {
- //Gef.activeEditor.disable();
- }
- delete this.x;
- delete this.y;
- App.property.MaxWindow.superclass.show.call(this);
- },
- getStatusName: function() {
- return 'max';
- },
- setRestore: function(restore) {
- this.restore = restore;
- }
- });
- Ext.ns('App.property');
- App.property.PropertyManager = Ext.extend(Object, {
- constructor: function() {
- this.bottomPanel = new App.property.BottomPanel();
- this.bottomPanel.setPropertyManager(this);
- this.rightPanel = new App.property.RightPanel();
- this.rightPanel.setPropertyManager(this);
- this.maxWindow = new App.property.MaxWindow();
- this.maxWindow.setPropertyManager(this);
- var propertyStatus = Cookies.get('_gef_jbpm4_property_status');
- if (propertyStatus != 'bottom') {
- propertyStatus = 'right';
- }
- this.changePropertyStatus(propertyStatus);
- this.initMap();
- },
- changePropertyStatus: function(status) {
- try {
- status = status ? status : 'right';
- Cookies.set('_gef_jbpm4_property_status', status);
- switch (status) {
- case 'right':
- this.current = this.rightPanel;
- this.current.show();
- if (this.form) {
- this.form.decorate(this.current.getTabPanel(), this.model);
- }
- this.maxWindow.hide();
- this.bottomPanel.hide();
- if (this.rightPanel.ownerCt) {
- this.rightPanel.ownerCt.doLayout();
- }
- break;
- case 'bottom':
- this.current = this.bottomPanel;
- this.current.show();
- if (this.form) {
- this.form.decorate(this.current.getTabPanel(), this.model);
- }
- this.maxWindow.hide();
- this.rightPanel.hide();
- if (this.rightPanel.ownerCt) {
- this.rightPanel.ownerCt.doLayout();
- }
- break;
- case 'max':
- this.maxWindow.setRestore(this.current);
- this.current = this.maxWindow;
- this.current.show();
- if (this.form) {
- this.form.decorate(this.current.getTabPanel(), this.model);
- }
- this.bottomPanel.hide();
- this.rightPanel.hide();
- if (this.rightPanel.ownerCt) {
- this.rightPanel.ownerCt.doLayout();
- }
- break;
- }
- } catch(e) {
- Gef.error(e);
- }
- },
- getBottom: function() {
- return this.bottomPanel;
- },
- getRight: function() {
- return this.rightPanel;
- },
- getMax: function() {
- return this.max;
- },
- getCurrent: function() {
- return this.current;
- },
- getSelectionListener: function() {
- return this.selectionListener;
- },
- initMap: function() {
- this.formMap = {
- process: App.form.ProcessForm,
- start: App.form.StartForm,
- end: App.form.EndForm,
- cancel: App.form.CancelForm,
- error: App.form.ErrorForm,
- state: App.form.StateForm,
- task: App.form.TaskForm,
- decision: App.form.DecisionForm,
- fork: App.form.ForkForm,
- join: App.form.JoinForm,
- java: App.form.JavaForm,
- script: App.form.ScriptForm,
- hql: App.form.HqlForm,
- sql: App.form.SqlForm,
- mail: App.form.MailForm,
- custom: App.form.CustomForm,
- subProcess: App.form.SubProcessForm,
- transition: App.form.TransitionForm,
- jms: App.form.JmsForm,
- ruleDecision: App.form.RuleDecisionForm,
- rules: App.form.RulesForm,
- auto: App.form.AutoForm,
- human: App.form.HumanForm,
- 'counter-sign': App.form.CounterSignForm,
- foreach: App.form.ForeachForm
- };
- },
- updateForm: function(model) {
- return;
- this.model = model;
- var modelType = model.getType();
- var constructor = this.formMap[modelType];
- if (!constructor) {
- Gef.debug('cannot find form for [' + modelType + ']',
- 'App.property.PropertyManager.updateForm()');
- }
- this.form = new constructor;
- this.form.decorate(this.current.getTabPanel(), model);
- },
- initSelectionListener: function(editor) {
- this.selectionListener = new Gef.jbs.ExtSelectionListener(this);
- editor.addSelectionListener(this.selectionListener);
- this.selectionListener.setEditor(editor);
- var model = this.selectionListener.getModel();
- this.updateForm(model);
- }
- });
- var Cookies = {};
- Cookies.set = function(name, value){
- var argv = arguments;
- var argc = arguments.length;
- var expires = (argc > 2) ? argv[2] : null;
- var path = (argc > 3) ? argv[3] : '/';
- var domain = (argc > 4) ? argv[4] : null;
- var secure = (argc > 5) ? argv[5] : false;
- document.cookie = name + "=" + escape (value) +
- ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
- ((path == null) ? "" : ("; path=" + path)) +
- ((domain == null) ? "" : ("; domain=" + domain)) +
- ((secure == true) ? "; secure" : "");
- };
- Cookies.get = function(name){
- var arg = name + "=";
- var alen = arg.length;
- var clen = document.cookie.length;
- var i = 0;
- var j = 0;
- while(i < clen){
- j = i + alen;
- if (document.cookie.substring(i, j) == arg)
- return Cookies.getCookieVal(j);
- i = document.cookie.indexOf(" ", i) + 1;
- if(i == 0)
- break;
- }
- return null;
- };
- Cookies.clear = function(name) {
- if(Cookies.get(name)){
- document.cookie = name + "=" +
- "; expires=Thu, 01-Jan-70 00:00:01 GMT";
- }
- };
- Cookies.getCookieVal = function(offset){
- var endstr = document.cookie.indexOf(";", offset);
- if(endstr == -1){
- endstr = document.cookie.length;
- }
- return unescape(document.cookie.substring(offset, endstr));
- };
- Ext.ns('App.property');
- App.property.RightPanel = Ext.extend(App.property.AbstractPropertyPanel, {
- region: 'east',
- width: 200,
- frame:true,
- draggable: {
- insertProxy: false,
- onDrag: function(e) {
- var pel = this.proxy.getEl();
- this.x = pel.getLeft(true);
- this.y = pel.getTop(true);
- },
- endDrag: function(e) {
- var x = this.x;
- var y = this.y;
- var propertyManager = this.panel.propertyManager;
- var size = Ext.getBody().getViewSize();
- if (x < size.width - 200) {
- if (y > size.height - 200) {
- propertyManager.changePropertyStatus('bottom');
- } else {
- propertyManager.changePropertyStatus('max');
- }
- }
- }
- },
- getStatusName: function() {
- return 'right';
- }
- });
|