1
/* This notice must be untouched at all times.
4
The latest version is available at
5
http://www.openjacob.org
7
Copyright (c) 2006 Andreas Herz. All rights reserved.
8
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )
12
This library is free software; you can redistribute it and/or
13
modify it under the terms of the GNU Lesser General Public
14
License (LGPL) as published by the Free Software Foundation; either
15
version 2.1 of the License, or (at your option) any later version.
17
This library is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
Lesser General Public License for more details.
22
You should have received a copy of the GNU Lesser General Public
23
License along with this library; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
25
or see http://www.gnu.org/copyleft/lesser.html
31
* @author Andreas Herz
34
draw2d.CommandDelete=function(/*:draw2d.Figure*/ figure)
36
draw2d.Command.call(this,"delete figure");
37
this.parent = figure.parent; // CompartmentFigure
39
this.workflow = figure.workflow;
40
this.connections = null;
43
draw2d.CommandDelete.prototype = new draw2d.Command;
45
draw2d.CommandDelete.prototype.type="CommandDelete";
48
* Execute the command the first time
51
draw2d.CommandDelete.prototype.execute=function()
60
draw2d.CommandDelete.prototype.undo=function()
62
this.workflow.addFigure(this.figure);
63
if(this.figure instanceof draw2d.Connection)
64
this.figure.reconnect();
66
this.workflow.setCurrentSelection(this.figure);
68
this.parent.addChild(this.figure);
69
for (var i = 0; i < this.connections.getSize(); ++i)
71
this.workflow.addFigure(this.connections.get(i));
72
this.connections.get(i).reconnect();
76
/** Redo the command after the user has undo this command
79
draw2d.CommandDelete.prototype.redo=function()
81
this.workflow.removeFigure(this.figure);
82
this.workflow.setCurrentSelection(null);
83
if(this.figure.getPorts && this.connections==null)
85
this.connections = new draw2d.ArrayList();
86
var ports = this.figure.getPorts();
87
for(var i=0; i<ports.getSize(); i++)
89
if(ports.get(i).getConnections)
90
this.connections.addAll(ports.get(i).getConnections());
94
if(this.connections == null)
95
this.connections = new draw2d.ArrayList();
98
// remove this figure from the parent CompartmentFigure
100
if(this.parent!=null)
101
this.parent.removeChild(this.figure);
104
for (var i = 0; i < this.connections.getSize(); ++i)
106
this.workflow.removeFigure(this.connections.get(i));