目的:在web设计器中使用command模式实现动作的撤销和重做
当前的一些设想:
1、构建能够支持单一应用的 application 组件,只能支持一种editor。
2、application 组件中注册、执行、撤销和重做command,约定一些特定的执行规则,执行参数的使用方式。
$('body',document).application('registerCommand','addTransition',{
getTitle:function(){
return '新增连线';
},
exec:function(){
var o = this.options;
if(o.event){//鼠标事件驱动的动作,不重复执行操作。
o.event = null;
}else{
$('#editor-workflow').workflow('addTransition',o.fromId,o.toId);
}
},
undo:function(){
var o = this.options;
$('#editor-workflow').workflow('removeTransition',o.fromId,o.toId);
}
});
3、在workflow组件中提供鼠标的动作的命令集成
$('#editor-workflow').workflow({
moveCommand:function(event,ui){
$('body',document).application('executeCommand','move',$.extend({
event:event
},ui));
},//集成鼠标动作的move命令
addTransitionCommand:function(event,ui){
$('body',document).application('executeCommand','addTransition',$.extend({
event:event
},ui));
}//集成鼠标动作的addTransition命令
});
(function($) {
$.widget("youi.application", {
_init:function(){
this.commands = [];//执行过的的命令数组,供撤销使用
this.undoCommands = [];//撤销过的命令数组,供重做使用
this.registedCommands = [];//map
this.element.addClass('youi-application');
this._defaultHtml();
},
_defaultHtml:function(){
//TODO 增加其他的html
var preHtmls = ['<div id="application-info" class="application-info"></div>'];
this.element.prepend(preHtmls.join(''));
},
/* 系统执行命令相关函数 **/
executeCommand:function(command,options){
if(typeof(command)=='string'){
options = $.extend({},command.defaults,options);
command = $.extend({options:options},this.registedCommands[command]);
}
this.commands.push(command);
this.exec();
this.undoCommands = [];//清空重做项
},
/**
* 执行命令
*/
exec:function(isRedo){
if(this.commands.length>0){
var command = this.commands[this.commands.length-1];
command.exec(isRedo);
$.youi.log.info('执行动作:'+command.getTitle());
}
},
/**
* 撤销
*/
undo:function(){
if(this.commands.length>0){
var undoCommand = this.commands.pop();
undoCommand.undo();
this.undoCommands.push(undoCommand);
$.youi.log.info('撤销动作:'+undoCommand.getTitle());
}
},
/**
* 重做
*/
redo:function(){
if(this.undoCommands.length>0){
var redoCommand = this.undoCommands.pop();
this.commands.push(redoCommand);
this.exec(true);
$.youi.log.info('重做动作:'+redoCommand.getTitle());
}
},
/**
* 注册命令
*/
registerCommand:function(name,command){
this.registedCommands[name] = command;
},
/**
* 销毁
*/
destroy:function(){
//TODO
}
});
$.extend($.youi.application,{
defaults:{
menu :'',
toolbar :'',
propertyTable:'',
type :''//dialog page
}
});
})(jQuery);
分享到:
相关推荐
大家在做jbpm的时候,肯定会考虑到将工作流提升到用户层面,让用户可以设计流程,而不是只在myeclipse中由程序员设计,这个软件就是这个作用,有需要的人可以下载。 注意:该文件是免费版,具备的功能是:图形化流程...
JBPM Web流程设计器,用js+extjs画的jbpm流程设计器,与eclipse插件类似,可以进行自定义。
jeecg-jbpm-framework 20130202.zipjeecg-jbpm-framework 20130202.zipjeecg-jbpm-framework 20130202.zipjeecg-jbpm-framework 20130202.zipjeecg-jbpm-framework 20130202.zipjeecg-jbpm-framework 20130202....
jbpm-jpdl-suite-3.2GA -(5)分开压缩(共5个文件)jbpm下载 jbpm-jpdl-suite-3.2GA -(5)分开压缩(共5个文件)jbpm下载
jbpmweb工程 博文链接:https://lansky07.iteye.com/blog/285847
jbpm-jpdl-designer-site-3.1.7.zip jbpm-jpdl-designer-site-3.1.7.zip jbpm-jpdl-designer-site-3.1.7.zip
extjs jbpm4 流程设计器,希望对你有所帮助!
jBPM Web Designer(jBPM Web 设计器、jBPM 流程设计器、工作流程设计器)
jbpm-jpdl-suite-3.2.3.zip工作流 设计器
jbpm-starters-kit-3.1.2插件,jbpm-starters-kit-3.1.2插件,jbpm-starters-kit-3.1.2插件,jbpm-starters-kit-3.1.2插件,jbpm-starters-kit-3.1.2插件,jbpm-starters-kit-3.1.2插件,共两卷
jbpm-flow-builder-5.1.0.Final.jar jbpm5
jbpm4整合流程例子及附代web流程设计器可以进行流程设计
NULL 博文链接:https://zhyi-12.iteye.com/blog/378159
JBPM设计器,纯JS
完整工作流JBPM项目实战全过程教程---项目详细讲解.doc
jbpm-jpdl-designer资源
jbpm-jpdl-suite-3.2.GA.zip
jbpm-jpdl-designer-3.0.13 关于jbpm的jpdl 设计器