Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 93   Methods: 3
NCLOC: 66   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UpdateTool.java 0% 0% 0% 0%
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.gui.palette;
 19   
 20    import java.awt.BorderLayout;
 21    import java.awt.Dimension;
 22   
 23    import javax.swing.ImageIcon;
 24    import javax.swing.JDialog;
 25    import javax.swing.JToggleButton;
 26   
 27    import org.ericmignot.modeler.action.UpdateAction;
 28    import org.ericmignot.modeler.gui.StaticValues;
 29    import org.ericmignot.modeler.gui.workarea.Item;
 30    import org.ericmignot.modeler.gui.workarea.Updatable;
 31    import org.ericmignot.modeler.util.action.NotifyableAction;
 32   
 33    public class UpdateTool extends ItemPaletteTool
 34    {
 35   
 36  0 public JToggleButton getButton()
 37    {
 38  0 if (this.button == null)
 39    {
 40  0 this.button = new JToggleButton(
 41    StaticValues.getInstance().get("Design.Palette.Update", "Update"),
 42    new ImageIcon(this.getClass().getClassLoader().getResource(
 43    "org/ericmignot/modeler/gui/palette/update.gif")));
 44  0 this.button.setToolTipText(StaticValues.getInstance().get("Design.Palette.UpdateTooltip", "Update tool"));
 45    }
 46  0 return this.button;
 47    }
 48   
 49  0 public boolean isItemCandidate(Item item)
 50    {
 51  0 return (item != null && (item instanceof Updatable));
 52    }
 53   
 54  0 public NotifyableAction getAction(Item item, int x, int y)
 55    {
 56  0 if (! ((Updatable)item).acceptUpdate(x, y))
 57    {
 58  0 return null;
 59    }
 60   
 61  0 UpdatePanel updatePanel = ((Updatable)item).createUpdatePanel();
 62  0 if (updatePanel == null)
 63    {
 64  0 return null;
 65    }
 66  0 JDialog updateDialog = new JDialog();
 67  0 updateDialog.setTitle("Update object");
 68  0 updatePanel.setBusinessObject(item.getBusinessObject());
 69  0 updatePanel.setDialog(updateDialog);
 70   
 71  0 updateDialog.getContentPane().setLayout(new BorderLayout());
 72  0 updateDialog.getContentPane().add(updatePanel);
 73  0 updateDialog.setModal(true);
 74  0 Dimension size = updatePanel.getPreferredSize();
 75  0 size.height += 40 + 25;
 76  0 updateDialog.setSize(size);
 77  0 updateDialog.setLocation(item.getLocationOnScreen());
 78  0 updateDialog.setVisible(true);
 79  0 if (updatePanel.getState() == UpdatePanel.OK)
 80    {
 81  0 UpdateAction updateAction = new UpdateAction(
 82    item.getBusinessObject(),
 83    updatePanel.getNewValues()
 84    );
 85  0 return updateAction;
 86    }
 87    else
 88    {
 89  0 return null;
 90    }
 91    }
 92   
 93    }