2012-07-16 70 views
0

我想刪除draw2d.js中兩個對象之間的連接。我試圖找到刪除連接的直接方法,但我沒有找到它。所以請告訴我,如果有任何方式或有任何方法可用刪除或斷開連接。 在此先感謝!如何刪除draw2d.js中的連接?

回答

0

沒有CommandStack支持:

canvas.removeFigure(connection); 

CommandStack支持(撤銷/重做):

var cmd = new draw2d.CommandDelete(connection); 
canvas.getCommandStack().excute(cmd); 
+0

謝謝這個工程。但需要做一次更改請在「執行」時使用正確的拼寫, – 2012-07-19 10:30:56

0
draw2d.ContextmenuConnection.prototype.getContextMenu = function() {  
    var menu = new draw2d.Menu(); 
    menu.appendMenuItem(new draw2d.MenuItem("Disconnect", null, function() { 
     //draw2d.Connection.workflow.removeFigure(draw2d.Connection.prototype); 
     var cmd = new draw2d.CommandDelete(**draw2d.Connection**); 
     draw2d.Connection.prototype.workflow.getCommandStack().excute(cmd); 
    })); 

}; 

你必須移交對象到CommandDelete的構造和NOT Draw2D的。連接

見下:

draw2d.ContextmenuConnection.prototype.getContextMenu = function() {  
    var menu = new draw2d.Menu(); 
    var oThis = this; 
    menu.appendMenuItem(new draw2d.MenuItem("Disconnect", null, function() { 
     //draw2d.Connection.workflow.removeFigure(draw2d.Connection.prototype); 
     var cmd = new draw2d.CommandDelete(oThis); 
     draw2d.Connection.prototype.workflow.getCommandStack().excute(cmd); 
    })); 

};