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 | 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"; | |
64 | 31 | public StringPropertySwixMLRepresentation() { |
65 | ||
66 | try { | |
67 | ||
68 | 31 | this.panel = |
69 | (JPanel) (new SwingEngine(this)).render(ClassLoader.getSystemClassLoader().getResource(UI_DEF_FILE_NAME)); | |
70 | ||
71 | 0 | } catch (Exception exception) { |
72 | ||
73 | this.logger.error("", exception); | |
74 | ||
75 | 31 | } |
76 | ||
77 | 31 | } |
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 | ||
85 | 30 | StringProperty targetProperty = null; |
86 | ||
87 | 30 | if (property instanceof StringProperty) { |
88 | ||
89 | 30 | targetProperty = (StringProperty) property; |
90 | ||
91 | 30 | this.propertyNameLabel.setText(targetProperty.getName()); |
92 | ||
93 | 30 | if (targetProperty.getValue()!=null) |
94 | { | |
95 | 25 | this.propertyValueTextField.setText( |
96 | targetProperty.getValue().toString()); | |
97 | } | |
98 | ||
99 | 30 | if (property.isReadOnly()) { |
100 | ||
101 | 0 | this.propertyValueTextField.setEditable(false); |
102 | ||
103 | } | |
104 | ||
105 | } else { | |
106 | ||
107 | 0 | throw new RuntimeException( |
108 | getClass() | |
109 | + " can only represent instances of class " | |
110 | 0 | + (StringProperty.class) |
111 | + ", but not those of class " | |
112 | + property.getClass()); | |
113 | ||
114 | } | |
115 | ||
116 | 30 | } |
117 | ||
118 | /** | |
119 | * @return | |
120 | */ | |
121 | ||
122 | public JPanel getPanel() { | |
123 | ||
124 | 29 | 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 | ||
134 | 2 | if (property instanceof StringProperty) { |
135 | ||
136 | 2 | property.setValue(this.propertyValueTextField.getText()); |
137 | ||
138 | } else { | |
139 | ||
140 | 0 | 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 | ||
149 | 2 | } |
150 | ||
151 | /* (non-Javadoc) | |
152 | * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#isEnteredDataValid() | |
153 | */ | |
154 | ||
155 | public boolean isEnteredDataValid() { | |
156 | ||
157 | 2 | return true; |
158 | ||
159 | } | |
160 | ||
161 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |