Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 104   Methods: 7
NCLOC: 79   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimplePointDeleteAction.java 58.3% 86.7% 71.4% 77.6%
coverage coverage
 1    /*
 2    * Copyright (C) 2007 Eric MIGNOT - mignots.eric@free.fr
 3    *
 4    * This library is free software; you can redistribute it and/or
 5    * modify it under the terms of the GNU Lesser General Public
 6    * License as published by the Free Software Foundation; either
 7    * version 2.1 of the License, or (at your option) any later version.
 8    *
 9    * This library is distributed in the hope that it will be useful,
 10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12    * Lesser General Public License for more details.
 13    *
 14    * You should have received a copy of the GNU Lesser General Public
 15    * License along with this library; if not, write to the Free Software
 16    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18    package org.ericmignot.modeler.action;
 19   
 20    import java.util.List;
 21   
 22    import org.ericmignot.modeler.data.Link;
 23    import org.ericmignot.modeler.data.Model;
 24    import org.ericmignot.modeler.data.SimplePoint;
 25    import org.ericmignot.modeler.util.action.ActionException;
 26    import org.ericmignot.modeler.util.action.NotifyableAction;
 27   
 28    public class SimplePointDeleteAction extends NotifyableAction
 29    {
 30    private SimplePoint target;
 31    private Model model;
 32    private List referencingBos;
 33    private Link startLink;
 34    private Link rootLink;
 35    private Link removedLink;
 36   
 37  2 public SimplePointDeleteAction(SimplePoint target, Model model)
 38    {
 39  2 this.target = target;
 40  2 this.model = model;
 41  2 this.referencingBos = model.getReferencingBos(target);
 42  2 this.startLink = this.getRemovedLinkToPoint();
 43  2 this.rootLink = model.getRootLink(this.startLink);
 44  2 this.removedLink = this.getRemovedLinkFromPoint();
 45    }
 46   
 47  0 public Link getStartLink()
 48    {
 49  0 return this.startLink;
 50    }
 51  0 public Link getRemovedLink()
 52    {
 53  0 return this.removedLink;
 54    }
 55   
 56  2 public Object execute(Object actionParameter) throws ActionException
 57    {
 58  2 this.model.removeBusinessObject(this.removedLink);
 59  2 this.model.removeBusinessObjectQuiet(this.target);
 60  2 this.startLink.setLinkEnd(this.removedLink.getLinkEnd());
 61  2 this.rootLink.removePoint(this.target.getCenter());
 62  2 return this.target;
 63    }
 64   
 65  1 public Object cancel(Object actionParameter) throws ActionException
 66    {
 67  1 this.model.addBusinessObject(this.target);
 68  1 this.model.addBusinessObject(this.removedLink);
 69  1 this.startLink.setLinkEnd(this.target);
 70  1 this.rootLink.addPoint(this.target.getCenter());
 71  1 return this.target;
 72    }
 73   
 74  2 protected Link getRemovedLinkToPoint()
 75    {
 76  2 for (int i=0; i<this.referencingBos.size(); i++)
 77    {
 78  2 if (this.referencingBos.get(i) instanceof Link)
 79    {
 80  2 Link link = (Link) this.referencingBos.get(i);
 81  2 if (link.getLinkEnd() == this.target)
 82    {
 83  2 return link;
 84    }
 85    }
 86    }
 87  0 return null;
 88    }
 89  2 protected Link getRemovedLinkFromPoint()
 90    {
 91  4 for (int i=0; i<this.referencingBos.size(); i++)
 92    {
 93  4 if (this.referencingBos.get(i) instanceof Link)
 94    {
 95  4 Link link = (Link) this.referencingBos.get(i);
 96  4 if (link.getLinkStart() == this.target)
 97    {
 98  2 return link;
 99    }
 100    }
 101    }
 102  0 return null;
 103    }
 104    }