Coverage Report - org.xmlhammer.gui.preferences.PropertiesPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertiesPanel
85% 
100% 
0
 
 1  
 /*
 2  
  * $Id: PropertiesPanel.java,v 1.12 2007/06/19 19:29:03 edankert Exp $
 3  
  *
 4  
  * The contents of this file are subject to the Mozilla Public License 
 5  
  * Version 1.1 (the "License"); you may not use this file except in 
 6  
  * compliance with the License. You may obtain a copy of the License at 
 7  
  * http://www.mozilla.org/MPL/ 
 8  
  *
 9  
  * Software distributed under the License is distributed on an "AS IS" basis, 
 10  
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 11  
  * for the specific language governing rights and limitations under the License.
 12  
  *
 13  
  * The Original Code is XML Hammer code. (org.xmlhammer.*)
 14  
  *
 15  
  * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
 16  
  * by the Initial Developer are Copyright (C) 2002 - 2006 the Initial Developer. 
 17  
  * All Rights Reserved.
 18  
  *
 19  
  * Contributor(s): Edwin Dankert <edankert@gmail.com>
 20  
  */
 21  
 
 22  
 package org.xmlhammer.gui.preferences;
 23  
 
 24  
 import java.util.ArrayList;
 25  
 import java.util.List;
 26  
 
 27  
 import javax.swing.JFrame;
 28  
 import javax.swing.table.DefaultTableModel;
 29  
 
 30  
 import org.xmlhammer.model.jaxp.Property;
 31  
 
 32  
 /**
 33  
  * This PrefixNamespaceMappingPanel is used to ...
 34  
  *
 35  
  * @version $Revision: 1.12 $, $Date: 2007/06/19 19:29:03 $
 36  
  * @author Edwin Dankert <edankert@gmail.com>
 37  
  */
 38  
 public class PropertiesPanel extends PreferencesTablePanel {
 39  
         private static final long serialVersionUID = 3403969820780811484L;
 40  
 
 41  
         public PropertiesPanel(JFrame parent, String name, String helpID) {
 42  44
                 this( parent, name, helpID, false);
 43  44
         }
 44  
         
 45  
         public PropertiesPanel(JFrame parent, String name, String helpID, boolean project) {
 46  110
                 super( parent, name, helpID, project);
 47  110
         }
 48  
     
 49  
     protected DefaultTableModel getModel() {
 50  506
         if ( model == null) {
 51  110
             model = new ActivatableTableModel();
 52  110
             model.setColumnCount(3);
 53  110
             model.setColumnIdentifiers( new String[] {" ", "Name", "Value"});
 54  
         }
 55  
         
 56  506
         return model;
 57  
     }
 58  
         
 59  
     protected Object[] getDefaultRowContent() {
 60  0
         return new Object[] {Boolean.TRUE, "New Property Name", "New Property Value"};
 61  
     }
 62  
 
 63  
     protected int[] getColumnWidths() {
 64  110
         return new int[] {25, 500, 500};
 65  
     }
 66  
 
 67  
     public void setProperties( List<Property> properties) {
 68  110
                 while (getModel().getRowCount() > 0) {
 69  0
             getModel().removeRow(0);
 70  0
                 }
 71  
                 
 72  154
                 for (int i = 0; i < properties.size(); i++) {
 73  44
             Property property = properties.get(i);
 74  
 
 75  44
             getModel().addRow(new Object[] {property.isActive(), property.getName(), property.getValue()});
 76  
                 }
 77  110
         }
 78  
         
 79  
         public List<Property> getProperties() {
 80  66
                 List<Property> properties = new ArrayList<Property>();
 81  
 
 82  110
                 for ( int i = 0; i < getModel().getRowCount(); i++) {
 83  44
                         Property property = new Property();
 84  44
             property.setActive((Boolean)getModel().getValueAt(i, 0));
 85  44
                         property.setName((String)getModel().getValueAt(i, 1));
 86  44
                         property.setValue((String)getModel().getValueAt(i, 2));
 87  
                         
 88  44
                         properties.add( property);
 89  
                 }
 90  
                 
 91  66
                 return properties;
 92  
         }
 93  
 
 94  
     @Override
 95  
     protected String getName(int row) {
 96  0
         return getModel().getValueAt(row, 1).toString();
 97  
     }
 98  
 }