Clover coverage report - Graph - 1.0.0
Coverage timestamp: ven. déc. 26 2003 02:14:20 CET
file stats: LOC: 97   Methods: 2
NCLOC: 60   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
GraphConsumerSelector.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * EJTools, the Enterprise Java Tools
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at www.gnu.org.
 6   
  */
 7   
 package org.ejtools.graph.service;
 8   
 
 9   
 import java.util.Arrays;
 10   
 import java.util.List;
 11   
 import java.util.ResourceBundle;
 12   
 
 13   
 import org.ejtools.graph.dialog.SelectGraphDialog;
 14   
 import org.ejtools.graph.frame.GraphInternalFrame;
 15   
 
 16   
 /**
 17   
  * Description of the Class
 18   
  *
 19   
  * @author    Laurent Etiemble
 20   
  * @version   $Revision: 1.5 $
 21   
  */
 22   
 public abstract class GraphConsumerSelector
 23   
 {
 24   
    /** Description of the Field */
 25   
    private static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.graph.GraphService");
 26   
 
 27   
 
 28   
    /**
 29   
     * Description of the Method
 30   
     *
 31   
     * @param mediator  Description of the Parameter
 32   
     * @param name      Description of the Parameter
 33   
     * @return          Description of the Return Value
 34   
     */
 35  0
    public static GraphConsumer select(GraphConsumerMediator mediator, String name)
 36   
    {
 37  0
       GraphConsumer[] consumers = mediator.getGraphConsumers();
 38  0
       GraphConsumer consumer = null;
 39   
 
 40  0
       for (int i = 0; i < consumers.length; i++)
 41   
       {
 42  0
          GraphConsumer gc = consumers[i];
 43  0
          if (gc.toString().equals(name))
 44   
          {
 45  0
             consumer = gc;
 46   
          }
 47   
       }
 48   
 
 49  0
       if (consumer == null)
 50   
       {
 51  0
          GraphInternalFrame frame = new GraphInternalFrame();
 52  0
          frame.setName(name);
 53  0
          consumer = frame;
 54   
       }
 55   
 
 56  0
       return consumer;
 57   
    }
 58   
 
 59   
 
 60   
    /**
 61   
     * @param mediator  Description of the Parameter
 62   
     * @return          Description of the Return Value
 63   
     */
 64  0
    public static GraphConsumer selectWithDialog(GraphConsumerMediator mediator)
 65   
    {
 66  0
       GraphConsumer[] consumers = mediator.getGraphConsumers();
 67  0
       List choices = Arrays.asList(consumers);
 68  0
       Object initial = resources.getString("graph.text.untitled");
 69  0
       if (choices.size() > 0)
 70   
       {
 71  0
          initial = choices.get(0);
 72   
       }
 73  0
       SelectGraphDialog dialog = new SelectGraphDialog(null, choices.toArray(), initial);
 74  0
       dialog.show();
 75  0
       Object selectedValue = dialog.getSelectedValue();
 76   
 
 77  0
       if (selectedValue == null)
 78   
       {
 79  0
          return null;
 80   
       }
 81   
 
 82  0
       int idx = choices.indexOf(selectedValue);
 83  0
       GraphConsumer consumer = null;
 84  0
       if (idx < 0)
 85   
       {
 86  0
          GraphInternalFrame frame = new GraphInternalFrame();
 87  0
          frame.setName("" + selectedValue);
 88  0
          consumer = frame;
 89   
       }
 90   
       else
 91   
       {
 92  0
          consumer = (GraphConsumer) choices.get(idx);
 93   
       }
 94  0
       return consumer;
 95   
    }
 96   
 }
 97