Author: tchemit Date: 2013-11-24 22:52:35 +0100 (Sun, 24 Nov 2013) New Revision: 2754 Url: http://nuiton.org/projects/jaxx/repository/revisions/2754 Log: refs #2929: Introduce some coordinate editors Added: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorHelper.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinate.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinate.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.css trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorHelper.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorHelper.java 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorHelper.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -517,7 +517,8 @@ public static JAXXObjectDescriptor getJAXXObjectDescriptor(Class<?> jaxxClass) { if (!JAXXObject.class.isAssignableFrom(jaxxClass) || - JAXXObject.class.equals(jaxxClass)) { + JAXXObject.class.equals(jaxxClass) || + jaxxClass.isInterface()) { return null; } try { Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinate.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinate.java 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinate.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,5 +1,29 @@ package jaxx.runtime.swing.editor.gis; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import org.jdesktop.beans.AbstractSerializableBean; /** Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinate.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.css =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.css 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.css 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,3 +1,26 @@ +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ #toolbarLeft { floatable:false; borderPainted:false; Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.css ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,3 +1,26 @@ +<!-- + #%L + JAXX :: Widgets + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2013 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> <JPanel id='editorPanel' layout='{new BorderLayout()}' onFocusGained='editor.requestFocus()'> <import> Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,5 +1,29 @@ package jaxx.runtime.swing.editor.gis; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import com.google.common.base.Preconditions; import jaxx.runtime.swing.editor.bean.BeanUIUtil; import org.apache.commons.lang3.StringUtils; Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorHandler.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,5 +1,29 @@ package jaxx.runtime.swing.editor.gis; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import java.io.Serializable; /** Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorModel.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinate.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinate.java 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinate.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,5 +1,29 @@ package jaxx.runtime.swing.editor.gis; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import org.jdesktop.beans.AbstractSerializableBean; /** Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinate.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.css =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.css 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.css 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,3 +1,26 @@ +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ #toolbarLeft { floatable:false; borderPainted:false; Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.css ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,3 +1,26 @@ +<!-- + #%L + JAXX :: Widgets + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2013 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> <JPanel id='editorPanel' layout='{new BorderLayout()}' onFocusGained='editor.requestFocus()'> <import> Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,5 +1,29 @@ package jaxx.runtime.swing.editor.gis; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import com.google.common.base.Preconditions; import jaxx.runtime.swing.editor.bean.BeanUIUtil; import org.apache.commons.lang3.StringUtils; Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorHandler.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java 2013-11-24 08:47:25 UTC (rev 2753) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -1,5 +1,29 @@ package jaxx.runtime.swing.editor.gis; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import java.io.Serializable; /** Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorModel.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Added: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java =================================================================== --- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java (rev 0) +++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -0,0 +1,216 @@ +package jaxx.runtime.swing.editor.gis; + +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.beans.AbstractSerializableBean; + +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.border.TitledBorder; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.text.ParseException; + +/** + * To test the {@link DmsCoordinateEditor}. + * <p/> + * Created on 10/17/13. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 2.6 + */ +public class DmdCoordinateEditorTest { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(DmdCoordinateEditorTest.class); + + public static class EditorBean extends AbstractSerializableBean { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_LONGITUDE_SIGN = "longitudeSign"; + + public static final String PROPERTY_LONGITUDE_DEGREE = "longitudeDegree"; + + public static final String PROPERTY_LONGITUDE_MINUTE = "longitudeMinute"; + + public static final String PROPERTY_LONGITUDE_DECIMAL = "longitudeDecimal"; + + public static final String PROPERTY_LATITUDE_SIGN = "latitudeSign"; + + public static final String PROPERTY_LATITUDE_DEGREE = "latitudeDegree"; + + public static final String PROPERTY_LATITUDE_MINUTE = "latitudeMinute"; + + public static final String PROPERTY_LATITUDE_DECIMAL = "latitudeDecimal"; + + protected final DmdCoordinate longitude = DmdCoordinate.empty(); + + protected final DmdCoordinate latitude = DmdCoordinate.empty(); + + public DmdCoordinate getLongitude() { + return longitude; + } + + public void setLongitudeDegree(Integer degre) { + Object oldValue = longitude.getDegree(); + longitude.setDegree(degre); + firePropertyChange(PROPERTY_LONGITUDE_DEGREE, oldValue, degre); + } + + public void setLongitudeMinute(Integer minute) { + Object oldValue = longitude.getMinute(); + longitude.setMinute(minute); + firePropertyChange(PROPERTY_LONGITUDE_MINUTE, oldValue, minute); + } + + public void setLongitudeDecimal(Integer decimal) { + Object oldValue = longitude.getDecimal(); + longitude.setDecimal(decimal); + firePropertyChange(PROPERTY_LONGITUDE_DECIMAL, oldValue, decimal); + } + + public void setLongitudeSign(boolean sign) { + Object oldValue = longitude.isSign(); + longitude.setSign(sign); + firePropertyChange(PROPERTY_LONGITUDE_SIGN, oldValue, sign); + } + + public DmdCoordinate getLatitude() { + return latitude; + } + + public void setLatitudeSign(boolean sign) { + Object oldValue = latitude.isSign(); + latitude.setSign(sign); + firePropertyChange(PROPERTY_LATITUDE_SIGN, oldValue, sign); + } + + public void setLatitudeDegree(Integer degre) { + Object oldValue = latitude.getDegree(); + latitude.setDegree(degre); + firePropertyChange(PROPERTY_LATITUDE_DEGREE, oldValue, degre); + } + + public void setLatitudeMinute(Integer minute) { + Object oldValue = latitude.getMinute(); + latitude.setMinute(minute); + firePropertyChange(PROPERTY_LATITUDE_MINUTE, oldValue, minute); + } + + public void setLatitudeDecimal(Integer decimal) { + Object oldValue = latitude.getDecimal(); + latitude.setDecimal(decimal); + firePropertyChange(PROPERTY_LATITUDE_DECIMAL, oldValue, decimal); + } + + @Override + public String toString() { + return "EditorBean{" + + "longitude=" + longitude + + ", latitude=" + latitude + + '}'; + } + } + + public static void main(String[] args) throws ParseException { + + + EditorBean bean = new EditorBean(); + + DmdCoordinateEditor longitudeEditor = new DmdCoordinateEditor(); + longitudeEditor.setBean(bean); + longitudeEditor.setPropertySign(EditorBean.PROPERTY_LONGITUDE_SIGN); + longitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LONGITUDE_DEGREE); + longitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LONGITUDE_MINUTE); + longitudeEditor.setPropertyDecimal(EditorBean.PROPERTY_LONGITUDE_DECIMAL); + longitudeEditor.setLongitudeEditor(true); + longitudeEditor.setShowReset(true); + longitudeEditor.init(); + + DmdCoordinateEditor latitudeEditor = new DmdCoordinateEditor(); + latitudeEditor.setBean(bean); + latitudeEditor.setPropertySign(EditorBean.PROPERTY_LATITUDE_SIGN); + latitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LATITUDE_DEGREE); + latitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LATITUDE_MINUTE); + latitudeEditor.setPropertyDecimal(EditorBean.PROPERTY_LATITUDE_DECIMAL); + latitudeEditor.setLongitudeEditor(false); + latitudeEditor.setShowReset(true); + latitudeEditor.init(); + + final JLabel latitudeResult = new JLabel(); + final JLabel longitudeResult = new JLabel(); + + bean.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + EditorBean source = (EditorBean) evt.getSource(); + String propertyName = evt.getPropertyName(); + if (log.isInfoEnabled()) { + log.info("[" + propertyName + "] value changed: " + evt.getNewValue()); + } + if (propertyName.startsWith("longitude")) { + longitudeResult.setText(source.getLongitude().toString()); + } else { + + latitudeResult.setText(source.getLatitude().toString()); + } + } + }); + + JPanel longitudeEditorPanel = new JPanel(new GridLayout()); + longitudeEditorPanel.setBorder(new TitledBorder("Longitude")); + longitudeEditorPanel.add(BorderLayout.CENTER, longitudeEditor); + longitudeEditorPanel.add(BorderLayout.EAST, longitudeResult); + + JPanel latitudeEditorPanel = new JPanel(new GridLayout()); + latitudeEditorPanel.setBorder(new TitledBorder("Latitude")); + latitudeEditorPanel.add(BorderLayout.CENTER, latitudeEditor); + latitudeEditorPanel.add(BorderLayout.EAST, latitudeResult); + + JPanel panel = new JPanel(new GridLayout(0, 1)); + panel.add(longitudeEditorPanel); + panel.add(latitudeEditorPanel); + + final JDialog frame = new JDialog(); + + frame.setContentPane(panel); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + frame.setSize(800, 200); + frame.setVisible(true); + } + }); + } +} Property changes on: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateEditorTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java =================================================================== --- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java (rev 0) +++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -0,0 +1,126 @@ +package jaxx.runtime.swing.editor.gis; + +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +import org.junit.Assert; +import org.junit.Test; + +/** + * Created on 10/25/13. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 2.6 + */ +public class DmdCoordinateTest { + + @Test + public void testFromDecimal() throws Exception { + + { + DmdCoordinate actual = DmdCoordinate.empty(); + + actual.fromDecimal(42.7f); + + Integer expectedDegree = 42; + Integer expectedMinute = 42; + Integer expectedDecimal = null; + + Assert.assertEquals(expectedDegree, actual.getDegree()); + Assert.assertEquals(expectedMinute, actual.getMinute()); + Assert.assertEquals(expectedDecimal, actual.getDecimal()); + } + + { + DmdCoordinate actual = DmdCoordinate.empty(); + + float decimalExcepted = 42.707f; + actual.fromDecimal(decimalExcepted); + + Integer expectedDegree = 42; + Integer expectedMinute = 42; + Integer expectedDecimal = 42; + + Assert.assertEquals(expectedDegree, actual.getDegree()); + Assert.assertEquals(expectedMinute, actual.getMinute()); + Assert.assertEquals(expectedDecimal, actual.getDecimal()); + + Float decimal = actual.toDecimal(); + Assert.assertEquals(decimalExcepted, decimal, 0.001); + } + } + + @Test + public void testToDecimal() throws Exception { + + { + DmdCoordinate component = DmdCoordinate.empty(); + component.setDegree(42); + component.setMinute(42); + component.setDecimal(42); + Float actual = component.toDecimal(); + Float expected = 42.707f; + Assert.assertEquals(expected, actual, 0.001); + } + + { + DmdCoordinate component = DmdCoordinate.empty(); + component.setDegree(12); + component.setMinute(12); + Float actual = component.toDecimal(); + Float expected = 12.2f; + Assert.assertEquals(expected, actual, 0.0001); + + component.fromDecimal(expected); + + Integer expectedDegree = 12; + Integer expectedMinute = 12; + Integer expectedDecimal = null; + + Assert.assertEquals(expectedDegree, component.getDegree()); + Assert.assertEquals(expectedMinute, component.getMinute()); + Assert.assertEquals(expectedDecimal, component.getDecimal()); + } + + { + DmdCoordinate component = DmdCoordinate.empty(); + component.setDegree(12); + component.setMinute(12); + component.setDecimal(20); + Float actual = component.toDecimal(); + Float expected = 12.203333f; + Assert.assertEquals(expected, actual, 0.001); + + component.fromDecimal(expected); + + Integer expectedDegree = 12; + Integer expectedMinute = 12; + Integer expectedDecimal = 20; + + Assert.assertEquals(expectedDegree, component.getDegree()); + Assert.assertEquals(expectedMinute, component.getMinute()); + Assert.assertEquals(expectedDecimal, component.getDecimal()); + } + } +} Property changes on: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmdCoordinateTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java =================================================================== --- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java (rev 0) +++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java 2013-11-24 21:52:35 UTC (rev 2754) @@ -0,0 +1,218 @@ +package jaxx.runtime.swing.editor.gis; + +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.beans.AbstractSerializableBean; + +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.border.TitledBorder; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.text.ParseException; + +/** + * To test the {@link DmsCoordinateEditor}. + * <p/> + * Created on 10/17/13. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 2.6 + */ +public class DmsCoordinateEditorTest { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(DmsCoordinateEditorTest.class); + + public static class EditorBean extends AbstractSerializableBean { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_LONGITUDE_SIGN = "longitudeSign"; + + public static final String PROPERTY_LONGITUDE_DEGREE = "longitudeDegree"; + + public static final String PROPERTY_LONGITUDE_MINUTE = "longitudeMinute"; + + public static final String PROPERTY_LONGITUDE_SECOND = "longitudeSecond"; + + public static final String PROPERTY_LATITUDE_SIGN = "latitudeSign"; + + public static final String PROPERTY_LATITUDE_DEGREE = "latitudeDegree"; + + public static final String PROPERTY_LATITUDE_MINUTE = "latitudeMinute"; + + public static final String PROPERTY_LATITUDE_SECOND = "latitudeSecond"; + + protected final DmsCoordinate longitude = DmsCoordinate.empty(); + + protected final DmsCoordinate latitude = DmsCoordinate.empty(); + + public DmsCoordinate getLongitude() { + return longitude; + } + + public void setLongitudeDegre(Integer degre) { + Object oldValue = longitude.getDegree(); + longitude.setDegree(degre); + firePropertyChange(PROPERTY_LONGITUDE_DEGREE, oldValue, degre); + } + + public void setLongitudeMinute(Integer minute) { + Object oldValue = longitude.getMinute(); + longitude.setMinute(minute); + firePropertyChange(PROPERTY_LONGITUDE_MINUTE, oldValue, minute); + } + + public void setLongitudeSecond(Integer seconde) { + Object oldValue = longitude.getSecond(); + + longitude.setSecond(seconde); + firePropertyChange(PROPERTY_LONGITUDE_SECOND, oldValue, seconde); + } + + public void setLongitudeSign(boolean sign) { + Object oldValue = longitude.isSign(); + longitude.setSign(sign); + firePropertyChange(PROPERTY_LONGITUDE_SIGN, oldValue, sign); + } + + public DmsCoordinate getLatitude() { + return latitude; + } + + public void setLatitudeDegre(Integer degre) { + Object oldValue = latitude.getDegree(); + latitude.setDegree(degre); + firePropertyChange(PROPERTY_LATITUDE_DEGREE, oldValue, degre); + } + + public void setLatitudeMinute(Integer minute) { + Object oldValue = latitude.getMinute(); + latitude.setMinute(minute); + firePropertyChange(PROPERTY_LATITUDE_MINUTE, oldValue, minute); + } + + + public void setLatitudeSecond(Integer seconde) { + Object oldValue = latitude.getSecond(); + latitude.setSecond(seconde); + firePropertyChange(PROPERTY_LATITUDE_SECOND, oldValue, seconde); + } + + public void setLatitudeSign(boolean sign) { + Object oldValue = latitude.isSign(); + latitude.setSign(sign); + firePropertyChange(PROPERTY_LATITUDE_SIGN, oldValue, sign); + } + + @Override + public String toString() { + return "EditorBean{" + + "longitude=" + longitude + + ", latitude=" + latitude + + '}'; + } + } + + public static void main(String[] args) throws ParseException { + + + EditorBean bean = new EditorBean(); + + DmsCoordinateEditor longitudeEditor = new DmsCoordinateEditor(); + longitudeEditor.setBean(bean); + longitudeEditor.setPropertySign(EditorBean.PROPERTY_LONGITUDE_SIGN); + longitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LONGITUDE_DEGREE); + longitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LONGITUDE_MINUTE); + longitudeEditor.setPropertySecond(EditorBean.PROPERTY_LONGITUDE_SECOND); + longitudeEditor.setLongitudeEditor(true); + longitudeEditor.setShowReset(true); + longitudeEditor.init(); + + DmsCoordinateEditor latitudeEditor = new DmsCoordinateEditor(); + latitudeEditor.setBean(bean); + latitudeEditor.setPropertySign(EditorBean.PROPERTY_LATITUDE_SIGN); + latitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LATITUDE_DEGREE); + latitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LATITUDE_MINUTE); + latitudeEditor.setPropertySecond(EditorBean.PROPERTY_LATITUDE_SECOND); + latitudeEditor.setLongitudeEditor(false); + latitudeEditor.setShowReset(true); + latitudeEditor.init(); + + final JLabel latitudeResult = new JLabel(); + final JLabel longitudeResult = new JLabel(); + + bean.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + EditorBean source = (EditorBean) evt.getSource(); + String propertyName = evt.getPropertyName(); + if (log.isInfoEnabled()) { + log.info("[" + propertyName + "] value changed: " + evt.getNewValue()); + } + if (propertyName.startsWith("longitude")) { + longitudeResult.setText(source.getLongitude().toString()); + } else { + + latitudeResult.setText(source.getLatitude().toString()); + } + } + }); + + JPanel longitudeEditorPanel = new JPanel(new GridLayout()); + longitudeEditorPanel.setBorder(new TitledBorder("Longitude")); + longitudeEditorPanel.add(BorderLayout.CENTER, longitudeEditor); + longitudeEditorPanel.add(BorderLayout.EAST, longitudeResult); + + JPanel latitudeEditorPanel = new JPanel(new GridLayout()); + latitudeEditorPanel.setBorder(new TitledBorder("Latitude")); + latitudeEditorPanel.add(BorderLayout.CENTER, latitudeEditor); + latitudeEditorPanel.add(BorderLayout.EAST, latitudeResult); + + JPanel panel = new JPanel(new GridLayout(0, 1)); + panel.add(longitudeEditorPanel); + panel.add(latitudeEditorPanel); + + final JDialog frame = new JDialog(); + + frame.setContentPane(panel); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + frame.setSize(800, 200); + frame.setVisible(true); + } + }); + } +} Property changes on: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/gis/DmsCoordinateEditorTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native