| 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 | import java.text.DecimalFormat; | |
| 34 | ||
| 35 | import javax.swing.JLabel; | |
| 36 | ||
| 37 | import javax.swing.JPanel; | |
| 38 | ||
| 39 | import javax.swing.JTextField; | |
| 40 | ||
| 41 | import org.apache.log4j.Logger; | |
| 42 | ||
| 43 | import org.swixml.SwingEngine; | |
| 44 | ||
| 45 | import net.sourceforge.demetrix.properties.DemetrixProperty; | |
| 46 | ||
| 47 | ||
| 48 | public class DoublePropertySwixMLRepresentation | |
| 49 | implements SwixMLDemetrixPropertyRepresentation { | |
| 50 | ||
| 51 | private Logger logger = Logger.getLogger(getClass()); | |
| 52 | ||
| 53 | private JPanel panel; | |
| 54 | ||
| 55 | public JLabel propertyNameLabel; | |
| 56 | ||
| 57 | public JTextField propertyValueTextField; | |
| 58 | public final static String UI_DEF_FILE_NAME="net/sourceforge/demetrix/properties/swixml/DoublePropertySwixMLRepresentation.xml"; | |
| 59 | ||
| 60 | 8 | public DoublePropertySwixMLRepresentation() { |
| 61 | ||
| 62 | ||
| 63 | try { | |
| 64 | ||
| 65 | 8 | this.panel = |
| 66 | (JPanel) (new SwingEngine(this)).render( | |
| 67 | ClassLoader.getSystemClassLoader().getResource(UI_DEF_FILE_NAME)); | |
| 68 | ||
| 69 | 0 | } catch (Exception exception) { |
| 70 | ||
| 71 | this.logger.error("", exception); | |
| 72 | ||
| 73 | 8 | } |
| 74 | ||
| 75 | 8 | } |
| 76 | ||
| 77 | /* (non-Javadoc) | |
| 78 | * @see net.sourceforge.demetrix.properties.swixml.SwixMLDemetrixPropertyRepresentation#getPanel() | |
| 79 | */ | |
| 80 | ||
| 81 | public JPanel getPanel() { | |
| 82 | ||
| 83 | 7 | return this.panel; |
| 84 | ||
| 85 | } | |
| 86 | ||
| 87 | /* (non-Javadoc) | |
| 88 | * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#updatePropertyData(net.sourceforge.demetrix.properties.DemetrixProperty) | |
| 89 | */ | |
| 90 | ||
| 91 | public void updatePropertyData(DemetrixProperty property) { | |
| 92 | ||
| 93 | 2 | String valueAsText = null; |
| 94 | ||
| 95 | 2 | double valueAsDouble = 0.; |
| 96 | ||
| 97 | 2 | valueAsText = this.propertyValueTextField.getText(); |
| 98 | ||
| 99 | try { | |
| 100 | ||
| 101 | 2 | valueAsDouble = Double.parseDouble(valueAsText); |
| 102 | ||
| 103 | 2 | property.setValue(new Double(valueAsDouble)); |
| 104 | ||
| 105 | 0 | } catch (NumberFormatException exception) { |
| 106 | ||
| 107 | 2 | } |
| 108 | ||
| 109 | 2 | } |
| 110 | ||
| 111 | /* (non-Javadoc) | |
| 112 | * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#updateRepresentation(net.sourceforge.demetrix.properties.DemetrixProperty) | |
| 113 | */ | |
| 114 | ||
| 115 | public void updateRepresentation(DemetrixProperty property) { | |
| 116 | ||
| 117 | 6 | DecimalFormat format = null; |
| 118 | ||
| 119 | 6 | this.propertyNameLabel.setText(property.getName()); |
| 120 | ||
| 121 | 6 | this.propertyValueTextField.setText( |
| 122 | "" + ((Double) property.getValue()).doubleValue()); | |
| 123 | ||
| 124 | 6 | } |
| 125 | ||
| 126 | /* (non-Javadoc) | |
| 127 | * @see net.sourceforge.demetrix.properties.DemetrixPropertyRepresentation#isEnteredDataValid() | |
| 128 | */ | |
| 129 | ||
| 130 | public boolean isEnteredDataValid() { | |
| 131 | ||
| 132 | try { | |
| 133 | ||
| 134 | 2 | Double.parseDouble(this.propertyValueTextField.getText()); |
| 135 | ||
| 136 | 2 | return true; |
| 137 | ||
| 138 | 0 | } catch (NumberFormatException exception) { |
| 139 | ||
| 140 | 0 | return false; |
| 141 | ||
| 142 | } | |
| 143 | ||
| 144 | } | |
| 145 | ||
| 146 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |