Commit 5584facc authored by Akikonata's avatar Akikonata

undo

parent 60272950
kity.extendClass( Minder, {
_getCommand: function ( name ) {
return this._commands[ name.toLowerCase() ];
kity.extendClass(Minder, {
_getCommand: function (name) {
return this._commands[name.toLowerCase()];
},
_queryCommand: function ( name, type, args ) {
var cmd = this._getCommand( name );
if ( cmd ) {
var queryCmd = cmd[ 'query' + type ];
if ( queryCmd )
return queryCmd.apply( cmd, [ this ].concat( args ) );
_queryCommand: function (name, type, args) {
var cmd = this._getCommand(name);
if (cmd) {
var queryCmd = cmd['query' + type];
if (queryCmd)
return queryCmd.apply(cmd, [this].concat(args));
}
return 0;
},
queryCommandState: function ( name ) {
return this._queryCommand( name, "State", Utils.argsToArray( 1 ) );
queryCommandState: function (name) {
return this._queryCommand(name, "State", Utils.argsToArray(1));
},
queryCommandValue: function ( name ) {
return this._queryCommand( name, "Value", Utils.argsToArray( 1 ) );
queryCommandValue: function (name) {
return this._queryCommand(name, "Value", Utils.argsToArray(1));
},
execCommand: function ( name ) {
execCommand: function (name) {
name = name.toLowerCase();
var cmdArgs = Utils.argsToArray( arguments, 1 ),
var cmdArgs = Utils.argsToArray(arguments, 1),
cmd, stoped, result, eventParams;
var me = this;
cmd = this._getCommand( name );
cmd = this._getCommand(name);
eventParams = {
command: cmd,
commandName: name.toLowerCase(),
commandArgs: cmdArgs
};
if ( !cmd ) {
if (!cmd) {
return false;
}
if ( !this._hasEnterExecCommand && cmd.isNeedUndo() ) {
if (!this._hasEnterExecCommand && cmd.isNeedUndo()) {
this._hasEnterExecCommand = true;
stoped = this._fire( new MinderEvent( 'beforeExecCommand', eventParams, true ) );
stoped = this._fire(new MinderEvent('beforeExecCommand', eventParams, true));
if ( !stoped ) {
if (!stoped) {
//保存场景
this._fire( new MinderEvent( 'saveScene' ) );
this._fire(new MinderEvent('saveScene'));
this._fire( new MinderEvent( "preExecCommand", eventParams, false ) );
this._fire(new MinderEvent("preExecCommand", eventParams, false));
result = cmd.execute.apply( cmd, [ me ].concat( cmdArgs ) );
result = cmd.execute.apply(cmd, [me].concat(cmdArgs));
this._fire( new MinderEvent( 'execCommand', eventParams, false ) );
this._fire(new MinderEvent('execCommand', eventParams, false));
//保存场景
this._fire( new MinderEvent( 'saveScene' ) );
this._fire(new MinderEvent('saveScene'));
if ( cmd.isContentChanged() ) {
this._firePharse( new MinderEvent( 'contentchange' ) );
if (cmd.isContentChanged()) {
this._firePharse(new MinderEvent('contentchange'));
}
if ( cmd.isSelectionChanged() ) {
this._firePharse( new MinderEvent( 'selectionchange' ) );
if (cmd.isSelectionChanged()) {
this._firePharse(new MinderEvent('selectionchange'));
}
this._firePharse( new MinderEvent( 'interactchange' ) );
this._firePharse(new MinderEvent('interactchange'));
}
this._hasEnterExecCommand = false;
} else {
result = cmd.execute.apply( cmd, [ me ].concat( cmdArgs ) );
result = cmd.execute.apply(cmd, [me].concat(cmdArgs));
if(!this._hasEnterExecCommand){
if ( cmd.isSelectionChanged() ) {
this._firePharse( new MinderEvent( 'selectionchange' ) );
if (!this._hasEnterExecCommand) {
if (cmd.isSelectionChanged()) {
this._firePharse(new MinderEvent('selectionchange'));
}
this._firePharse( new MinderEvent( 'interactchange' ) );
this._firePharse(new MinderEvent('interactchange'));
}
}
return result === undefined ? null : result;
}
} );
\ No newline at end of file
});
\ No newline at end of file
This diff is collapsed.
......@@ -266,7 +266,7 @@ KityMinder.registerModule("LayoutDefault", function () {
var result = [];
for (var len = 0; len < children.length; len++) {
var l = children[len].getLayout();
if (l.added) {
if (l && l.added) {
result.push(children[len]);
}
}
......@@ -442,65 +442,6 @@ KityMinder.registerModule("LayoutDefault", function () {
getCurrentLayoutStyle: function () {
return nodeStyles;
},
highlightNode: function (node) {
var highlight = node.isHighlight();
var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType];
var Layout = node.getLayout();
switch (nodeType) {
case "root":
case "main":
if (highlight) {
Layout.bgRect.fill(nodeStyle.highlight);
} else {
Layout.bgRect.fill(nodeStyle.fill);
}
break;
case "sub":
if (highlight) {
Layout.highlightshape.fill(nodeStyle.highlight).setOpacity(1);
node.getTextShape().fill(node.getData('fontcolor') || 'black');
} else {
Layout.highlightshape.setOpacity(0);
node.getTextShape().fill(node.getData('fontcolor') || 'white');
}
break;
default:
break;
}
},
updateLayout: function (node) {
node.getContRc().clear();
this._firePharse(new MinderEvent("RenderNodeLeft", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeCenter", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeRight", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeBottom", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeTop", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNode", {
node: node
}, false));
updateShapeByCont(node);
var set1 = updateLayoutHorizon(node);
var set2 = updateLayoutVertical(node, node.getParent(), "change");
var set = uSet(set1, set2);
for (var i = 0; i < set.length; i++) {
translateNode(set [i]);
updateConnectAndshIcon(set [i]);
}
if (this.isNodeSelected(node)) {
this.highlightNode(node)
}
},
initStyle: function () {
//渲染根节点
var _root = minder.getRoot();
......@@ -545,6 +486,38 @@ KityMinder.registerModule("LayoutDefault", function () {
}
_root.setPoint(_root.getLayout().x, _root.getLayout().y);
},
updateLayout: function (node) {
node.getContRc().clear();
this._firePharse(new MinderEvent("RenderNodeLeft", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeCenter", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeRight", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeBottom", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeTop", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNode", {
node: node
}, false));
updateShapeByCont(node);
var set1 = updateLayoutHorizon(node);
var set2 = updateLayoutVertical(node, node.getParent(), "change");
var set = uSet(set1, set2);
for (var i = 0; i < set.length; i++) {
translateNode(set [i]);
updateConnectAndshIcon(set [i]);
}
if (this.isNodeSelected(node)) {
this.highlightNode(node)
}
},
expandNode: function (ico) {
var isExpand, node;
if (ico instanceof MinderNode) {
......@@ -746,6 +719,33 @@ KityMinder.registerModule("LayoutDefault", function () {
_buffer.shift();
}
}
},
highlightNode: function (node) {
var highlight = node.isHighlight();
var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType];
var Layout = node.getLayout();
switch (nodeType) {
case "root":
case "main":
if (highlight) {
Layout.bgRect.fill(nodeStyle.highlight);
} else {
Layout.bgRect.fill(nodeStyle.fill);
}
break;
case "sub":
if (highlight) {
Layout.highlightshape.fill(nodeStyle.highlight).setOpacity(1);
node.getTextShape().fill(node.getData('fontcolor') || 'black');
} else {
Layout.highlightshape.setOpacity(0);
node.getTextShape().fill(node.getData('fontcolor') || 'white');
}
break;
default:
break;
}
}
};
this.addLayoutStyle("default", _style);
......
......@@ -283,21 +283,21 @@ KityMinder.registerModule("LayoutModule", function () {
cmdName: 'removenode'
}, {
divider: 1
},{
label: this.getLang('layout.default'),
exec: function () {
this.execCommand('switchlayout','default');
this.initStyle();
},
cmdName: 'switchlayout'
},{
label: this.getLang('layout.bottom'),
exec: function () {
this.execCommand('switchlayout', 'bottom');
this.initStyle();
},
cmdName: 'switchlayout'
}
}, {
label: this.getLang('layout.default'),
exec: function () {
this.execCommand('switchlayout', 'default');
this.initStyle();
},
cmdName: 'switchlayout'
}, {
label: this.getLang('layout.bottom'),
exec: function () {
this.execCommand('switchlayout', 'bottom');
this.initStyle();
},
cmdName: 'switchlayout'
}
],
"defaultOptions": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment