Coverage Report - us.paulevans.basicxslt.ParameterTextFieldGroup
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterTextFieldGroup
0%
0/28
0%
0/3
1.5
 
 1  
 /*
 2  
         Copyright 2006 Paul Evans 
 3  
 
 4  
         Licensed under the Apache License, Version 2.0 (the "License"); 
 5  
         you may not use this file except in compliance with the License. 
 6  
         You may obtain a copy of the License at 
 7  
 
 8  
                 http://www.apache.org/licenses/LICENSE-2.0 
 9  
 
 10  
         Unless required by applicable law or agreed to in writing, software 
 11  
         distributed under the License is distributed on an "AS IS" BASIS, 
 12  
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 13  
         See the License for the specific language governing permissions and 
 14  
         limitations under the License.
 15  
  */
 16  
 package us.paulevans.basicxslt;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import javax.swing.JCheckBox;
 21  
 import javax.swing.JPanel;
 22  
 import javax.swing.JTextField;
 23  
 
 24  
 /**
 25  
  * Helper class used by the TransformParametersFrame - models each parameter
 26  
  * row in the parameters-frame and provides a 'remove-row' method.
 27  
  * @author pevans
 28  
  *
 29  
  */
 30  
 public class ParameterTextFieldGroup {
 31  
         
 32  
         // instance members...
 33  
         private JPanel parent;
 34  
         private JTextField paramName, paramValue, paramNamespaceURI;
 35  
         private JCheckBox removeCb;
 36  
 
 37  
         /**
 38  
          * Constructor
 39  
          * @param aParent
 40  
          * @param aParamName
 41  
          * @param aParamValue
 42  
          * @param aParamNamespaceURI
 43  
          * @param aRemoveCb
 44  
          */
 45  
         public ParameterTextFieldGroup(JPanel aParent, JTextField aParamName,
 46  
                 JTextField aParamValue, JTextField aParamNamespaceURI,
 47  0
                 JCheckBox aRemoveCb) {
 48  0
                 parent = aParent;
 49  0
                 paramName = aParamName;
 50  0
                 paramValue = aParamValue;
 51  0
                 removeCb = aRemoveCb;
 52  0
                 paramNamespaceURI = aParamNamespaceURI;
 53  0
         }
 54  
         
 55  
         /**
 56  
          * Getter
 57  
          * @return
 58  
          */
 59  
         public JCheckBox getRemoveCb() {
 60  0
                 return removeCb;
 61  
         }
 62  
 
 63  
         /**
 64  
          * Getter
 65  
          * @return
 66  
          */
 67  
         public JTextField getParamNameTf() {
 68  0
                 return paramName;
 69  
         }
 70  
         
 71  
         /**
 72  
          * Getter
 73  
          * @return
 74  
          */
 75  
         public JTextField getParamValueTf() {
 76  0
                 return paramValue;
 77  
         }
 78  
         
 79  
         /**
 80  
          * Getter
 81  
          * @return
 82  
          */
 83  
         public JTextField getParamNamespaceURITf() {
 84  0
                 return paramNamespaceURI;
 85  
         }
 86  
         
 87  
         /**
 88  
          * Loops over aRows - for each row the components are removed from their
 89  
          * parent panel.
 90  
          * @param aRows
 91  
          * @return
 92  
          */
 93  
         public static int removeChecked(List aRows) {
 94  
                 
 95  
                 int loop, size, numRemoved;
 96  
                 ParameterTextFieldGroup parameterTfGrp;
 97  
                 JPanel parent;
 98  
                 
 99  0
                 numRemoved = 0;
 100  0
                 size = aRows.size();
 101  0
                 parent = null;
 102  0
                 for (loop = size -1; loop >= 0; loop--) {
 103  0
                         parameterTfGrp = (ParameterTextFieldGroup)aRows.get(loop);
 104  0
                         parent = parameterTfGrp.parent;
 105  0
                         if (parameterTfGrp.removeCb.isSelected()) {
 106  0
                                 parameterTfGrp.parent.remove(parameterTfGrp.paramName);
 107  0
                                 parameterTfGrp.parent.remove(parameterTfGrp.paramValue);
 108  0
                                 parameterTfGrp.parent.remove(parameterTfGrp.paramNamespaceURI);
 109  0
                                 parameterTfGrp.parent.remove(parameterTfGrp.removeCb);
 110  0
                                 aRows.remove(loop);                                
 111  0
                                 numRemoved++;
 112  
                         }
 113  
                 }
 114  0
                 if (numRemoved > 0) {
 115  0
                         parent.repaint();
 116  0
                         parent.revalidate();
 117  
                 }
 118  0
                 return numRemoved;
 119  
         }
 120  
 }