Coverage details for net.sourceforge.demetrix.properties.swixml.StringPropertySwixMLRepresentation

LineHitsSource
1 /*******************************************************************************
2  * Demetrix process modelling system
3  *
4  * Copyright (c) 2003, 2004 Dimitri A. Pissarenko
5  *
6  * This file is part of Demetrix.
7  *
8  * Demetrix is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * Demetrix is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Demetrix; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * For further information you may
23  *
24  * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net
25  * - look at http://sourceforge.net/projects/demetrix/
26  * - look at http://demetrix.sourceforge.net/
27  * - look at http://members.inode.at/d.pissarenko/
28  *
29  *****************************************************************************/
30  
31 package net.sourceforge.demetrix.properties.swixml;
32  
33  
34 import javax.swing.JLabel;
35  
36 import javax.swing.JPanel;
37  
38 import javax.swing.JTextField;
39  
40 import net.sourceforge.demetrix.properties.DemetrixProperty;
41  
42 import net.sourceforge.demetrix.properties.StringProperty;
43  
44 import org.apache.log4j.Logger;
45  
46 import org.swixml.SwingEngine;
47  
48 /**
49  * @author Dimitri Pissarenko
50  *
51  */
52  
53 public class StringPropertySwixMLRepresentation
54     implements SwixMLDemetrixPropertyRepresentation {
55  
56     private Logger logger = Logger.getLogger(getClass());
57  
58     private JPanel panel;
59  
60     public JLabel propertyNameLabel;
61  
62     public JTextField propertyValueTextField;
63     public final static String UI_DEF_FILE_NAME="net/sourceforge/demetrix/properties/swixml/StringPropertySwixMLRepresentation.xml";
6431    public StringPropertySwixMLRepresentation() {
65  
66         try {
67  
6831            this.panel =
69                 (JPanel) (new SwingEngine(this)).render(ClassLoader.getSystemClassLoader().getResource(UI_DEF_FILE_NAME));
70  
710        } catch (Exception exception) {
72  
73             this.logger.error("", exception);
74  
7531        }
76  
7731    }
78  
79     /* (non-Javadoc)
80      * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#updateRepresentation(net.sourceforge.demetrix.properties.DemetrixProperty)
81      */
82  
83     public void updateRepresentation(DemetrixProperty property) {
84  
8530        StringProperty targetProperty = null;
86  
8730        if (property instanceof StringProperty) {
88  
8930            targetProperty = (StringProperty) property;
90  
9130            this.propertyNameLabel.setText(targetProperty.getName());
92  
9330            if (targetProperty.getValue()!=null)
94             {
9525                this.propertyValueTextField.setText(
96                     targetProperty.getValue().toString());
97             }
98  
9930            if (property.isReadOnly()) {
100  
1010                this.propertyValueTextField.setEditable(false);
102  
103             }
104  
105         } else {
106  
1070            throw new RuntimeException(
108                 getClass()
109                     + " can only represent instances of class "
1100                    + (StringProperty.class)
111                     + ", but not those of class "
112                     + property.getClass());
113  
114         }
115  
11630    }
117  
118     /**
119      * @return
120      */
121  
122     public JPanel getPanel() {
123  
12429        return panel;
125  
126     }
127  
128     /* (non-Javadoc)
129      * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#updatePropertyData(net.sourceforge.demetrix.properties.DemetrixProperty)
130      */
131  
132     public void updatePropertyData(DemetrixProperty property) {
133  
1342        if (property instanceof StringProperty) {
135  
1362            property.setValue(this.propertyValueTextField.getText());
137  
138         } else {
139  
1400            throw new RuntimeException(
141                 getClass()
142                     + " can only represent instances of class "
143                     + (StringProperty.class)
144                     + ", but not those of class "
145                     + property.getClass());
146  
147         }
148  
1492    }
150  
151     /* (non-Javadoc)
152      * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#isEnteredDataValid()
153      */
154  
155     public boolean isEnteredDataValid() {
156  
1572        return true;
158  
159     }
160  
161 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.