Line | Hits | Source |
---|---|---|
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 | * Created on 10.02.2004 | |
32 | */ | |
33 | package net.sourceforge.demetrix.properties.swixml; | |
34 | ||
35 | import javax.swing.JLabel; | |
36 | import javax.swing.JPanel; | |
37 | import javax.swing.JTextField; | |
38 | ||
39 | import org.apache.log4j.Logger; | |
40 | import org.swixml.SwingEngine; | |
41 | ||
42 | import net.sourceforge.demetrix.properties.DemetrixProperty; | |
43 | ||
44 | /** | |
45 | * @author Dimitri Pissarenko | |
46 | * | |
47 | */ | |
48 | public class IntegerPropertySwixMLRepresentation | |
49 | implements SwixMLDemetrixPropertyRepresentation { | |
50 | private Logger logger = Logger.getLogger(getClass()); | |
51 | ||
52 | private JPanel panel; | |
53 | ||
54 | public JLabel propertyNameLabel; | |
55 | ||
56 | public JTextField propertyValueTextField; | |
57 | public final static String UI_DEF_FILE_NAME = | |
58 | "net/sourceforge/demetrix/properties/swixml/IntegerPropertySwixMLRepresentation.xml"; | |
59 | ||
60 | 11 | public IntegerPropertySwixMLRepresentation() { |
61 | ||
62 | try { | |
63 | ||
64 | 11 | this.panel = |
65 | (JPanel) (new SwingEngine(this)).render( | |
66 | ClassLoader.getSystemClassLoader().getResource( | |
67 | UI_DEF_FILE_NAME)); | |
68 | ||
69 | 0 | } catch (Exception exception) { |
70 | ||
71 | this.logger.error("", exception); | |
72 | ||
73 | 11 | } |
74 | ||
75 | 11 | } |
76 | ||
77 | /* (non-Javadoc) | |
78 | * @see net.sourceforge.demetrix.properties.swixml.SwixMLDemetrixPropertyRepresentation#getPanel() | |
79 | */ | |
80 | public JPanel getPanel() { | |
81 | 7 | return this.panel; |
82 | } | |
83 | ||
84 | /* (non-Javadoc) | |
85 | * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#isEnteredDataValid() | |
86 | */ | |
87 | public boolean isEnteredDataValid() { | |
88 | try | |
89 | { | |
90 | 5 | Integer.parseInt(this.propertyValueTextField.getText()); |
91 | 3 | return true; |
92 | } | |
93 | 2 | catch (NumberFormatException exception) |
94 | { | |
95 | 2 | return false; |
96 | } | |
97 | } | |
98 | ||
99 | /* (non-Javadoc) | |
100 | * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#updatePropertyData(net.sourceforge.demetrix.properties.DemetrixProperty) | |
101 | */ | |
102 | public void updatePropertyData(DemetrixProperty property) { | |
103 | 4 | String valueAsString=null; |
104 | 4 | int valueAsInt=0; |
105 | ||
106 | 4 | valueAsString=this.propertyValueTextField.getText(); |
107 | try | |
108 | { | |
109 | 4 | valueAsInt=Integer.parseInt(valueAsString); |
110 | 3 | property.setValue(new Integer(valueAsInt)); |
111 | } | |
112 | 1 | catch (NumberFormatException exception) |
113 | { | |
114 | 3 | } |
115 | 4 | } |
116 | ||
117 | /* (non-Javadoc) | |
118 | * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#updateRepresentation(net.sourceforge.demetrix.properties.DemetrixProperty) | |
119 | */ | |
120 | public void updateRepresentation(DemetrixProperty property) { | |
121 | 7 | this.propertyNameLabel.setText(property.getName()); |
122 | 7 | this.propertyValueTextField.setText(property.getValue().toString()); |
123 | 7 | } |
124 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |