Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 141   Methods: 2
NCLOC: 121   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AppletviewerEditor.java 0% 0% 0% 0%
coverage
 1   
 package abbot.editor.editors;
 2   
 
 3   
 import java.awt.*;
 4   
 import java.awt.event.ActionEvent;
 5   
 import java.lang.reflect.*;
 6   
 import java.util.*;
 7   
 
 8   
 import javax.swing.*;
 9   
 import javax.swing.border.*;
 10   
 
 11   
 import abbot.i18n.Strings;
 12   
 import abbot.script.Appletviewer;
 13   
 import abbot.editor.widgets.ArrayEditor;
 14   
 
 15   
 /** Provide convenient editing of an applet launch step. */
 16   
 public class AppletviewerEditor extends StepEditor {
 17   
 
 18   
     public static final String HELP_DESC = Strings.get("editor.applet.desc");
 19   
 
 20   
     private Appletviewer applet;
 21   
 
 22   
     private JTextField code;
 23   
     private ArrayEditor params;
 24   
     private JTextField codebase;
 25   
     private JTextField archive;
 26   
     private JTextField width;
 27   
     private JTextField height;
 28   
 
 29  0
     public AppletviewerEditor(Appletviewer applet) {
 30  0
         super(applet);
 31  0
         this.applet = applet;
 32   
 
 33  0
         code = addTextField(Strings.get("editor.applet.code"),
 34   
                             applet.getCode());
 35  0
         width = addTextField(Strings.get("editor.applet.width"),
 36   
                              applet.getWidth());
 37  0
         height = addTextField(Strings.get("editor.applet.height"),
 38   
                               applet.getHeight());
 39   
         // For some reason, if we *don't* futz with the layout of
 40   
         // width/height, the pane never reconfigures properly for the array
 41   
         // editor. 
 42  0
         Component c;
 43  0
         ArrayList list = new ArrayList();
 44  0
         while ((c = getComponent(getComponentCount()-1)) != code) {
 45  0
             remove(c);
 46  0
             list.add(c);
 47   
         }
 48  0
         JPanel p = new JPanel();
 49   
         //p.setBorder(new TitledBorder(Strings.get("editor.applet.size")));
 50  0
         p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
 51  0
         for (int i=list.size()-1;i >= 0;i--) {
 52  0
             p.add((Component)list.get(i));
 53  0
             if (i != 0)
 54  0
                 p.add(Box.createHorizontalStrut(MARGIN));
 55   
         }
 56  0
         add(p);
 57   
 
 58  0
         params = addArrayEditor(Strings.get("editor.applet.params"),
 59   
                                 applet.getParamsAsArray());
 60   
 
 61  0
         codebase = addTextField(Strings.get("editor.applet.codebase"),
 62   
                                 applet.getCodebase());
 63  0
         archive = addTextField(Strings.get("editor.applet.archive"),
 64   
                                applet.getArchive());
 65   
     }
 66   
 
 67  0
     public void actionPerformed(ActionEvent ev) {
 68  0
         Object src = ev.getSource();
 69  0
         if (src == code) {
 70  0
             applet.setCode(code.getText());
 71  0
             fireStepChanged();
 72   
         }
 73  0
         else if (src == params) {
 74  0
             Object[] values = params.getValues();
 75  0
             Map map = new HashMap();
 76  0
             for (int i=0;i < values.length;i++) {
 77  0
                 String v = (String)values[i];
 78  0
                 int eq = v.indexOf("=");
 79  0
                 if (eq != -1) {
 80  0
                     String key = v.substring(0, eq);
 81  0
                     String value = v.substring(eq+1);
 82  0
                     map.put(key, value);
 83   
                 }
 84   
             }
 85  0
             applet.setParams(map);
 86  0
             fireStepChanged();
 87   
         }
 88  0
         else if (src == codebase) {
 89  0
             String value = codebase.getText();
 90  0
             if ("".equals(value))
 91  0
                 value = null;
 92  0
             applet.setCodebase(value);
 93  0
             fireStepChanged();
 94   
         }
 95  0
         else if (src == archive) {
 96  0
             String value = archive.getText();
 97  0
             if ("".equals(value))
 98  0
                 value = null;
 99  0
             applet.setArchive(value);
 100  0
             fireStepChanged();
 101   
         }
 102  0
         else if (src == width) {
 103  0
             String value = width.getText();
 104  0
             if ("".equals(value))
 105  0
                 value = null;
 106  0
             try {
 107  0
                 Integer.parseInt(value);
 108  0
                 applet.setWidth(value);
 109  0
                 width.setForeground(DEFAULT_FOREGROUND);
 110  0
                 fireStepChanged();
 111   
             }
 112   
             catch(NumberFormatException e) {
 113  0
                 width.setForeground(ERROR_FOREGROUND);
 114   
             }
 115   
         }
 116  0
         else if (src == height) {
 117  0
             String value = height.getText();
 118  0
             if ("".equals(value))
 119  0
                 value = null;
 120  0
             try {
 121  0
                 Integer.parseInt(value);
 122  0
                 applet.setHeight(value);
 123  0
                 width.setForeground(DEFAULT_FOREGROUND);
 124  0
                 fireStepChanged();
 125   
             }
 126   
             catch(NumberFormatException e) {
 127  0
                 width.setForeground(ERROR_FOREGROUND);
 128   
             }
 129   
         }
 130   
         else {
 131  0
             super.actionPerformed(ev);
 132   
         }
 133   
 
 134   
         // Remove the default placeholder description
 135  0
         if (HELP_DESC.equals(applet.getDescription())) {
 136  0
             applet.setDescription(null);
 137  0
             fireStepChanged();
 138   
         }
 139   
     }
 140   
 }
 141